Skip to content
Snippets Groups Projects
Commit 512639dd authored by Daniel Czerwonk's avatar Daniel Czerwonk
Browse files

32bit asn open cap decoding

parent 7fe22926
No related branches found
No related tags found
No related merge requests found
......@@ -40,9 +40,9 @@ func main() {
b.AddPeer(config.Peer{
AdminEnabled: true,
LocalAS: 6695,
LocalAS: 65200,
PeerAS: 65300,
PeerAddress: net.IP([]byte{169, 254, 200, 1}),
PeerAddress: net.IP([]byte{172, 17, 0, 3}),
LocalAddress: net.IP([]byte{169, 254, 200, 0}),
ReconnectInterval: time.Second * 15,
HoldTime: time.Second * 90,
......@@ -59,9 +59,9 @@ func main() {
b.AddPeer(config.Peer{
AdminEnabled: true,
LocalAS: 6695,
LocalAS: 65200,
PeerAS: 65100,
PeerAddress: net.IP([]byte{169, 254, 100, 0}),
PeerAddress: net.IP([]byte{172, 17, 0, 2}),
LocalAddress: net.IP([]byte{169, 254, 100, 1}),
ReconnectInterval: time.Second * 15,
HoldTime: time.Second * 90,
......
......@@ -242,6 +242,12 @@ func decodeCapability(buf *bytes.Buffer) (Capability, error) {
return cap, fmt.Errorf("Unable to decode add path capability")
}
cap.Value = addPathCap
case ASN4CapabilityCode:
asn4Cap, err := decodeASN4Capability(buf)
if err != nil {
return cap, fmt.Errorf("Unable to decode 4 octet ASN capability")
}
cap.Value = asn4Cap
default:
for i := uint8(0); i < cap.Length; i++ {
_, err := buf.ReadByte()
......@@ -270,6 +276,20 @@ func decodeAddPathCapability(buf *bytes.Buffer) (AddPathCapability, error) {
return addPathCap, nil
}
func decodeASN4Capability(buf *bytes.Buffer) (ASN4Capability, error) {
asn4Cap := ASN4Capability{}
fields := []interface{}{
&asn4Cap.ASN4,
}
err := decode(buf, fields)
if err != nil {
return asn4Cap, err
}
return asn4Cap, nil
}
func validateOpen(msg *BGPOpen) error {
if msg.Version != BGP4Version {
return BGPError{
......
......@@ -65,7 +65,7 @@ func TestOpenMsgReceived(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
fsm := newFSM2(&Peer{
fsm := newFSM2(&peer{
peerASN: test.asn,
})
......
......@@ -70,7 +70,7 @@ func TestOpenMessage(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
p := Peer{
p := peer{
localASN: test.localASN,
holdTime: test.holdTime,
routerID: test.routerID,
......
......@@ -108,6 +108,7 @@ func newPeer(c config.Peer, rib routingtable.RouteTableClient, server *bgpServer
server: server,
addr: c.PeerAddress,
peerASN: c.PeerAS,
localASN: c.LocalAS,
fsms: make([]*FSM, 0),
rib: rib,
addPathSend: c.AddPathSend,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment