diff options
author | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2015-05-19 19:30:26 +0900 |
---|---|---|
committer | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2015-05-19 20:14:43 +0900 |
commit | f91a3a61b48fb7a3aad6aac492d487fb72b32a34 (patch) | |
tree | f1244dbec6e795c3de599911d26913cb8b94b2b7 /table | |
parent | cd4412ae538542ca7dc7f599bc30b7ac2b14fbb2 (diff) |
policy: support aspath condition
Diffstat (limited to 'table')
-rw-r--r-- | table/path.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/table/path.go b/table/path.go index ffbdd902..6c2995a8 100644 --- a/table/path.go +++ b/table/path.go @@ -35,6 +35,7 @@ type Path interface { GetRouteFamily() bgp.RouteFamily GetAsPathLen() int GetAsList() []uint32 + GetAsSeqList() []uint32 setSource(source *PeerInfo) GetSource() *PeerInfo GetSourceAs() uint32 @@ -363,14 +364,29 @@ func (pd *PathDefault) GetAsPathLen() int { } func (pd *PathDefault) GetAsList() []uint32 { + return pd.getAsListofSpecificType(true, true) + +} + +func (pd *PathDefault) GetAsSeqList() []uint32 { + return pd.getAsListofSpecificType(true, false) + +} + +func (pd *PathDefault) getAsListofSpecificType(getAsSeq, getAsSet bool) []uint32 { asList := []uint32{} 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) - asList = append(asList, segment.AS...) + if getAsSeq && segment.Type == bgp.BGP_ASPATH_ATTR_TYPE_SEQ{ + asList = append(asList, segment.AS...) + continue + } + if getAsSet && segment.Type == bgp.BGP_ASPATH_ATTR_TYPE_SET{ + asList = append(asList, segment.AS...) + } } - } return asList } |