int index;
int offset;
- static uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,
- 0xf8, 0xfc, 0xfe, 0xff};
+ static const uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,
+ 0xf8, 0xfc, 0xfe, 0xff};
switch (rprefix->prefix.addr_family) {
case AF_INET:
}
}
- if (bpi->attr && bpi->attr->ecommunity) {
+ if (bpi->attr->ecommunity) {
s = ecommunity_ecom2str(bpi->attr->ecommunity,
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
vty_out(vty, " EC{%s}", s);
* RFP option sizes (they are opaque values)
* extended communities (RTs)
*/
- if (bpi->attr) {
- uint32_t lifetime;
- int printed_1st_gol = 0;
- struct bgp_attr_encap_subtlv *pEncap;
- struct prefix pfx_un;
- int af = BGP_MP_NEXTHOP_FAMILY(bpi->attr->mp_nexthop_len);
-
- /* Nexthop */
- if (af == AF_INET) {
- r = snprintf(p, REMAIN, "%s",
- inet_ntop(AF_INET,
- &bpi->attr->mp_nexthop_global_in,
- buf, BUFSIZ));
- INCP;
- } else if (af == AF_INET6) {
- r = snprintf(p, REMAIN, "%s",
- inet_ntop(AF_INET6,
- &bpi->attr->mp_nexthop_global,
- buf, BUFSIZ));
- INCP;
- } else {
- r = snprintf(p, REMAIN, "?");
- INCP;
- }
+ uint32_t lifetime;
+ int printed_1st_gol = 0;
+ struct bgp_attr_encap_subtlv *pEncap;
+ struct prefix pfx_un;
+ int af = BGP_MP_NEXTHOP_FAMILY(bpi->attr->mp_nexthop_len);
+
+ /* Nexthop */
+ if (af == AF_INET) {
+ r = snprintf(p, REMAIN, "%s",
+ inet_ntop(AF_INET,
+ &bpi->attr->mp_nexthop_global_in, buf,
+ BUFSIZ));
+ INCP;
+ } else if (af == AF_INET6) {
+ r = snprintf(p, REMAIN, "%s",
+ inet_ntop(AF_INET6, &bpi->attr->mp_nexthop_global,
+ buf, BUFSIZ));
+ INCP;
+ } else {
+ r = snprintf(p, REMAIN, "?");
+ INCP;
+ }
- /*
- * VNC tunnel subtlv, if present, contains UN address
- */
- if (!rfapiGetVncTunnelUnAddr(bpi->attr, &pfx_un)) {
- r = snprintf(p, REMAIN, " un=%s",
- inet_ntop(pfx_un.family, pfx_un.u.val, buf,
- BUFSIZ));
- INCP;
- }
+ /*
+ * VNC tunnel subtlv, if present, contains UN address
+ */
+ if (!rfapiGetVncTunnelUnAddr(bpi->attr, &pfx_un)) {
+ r = snprintf(
+ p, REMAIN, " un=%s",
+ inet_ntop(pfx_un.family, pfx_un.u.val, buf, BUFSIZ));
+ INCP;
+ }
- /* Lifetime */
- if (rfapiGetVncLifetime(bpi->attr, &lifetime)) {
- r = snprintf(p, REMAIN, " nolife");
- INCP;
- } else {
- if (lifetime == 0xffffffff)
- r = snprintf(p, REMAIN, " %6s", "infini");
- else
- r = snprintf(p, REMAIN, " %6u", lifetime);
- INCP;
- }
+ /* Lifetime */
+ if (rfapiGetVncLifetime(bpi->attr, &lifetime)) {
+ r = snprintf(p, REMAIN, " nolife");
+ INCP;
+ } else {
+ if (lifetime == 0xffffffff)
+ r = snprintf(p, REMAIN, " %6s", "infini");
+ else
+ r = snprintf(p, REMAIN, " %6u", lifetime);
+ INCP;
+ }
- /* RFP option lengths */
- for (pEncap = bpi->attr->vnc_subtlvs; pEncap;
- pEncap = pEncap->next) {
+ /* RFP option lengths */
+ for (pEncap = bpi->attr->vnc_subtlvs; pEncap; pEncap = pEncap->next) {
- if (pEncap->type == BGP_VNC_SUBTLV_TYPE_RFPOPTION) {
- if (printed_1st_gol) {
- r = snprintf(p, REMAIN, ",");
- INCP;
- } else {
- r = snprintf(p, REMAIN,
- " "); /* leading space */
- INCP;
- }
- r = snprintf(p, REMAIN, "%d", pEncap->length);
+ if (pEncap->type == BGP_VNC_SUBTLV_TYPE_RFPOPTION) {
+ if (printed_1st_gol) {
+ r = snprintf(p, REMAIN, ",");
+ INCP;
+ } else {
+ r = snprintf(p, REMAIN,
+ " "); /* leading space */
INCP;
- printed_1st_gol = 1;
}
- }
-
- /* RT list */
- if (bpi->attr->ecommunity) {
- s = ecommunity_ecom2str(bpi->attr->ecommunity,
- ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
- r = snprintf(p, REMAIN, " %s", s);
+ r = snprintf(p, REMAIN, "%d", pEncap->length);
INCP;
- XFREE(MTYPE_ECOMMUNITY_STR, s);
+ printed_1st_gol = 1;
}
}
+ /* RT list */
+ if (bpi->attr->ecommunity) {
+ s = ecommunity_ecom2str(bpi->attr->ecommunity,
+ ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
+ r = snprintf(p, REMAIN, " %s", s);
+ INCP;
+ XFREE(MTYPE_ECOMMUNITY_STR, s);
+ }
+
r = snprintf(p, REMAIN, " bpi@%p", bpi);
INCP;
INCP;
}
- if (bpi->attr) {
-
- if (bpi->attr->weight) {
- r = snprintf(p, REMAIN, " W=%d", bpi->attr->weight);
- INCP;
- }
+ if (bpi->attr->weight) {
+ r = snprintf(p, REMAIN, " W=%d", bpi->attr->weight);
+ INCP;
+ }
- if (bpi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) {
- r = snprintf(p, REMAIN, " LP=%d",
- bpi->attr->local_pref);
- INCP;
- } else {
- r = snprintf(p, REMAIN, " LP=unset");
- INCP;
- }
+ if (bpi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) {
+ r = snprintf(p, REMAIN, " LP=%d", bpi->attr->local_pref);
+ INCP;
+ } else {
+ r = snprintf(p, REMAIN, " LP=unset");
+ INCP;
}
r = snprintf(p, REMAIN, " %c:%u", zebra_route_char(bpi->type),
* See rfapi_import.c'rfapiRouteInfo2NextHopEntry() for conversion
* back to cost.
*/
- if (bpi->attr) {
- uint32_t local_pref;
- if (bpi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
- local_pref = bpi->attr->local_pref;
- else
- local_pref = 0;
- cost = (local_pref > 255) ? 0 : 255 - local_pref;
- } else {
- cost = 0;
- }
+ uint32_t local_pref;
+
+ if (bpi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
+ local_pref = bpi->attr->local_pref;
+ else
+ local_pref = 0;
+ cost = (local_pref > 255) ? 0 : 255 - local_pref;
fp(out, "%-20s ", buf_pfx);
fp(out, "%-15s ", buf_vn);
rfapiQprefix2Rprefix(&pfx, &rpfx);
memset(optary, 0, sizeof(optary));
if (arg_rd) {
- if (opt != NULL)
- opt->next = &optary[cur_opt];
opt = &optary[cur_opt++];
opt->type = RFAPI_VN_OPTION_TYPE_INTERNAL_RD;
if (!str2prefix_rd(arg_rd, &opt->v.internal_rd)) {