]> Cypherpunks repositories - gostls13.git/commitdiff
Revert "syscall: route_freebsd switch routing socket sysctl to use NET_RT_IFLISTL"
authorYuval Pavel Zholkover <paulzhol@gmail.com>
Sat, 5 Dec 2015 07:28:25 +0000 (07:28 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sat, 5 Dec 2015 07:45:01 +0000 (07:45 +0000)
This reverts commit f25f6eab0cb732d24759b2e166a9a644ae96dffe.

Sorry, this was not meant to go in without the ztypes_freebsd_arm.go and the copyFromV9 function.

Change-Id: I4ac2a8a23809ec1b1b9e42992cd0f3c349848f06
Reviewed-on: https://go-review.googlesource.com/17472
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
16 files changed:
src/net/interface_bsd.go
src/net/interface_darwin.go
src/net/interface_dragonfly.go
src/net/interface_freebsd.go
src/net/interface_netbsd.go
src/net/interface_openbsd.go
src/syscall/route_bsd_test.go
src/syscall/route_freebsd.go
src/syscall/route_freebsd_32bit.go
src/syscall/route_freebsd_64bit.go
src/syscall/syscall_freebsd_386.go
src/syscall/syscall_freebsd_amd64.go
src/syscall/syscall_freebsd_arm.go
src/syscall/types_freebsd.go
src/syscall/ztypes_freebsd_386.go
src/syscall/ztypes_freebsd_amd64.go

index e42b7a9e6d4192324b633b312b86cd4f6dd7e2d8..208f37f9fd34aa45d862f0886b78fb376d44dafd 100644 (file)
@@ -16,7 +16,7 @@ import (
 // network interfaces.  Otherwise it returns a mapping of a specific
 // interface.
 func interfaceTable(ifindex int) ([]Interface, error) {
-       tab, err := syscall.RouteRIB(rtSockIfListSyscall, ifindex)
+       tab, err := syscall.RouteRIB(syscall.NET_RT_IFLIST, ifindex)
        if err != nil {
                return nil, os.NewSyscallError("routerib", err)
        }
@@ -102,7 +102,7 @@ func interfaceAddrTable(ifi *Interface) ([]Addr, error) {
        if ifi != nil {
                index = ifi.Index
        }
-       tab, err := syscall.RouteRIB(rtSockIfListSyscall, index)
+       tab, err := syscall.RouteRIB(syscall.NET_RT_IFLIST, index)
        if err != nil {
                return nil, os.NewSyscallError("routerib", err)
        }
index 2b0103d16143024bea9f7a156344ed73dad5c19d..b7a333849d142f48322ab880de91413cdddb7e17 100644 (file)
@@ -9,8 +9,6 @@ import (
        "syscall"
 )
 
-const rtSockIfListSyscall = syscall.NET_RT_IFLIST
-
 // interfaceMulticastAddrTable returns addresses for a specific
 // interface.
 func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error) {
index 3d417067d5b91e4a3b606100cf61864475cfc0d8..c9ce5a7ac15a4f1ee30092974957a111b8e9f6ef 100644 (file)
@@ -4,10 +4,6 @@
 
 package net
 
-import "syscall"
-
-const rtSockIfListSyscall = syscall.NET_RT_IFLIST
-
 // interfaceMulticastAddrTable returns addresses for a specific
 // interface.
 func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error) {
index e0e30f8cf0892aa890aad6d59d42599afccc7e83..c42d90b7403e8b858673ff01b3971b72d975dc81 100644 (file)
@@ -9,8 +9,6 @@ import (
        "syscall"
 )
 
-const rtSockIfListSyscall = syscall.NET_RT_IFLISTL
-
 // interfaceMulticastAddrTable returns addresses for a specific
 // interface.
 func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error) {
index 3d417067d5b91e4a3b606100cf61864475cfc0d8..c9ce5a7ac15a4f1ee30092974957a111b8e9f6ef 100644 (file)
@@ -4,10 +4,6 @@
 
 package net
 
-import "syscall"
-
-const rtSockIfListSyscall = syscall.NET_RT_IFLIST
-
 // interfaceMulticastAddrTable returns addresses for a specific
 // interface.
 func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error) {
index 3d417067d5b91e4a3b606100cf61864475cfc0d8..c9ce5a7ac15a4f1ee30092974957a111b8e9f6ef 100644 (file)
@@ -4,10 +4,6 @@
 
 package net
 
-import "syscall"
-
-const rtSockIfListSyscall = syscall.NET_RT_IFLIST
-
 // interfaceMulticastAddrTable returns addresses for a specific
 // interface.
 func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error) {
index 1bee70197a652f9c2a273b6ad8acee2821a2644b..74d11f9f0a578e405c3077aad84b6a9e54d33549 100644 (file)
@@ -10,18 +10,13 @@ import (
        "fmt"
        "net"
        "os"
-       "runtime"
        "syscall"
        "testing"
        "time"
 )
 
 func TestRouteRIB(t *testing.T) {
-       var rtSockIfListSyscall = syscall.NET_RT_IFLIST
-       if runtime.GOOS == "freebsd" {
-               rtSockIfListSyscall = syscall.NET_RT_IFLISTL
-       }
-       for _, facility := range []int{syscall.NET_RT_DUMP, rtSockIfListSyscall} {
+       for _, facility := range []int{syscall.NET_RT_DUMP, syscall.NET_RT_IFLIST} {
                for _, param := range []int{syscall.AF_UNSPEC, syscall.AF_INET, syscall.AF_INET6} {
                        var err error
                        var b []byte
index ad1af4464be36462ab326e0a40f422820b04db9a..0e181038555ccb787c9eb069f10d50564f9f1464 100644 (file)
@@ -6,7 +6,7 @@ package syscall
 
 import "unsafe"
 
-// See https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/versions.html#freebsd-versions-table.
+// See http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html.
 var freebsdVersion uint32
 
 func init() {
@@ -42,7 +42,8 @@ func (any *anyMessage) toRoutingMessage(b []byte) RoutingMessage {
                p := (*InterfaceAnnounceMessage)(unsafe.Pointer(any))
                return &InterfaceAnnounceMessage{Header: p.Header}
        case RTM_NEWADDR, RTM_DELADDR:
-               return any.parseInterfaceAddrMessage(b)
+               p := (*InterfaceAddrMessage)(unsafe.Pointer(any))
+               return &InterfaceAddrMessage{Header: p.Header, Data: b[SizeofIfaMsghdr:any.Msglen]}
        case RTM_NEWMADDR, RTM_DELMADDR:
                p := (*InterfaceMulticastAddrMessage)(unsafe.Pointer(any))
                return &InterfaceMulticastAddrMessage{Header: p.Header, Data: b[SizeofIfmaMsghdr:any.Msglen]}
@@ -50,124 +51,6 @@ func (any *anyMessage) toRoutingMessage(b []byte) RoutingMessage {
        return nil
 }
 
-func (any *anyMessage) parseInterfaceMessage(b []byte) *InterfaceMessage {
-       p := (*ifMsghdrFixed)(unsafe.Pointer(any))
-       h := IfMsghdr{
-               Msglen:   p.Msglen,
-               Version:  p.Version,
-               Type:     p.Type,
-               Addrs:    p.Addrs,
-               Flags:    p.Flags,
-               Index:    p.Index,
-               Len:      p.Len,
-               Data_off: p.Data_off,
-       }
-
-       switch {
-       case freebsdVersion >= 1100011:
-               // FreeBSD 11 uses a new struct if_data layout
-               // See https://svnweb.freebsd.org/base?view=revision&revision=263102
-               data11 := *(*ifData11Raw)(unsafe.Pointer(&b[p.Data_off:p.Len][0]))
-               h.Data.copyFromV11Raw(&data11)
-       case freebsdVersion >= 1001000:
-               // FreeBSD 10.1 and newer
-               data10 := *(*ifData10)(unsafe.Pointer(&b[p.Data_off:p.Len][0]))
-               h.Data.copyFromV10(&data10)
-       case freebsdVersion >= 903000:
-               // TODO
-       }
-
-       return &InterfaceMessage{Header: h, Data: b[p.Len:any.Msglen]}
-}
-
-func (d *IfData) copyFromV11Raw(data11 *ifData11Raw) {
-       d.Type = data11.Type
-       d.Physical = data11.Physical
-       d.Addrlen = data11.Addrlen
-       d.Hdrlen = data11.Hdrlen
-       d.Link_state = data11.Link_state
-       d.Vhid = data11.Vhid
-       d.Datalen = data11.Datalen
-       d.Mtu = data11.Mtu
-       d.Metric = data11.Metric
-       d.Baudrate = data11.Baudrate
-       d.Ipackets = data11.Ipackets
-       d.Ierrors = data11.Ierrors
-       d.Opackets = data11.Opackets
-       d.Oerrors = data11.Oerrors
-       d.Collisions = data11.Collisions
-       d.Ibytes = data11.Ibytes
-       d.Obytes = data11.Obytes
-       d.Imcasts = data11.Imcasts
-       d.Omcasts = data11.Omcasts
-       d.Iqdrops = data11.Iqdrops
-       d.Oqdrops = data11.Oqdrops
-       d.Noproto = data11.Noproto
-       d.Hwassist = data11.Hwassist
-
-       d.fillEpochLastChange(data11)
-}
-
-func (d *IfData) copyFromV10(data10 *ifData10) {
-       d.Type = data10.Type
-       d.Physical = data10.Physical
-       d.Addrlen = data10.Addrlen
-       d.Hdrlen = data10.Hdrlen
-       d.Link_state = data10.Link_state
-       d.Vhid = data10.Vhid
-       d.Datalen = uint16(data10.Datalen)
-       d.Mtu = uint32(data10.Mtu)
-       d.Metric = uint32(data10.Metric)
-       d.Baudrate = uint64(data10.Baudrate)
-       d.Ipackets = uint64(data10.Ipackets)
-       d.Ierrors = uint64(data10.Ierrors)
-       d.Opackets = uint64(data10.Opackets)
-       d.Oerrors = uint64(data10.Oerrors)
-       d.Collisions = uint64(data10.Collisions)
-       d.Ibytes = uint64(data10.Ibytes)
-       d.Obytes = uint64(data10.Obytes)
-       d.Imcasts = uint64(data10.Imcasts)
-       d.Omcasts = uint64(data10.Omcasts)
-       d.Iqdrops = uint64(data10.Iqdrops)
-       d.Oqdrops = uint64(data10.Oqdrops)
-       d.Noproto = uint64(data10.Noproto)
-       d.Hwassist = uint64(data10.Hwassist)
-
-       d.Epoch = data10.Epoch
-       d.Lastchange = data10.Lastchange
-}
-
-func (any *anyMessage) parseInterfaceAddrMessage(b []byte) *InterfaceAddrMessage {
-       p := (*IfaMsghdr)(unsafe.Pointer(any))
-
-       h := IfaMsghdr{
-               Msglen:   p.Msglen,
-               Version:  p.Version,
-               Type:     p.Type,
-               Addrs:    p.Addrs,
-               Flags:    p.Flags,
-               Index:    p.Index,
-               Len:      p.Len,
-               Data_off: p.Data_off,
-               Metric:   p.Metric,
-       }
-
-       switch {
-       case freebsdVersion >= 1100011:
-               // FreeBSD 11 uses a new struct if_data layout
-               // See https://svnweb.freebsd.org/base?view=revision&revision=263102
-               data11 := *(*ifData11Raw)(unsafe.Pointer(&b[p.Data_off:p.Len][0]))
-               h.Data.copyFromV11Raw(&data11)
-       case freebsdVersion >= 1001000:
-               // FreeBSD 10.1 and newer
-               data10 := *(*ifData10)(unsafe.Pointer(&b[p.Data_off:p.Len][0]))
-               h.Data.copyFromV10(&data10)
-       case freebsdVersion >= 903000:
-               // TODO
-       }
-       return &InterfaceAddrMessage{Header: h, Data: b[p.Len:any.Msglen]}
-}
-
 // InterfaceAnnounceMessage represents a routing message containing
 // network interface arrival and departure information.
 type InterfaceAnnounceMessage struct {
index 86995c922f63755f4553c6699769e30b3093d928..5c10b05e24df5211d44165ff36c135dc7f9d3976 100644 (file)
@@ -16,3 +16,18 @@ func (any *anyMessage) parseRouteMessage(b []byte) *RouteMessage {
        }
        return &RouteMessage{Header: p.Header, Data: b[rsaAlignOf(off):any.Msglen]}
 }
+
+func (any *anyMessage) parseInterfaceMessage(b []byte) *InterfaceMessage {
+       p := (*InterfaceMessage)(unsafe.Pointer(any))
+       // FreeBSD 10 and beyond have a restructured mbuf
+       // packet header view.
+       // See http://svnweb.freebsd.org/base?view=revision&revision=254804.
+       if freebsdVersion >= 1000000 {
+               m := (*ifMsghdr)(unsafe.Pointer(any))
+               p.Header.Data.Hwassist = uint32(m.Data.Hwassist)
+               p.Header.Data.Epoch = m.Data.Epoch
+               p.Header.Data.Lastchange = m.Data.Lastchange
+               return &InterfaceMessage{Header: p.Header, Data: b[int(unsafe.Offsetof(p.Header.Data))+int(p.Header.Data.Datalen) : any.Msglen]}
+       }
+       return &InterfaceMessage{Header: p.Header, Data: b[int(unsafe.Offsetof(p.Header.Data))+int(p.Header.Data.Datalen) : any.Msglen]}
+}
index 6db1c404889db3024dedfa5f4dec947faca3ae91..728837ebb5aa9e18c39964f0b35f1b6fad8e3632 100644 (file)
@@ -12,3 +12,8 @@ func (any *anyMessage) parseRouteMessage(b []byte) *RouteMessage {
        p := (*RouteMessage)(unsafe.Pointer(any))
        return &RouteMessage{Header: p.Header, Data: b[rsaAlignOf(int(unsafe.Offsetof(p.Header.Rmx))+SizeofRtMetrics):any.Msglen]}
 }
+
+func (any *anyMessage) parseInterfaceMessage(b []byte) *InterfaceMessage {
+       p := (*InterfaceMessage)(unsafe.Pointer(any))
+       return &InterfaceMessage{Header: p.Header, Data: b[int(unsafe.Offsetof(p.Header.Data))+int(p.Header.Data.Datalen) : any.Msglen]}
+}
index 60c96312e8739bd8129259b34290280c5b6f1f6b..ebd3d4c9cf835317c394ebeb976975c866802330 100644 (file)
@@ -43,12 +43,6 @@ func (cmsg *Cmsghdr) SetLen(length int) {
        cmsg.Len = uint32(length)
 }
 
-func (d *IfData) fillEpochLastChange(data11 *ifData11Raw) {
-       d.Epoch = *(*int32)(unsafe.Pointer(&data11.X__ifi_epoch[0]))
-       d.Lastchange.Sec = *(*int32)(unsafe.Pointer(&data11.X__ifi_lastchange[0:4][0]))
-       d.Lastchange.Usec = *(*int32)(unsafe.Pointer(&data11.X__ifi_lastchange[4:8][0]))
-}
-
 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
        var writtenOut uint64 = 0
        _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
index b9b30a485f1e7f7a8d1850e40cbbba5f8c964652..70c2ffb0350085d53af429abc6fd211738af2301 100644 (file)
@@ -43,12 +43,6 @@ func (cmsg *Cmsghdr) SetLen(length int) {
        cmsg.Len = uint32(length)
 }
 
-func (d *IfData) fillEpochLastChange(data11 *ifData11Raw) {
-       d.Epoch = *(*int64)(unsafe.Pointer(&data11.X__ifi_epoch[0]))
-       d.Lastchange.Sec = *(*int64)(unsafe.Pointer(&data11.X__ifi_lastchange[0:8][0]))
-       d.Lastchange.Usec = *(*int64)(unsafe.Pointer(&data11.X__ifi_lastchange[8:16][0]))
-}
-
 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
        var writtenOut uint64 = 0
        _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
index 4deceb451c0182aeadcc79ebd61fa4be15891343..ab72871ddadb0d4333688df8fc0f65b72eb59037 100644 (file)
@@ -43,12 +43,6 @@ func (cmsg *Cmsghdr) SetLen(length int) {
        cmsg.Len = uint32(length)
 }
 
-func (d *IfData) fillEpochLastChange(data11 *ifData11Raw) {
-       d.Epoch = *(*int64)(unsafe.Pointer(&data11.X__ifi_epoch[0]))
-       d.Lastchange.Sec = *(*int64)(unsafe.Pointer(&data11.X__ifi_lastchange[0:8][0]))
-       d.Lastchange.Usec = *(*int32)(unsafe.Pointer(&data11.X__ifi_lastchange[8:12][0]))
-}
-
 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
        var writtenOut uint64 = 0
        _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
index 0210e3a3a2105dfffccdb89dd958d581421eda5e..68a69312b207982ca988ef9226587f05b7719bfe 100644 (file)
@@ -104,169 +104,47 @@ struct stat8 {
 #endif
 };
 
-// This structure is a duplicate of if_data on FreeBSD 11-CURRENT 7b9bab6fbb69066f6e2ca96e5ca5b62fe834a2bb.
-// See sys/net/if.h.
-struct if_data11_raw {
-       uint8_t ifi_type;
-       uint8_t ifi_physical;
-       uint8_t ifi_addrlen;
-       uint8_t ifi_hdrlen;
-       uint8_t ifi_link_state;
-       uint8_t ifi_vhid;
-       uint16_t        ifi_datalen;
-       uint32_t        ifi_mtu;
-       uint32_t        ifi_metric;
-       uint64_t        ifi_baudrate;
-
-       uint64_t        ifi_ipackets;
-       uint64_t        ifi_ierrors;
-       uint64_t        ifi_opackets;
-       uint64_t        ifi_oerrors;
-       uint64_t        ifi_collisions;
-       uint64_t        ifi_ibytes;
-       uint64_t        ifi_obytes;
-       uint64_t        ifi_imcasts;
-       uint64_t        ifi_omcasts;
-       uint64_t        ifi_iqdrops;
-       uint64_t        ifi_oqdrops;
-       uint64_t        ifi_noproto;
-       uint64_t        ifi_hwassist;
-
-       union {
-               time_t          tt;
-               uint64_t        ph;
-       } __ifi_epoch;
-//#define      ifi_epoch       __ifi_epoch.tt
-       union {
-               struct timeval  tv;
-               struct {
-                       uint64_t ph1;
-                       uint64_t ph2;
-               } ph;
-       } __ifi_lastchange;
-//#define      ifi_lastchange  __ifi_lastchange.tv
+// This structure is a duplicate of if_data on FreeBSD 8-STABLE.
+// See /usr/include/net/if.h.
+struct if_data8 {
+       u_char  ifi_type;
+       u_char  ifi_physical;
+       u_char  ifi_addrlen;
+       u_char  ifi_hdrlen;
+       u_char  ifi_link_state;
+       u_char  ifi_spare_char1;
+       u_char  ifi_spare_char2;
+       u_char  ifi_datalen;
+       u_long  ifi_mtu;
+       u_long  ifi_metric;
+       u_long  ifi_baudrate;
+       u_long  ifi_ipackets;
+       u_long  ifi_ierrors;
+       u_long  ifi_opackets;
+       u_long  ifi_oerrors;
+       u_long  ifi_collisions;
+       u_long  ifi_ibytes;
+       u_long  ifi_obytes;
+       u_long  ifi_imcasts;
+       u_long  ifi_omcasts;
+       u_long  ifi_iqdrops;
+       u_long  ifi_noproto;
+       u_long  ifi_hwassist;
+       time_t  ifi_epoch;
+       struct  timeval ifi_lastchange;
 };
 
-// same as if_data11_raw with the unions removed
-struct if_data11 {
-       uint8_t ifi_type;
-       uint8_t ifi_physical;
-       uint8_t ifi_addrlen;
-       uint8_t ifi_hdrlen;
-       uint8_t ifi_link_state;
-       uint8_t ifi_vhid;
-       uint16_t        ifi_datalen;
-       uint32_t        ifi_mtu;
-       uint32_t        ifi_metric;
-       uint64_t        ifi_baudrate;
-
-       uint64_t        ifi_ipackets;
-       uint64_t        ifi_ierrors;
-       uint64_t        ifi_opackets;
-       uint64_t        ifi_oerrors;
-       uint64_t        ifi_collisions;
-       uint64_t        ifi_ibytes;
-       uint64_t        ifi_obytes;
-       uint64_t        ifi_imcasts;
-       uint64_t        ifi_omcasts;
-       uint64_t        ifi_iqdrops;
-       uint64_t        ifi_oqdrops;
-       uint64_t        ifi_noproto;
-       uint64_t        ifi_hwassist;
-
-       time_t          ifi_epoch;
-       struct timeval  ifi_lastchange;
+// This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE.
+// See /usr/include/net/if.h.
+struct if_msghdr8 {
+       u_short ifm_msglen;
+       u_char  ifm_version;
+       u_char  ifm_type;
+       int     ifm_addrs;
+       int     ifm_flags;
+       u_short ifm_index;
+       struct  if_data8 ifm_data;
 };
-
-// This structure is a duplicate of if_msghdrl on FreeBSD 11-CURRENT 7b9bab6fbb69066f6e2ca96e5ca5b62fe834a2bb.
-// See sys/net/if.h.
-struct if_msghdrl11 {
-       u_short ifm_msglen;
-       u_char  ifm_version;
-       u_char  ifm_type;
-       int     ifm_addrs;
-       int     ifm_flags;
-       u_short ifm_index;
-       u_short _ifm_spare1;
-       u_short ifm_len;
-       u_short ifm_data_off;
-       struct  if_data11 ifm_data;
-};
-
-struct if_msghdrl_fixed {
-       u_short ifm_msglen;
-       u_char  ifm_version;
-       u_char  ifm_type;
-       int     ifm_addrs;
-       int     ifm_flags;
-       u_short ifm_index;
-       u_short _ifm_spare1;
-       u_short ifm_len;
-       u_short ifm_data_off;
-};
-
-
-// This structure is a duplicate of ifa_msghdrl on FreeBSD 11-CURRENT 7b9bab6fbb69066f6e2ca96e5ca5b62fe834a2bb.
-// See sys/net/if.h.
-struct ifa_msghdrl11 {
-       u_short ifam_msglen;
-       u_char  ifam_version;
-       u_char  ifam_type;
-       int     ifam_addrs;
-       int     ifam_flags;
-       u_short ifam_index;
-       u_short _ifam_spare1;
-       u_short ifam_len;
-       u_short ifam_data_off;
-       int     ifam_metric;
-       struct  if_data11 ifam_data;
-};
-
-struct ifa_msghdrl_fixed {
-       u_short ifam_msglen;
-       u_char  ifam_version;
-       u_char  ifam_type;
-       int     ifam_addrs;
-       int     ifam_flags;
-       u_short ifam_index;
-       u_short _ifam_spare1;
-       u_short ifam_len;
-       u_short ifam_data_off;
-       int     ifam_metric;
-};
-
-// This structure is a duplicate of if_data on FreeBSD 10.2-RELEASE 1e3b3008927ebb2708c3f6a87ba9f302ad3c0c66.
-// See sys/net/if.h.
-struct if_data10 {
-       u_char  ifi_type;
-       u_char  ifi_physical;
-       u_char  ifi_addrlen;
-       u_char  ifi_hdrlen;
-       u_char  ifi_link_state;
-       u_char  ifi_vhid;
-       u_char  ifi_baudrate_pf;
-       u_char  ifi_datalen;
-       u_long  ifi_mtu;
-       u_long  ifi_metric;
-       u_long  ifi_baudrate;
-       u_long  ifi_ipackets;
-       u_long  ifi_ierrors;
-       u_long  ifi_opackets;
-       u_long  ifi_oerrors;
-       u_long  ifi_collisions;
-       u_long  ifi_ibytes;
-       u_long  ifi_obytes;
-       u_long  ifi_imcasts;
-       u_long  ifi_omcasts;
-       u_long  ifi_iqdrops;
-       u_long  ifi_noproto;
-       uint64_t ifi_hwassist;
-       time_t  ifi_epoch;
-       struct  timeval ifi_lastchange;
-       u_long  ifi_oqdrops;
-};
-
-
 */
 import "C"
 
@@ -404,25 +282,26 @@ type FdSet C.fd_set
 // Routing and interface messages
 
 const (
+       sizeofIfMsghdr         = C.sizeof_struct_if_msghdr
+       SizeofIfMsghdr         = C.sizeof_struct_if_msghdr8
+       sizeofIfData           = C.sizeof_struct_if_data
+       SizeofIfData           = C.sizeof_struct_if_data8
+       SizeofIfaMsghdr        = C.sizeof_struct_ifa_msghdr
        SizeofIfmaMsghdr       = C.sizeof_struct_ifma_msghdr
        SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
        SizeofRtMsghdr         = C.sizeof_struct_rt_msghdr
        SizeofRtMetrics        = C.sizeof_struct_rt_metrics
 )
 
-type IfData C.struct_if_data11
-
-type IfMsghdr C.struct_if_msghdrl11
-
-type ifMsghdrFixed C.struct_if_msghdrl_fixed
+type ifMsghdr C.struct_if_msghdr
 
-type IfaMsghdr C.struct_ifa_msghdrl11
+type IfMsghdr C.struct_if_msghdr8
 
-type ifaMsghdrFixed C.struct_ifa_msghdrl_fixed
+type ifData C.struct_if_data
 
-type ifData11Raw C.struct_if_data11_raw
+type IfData C.struct_if_data8
 
-type ifData10 C.struct_if_data10
+type IfaMsghdr C.struct_ifa_msghdr
 
 type IfmaMsghdr C.struct_ifma_msghdr
 
index 777a776c675bfeed7ed7fb79a3f8946a42c0edbf..d972fb6bdf0ca6e62b4ec3dd6096c2f7d4404173 100644 (file)
@@ -280,121 +280,40 @@ type FdSet struct {
 }
 
 const (
+       sizeofIfMsghdr         = 0x64
+       SizeofIfMsghdr         = 0x60
+       sizeofIfData           = 0x54
+       SizeofIfData           = 0x50
+       SizeofIfaMsghdr        = 0x14
        SizeofIfmaMsghdr       = 0x10
        SizeofIfAnnounceMsghdr = 0x18
        SizeofRtMsghdr         = 0x5c
        SizeofRtMetrics        = 0x38
 )
 
-type IfData struct {
-       Type       uint8
-       Physical   uint8
-       Addrlen    uint8
-       Hdrlen     uint8
-       Link_state uint8
-       Vhid       uint8
-       Datalen    uint16
-       Mtu        uint32
-       Metric     uint32
-       Baudrate   uint64
-       Ipackets   uint64
-       Ierrors    uint64
-       Opackets   uint64
-       Oerrors    uint64
-       Collisions uint64
-       Ibytes     uint64
-       Obytes     uint64
-       Imcasts    uint64
-       Omcasts    uint64
-       Iqdrops    uint64
-       Oqdrops    uint64
-       Noproto    uint64
-       Hwassist   uint64
-       Epoch      int32
-       Lastchange Timeval
+type ifMsghdr struct {
+       Msglen    uint16
+       Version   uint8
+       Type      uint8
+       Addrs     int32
+       Flags     int32
+       Index     uint16
+       Pad_cgo_0 [2]byte
+       Data      ifData
 }
 
 type IfMsghdr struct {
-       Msglen       uint16
-       Version      uint8
-       Type         uint8
-       Addrs        int32
-       Flags        int32
-       Index        uint16
-       X_ifm_spare1 uint16
-       Len          uint16
-       Data_off     uint16
-       Data         IfData
-}
-
-type ifMsghdrFixed struct {
-       Msglen       uint16
-       Version      uint8
-       Type         uint8
-       Addrs        int32
-       Flags        int32
-       Index        uint16
-       X_ifm_spare1 uint16
-       Len          uint16
-       Data_off     uint16
+       Msglen    uint16
+       Version   uint8
+       Type      uint8
+       Addrs     int32
+       Flags     int32
+       Index     uint16
+       Pad_cgo_0 [2]byte
+       Data      IfData
 }
 
-type IfaMsghdr struct {
-       Msglen        uint16
-       Version       uint8
-       Type          uint8
-       Addrs         int32
-       Flags         int32
-       Index         uint16
-       X_ifam_spare1 uint16
-       Len           uint16
-       Data_off      uint16
-       Metric        int32
-       Data          IfData
-}
-
-type ifaMsghdrFixed struct {
-       Msglen        uint16
-       Version       uint8
-       Type          uint8
-       Addrs         int32
-       Flags         int32
-       Index         uint16
-       X_ifam_spare1 uint16
-       Len           uint16
-       Data_off      uint16
-       Metric        int32
-}
-
-type ifData11Raw struct {
-       Type              uint8
-       Physical          uint8
-       Addrlen           uint8
-       Hdrlen            uint8
-       Link_state        uint8
-       Vhid              uint8
-       Datalen           uint16
-       Mtu               uint32
-       Metric            uint32
-       Baudrate          uint64
-       Ipackets          uint64
-       Ierrors           uint64
-       Opackets          uint64
-       Oerrors           uint64
-       Collisions        uint64
-       Ibytes            uint64
-       Obytes            uint64
-       Imcasts           uint64
-       Omcasts           uint64
-       Iqdrops           uint64
-       Oqdrops           uint64
-       Noproto           uint64
-       Hwassist          uint64
-       X__ifi_epoch      [8]byte
-       X__ifi_lastchange [16]byte
-}
-
-type ifData10 struct {
+type ifData struct {
        Type        uint8
        Physical    uint8
        Addrlen     uint8
@@ -420,7 +339,45 @@ type ifData10 struct {
        Hwassist    uint64
        Epoch       int32
        Lastchange  Timeval
-       Oqdrops     uint32
+}
+
+type IfData struct {
+       Type        uint8
+       Physical    uint8
+       Addrlen     uint8
+       Hdrlen      uint8
+       Link_state  uint8
+       Spare_char1 uint8
+       Spare_char2 uint8
+       Datalen     uint8
+       Mtu         uint32
+       Metric      uint32
+       Baudrate    uint32
+       Ipackets    uint32
+       Ierrors     uint32
+       Opackets    uint32
+       Oerrors     uint32
+       Collisions  uint32
+       Ibytes      uint32
+       Obytes      uint32
+       Imcasts     uint32
+       Omcasts     uint32
+       Iqdrops     uint32
+       Noproto     uint32
+       Hwassist    uint32
+       Epoch       int32
+       Lastchange  Timeval
+}
+
+type IfaMsghdr struct {
+       Msglen    uint16
+       Version   uint8
+       Type      uint8
+       Addrs     int32
+       Flags     int32
+       Index     uint16
+       Pad_cgo_0 [2]byte
+       Metric    int32
 }
 
 type IfmaMsghdr struct {
index ca232f74fa3dbec2097e9900f6a6059bdf97da06..0a5a10bf7dba010509e4e99ade5c29507ea21ea4 100644 (file)
@@ -282,122 +282,40 @@ type FdSet struct {
 }
 
 const (
+       sizeofIfMsghdr         = 0xa8
+       SizeofIfMsghdr         = 0xa8
+       sizeofIfData           = 0x98
+       SizeofIfData           = 0x98
+       SizeofIfaMsghdr        = 0x14
        SizeofIfmaMsghdr       = 0x10
        SizeofIfAnnounceMsghdr = 0x18
        SizeofRtMsghdr         = 0x98
        SizeofRtMetrics        = 0x70
 )
 
-type IfData struct {
-       Type       uint8
-       Physical   uint8
-       Addrlen    uint8
-       Hdrlen     uint8
-       Link_state uint8
-       Vhid       uint8
-       Datalen    uint16
-       Mtu        uint32
-       Metric     uint32
-       Baudrate   uint64
-       Ipackets   uint64
-       Ierrors    uint64
-       Opackets   uint64
-       Oerrors    uint64
-       Collisions uint64
-       Ibytes     uint64
-       Obytes     uint64
-       Imcasts    uint64
-       Omcasts    uint64
-       Iqdrops    uint64
-       Oqdrops    uint64
-       Noproto    uint64
-       Hwassist   uint64
-       Epoch      int64
-       Lastchange Timeval
+type ifMsghdr struct {
+       Msglen    uint16
+       Version   uint8
+       Type      uint8
+       Addrs     int32
+       Flags     int32
+       Index     uint16
+       Pad_cgo_0 [2]byte
+       Data      ifData
 }
 
 type IfMsghdr struct {
-       Msglen       uint16
-       Version      uint8
-       Type         uint8
-       Addrs        int32
-       Flags        int32
-       Index        uint16
-       X_ifm_spare1 uint16
-       Len          uint16
-       Data_off     uint16
-       Pad_cgo_0    [4]byte
-       Data         IfData
-}
-
-type ifMsghdrFixed struct {
-       Msglen       uint16
-       Version      uint8
-       Type         uint8
-       Addrs        int32
-       Flags        int32
-       Index        uint16
-       X_ifm_spare1 uint16
-       Len          uint16
-       Data_off     uint16
+       Msglen    uint16
+       Version   uint8
+       Type      uint8
+       Addrs     int32
+       Flags     int32
+       Index     uint16
+       Pad_cgo_0 [2]byte
+       Data      IfData
 }
 
-type IfaMsghdr struct {
-       Msglen        uint16
-       Version       uint8
-       Type          uint8
-       Addrs         int32
-       Flags         int32
-       Index         uint16
-       X_ifam_spare1 uint16
-       Len           uint16
-       Data_off      uint16
-       Metric        int32
-       Data          IfData
-}
-
-type ifaMsghdrFixed struct {
-       Msglen        uint16
-       Version       uint8
-       Type          uint8
-       Addrs         int32
-       Flags         int32
-       Index         uint16
-       X_ifam_spare1 uint16
-       Len           uint16
-       Data_off      uint16
-       Metric        int32
-}
-
-type ifData11Raw struct {
-       Type              uint8
-       Physical          uint8
-       Addrlen           uint8
-       Hdrlen            uint8
-       Link_state        uint8
-       Vhid              uint8
-       Datalen           uint16
-       Mtu               uint32
-       Metric            uint32
-       Baudrate          uint64
-       Ipackets          uint64
-       Ierrors           uint64
-       Opackets          uint64
-       Oerrors           uint64
-       Collisions        uint64
-       Ibytes            uint64
-       Obytes            uint64
-       Imcasts           uint64
-       Omcasts           uint64
-       Iqdrops           uint64
-       Oqdrops           uint64
-       Noproto           uint64
-       Hwassist          uint64
-       X__ifi_epoch      [8]byte
-       X__ifi_lastchange [16]byte
-}
-
-type ifData10 struct {
+type ifData struct {
        Type        uint8
        Physical    uint8
        Addrlen     uint8
@@ -423,7 +341,45 @@ type ifData10 struct {
        Hwassist    uint64
        Epoch       int64
        Lastchange  Timeval
-       Oqdrops     uint64
+}
+
+type IfData struct {
+       Type        uint8
+       Physical    uint8
+       Addrlen     uint8
+       Hdrlen      uint8
+       Link_state  uint8
+       Spare_char1 uint8
+       Spare_char2 uint8
+       Datalen     uint8
+       Mtu         uint64
+       Metric      uint64
+       Baudrate    uint64
+       Ipackets    uint64
+       Ierrors     uint64
+       Opackets    uint64
+       Oerrors     uint64
+       Collisions  uint64
+       Ibytes      uint64
+       Obytes      uint64
+       Imcasts     uint64
+       Omcasts     uint64
+       Iqdrops     uint64
+       Noproto     uint64
+       Hwassist    uint64
+       Epoch       int64
+       Lastchange  Timeval
+}
+
+type IfaMsghdr struct {
+       Msglen    uint16
+       Version   uint8
+       Type      uint8
+       Addrs     int32
+       Flags     int32
+       Index     uint16
+       Pad_cgo_0 [2]byte
+       Metric    int32
 }
 
 type IfmaMsghdr struct {