1 /* A generic nexthop structure
2 * Copyright (C) 2013 Cumulus Networks, Inc.
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
30 #include "sockunion.h"
36 /* check if nexthops are same, non-recursive */
38 nexthop_same_no_recurse (struct nexthop
*next1
, struct nexthop
*next2
)
40 if (next1
->type
!= next2
->type
)
45 case NEXTHOP_TYPE_IPV4
:
46 case NEXTHOP_TYPE_IPV4_IFINDEX
:
47 if (! IPV4_ADDR_SAME (&next1
->gate
.ipv4
, &next2
->gate
.ipv4
))
49 if (next1
->ifindex
&& (next1
->ifindex
!= next2
->ifindex
))
52 case NEXTHOP_TYPE_IFINDEX
:
53 case NEXTHOP_TYPE_IFNAME
:
54 if (next1
->ifindex
!= next2
->ifindex
)
58 case NEXTHOP_TYPE_IPV6
:
59 if (! IPV6_ADDR_SAME (&next1
->gate
.ipv6
, &next2
->gate
.ipv6
))
62 case NEXTHOP_TYPE_IPV6_IFINDEX
:
63 case NEXTHOP_TYPE_IPV6_IFNAME
:
64 if (! IPV6_ADDR_SAME (&next1
->gate
.ipv6
, &next2
->gate
.ipv6
))
66 if (next1
->ifindex
!= next2
->ifindex
)
69 #endif /* HAVE_IPV6 */
81 nexthop_type_to_str (enum nexthop_types_t nh_type
)
83 static const char *desc
[] = {
88 "IPv4 nexthop with ifindex",
89 "IPv4 nexthop with ifname",
91 "IPv6 nexthop with ifindex",
92 "IPv6 nexthop with ifname",
96 if (nh_type
>= ZEBRA_NUM_OF (desc
))
97 return "<Invalid nh type>";