diff options
author | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2015-06-02 20:25:58 +0900 |
---|---|---|
committer | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2015-06-02 21:09:04 +0900 |
commit | e985f476a182f1a66084b3ed4b1c2376f9cc5018 (patch) | |
tree | 91dfbaf8f5685bac44afad834cbf4c1d32b7c8c5 /table/path_test.go | |
parent | 007c0df5092df0be2e03df457dcfcb89c92080d6 (diff) |
packet: return aspath length based on the segment type.
Diffstat (limited to 'table/path_test.go')
-rw-r--r-- | table/path_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/table/path_test.go b/table/path_test.go index aa8c4aa2..05aa423d 100644 --- a/table/path_test.go +++ b/table/path_test.go @@ -145,6 +145,35 @@ func TestPathGetAttribute(t *testing.T) { assert.Equal(t, r_nh, nh) } +func TestASPathLen(t *testing.T) { + assert := assert.New(t) + origin := bgp.NewPathAttributeOrigin(0) + aspathParam := []bgp.AsPathParamInterface{ + bgp.NewAsPathParam(bgp.BGP_ASPATH_ATTR_TYPE_SEQ, []uint16{65001, 65002, 65003, 65004, 65004, 65004, 65004, 65004, 65005}), + bgp.NewAsPathParam(bgp.BGP_ASPATH_ATTR_TYPE_SET, []uint16{65001, 65002, 65003, 65004, 65005}), + bgp.NewAsPathParam(bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SEQ, []uint16{65100, 65101, 65102}), + bgp.NewAsPathParam(bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SET, []uint16{65100, 65101}),} + aspath := bgp.NewPathAttributeAsPath(aspathParam) + nexthop := bgp.NewPathAttributeNextHop("192.168.50.1") + med := bgp.NewPathAttributeMultiExitDisc(0) + + pathAttributes := []bgp.PathAttributeInterface{ + origin, + aspath, + nexthop, + med, + } + + nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")} + withdrawnRoutes := []bgp.WithdrawnRoute{} + bgpmsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri) + update := bgpmsg.Body.(*bgp.BGPUpdate) + UpdatePathAttrs4ByteAs(update) + peer := PathCreatePeer() + p, _:= CreatePath(peer[0], &update.NLRI[0], update.PathAttributes, false, time.Now()) + assert.Equal(10, p.GetAsPathLen()) +} + func PathCreatePeer() []*PeerInfo { peerP1 := &PeerInfo{AS: 65000} peerP2 := &PeerInfo{AS: 65001} |