mirror of
https://github.com/vishvananda/netlink
synced 2024-12-20 22:00:46 +00:00
48 lines
937 B
Go
48 lines
937 B
Go
package nl
|
|
|
|
import (
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
type IfAddrmsg struct {
|
|
syscall.IfAddrmsg
|
|
}
|
|
|
|
func NewIfAddrmsg(family int) *IfAddrmsg {
|
|
return &IfAddrmsg{
|
|
IfAddrmsg: syscall.IfAddrmsg{
|
|
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 {
|
|
return (*IfAddrmsg)(unsafe.Pointer(&b[0:syscall.SizeofIfAddrmsg][0]))
|
|
}
|
|
|
|
func (msg *IfAddrmsg) Serialize() []byte {
|
|
return (*(*[syscall.SizeofIfAddrmsg]byte)(unsafe.Pointer(msg)))[:]
|
|
}
|
|
|
|
func (msg *IfAddrmsg) Len() int {
|
|
return syscall.SizeofIfAddrmsg
|
|
}
|