}
/* Return 1 if there are any 4-byte ASes in the path */
-unsigned int aspath_has_as4(struct aspath *aspath)
+bool aspath_has_as4(struct aspath *aspath)
{
struct assegment *seg = aspath->segments;
unsigned int i;
while (seg) {
for (i = 0; i < seg->length; i++)
if (seg->as[i] > BGP_AS_MAX)
- return 1;
+ return true;
seg = seg->next;
}
- return 0;
+ return false;
}
/* Convert aspath structure to string expression. */
/* When a BGP router receives an UPDATE with an MP_REACH_NLRI
attribute, check the leftmost AS number in the AS_PATH attribute is
or not the peer's AS number. */
-int aspath_firstas_check(struct aspath *aspath, as_t asno)
+bool aspath_firstas_check(struct aspath *aspath, as_t asno)
{
if ((aspath == NULL) || (aspath->segments == NULL))
- return 0;
+ return false;
if (aspath->segments && (aspath->segments->type == AS_SEQUENCE)
&& (aspath->segments->as[0] == asno))
- return 1;
+ return true;
- return 0;
+ return false;
}
unsigned int aspath_get_first_as(struct aspath *aspath)
}
/* When all of AS path is private AS return 1. */
-int aspath_private_as_check(struct aspath *aspath)
+bool aspath_private_as_check(struct aspath *aspath)
{
struct assegment *seg;
if (!(aspath && aspath->segments))
- return 0;
+ return false;
seg = aspath->segments;
for (i = 0; i < seg->length; i++) {
if (!BGP_AS_IS_PRIVATE(seg->as[i]))
- return 0;
+ return false;
}
seg = seg->next;
}
- return 1;
+ return true;
}
/* Return True if the entire ASPATH consist of the specified ASN */
-int aspath_single_asn_check(struct aspath *aspath, as_t asn)
+bool aspath_single_asn_check(struct aspath *aspath, as_t asn)
{
struct assegment *seg;
if (!(aspath && aspath->segments))
- return 0;
+ return false;
seg = aspath->segments;
for (i = 0; i < seg->length; i++) {
if (seg->as[i] != asn)
- return 0;
+ return false;
}
seg = seg->next;
}
- return 1;
+ return true;
}
/* Replace all instances of the target ASN with our own ASN */
/* AS path confed check. If aspath contains confed set or sequence then return
* 1. */
-int aspath_confed_check(struct aspath *aspath)
+bool aspath_confed_check(struct aspath *aspath)
{
struct assegment *seg;
if (!(aspath && aspath->segments))
- return 0;
+ return false;
seg = aspath->segments;
while (seg) {
if (seg->type == AS_CONFED_SET
|| seg->type == AS_CONFED_SEQUENCE)
- return 1;
+ return true;
seg = seg->next;
}
- return 0;
+ return false;
}
/* Leftmost AS path segment confed check. If leftmost AS segment is of type
AS_CONFED_SEQUENCE or AS_CONFED_SET then return 1. */
-int aspath_left_confed_check(struct aspath *aspath)
+bool aspath_left_confed_check(struct aspath *aspath)
{
if (!(aspath && aspath->segments))
- return 0;
+ return false;
if ((aspath->segments->type == AS_CONFED_SEQUENCE)
|| (aspath->segments->type == AS_CONFED_SET))
- return 1;
+ return true;
- return 0;
+ return false;
}
/* Merge as1 to as2. as2 should be uninterned aspath. */
/* Compare leftmost AS value for MED check. If as1's leftmost AS and
as2's leftmost AS is same return 1. */
-int aspath_cmp_left(const struct aspath *aspath1, const struct aspath *aspath2)
+bool aspath_cmp_left(const struct aspath *aspath1, const struct aspath *aspath2)
{
const struct assegment *seg1;
const struct assegment *seg2;
if (!(aspath1 && aspath2))
- return 0;
+ return false;
seg1 = aspath1->segments;
seg2 = aspath2->segments;
/* If both paths are originated in this AS then we do want to compare
* MED */
if (!seg1 && !seg2)
- return 1;
+ return true;
/* find first non-confed segments for each */
while (seg1 && ((seg1->type == AS_CONFED_SEQUENCE)
/* Check as1's */
if (!(seg1 && seg2 && (seg1->type == AS_SEQUENCE)
&& (seg2->type == AS_SEQUENCE)))
- return 0;
+ return false;
if (seg1->as[0] == seg2->as[0])
- return 1;
+ return true;
- return 0;
+ return false;
}
/* Truncate an aspath after a number of hops, and put the hops remaining
extern struct aspath *aspath_add_seq(struct aspath *, as_t);
extern struct aspath *aspath_add_confed_seq(struct aspath *, as_t);
extern bool aspath_cmp(const void *as1, const void *as2);
-extern int aspath_cmp_left(const struct aspath *, const struct aspath *);
+extern bool aspath_cmp_left(const struct aspath *, const struct aspath *);
extern bool aspath_cmp_left_confed(const struct aspath *as1,
const struct aspath *as2xs);
extern struct aspath *aspath_delete_confed_seq(struct aspath *);
extern unsigned int aspath_get_first_as(struct aspath *);
extern unsigned int aspath_get_last_as(struct aspath *);
extern int aspath_loop_check(struct aspath *, as_t);
-extern int aspath_private_as_check(struct aspath *);
-extern int aspath_single_asn_check(struct aspath *, as_t asn);
+extern bool aspath_private_as_check(struct aspath *);
+extern bool aspath_single_asn_check(struct aspath *, as_t asn);
extern struct aspath *aspath_replace_specific_asn(struct aspath *aspath,
as_t target_asn,
as_t our_asn);
as_t asn, as_t peer_asn);
extern struct aspath *aspath_remove_private_asns(struct aspath *aspath,
as_t peer_asn);
-extern int aspath_firstas_check(struct aspath *, as_t);
-extern int aspath_confed_check(struct aspath *);
-extern int aspath_left_confed_check(struct aspath *);
+extern bool aspath_firstas_check(struct aspath *, as_t);
+extern bool aspath_confed_check(struct aspath *);
+extern bool aspath_left_confed_check(struct aspath *);
extern unsigned long aspath_count(void);
extern unsigned int aspath_count_hops(const struct aspath *);
extern bool aspath_check_as_sets(struct aspath *aspath);
extern size_t aspath_put(struct stream *, struct aspath *, int);
extern struct aspath *aspath_reconcile_as4(struct aspath *, struct aspath *);
-extern unsigned int aspath_has_as4(struct aspath *);
+extern bool aspath_has_as4(struct aspath *);
/* For SNMP BGP4PATHATTRASPATHSEGMENT, might be useful for debug */
extern uint8_t *aspath_snmp_pathseg(struct aspath *, size_t *);