Convert addr and xfrm to use IPNet pointers

This commit is contained in:
Vishvananda Ishaya 2014-09-07 11:27:29 -07:00
parent 9f98335fb3
commit 0e7e6d493a
4 changed files with 7 additions and 7 deletions

View File

@ -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
}

View File

@ -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)),
}

View File

@ -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)}
}
}

View File

@ -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