diff options
Diffstat (limited to 'bgpd/bgp_aspath.h')
-rw-r--r-- | bgpd/bgp_aspath.h | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/bgpd/bgp_aspath.h b/bgpd/bgp_aspath.h index d55f9ce6..74eb775c 100644 --- a/bgpd/bgp_aspath.h +++ b/bgpd/bgp_aspath.h @@ -21,6 +21,13 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #ifndef _QUAGGA_BGP_ASPATH_H #define _QUAGGA_BGP_ASPATH_H +#include <stdbool.h> + +/* Macro in case there are particular compiler issues. */ +#ifndef Inline + #define Inline static inline +#endif + /* AS path segment type. */ #define AS_SET 1 #define AS_SEQUENCE 2 @@ -47,14 +54,14 @@ struct assegment }; /* AS path may be include some AsSegments. */ -struct aspath +struct aspath { /* Reference count to this aspath. */ unsigned long refcnt; /* segment data */ struct assegment *segments; - + /* String expression of AS path. This string is used by vty output and AS path regular expression match. */ char *str; @@ -65,7 +72,7 @@ struct aspath /* Prototypes. */ extern void aspath_init (void); extern void aspath_finish (void); -extern struct aspath *aspath_parse (struct stream *, size_t, int); +extern struct aspath *aspath_parse (struct stream *, size_t, bool, bool); extern struct aspath *aspath_dup (struct aspath *); extern struct aspath *aspath_aggregate (struct aspath *, struct aspath *); extern struct aspath *aspath_prepend (struct aspath *, struct aspath *); @@ -103,4 +110,22 @@ extern unsigned int aspath_has_as4 (struct aspath *); /* For SNMP BGP4PATHATTRASPATHSEGMENT, might be useful for debug */ extern u_char *aspath_snmp_pathseg (struct aspath *, size_t *); +Inline as_t +aspath_origin(struct aspath* asp) +{ + struct assegment* seg ; + + if ((asp == NULL) || (asp->segments == NULL)) + return 0 ; + + seg = asp->segments ; + while (seg->next != NULL) + seg = seg->next ; + + if ((seg->length == 0) || (seg->type != AS_SEQUENCE)) + return 0 ; + + return seg->as[seg->length - 1] ; +} ; + #endif /* _QUAGGA_BGP_ASPATH_H */ |