]> git.proxmox.com Git - mirror_frr.git/blame - lib/nexthop.h
nexthop-tracking.patch
[mirror_frr.git] / lib / nexthop.h
CommitLineData
fb018d25
DS
1/*
2 * Nexthop structure definition.
3 * Copyright (C) 2013 Cumulus Networks, Inc.
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23#ifndef _LIB_NEXTHOP_H
24#define _LIB_NEXTHOP_H
25
26#include "prefix.h"
27
28union g_addr {
29 struct in_addr ipv4;
30#ifdef HAVE_IPV6
31 struct in6_addr ipv6;
32#endif /* HAVE_IPV6 */
33};
34
35enum nexthop_types_t
36{
37 NEXTHOP_TYPE_IFINDEX = 1, /* Directly connected. */
38 NEXTHOP_TYPE_IFNAME, /* Interface route. */
39 NEXTHOP_TYPE_IPV4, /* IPv4 nexthop. */
40 NEXTHOP_TYPE_IPV4_IFINDEX, /* IPv4 nexthop with ifindex. */
41 NEXTHOP_TYPE_IPV4_IFNAME, /* IPv4 nexthop with ifname. */
42 NEXTHOP_TYPE_IPV6, /* IPv6 nexthop. */
43 NEXTHOP_TYPE_IPV6_IFINDEX, /* IPv6 nexthop with ifindex. */
44 NEXTHOP_TYPE_IPV6_IFNAME, /* IPv6 nexthop with ifname. */
45 NEXTHOP_TYPE_BLACKHOLE, /* Null0 nexthop. */
46};
47
48/* Nexthop structure. */
49struct nexthop
50{
51 struct nexthop *next;
52 struct nexthop *prev;
53
54 /* Interface index. */
55 char *ifname;
56 unsigned int ifindex;
57
58 enum nexthop_types_t type;
59
60 u_char flags;
61#define NEXTHOP_FLAG_ACTIVE (1 << 0) /* This nexthop is alive. */
62#define NEXTHOP_FLAG_FIB (1 << 1) /* FIB nexthop. */
63#define NEXTHOP_FLAG_RECURSIVE (1 << 2) /* Recursive nexthop. */
64#define NEXTHOP_FLAG_ONLINK (1 << 3) /* Nexthop should be installed onlink. */
65#define NEXTHOP_FLAG_MATCHED (1 << 4) /* Already matched vs a nexthop */
66
67 /* Nexthop address */
68 union g_addr gate;
69 union g_addr src;
70
71 /* Nexthops obtained by recursive resolution.
72 *
73 * If the nexthop struct needs to be resolved recursively,
74 * NEXTHOP_FLAG_RECURSIVE will be set in flags and the nexthops
75 * obtained by recursive resolution will be added to `resolved'.
76 * Only one level of recursive resolution is currently supported. */
77 struct nexthop *resolved;
78};
79
80#define nexthop_new() \
81({ \
82 struct nexthop *n = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); \
83 n; \
84})
85
86extern const char *nexthop_type_to_str (enum nexthop_types_t nh_type);
87extern int nexthop_same_no_recurse (struct nexthop *next1, struct nexthop *next2);
88
89#endif /*_LIB_NEXTHOP_H */