Skip to content
Snippets Groups Projects
Select Git revision
  • dc8e17be99103cbb9ca17b91d08e7d48b7e23162
  • master default protected
  • renovate/configure
  • 2-create-ospf-example
  • feature/isis
  • migrate-to-github-actions
  • aspath/convenience
  • hashroute/public
  • cmd/rismirror
  • riscli/vrf
  • fix/bmp_down
  • ris/logging
  • fix/ris_race
  • fix/bmp_metrics
  • please-go-vet
  • fix/lock_copy
  • fix/dedup_mem
  • add-get-routers-rpc
  • feature/bgp_md5
  • is-is/srv
  • feature/ris/lpm_any
  • v0.0.3-pre4
  • v0.0.3-pre3
  • v0.0.3-pre2
  • v0.0.3-pre1
  • v0.0.2-pre9
  • v0.0.2-pre8
  • v0.0.2-pre7
  • v0.0.2-pre6
  • v0.0.2-pre5
  • v0.0.2-pre4
  • v0.0.2-pre3
  • v0.0.2-pre2
  • v0.0.2-pre1
  • v0.0.1-pre10
  • v0.0.1-pre9
  • v0.0.1-pre7
  • v0.0.1-pre8
  • v0.0.1-pre6
  • v0.0.1-pre4
  • v0.0.1-pre5
41 results

bgp.go

  • user avatar
    Oliver Herms authored
    4d41fee4
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    bgp.go 2.99 KiB
    package packet
    
    const (
    	OctetLen       = 8
    	MaxASNsSegment = 255
    	BGP4Version    = 4
    	MinOpenLen     = 29
    
    	MarkerLen         = 16
    	HeaderLen         = 19
    	MinLen            = 19
    	MaxLen            = 4096
    	MinUpdateLen      = 4
    	NLRIMaxLen        = 5
    	CommunityLen      = 4
    	LargeCommunityLen = 12
    
    	OpenMsg         = 1
    	UpdateMsg       = 2
    	NotificationMsg = 3
    	KeepaliveMsg    = 4
    
    	MessageHeaderError      = 1
    	OpenMessageError        = 2
    	UpdateMessageError      = 3
    	HoldTimeExpired         = 4
    	FiniteStateMachineError = 5
    	Cease                   = 6
    
    	// Msg Header Errors
    	ConnectionNotSync = 1
    	BadMessageLength  = 2
    	BadMessageType    = 3
    
    	// Open Msg Errors
    	UnsupportedVersionNumber     = 1
    	BadPeerAS                    = 2
    	BadBGPIdentifier             = 3
    	UnsupportedOptionalParameter = 4
    	DeprecatedOpenMsgError5      = 5
    	UnacceptableHoldTime         = 6
    
    	// Update Msg Errors
    	MalformedAttributeList    = 1
    	UnrecognizedWellKnownAttr = 2
    	MissingWellKnonAttr       = 3
    	AttrFlagsError            = 4
    	AttrLengthError           = 5
    	InvalidOriginAttr         = 6
    	DeprecatedUpdateMsgError7 = 7
    	InvalidNextHopAttr        = 8
    	OptionalAttrError         = 9
    	InvalidNetworkField       = 10
    	MalformedASPath           = 11
    
    	// Notification Msg Subcodes
    	AdministrativeShutdown = 2
    	AdministrativeReset    = 4
    
    	// Attribute Type Codes
    	OriginAttr           = 1
    	ASPathAttr           = 2
    	NextHopAttr          = 3
    	MEDAttr              = 4
    	LocalPrefAttr        = 5
    	AtomicAggrAttr       = 6
    	AggregatorAttr       = 7
    	CommunitiesAttr      = 8
    	AS4PathAttr          = 17
    	AS4AggregatorAttr    = 18
    	LargeCommunitiesAttr = 32
    
    	// ORIGIN values
    	IGP        = 0
    	EGP        = 1
    	INCOMPLETE = 2
    
    	// NOTIFICATION Cease error SubCodes (RFC4486)
    	MaxPrefReached                = 1
    	AdminShut                     = 2
    	PeerDeconfigured              = 3
    	AdminReset                    = 4
    	ConnectionRejected            = 5
    	OtherConfigChange             = 8
    	ConnectionCollisionResolution = 7
    	OutOfResoutces                = 8
    
    	IPv4AFI               = 1
    	UnicastSAFI           = 1
    	CapabilitiesParamType = 2
    	AddPathCapabilityCode = 69
    	ASN4CapabilityCode    = 65
    	AddPathReceive        = 1
    	AddPathSend           = 2
    	AddPathSendReceive    = 3
    	ASTransASN            = 23456
    )
    
    type BGPError struct {
    	ErrorCode    uint8
    	ErrorSubCode uint8
    	ErrorStr     string
    }
    
    func (b BGPError) Error() string {
    	return b.ErrorStr
    }
    
    type BGPMessage struct {
    	Header *BGPHeader
    	Body   interface{}
    }
    
    type BGPHeader struct {
    	Length uint16
    	Type   uint8
    }
    
    type BGPOpen struct {
    	Version       uint8
    	ASN           uint16
    	HoldTime      uint16
    	BGPIdentifier uint32
    	OptParmLen    uint8
    	OptParams     []OptParam
    }
    
    type BGPNotification struct {
    	ErrorCode    uint8
    	ErrorSubcode uint8
    }
    
    type PathAttribute struct {
    	Length         uint16
    	Optional       bool
    	Transitive     bool
    	Partial        bool
    	ExtendedLength bool
    	TypeCode       uint8
    	Value          interface{}
    	Next           *PathAttribute
    }
    
    type Aggretator struct {
    	Addr uint32
    	ASN  uint16
    }