2014-09-19 02:04:48 +00:00
|
|
|
package nl
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unsafe"
|
2017-10-20 20:38:07 +00:00
|
|
|
|
|
|
|
"golang.org/x/sys/unix"
|
2014-09-19 02:04:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type IfAddrmsg struct {
|
2017-10-20 20:38:07 +00:00
|
|
|
unix.IfAddrmsg
|
2014-09-19 02:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewIfAddrmsg(family int) *IfAddrmsg {
|
|
|
|
return &IfAddrmsg{
|
2017-10-20 20:38:07 +00:00
|
|
|
IfAddrmsg: unix.IfAddrmsg{
|
2014-09-19 02:04:48 +00:00
|
|
|
Family: uint8(family),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// struct ifaddrmsg {
|
|
|
|
// __u8 ifa_family;
|
|
|
|
// __u8 ifa_prefixlen; /* The prefix length */
|
|
|
|
// __u8 ifa_flags; /* Flags */
|
|
|
|
// __u8 ifa_scope; /* Address scope */
|
|
|
|
// __u32 ifa_index; /* Link index */
|
|
|
|
// };
|
|
|
|
|
|
|
|
// type IfAddrmsg struct {
|
|
|
|
// Family uint8
|
|
|
|
// Prefixlen uint8
|
|
|
|
// Flags uint8
|
|
|
|
// Scope uint8
|
|
|
|
// Index uint32
|
|
|
|
// }
|
|
|
|
// SizeofIfAddrmsg = 0x8
|
|
|
|
|
|
|
|
func DeserializeIfAddrmsg(b []byte) *IfAddrmsg {
|
2017-10-20 20:38:07 +00:00
|
|
|
return (*IfAddrmsg)(unsafe.Pointer(&b[0:unix.SizeofIfAddrmsg][0]))
|
2014-09-19 02:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (msg *IfAddrmsg) Serialize() []byte {
|
2017-10-20 20:38:07 +00:00
|
|
|
return (*(*[unix.SizeofIfAddrmsg]byte)(unsafe.Pointer(msg)))[:]
|
2014-09-19 02:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (msg *IfAddrmsg) Len() int {
|
2017-10-20 20:38:07 +00:00
|
|
|
return unix.SizeofIfAddrmsg
|
2014-09-19 02:04:48 +00:00
|
|
|
}
|
2017-04-12 16:54:00 +00:00
|
|
|
|
|
|
|
// struct ifa_cacheinfo {
|
|
|
|
// __u32 ifa_prefered;
|
|
|
|
// __u32 ifa_valid;
|
|
|
|
// __u32 cstamp; /* created timestamp, hundredths of seconds */
|
|
|
|
// __u32 tstamp; /* updated timestamp, hundredths of seconds */
|
|
|
|
// };
|
|
|
|
|
|
|
|
type IfaCacheInfo struct {
|
2020-01-21 13:17:15 +00:00
|
|
|
unix.IfaCacheinfo
|
2017-04-12 16:54:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (msg *IfaCacheInfo) Len() int {
|
2020-01-21 13:17:15 +00:00
|
|
|
return unix.SizeofIfaCacheinfo
|
2017-04-12 16:54:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func DeserializeIfaCacheInfo(b []byte) *IfaCacheInfo {
|
2020-01-21 13:17:15 +00:00
|
|
|
return (*IfaCacheInfo)(unsafe.Pointer(&b[0:unix.SizeofIfaCacheinfo][0]))
|
2017-04-12 16:54:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (msg *IfaCacheInfo) Serialize() []byte {
|
2020-01-21 13:17:15 +00:00
|
|
|
return (*(*[unix.SizeofIfaCacheinfo]byte)(unsafe.Pointer(msg)))[:]
|
2017-04-12 16:54:00 +00:00
|
|
|
}
|