"net": {
"L0", "CGO",
"context", "math/rand", "os", "reflect", "sort", "syscall", "time",
- "internal/nettrace", "internal/poll",
+ "internal/nettrace", "internal/poll", "internal/syscall/unix",
"internal/syscall/windows", "internal/singleflight", "internal/race",
"golang_org/x/net/dns/dnsmessage", "golang_org/x/net/lif", "golang_org/x/net/route",
},
--- /dev/null
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "textflag.h"
+
+//
+// System calls for aix/ppc64 are implemented in syscall/syscall_aix.go
+//
+
+TEXT ·syscall6(SB),NOSPLIT,$0
+ JMP syscall·syscall6(SB)
--- /dev/null
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+//go:cgo_import_dynamic libc_ioctl ioctl "libc.a/shr_64.o"
+//go:linkname libc_ioctl libc_ioctl
+var libc_ioctl uintptr
+
+// Implemented in syscall/syscall_aix.go.
+func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
+
+func Ioctl(fd int, cmd int, args uintptr) (err error) {
+ _, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_ioctl)), 3, uintptr(fd), uintptr(cmd), uintptr(args), 0, 0, 0)
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
package net
import (
- //"os"
+ "internal/syscall/unix"
"syscall"
"unsafe"
)
-type RawSockaddrDatalink struct {
+type rawSockaddrDatalink struct {
Len uint8
Family uint8
Index uint16
Data [120]byte
}
+type ifreq struct {
+ Name [16]uint8
+ Ifru [16]byte
+}
+
const _KINFO_RT_IFLIST = (0x1 << 8) | 3 | (1 << 30)
const _RTAX_NETMASK = 2
func getIfList() ([]byte, error) {
needed, err := syscall.Getkerninfo(_KINFO_RT_IFLIST, 0, 0, 0)
if err != nil {
- return nil, nil // XXX
+ return nil, err
}
tab := make([]byte, needed)
_, err = syscall.Getkerninfo(_KINFO_RT_IFLIST, uintptr(unsafe.Pointer(&tab[0])), uintptr(unsafe.Pointer(&needed)), 0)
if err != nil {
- return nil, nil // XXX
+ return nil, err
}
return tab[:needed], nil
}
}
if ifm.Type == syscall.RTM_IFINFO {
if ifindex == 0 || ifindex == int(ifm.Index) {
- sdl := (*RawSockaddrDatalink)(unsafe.Pointer(&tab[syscall.SizeofIfMsghdr]))
+ sdl := (*rawSockaddrDatalink)(unsafe.Pointer(&tab[syscall.SizeofIfMsghdr]))
ifi := &Interface{Index: int(ifm.Index), Flags: linkFlags(ifm.Flags)}
ifi.Name = string(sdl.Data[:sdl.Nlen])
ifi.HardwareAddr = sdl.Data[sdl.Nlen : sdl.Nlen+sdl.Alen]
- /* XXX MTU? */
+
+ // Retrieve MTU
+ ifr := &ifreq{}
+ copy(ifr.Name[:], ifi.Name)
+ sock, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_DGRAM, 0)
+ if err != nil {
+ return nil, err
+ }
+ err = unix.Ioctl(sock, syscall.SIOCGIFMTU, uintptr(unsafe.Pointer(ifr)))
+ if err != nil {
+ return nil, err
+ }
+ ifi.MTU = int(ifr.Ifru[0])<<24 | int(ifr.Ifru[1])<<16 | int(ifr.Ifru[2])<<8 | int(ifr.Ifru[3])
+
ift = append(ift, *ifi)
if ifindex == int(ifm.Index) {
break