mirror of https://github.com/vishvananda/netlink
Convert addr and xfrm to use IPNet pointers
This commit is contained in:
parent
9f98335fb3
commit
0e7e6d493a
2
addr.go
2
addr.go
|
@ -9,7 +9,7 @@ import (
|
|||
// Addr represents an IP address from netlink. Netlink ip addresses
|
||||
// include a mask, so it stores the address as a net.IPNet.
|
||||
type Addr struct {
|
||||
net.IPNet
|
||||
*net.IPNet
|
||||
Label string
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ func AddrList(link *Link, family int) ([]Addr, error) {
|
|||
for _, attr := range attrs {
|
||||
switch attr.Attr.Type {
|
||||
case syscall.IFA_ADDRESS:
|
||||
addr.IPNet = net.IPNet{
|
||||
addr.IPNet = &net.IPNet{
|
||||
IP: attr.Value,
|
||||
Mask: net.CIDRMask(int(msg.Prefixlen), 8*len(attr.Value)),
|
||||
}
|
||||
|
|
|
@ -94,12 +94,12 @@ func (x *XfrmAddress) ToIP() net.IP {
|
|||
return ip
|
||||
}
|
||||
|
||||
func (x *XfrmAddress) ToIPNet(prefixlen uint8) net.IPNet {
|
||||
func (x *XfrmAddress) ToIPNet(prefixlen uint8) *net.IPNet {
|
||||
ip := x.ToIP()
|
||||
if GetIPFamily(ip) == FAMILY_V4 {
|
||||
return net.IPNet{ip, net.CIDRMask(int(prefixlen), 32)}
|
||||
return &net.IPNet{ip, net.CIDRMask(int(prefixlen), 32)}
|
||||
} else {
|
||||
return net.IPNet{ip, net.CIDRMask(int(prefixlen), 128)}
|
||||
return &net.IPNet{ip, net.CIDRMask(int(prefixlen), 128)}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ type XfrmPolicyTmpl struct {
|
|||
// and has a list of XfrmPolicyTmpls representing the base addresses of
|
||||
// the policy.
|
||||
type XfrmPolicy struct {
|
||||
Dst net.IPNet
|
||||
Src net.IPNet
|
||||
Dst *net.IPNet
|
||||
Src *net.IPNet
|
||||
Dir Dir
|
||||
Priority int
|
||||
Index int
|
||||
|
|
Loading…
Reference in New Issue