summaryrefslogtreecommitdiff
path: root/lib/nexthop.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nexthop.c')
-rw-r--r--lib/nexthop.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/nexthop.c b/lib/nexthop.c
index 2dba412f45..ea6a310a4a 100644
--- a/lib/nexthop.c
+++ b/lib/nexthop.c
@@ -71,6 +71,39 @@ int nexthop_same_no_recurse(const struct nexthop *next1,
return 1;
}
+int
+nexthop_same_firsthop (struct nexthop *next1, struct nexthop *next2)
+{
+ int type1 = NEXTHOP_FIRSTHOPTYPE(next1->type);
+ int type2 = NEXTHOP_FIRSTHOPTYPE(next2->type);
+
+ if (type1 != type2)
+ return 0;
+ switch (type1)
+ {
+ case NEXTHOP_TYPE_IPV4_IFINDEX:
+ if (! IPV4_ADDR_SAME (&next1->gate.ipv4, &next2->gate.ipv4))
+ return 0;
+ if (next1->ifindex != next2->ifindex)
+ return 0;
+ break;
+ case NEXTHOP_TYPE_IFINDEX:
+ if (next1->ifindex != next2->ifindex)
+ return 0;
+ break;
+ case NEXTHOP_TYPE_IPV6_IFINDEX:
+ if (! IPV6_ADDR_SAME (&next1->gate.ipv6, &next2->gate.ipv6))
+ return 0;
+ if (next1->ifindex != next2->ifindex)
+ return 0;
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+ return 1;
+}
+
/*
* nexthop_type_to_str
*/