eigrpd: Cleanup address dump functions to be a bit smarter

The address dump functionality needed to be written a bit
better.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2019-11-22 08:17:27 -05:00
parent 152e64e301
commit d2d3d39415
2 changed files with 15 additions and 45 deletions

View File

@ -150,48 +150,6 @@ const char *eigrp_if_name_string(struct eigrp_interface *ei)
return ei->ifp->name;
}
const char *eigrp_topology_ip_string(struct eigrp_prefix_entry *tn)
{
static char buf[EIGRP_IF_STRING_MAXLEN] = "";
uint32_t ifaddr;
ifaddr = ntohl(tn->destination->u.prefix4.s_addr);
snprintf(buf, EIGRP_IF_STRING_MAXLEN, "%u.%u.%u.%u",
(ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff,
(ifaddr >> 8) & 0xff, ifaddr & 0xff);
return buf;
}
const char *eigrp_if_ip_string(struct eigrp_interface *ei)
{
static char buf[EIGRP_IF_STRING_MAXLEN] = "";
uint32_t ifaddr;
if (!ei)
return "inactive";
ifaddr = ntohl(ei->address.u.prefix4.s_addr);
snprintf(buf, EIGRP_IF_STRING_MAXLEN, "%u.%u.%u.%u",
(ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff,
(ifaddr >> 8) & 0xff, ifaddr & 0xff);
return buf;
}
const char *eigrp_neigh_ip_string(struct eigrp_neighbor *nbr)
{
static char buf[EIGRP_IF_STRING_MAXLEN] = "";
uint32_t ifaddr;
ifaddr = ntohl(nbr->src.s_addr);
snprintf(buf, EIGRP_IF_STRING_MAXLEN, "%u.%u.%u.%u",
(ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff,
(ifaddr >> 8) & 0xff, ifaddr & 0xff);
return buf;
}
void show_ip_eigrp_interface_header(struct vty *vty, struct eigrp *eigrp)
{

View File

@ -138,9 +138,21 @@ extern unsigned long term_debug_eigrp_zebra;
/* Prototypes. */
extern const char *eigrp_if_name_string(struct eigrp_interface *);
extern const char *eigrp_if_ip_string(struct eigrp_interface *);
extern const char *eigrp_neigh_ip_string(struct eigrp_neighbor *);
extern const char *eigrp_topology_ip_string(struct eigrp_prefix_entry *);
static inline const char
*eigrp_topology_ip_string(struct eigrp_prefix_entry *tn)
{
return inet_ntoa(tn->destination->u.prefix4);
}
static inline const char *eigrp_if_ip_string(struct eigrp_interface *ei)
{
return ei ? inet_ntoa(ei->address.u.prefix4) : "inactive";
}
static inline const char *eigrp_neigh_ip_string(struct eigrp_neighbor *nbr)
{
return inet_ntoa(nbr->src);
}
extern void eigrp_ip_header_dump(struct ip *);
extern void eigrp_header_dump(struct eigrp_header *);