forked from Mirror/frr
lib: add zapi_nexthop2str()
Add a handy 2str api for zapi nexthop debugging. Signed-off-by: Mark Stapp <mjs@voltanet.io>
This commit is contained in:
parent
daaeaa2150
commit
ae076fc276
|
@ -1542,6 +1542,39 @@ int zapi_backup_nexthop_from_nexthop(struct zapi_nexthop *znh,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Format some info about a zapi nexthop, for debug or logging.
|
||||||
|
*/
|
||||||
|
const char *zapi_nexthop2str(const struct zapi_nexthop *znh, char *buf,
|
||||||
|
int bufsize)
|
||||||
|
{
|
||||||
|
char tmp[INET6_ADDRSTRLEN];
|
||||||
|
|
||||||
|
switch (znh->type) {
|
||||||
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
|
snprintf(buf, bufsize, "if %u", znh->ifindex);
|
||||||
|
break;
|
||||||
|
case NEXTHOP_TYPE_IPV4:
|
||||||
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||||
|
inet_ntop(AF_INET, &znh->gate.ipv4, tmp, sizeof(tmp));
|
||||||
|
snprintf(buf, bufsize, "%s if %u", tmp, znh->ifindex);
|
||||||
|
break;
|
||||||
|
case NEXTHOP_TYPE_IPV6:
|
||||||
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||||
|
inet_ntop(AF_INET6, &znh->gate.ipv6, tmp, sizeof(tmp));
|
||||||
|
snprintf(buf, bufsize, "%s if %u", tmp, znh->ifindex);
|
||||||
|
break;
|
||||||
|
case NEXTHOP_TYPE_BLACKHOLE:
|
||||||
|
snprintf(buf, bufsize, "blackhole");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
snprintf(buf, bufsize, "unknown");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Decode the nexthop-tracking update message
|
* Decode the nexthop-tracking update message
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -804,6 +804,8 @@ int zapi_backup_nexthop_from_nexthop(struct zapi_nexthop *znh,
|
||||||
const struct nexthop *nh);
|
const struct nexthop *nh);
|
||||||
extern bool zapi_nexthop_update_decode(struct stream *s,
|
extern bool zapi_nexthop_update_decode(struct stream *s,
|
||||||
struct zapi_route *nhr);
|
struct zapi_route *nhr);
|
||||||
|
const char *zapi_nexthop2str(const struct zapi_nexthop *znh, char *buf,
|
||||||
|
int bufsize);
|
||||||
|
|
||||||
/* Decode the zebra error message */
|
/* Decode the zebra error message */
|
||||||
extern bool zapi_error_decode(struct stream *s, enum zebra_error_types *error);
|
extern bool zapi_error_decode(struct stream *s, enum zebra_error_types *error);
|
||||||
|
|
Loading…
Reference in a new issue