summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--packet/bgp.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/packet/bgp.go b/packet/bgp.go
index c1dd4fcb..a1b797c1 100644
--- a/packet/bgp.go
+++ b/packet/bgp.go
@@ -6206,6 +6206,18 @@ func (msg *BGPUpdate) Serialize() ([]byte, error) {
return buf, nil
}
+func (msg *BGPUpdate) IsEndOfRib() (bool, RouteFamily) {
+ if len(msg.WithdrawnRoutes) == 0 && len(msg.NLRI) == 0 {
+ if len(msg.PathAttributes) == 0 {
+ return true, RF_IPv4_UC
+ } else if len(msg.PathAttributes) == 1 && msg.PathAttributes[0].GetType() == BGP_ATTR_TYPE_MP_UNREACH_NLRI {
+ unreach := msg.PathAttributes[0].(*PathAttributeMpUnreachNLRI)
+ return true, AfiSafiToRouteFamily(unreach.AFI, unreach.SAFI)
+ }
+ }
+ return false, RouteFamily(0)
+}
+
func NewBGPUpdateMessage(withdrawnRoutes []*IPAddrPrefix, pathattrs []PathAttributeInterface, nlri []*IPAddrPrefix) *BGPMessage {
return &BGPMessage{
Header: BGPHeader{Type: BGP_MSG_UPDATE},
@@ -6213,6 +6225,19 @@ func NewBGPUpdateMessage(withdrawnRoutes []*IPAddrPrefix, pathattrs []PathAttrib
}
}
+func NewEndOfRib(family RouteFamily) *BGPMessage {
+ if family == RF_IPv4_UC {
+ return NewBGPUpdateMessage(nil, nil, nil)
+ } else {
+ afi, safi := RouteFamilyToAfiSafi(family)
+ unreach := &PathAttributeMpUnreachNLRI{
+ AFI: afi,
+ SAFI: safi,
+ }
+ return NewBGPUpdateMessage(nil, []PathAttributeInterface{unreach}, nil)
+ }
+}
+
type BGPNotification struct {
ErrorCode uint8
ErrorSubcode uint8