From 264bd0ca126bf721687764332a01315d56e5b671 Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Tue, 27 Feb 2018 09:49:35 +0900 Subject: 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 --- server/rpki.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'server/rpki.go') 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 -- cgit v1.2.3