unix/linux: Prefixmsg and PrefixCacheinfo structs

These structs and enumeration constants are used
to parse RTM_NEWPREFIX netlink messages.

Fixes golang/go#77662

Change-Id: I1e7a92e771701c0c790c15e58ad78cd8fe1e5cf5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/746420
Reviewed-by: Mark Freeman <markfreeman@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
Skye Soss
2026-02-18 12:31:42 -08:00
committed by Gopher Robot
parent 3687fbd716
commit acef38879e
2 changed files with 238 additions and 208 deletions
+9
View File
@@ -932,12 +932,17 @@ const (
RTN_THROW = C.RTN_THROW
RTN_NAT = C.RTN_NAT
RTN_XRESOLVE = C.RTN_XRESOLVE
PREFIX_UNSPEC = C.PREFIX_UNSPEC
PREFIX_ADDRESS = C.PREFIX_ADDRESS
PREFIX_CACHEINFO = C.PREFIX_CACHEINFO
SizeofNlMsghdr = C.sizeof_struct_nlmsghdr
SizeofNlMsgerr = C.sizeof_struct_nlmsgerr
SizeofRtGenmsg = C.sizeof_struct_rtgenmsg
SizeofNlAttr = C.sizeof_struct_nlattr
SizeofRtAttr = C.sizeof_struct_rtattr
SizeofIfInfomsg = C.sizeof_struct_ifinfomsg
SizeofPrefixmsg = C.sizeof_struct_prefixmsg
SizeofPrefixCacheinfo = C.sizeof_struct_prefix_cacheinfo
SizeofIfAddrmsg = C.sizeof_struct_ifaddrmsg
SizeofIfAddrlblmsg = C.sizeof_struct_ifaddrlblmsg
SizeofIfaCacheinfo = C.sizeof_struct_ifa_cacheinfo
@@ -959,6 +964,10 @@ type RtAttr C.struct_rtattr
type IfInfomsg C.struct_ifinfomsg
type Prefixmsg C.struct_prefixmsg
type PrefixCacheinfo C.struct_prefix_cacheinfo
type IfAddrmsg C.struct_ifaddrmsg
type IfAddrlblmsg C.struct_ifaddrlblmsg
+21
View File
@@ -684,12 +684,17 @@ const (
RTN_THROW = 0x9
RTN_NAT = 0xa
RTN_XRESOLVE = 0xb
PREFIX_UNSPEC = 0x0
PREFIX_ADDRESS = 0x1
PREFIX_CACHEINFO = 0x2
SizeofNlMsghdr = 0x10
SizeofNlMsgerr = 0x14
SizeofRtGenmsg = 0x1
SizeofNlAttr = 0x4
SizeofRtAttr = 0x4
SizeofIfInfomsg = 0x10
SizeofPrefixmsg = 0xc
SizeofPrefixCacheinfo = 0x8
SizeofIfAddrmsg = 0x8
SizeofIfAddrlblmsg = 0xc
SizeofIfaCacheinfo = 0x10
@@ -735,6 +740,22 @@ type IfInfomsg struct {
Change uint32
}
type Prefixmsg struct {
Family uint8
Pad1 uint8
Pad2 uint16
Ifindex int32
Type uint8
Len uint8
Flags uint8
Pad3 uint8
}
type PrefixCacheinfo struct {
Preferred_time uint32
Valid_time uint32
}
type IfAddrmsg struct {
Family uint8
Prefixlen uint8