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 /packet/bgp_test.go | |
parent | 007c0df5092df0be2e03df457dcfcb89c92080d6 (diff) |
packet: return aspath length based on the segment type.
Diffstat (limited to 'packet/bgp_test.go')
-rw-r--r-- | packet/bgp_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/packet/bgp_test.go b/packet/bgp_test.go index 3b5d7b4c..8afa7363 100644 --- a/packet/bgp_test.go +++ b/packet/bgp_test.go @@ -323,3 +323,42 @@ func Test_RFC5512(t *testing.T) { assert.Equal(nil, err) assert.Equal("2001::1", n2.String()) } + +func Test_ASLen(t *testing.T) { + assert := assert.New(t) + + aspath := AsPathParam{ + Num: 2, + AS: []uint16{65000, 65001}, + } + aspath.Type = BGP_ASPATH_ATTR_TYPE_SEQ + assert.Equal(2, aspath.ASLen()) + + aspath.Type = BGP_ASPATH_ATTR_TYPE_SET + assert.Equal(1, aspath.ASLen()) + + aspath.Type = BGP_ASPATH_ATTR_TYPE_CONFED_SEQ + assert.Equal(0, aspath.ASLen()) + + aspath.Type = BGP_ASPATH_ATTR_TYPE_CONFED_SET + assert.Equal(0, aspath.ASLen()) + + + as4path := As4PathParam{ + Num: 2, + AS: []uint32{65000, 65001}, + } + as4path.Type = BGP_ASPATH_ATTR_TYPE_SEQ + assert.Equal(2, as4path.ASLen()) + + as4path.Type = BGP_ASPATH_ATTR_TYPE_SET + assert.Equal(1, as4path.ASLen()) + + as4path.Type = BGP_ASPATH_ATTR_TYPE_CONFED_SEQ + assert.Equal(0, as4path.ASLen()) + + as4path.Type = BGP_ASPATH_ATTR_TYPE_CONFED_SET + assert.Equal(0, as4path.ASLen()) + +} + |