summaryrefslogtreecommitdiffhomepage
path: root/table/path.go
diff options
context:
space:
mode:
Diffstat (limited to 'table/path.go')
-rw-r--r--table/path.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/table/path.go b/table/path.go
index 62a98aab..29d8a92d 100644
--- a/table/path.go
+++ b/table/path.go
@@ -35,6 +35,7 @@ type Path interface {
GetRouteFamily() bgp.RouteFamily
setSource(source *PeerInfo)
GetSource() *PeerInfo
+ GetSourceAs() uint32
GetNexthop() net.IP
SetNexthop(net.IP)
setWithdraw(withdraw bool)
@@ -224,6 +225,22 @@ func (pd *PathDefault) GetSource() *PeerInfo {
return pd.source
}
+func (pd *PathDefault) GetSourceAs() uint32 {
+ _, attr := pd.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ if attr != nil {
+ asPathParam := attr.(*bgp.PathAttributeAsPath).Value
+ if len(asPathParam) == 0 {
+ return 0
+ }
+ asPath := asPathParam[len(asPathParam)-1].(*bgp.As4PathParam)
+ if asPath.Num == 0 {
+ return 0
+ }
+ return asPath.AS[asPath.Num-1]
+ }
+ return 0
+}
+
func (pd *PathDefault) GetNexthop() net.IP {
_, attr := pd.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
if attr != nil {