diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2018-02-27 09:49:35 +0900 |
---|---|---|
committer | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2018-04-03 09:16:41 +0900 |
commit | 264bd0ca126bf721687764332a01315d56e5b671 (patch) | |
tree | 05a0eb911e99fcba2a621fde34f6fc749f130d1d /server/rpki.go | |
parent | a25522edddf05653bef26c5ff220f34f7354791f (diff) |
packet/bgp: Getter functions for AS segment
This patch adds getter functions for the segment type and AS list of
each segment without using type assertion.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'server/rpki.go')
-rw-r--r-- | server/rpki.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/server/rpki.go b/server/rpki.go index 8f286930..75f25409 100644 --- a/server/rpki.go +++ b/server/rpki.go @@ -511,13 +511,14 @@ func ValidatePath(ownAs uint32, tree *radix.Tree, cidr string, asPath *bgp.PathA if asPath == nil || len(asPath.Value) == 0 { as = ownAs } else { - asParam := asPath.Value[len(asPath.Value)-1].(*bgp.As4PathParam) - switch asParam.Type { + param := asPath.Value[len(asPath.Value)-1] + switch param.GetType() { case bgp.BGP_ASPATH_ATTR_TYPE_SEQ: - if len(asParam.AS) == 0 { + asList := param.GetAS() + if len(asList) == 0 { as = ownAs } else { - as = asParam.AS[len(asParam.AS)-1] + as = asList[len(asList)-1] } case bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SET, bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SEQ: as = ownAs |