summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-04-21 02:11:06 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-07-01 21:24:40 +0900
commite05f71ed34b04a48184e0544126f47fc8ea50a02 (patch)
treec321ac8b6a41778ccb0fdee551c72a49bd27c514 /packet/bgp.go
parent3febd24db7572347af162fc992876a7279e3022c (diff)
packet: push detailed evpn information to api struct
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'packet/bgp.go')
-rw-r--r--packet/bgp.go38
1 files changed, 36 insertions, 2 deletions
diff --git a/packet/bgp.go b/packet/bgp.go
index 9aa29cbd..0d0abd3f 100644
--- a/packet/bgp.go
+++ b/packet/bgp.go
@@ -1441,6 +1441,19 @@ func (er *EVPNMacIPAdvertisementRoute) Serialize() ([]byte, error) {
return buf, nil
}
+func (er *EVPNMacIPAdvertisementRoute) ToApiStruct() *api.EvpnMacIpAdvertisement {
+ return &api.EvpnMacIpAdvertisement{
+ MacAddr: er.MacAddress.String(),
+ MacAddrLen: uint32(er.MacAddressLength),
+ IpAddr: er.IPAddress.String(),
+ IpAddrLen: uint32(er.IPAddressLength),
+ Rd: er.RD.String(),
+ Esi: er.ESI.String(),
+ Etag: er.ETag,
+ Labels: er.Labels,
+ }
+}
+
func (er *EVPNMacIPAdvertisementRoute) String() string {
return fmt.Sprintf("[type:macadv][rd:%s][esi:%s][etag:%d][mac:%s][ip:%s][labels:%v]", er.RD, er.ESI.String(), er.ETag, er.MacAddress, er.IPAddress, er.Labels)
}
@@ -1489,6 +1502,15 @@ func (er *EVPNMulticastEthernetTagRoute) Serialize() ([]byte, error) {
return buf, nil
}
+func (er *EVPNMulticastEthernetTagRoute) ToApiStruct() *api.EvpnInclusiveMulticastEthernetTag {
+ return &api.EvpnInclusiveMulticastEthernetTag{
+ Rd: er.RD.String(),
+ Etag: er.ETag,
+ IpAddr: er.IPAddress.String(),
+ IpAddrLen: uint32(er.IPAddressLength),
+ }
+}
+
func (er *EVPNMulticastEthernetTagRoute) String() string {
return fmt.Sprintf("[type:multicast][rd:%s][etag:%d][ip:%s]", er.RD, er.ETag, er.IPAddress)
}
@@ -1625,9 +1647,21 @@ func (n *EVPNNLRI) String() string {
}
func (n *EVPNNLRI) ToApiStruct() *api.Nlri {
+ evpn := &api.EVPNNlri{}
+ switch n.RouteType {
+ case EVPN_ROUTE_TYPE_MAC_IP_ADVERTISEMENT:
+ evpn.Type = api.EVPN_TYPE_ROUTE_TYPE_MAC_IP_ADVERTISEMENT
+ macIpAdv := n.RouteTypeData.(*EVPNMacIPAdvertisementRoute).ToApiStruct()
+ evpn.MacIpAdv = macIpAdv
+ case EVPN_INCLUSIVE_MULTICAST_ETHERNET_TAG:
+ evpn.Type = api.EVPN_TYPE_INCLUSIVE_MULTICAST_ETHERNET_TAG
+ eTag := n.RouteTypeData.(*EVPNMulticastEthernetTagRoute).ToApiStruct()
+ evpn.MulticastEtag = eTag
+ }
return &api.Nlri{
- Af: &api.AddressFamily{api.AFI(n.AFI()), api.SAFI(n.SAFI())},
- Prefix: n.String(),
+ Af: &api.AddressFamily{api.AFI(n.AFI()), api.SAFI(n.SAFI())},
+ Prefix: n.String(),
+ EvpnNlri: evpn,
}
}