#include "prefix.h"
#include "nexthop.h"
#include "mpls.h"
+#include "jhash.h"
DEFINE_MTYPE_STATIC(LIB, NEXTHOP, "Nexthop")
DEFINE_MTYPE_STATIC(LIB, NH_LABEL, "Nexthop label")
}
}
-const char *nexthop2str(struct nexthop *nexthop, char *str, int size)
+const char *nexthop2str(const struct nexthop *nexthop, char *str, int size)
{
switch (nexthop->type) {
case NEXTHOP_TYPE_IFINDEX:
snprintf(str, size, "if %u", nexthop->ifindex);
break;
case NEXTHOP_TYPE_IPV4:
- snprintf(str, size, "%s", inet_ntoa(nexthop->gate.ipv4));
- break;
case NEXTHOP_TYPE_IPV4_IFINDEX:
snprintf(str, size, "%s if %u", inet_ntoa(nexthop->gate.ipv4),
nexthop->ifindex);
break;
case NEXTHOP_TYPE_IPV6:
- snprintf(str, size, "%s", inet6_ntoa(nexthop->gate.ipv6));
- break;
case NEXTHOP_TYPE_IPV6_IFINDEX:
snprintf(str, size, "%s if %u", inet6_ntoa(nexthop->gate.ipv6),
nexthop->ifindex);
return rv;
}
+
+uint32_t nexthop_hash(struct nexthop *nexthop)
+{
+ uint32_t key;
+
+ key = jhash_1word(nexthop->vrf_id, 0x45afe398);
+ key = jhash_1word(nexthop->ifindex, key);
+ key = jhash_1word(nexthop->type, key);
+ key = jhash(&nexthop->gate, sizeof(union g_addr), key);
+
+ return key;
+}