From 4a2915052bcfd1c24d0277be2e4f53f309e7be89 Mon Sep 17 00:00:00 2001 From: Yuval Pavel Zholkover Date: Sat, 5 Dec 2015 07:28:25 +0000 Subject: [PATCH] Revert "syscall: route_freebsd switch routing socket sysctl to use NET_RT_IFLISTL" 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 Run-TryBot: Alex Brainman TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/net/interface_bsd.go | 4 +- src/net/interface_darwin.go | 2 - src/net/interface_dragonfly.go | 4 - src/net/interface_freebsd.go | 2 - src/net/interface_netbsd.go | 4 - src/net/interface_openbsd.go | 4 - src/syscall/route_bsd_test.go | 7 +- src/syscall/route_freebsd.go | 123 +-------------- src/syscall/route_freebsd_32bit.go | 15 ++ src/syscall/route_freebsd_64bit.go | 5 + src/syscall/syscall_freebsd_386.go | 6 - src/syscall/syscall_freebsd_amd64.go | 6 - src/syscall/syscall_freebsd_arm.go | 6 - src/syscall/types_freebsd.go | 217 ++++++--------------------- src/syscall/ztypes_freebsd_386.go | 167 ++++++++------------- src/syscall/ztypes_freebsd_amd64.go | 168 ++++++++------------- 16 files changed, 198 insertions(+), 542 deletions(-) diff --git a/src/net/interface_bsd.go b/src/net/interface_bsd.go index e42b7a9e6d4..208f37f9fd3 100644 --- a/src/net/interface_bsd.go +++ b/src/net/interface_bsd.go @@ -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) } diff --git a/src/net/interface_darwin.go b/src/net/interface_darwin.go index 2b0103d1614..b7a333849d1 100644 --- a/src/net/interface_darwin.go +++ b/src/net/interface_darwin.go @@ -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) { diff --git a/src/net/interface_dragonfly.go b/src/net/interface_dragonfly.go index 3d417067d5b..c9ce5a7ac15 100644 --- a/src/net/interface_dragonfly.go +++ b/src/net/interface_dragonfly.go @@ -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) { diff --git a/src/net/interface_freebsd.go b/src/net/interface_freebsd.go index e0e30f8cf08..c42d90b7403 100644 --- a/src/net/interface_freebsd.go +++ b/src/net/interface_freebsd.go @@ -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) { diff --git a/src/net/interface_netbsd.go b/src/net/interface_netbsd.go index 3d417067d5b..c9ce5a7ac15 100644 --- a/src/net/interface_netbsd.go +++ b/src/net/interface_netbsd.go @@ -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) { diff --git a/src/net/interface_openbsd.go b/src/net/interface_openbsd.go index 3d417067d5b..c9ce5a7ac15 100644 --- a/src/net/interface_openbsd.go +++ b/src/net/interface_openbsd.go @@ -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) { diff --git a/src/syscall/route_bsd_test.go b/src/syscall/route_bsd_test.go index 1bee70197a6..74d11f9f0a5 100644 --- a/src/syscall/route_bsd_test.go +++ b/src/syscall/route_bsd_test.go @@ -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 diff --git a/src/syscall/route_freebsd.go b/src/syscall/route_freebsd.go index ad1af4464be..0e181038555 100644 --- a/src/syscall/route_freebsd.go +++ b/src/syscall/route_freebsd.go @@ -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 { diff --git a/src/syscall/route_freebsd_32bit.go b/src/syscall/route_freebsd_32bit.go index 86995c922f6..5c10b05e24d 100644 --- a/src/syscall/route_freebsd_32bit.go +++ b/src/syscall/route_freebsd_32bit.go @@ -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]} +} diff --git a/src/syscall/route_freebsd_64bit.go b/src/syscall/route_freebsd_64bit.go index 6db1c404889..728837ebb5a 100644 --- a/src/syscall/route_freebsd_64bit.go +++ b/src/syscall/route_freebsd_64bit.go @@ -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]} +} diff --git a/src/syscall/syscall_freebsd_386.go b/src/syscall/syscall_freebsd_386.go index 60c96312e87..ebd3d4c9cf8 100644 --- a/src/syscall/syscall_freebsd_386.go +++ b/src/syscall/syscall_freebsd_386.go @@ -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) diff --git a/src/syscall/syscall_freebsd_amd64.go b/src/syscall/syscall_freebsd_amd64.go index b9b30a485f1..70c2ffb0350 100644 --- a/src/syscall/syscall_freebsd_amd64.go +++ b/src/syscall/syscall_freebsd_amd64.go @@ -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) diff --git a/src/syscall/syscall_freebsd_arm.go b/src/syscall/syscall_freebsd_arm.go index 4deceb451c0..ab72871ddad 100644 --- a/src/syscall/syscall_freebsd_arm.go +++ b/src/syscall/syscall_freebsd_arm.go @@ -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) diff --git a/src/syscall/types_freebsd.go b/src/syscall/types_freebsd.go index 0210e3a3a21..68a69312b20 100644 --- a/src/syscall/types_freebsd.go +++ b/src/syscall/types_freebsd.go @@ -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_msghdr -type IfMsghdr C.struct_if_msghdrl11 +type IfMsghdr C.struct_if_msghdr8 -type ifMsghdrFixed C.struct_if_msghdrl_fixed +type ifData C.struct_if_data -type IfaMsghdr C.struct_ifa_msghdrl11 +type IfData C.struct_if_data8 -type ifaMsghdrFixed C.struct_ifa_msghdrl_fixed - -type ifData11Raw C.struct_if_data11_raw - -type ifData10 C.struct_if_data10 +type IfaMsghdr C.struct_ifa_msghdr type IfmaMsghdr C.struct_ifma_msghdr diff --git a/src/syscall/ztypes_freebsd_386.go b/src/syscall/ztypes_freebsd_386.go index 777a776c675..d972fb6bdf0 100644 --- a/src/syscall/ztypes_freebsd_386.go +++ b/src/syscall/ztypes_freebsd_386.go @@ -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 + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]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 -} - -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 { diff --git a/src/syscall/ztypes_freebsd_amd64.go b/src/syscall/ztypes_freebsd_amd64.go index ca232f74fa3..0a5a10bf7db 100644 --- a/src/syscall/ztypes_freebsd_amd64.go +++ b/src/syscall/ztypes_freebsd_amd64.go @@ -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 + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]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 -} - -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 {