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.go | |
parent | 007c0df5092df0be2e03df457dcfcb89c92080d6 (diff) |
packet: return aspath length based on the segment type.
Diffstat (limited to 'packet/bgp.go')
-rw-r--r-- | packet/bgp.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/packet/bgp.go b/packet/bgp.go index 533b0288..6f541037 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -1997,7 +1997,15 @@ func (a *AsPathParam) Len() int { } func (a *AsPathParam) ASLen() int { - return len(a.AS) + switch a.Type { + case BGP_ASPATH_ATTR_TYPE_SEQ: + return len(a.AS) + case BGP_ASPATH_ATTR_TYPE_SET: + return 1 + case BGP_ASPATH_ATTR_TYPE_CONFED_SET,BGP_ASPATH_ATTR_TYPE_CONFED_SEQ: + return 0 + } + return 0 } func NewAsPathParam(segType uint8, as []uint16) *AsPathParam { @@ -2048,7 +2056,15 @@ func (a *As4PathParam) Len() int { } func (a *As4PathParam) ASLen() int { - return len(a.AS) + switch a.Type { + case BGP_ASPATH_ATTR_TYPE_SEQ: + return len(a.AS) + case BGP_ASPATH_ATTR_TYPE_SET: + return 1 + case BGP_ASPATH_ATTR_TYPE_CONFED_SET,BGP_ASPATH_ATTR_TYPE_CONFED_SEQ: + return 0 + } + return 0 } func NewAs4PathParam(segType uint8, as []uint32) *As4PathParam { |