summaryrefslogtreecommitdiffhomepage
path: root/table/path.go
diff options
context:
space:
mode:
Diffstat (limited to 'table/path.go')
-rw-r--r--table/path.go13
1 files changed, 3 insertions, 10 deletions
diff --git a/table/path.go b/table/path.go
index 522534d9..b72a894e 100644
--- a/table/path.go
+++ b/table/path.go
@@ -339,29 +339,22 @@ func (pi *PathDefault) getPrefix() string {
return pi.nlri.String()
}
-// return total length of AS_PATH whose type is AS_SEQ or AS_SET
+// GetAsPathLen returns the number of AS_PATH
func (pd *PathDefault) GetAsPathLen() int {
- aslen := func(p *bgp.As4PathParam) int {
- if p.Type == bgp.BGP_ASPATH_ATTR_TYPE_SEQ || p.Type == bgp.BGP_ASPATH_ATTR_TYPE_SET {
- return p.ASLen()
- }
- return 0
- }
-
var length int = 0
if _, attr := pd.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH); attr != nil {
aspath := attr.(*bgp.PathAttributeAsPath)
for _, paramIf := range aspath.Value {
segment := paramIf.(*bgp.As4PathParam)
- length += aslen(segment)
+ length += segment.ASLen()
}
} else {
_, attr := pd.getPathAttr(bgp.BGP_ATTR_TYPE_AS4_PATH)
aspath := attr.(*bgp.PathAttributeAs4Path)
for _, segment := range aspath.Value {
- length += aslen(segment)
+ length += segment.ASLen()
}
}
return length