diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-07-27 11:23:58 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-07-27 12:51:36 +0900 |
commit | e15c582a6379e7ef6153c6cf954e4f0de93ffb9a (patch) | |
tree | e2ee9c1d4fa2715ef31e38083ee360f5dc90ad76 /server/zapi.go | |
parent | 27ba012b41d84d7f4c824934b607ba88e8ccc101 (diff) |
server: support ipv6 route zapi
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/zapi.go')
-rw-r--r-- | server/zapi.go | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/server/zapi.go b/server/zapi.go index bd80dba9..4a239fec 100644 --- a/server/zapi.go +++ b/server/zapi.go @@ -34,7 +34,10 @@ func (m *broadcastZapiMsg) send() { } func newIPRouteMessage(path *table.Path) *zebra.Message { + l := strings.SplitN(path.GetNlri().String(), "/", 2) var command zebra.API_TYPE + var prefix net.IP + nexthops := []net.IP{} switch path.GetRouteFamily() { case bgp.RF_IPv4_UC: if path.IsWithdraw == true { @@ -42,30 +45,40 @@ func newIPRouteMessage(path *table.Path) *zebra.Message { } else { command = zebra.IPV4_ROUTE_ADD } + prefix = net.ParseIP(l[0]).To4() + nexthops = append(nexthops, path.GetNexthop().To4()) case bgp.RF_IPv6_UC: if path.IsWithdraw == true { command = zebra.IPV6_ROUTE_DELETE } else { command = zebra.IPV6_ROUTE_ADD } + prefix = net.ParseIP(l[0]).To16() + nexthops = append(nexthops, path.GetNexthop().To16()) default: return nil } - l := strings.SplitN(path.GetNlri().String(), "/", 2) + flags := uint8(zebra.MESSAGE_NEXTHOP) plen, _ := strconv.Atoi(l[1]) - med, _ := path.GetMed() + med, err := path.GetMed() + if err == nil { + flags |= zebra.MESSAGE_METRIC + } return &zebra.Message{ Header: zebra.Header{ + Len: zebra.HEADER_SIZE, + Marker: zebra.HEADER_MARKER, + Version: zebra.VERSION, Command: command, }, - Body: &zebra.IPv4RouteBody{ + Body: &zebra.IPRouteBody{ Type: zebra.ROUTE_BGP, SAFI: zebra.SAFI_UNICAST, - Message: zebra.MESSAGE_NEXTHOP, - Prefix: net.ParseIP(l[0]), + Message: flags, + Prefix: prefix, PrefixLength: uint8(plen), - Nexthops: []net.IP{path.GetNexthop()}, + Nexthops: nexthops, Metric: med, }, } |