bgp_attr_extcom_tunnel_type(attr,
(bgp_encap_types *)&attr->encap_tunneltype);
+ /* Extract link bandwidth, if any. */
+ (void)ecommunity_linkbw_present(attr->ecommunity, &attr->link_bw);
+
return BGP_ATTR_PARSE_PROCEED;
}
/* rmap set table */
uint32_t rmap_table_id;
+
+ /* Link bandwidth value, if any. */
+ uint32_t link_bw;
};
/* rmap_change_flags definition */
{
return (attr) ? attr->mm_seqnum : 0;
}
-
#endif /* _QUAGGA_BGP_ATTR_H */
}
}
}
+
+/*
+ * return the BGP link bandwidth extended community, if present;
+ * the actual bandwidth is returned via param
+ */
+const uint8_t *ecommunity_linkbw_present(struct ecommunity *ecom, uint32_t *bw)
+{
+ const uint8_t *eval;
+ int i;
+
+ if (bw)
+ *bw = 0;
+
+ if (!ecom || !ecom->size)
+ return NULL;
+
+ for (i = 0; i < ecom->size; i++) {
+ const uint8_t *pnt;
+ uint8_t type, sub_type;
+ uint32_t bwval;
+
+ eval = pnt = (ecom->val + (i * ECOMMUNITY_SIZE));
+ type = *pnt++;
+ sub_type = *pnt++;
+
+ if ((type == ECOMMUNITY_ENCODE_AS ||
+ type == ECOMMUNITY_ENCODE_AS_NON_TRANS) &&
+ sub_type == ECOMMUNITY_LINK_BANDWIDTH) {
+ pnt += 2; /* bandwidth is encoded as AS:val */
+ pnt = ptr_get_be32(pnt, &bwval);
+ (void)pnt; /* consume value */
+ if (bw)
+ *bw = bwval;
+ return eval;
+ }
+ }
+
+ return NULL;
+}
struct bgp_aggregate *aggregate,
struct ecommunity *ecommunity);
extern void bgp_aggr_ecommunity_remove(void *arg);
-
+extern const uint8_t *ecommunity_linkbw_present(struct ecommunity *ecom,
+ uint32_t *bw);
static inline void ecommunity_strip_rts(struct ecommunity *ecom)
{