diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-11-18 21:07:45 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-11-18 21:07:45 -0800 |
commit | f6897fd47f74abf4c33f003063d6cd201c6e4d05 (patch) | |
tree | 1c963c1cf74f6ee9def46d36a4035cdccd250241 /table/destination.go | |
parent | e8bff5b3662713180518de6eb12b3c11bd0d7775 (diff) |
rpki: fix IPv4-mapped addresss handling
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/destination.go')
-rw-r--r-- | table/destination.go | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/table/destination.go b/table/destination.go index 9c7b4f91..c2794a6a 100644 --- a/table/destination.go +++ b/table/destination.go @@ -42,7 +42,7 @@ const ( BPR_ROUTER_ID = "Router ID" ) -func toRadixkey(b []byte, max uint8) string { +func IpToRadixkey(b []byte, max uint8) string { var buffer bytes.Buffer for i := 0; i < len(b) && i < int(max); i++ { buffer.WriteString(fmt.Sprintf("%08b", b[i])) @@ -50,18 +50,10 @@ func toRadixkey(b []byte, max uint8) string { return buffer.String()[:max] } -func IpToRadixkey(prefix net.IP, prefixLen uint8) string { - b := prefix.To4() - if b == nil { - b = prefix.To16() - } - return toRadixkey(b, prefixLen) -} - func CidrToRadixkey(cidr string) string { _, n, _ := net.ParseCIDR(cidr) ones, _ := n.Mask.Size() - return toRadixkey(n.IP, uint8(ones)) + return IpToRadixkey(n.IP, uint8(ones)) } type PeerInfo struct { |