]> git.proxmox.com Git - mirror_frr.git/blame - lib/nexthop.h
Update comments for ALL_NEXTHOPS_RO definition
[mirror_frr.git] / lib / nexthop.h
CommitLineData
fb018d25
DS
1/*
2 * Nexthop structure definition.
a399694f 3 * Copyright (C) 1997, 98, 99, 2001 Kunihiro Ishiguro
fb018d25
DS
4 * Copyright (C) 2013 Cumulus Networks, Inc.
5 *
a399694f 6 * This file is part of Quagga.
fb018d25 7 *
a399694f 8 * Quagga is free software; you can redistribute it and/or modify it
fb018d25
DS
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
a399694f 13 * Quagga is distributed in the hope that it will be useful, but
fb018d25
DS
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
896014f4
DL
18 * You should have received a copy of the GNU General Public License along
19 * with this program; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
fb018d25
DS
21 */
22
23#ifndef _LIB_NEXTHOP_H
24#define _LIB_NEXTHOP_H
25
26#include "prefix.h"
54d48ea1 27#include "mpls.h"
fb018d25 28
80c2442a 29/* Maximum next hop string length - gateway + ifindex */
30#define NEXTHOP_STRLEN (INET6_ADDRSTRLEN + 30)
31
fb018d25
DS
32union g_addr {
33 struct in_addr ipv4;
fb018d25 34 struct in6_addr ipv6;
fb018d25
DS
35};
36
37enum nexthop_types_t
38{
39 NEXTHOP_TYPE_IFINDEX = 1, /* Directly connected. */
fb018d25
DS
40 NEXTHOP_TYPE_IPV4, /* IPv4 nexthop. */
41 NEXTHOP_TYPE_IPV4_IFINDEX, /* IPv4 nexthop with ifindex. */
fb018d25
DS
42 NEXTHOP_TYPE_IPV6, /* IPv6 nexthop. */
43 NEXTHOP_TYPE_IPV6_IFINDEX, /* IPv6 nexthop with ifindex. */
fb018d25
DS
44 NEXTHOP_TYPE_BLACKHOLE, /* Null0 nexthop. */
45};
46
54d48ea1 47/* Nexthop label structure. */
48struct nexthop_label
49{
50 u_int8_t num_labels;
51 u_int8_t reserved[3];
52 mpls_label_t label[0]; /* 1 or more labels. */
53};
54
fb018d25
DS
55/* Nexthop structure. */
56struct nexthop
57{
58 struct nexthop *next;
59 struct nexthop *prev;
60
61 /* Interface index. */
b892f1dd 62 ifindex_t ifindex;
fb018d25
DS
63
64 enum nexthop_types_t type;
65
66 u_char flags;
67#define NEXTHOP_FLAG_ACTIVE (1 << 0) /* This nexthop is alive. */
68#define NEXTHOP_FLAG_FIB (1 << 1) /* FIB nexthop. */
69#define NEXTHOP_FLAG_RECURSIVE (1 << 2) /* Recursive nexthop. */
70#define NEXTHOP_FLAG_ONLINK (1 << 3) /* Nexthop should be installed onlink. */
71#define NEXTHOP_FLAG_MATCHED (1 << 4) /* Already matched vs a nexthop */
6e26278c 72#define NEXTHOP_FLAG_FILTERED (1 << 5) /* rmap filtered, used by static only */
fb018d25
DS
73
74 /* Nexthop address */
75 union g_addr gate;
76 union g_addr src;
c52ef59f 77 union g_addr rmap_src; /* Src is set via routemap */
fb018d25
DS
78
79 /* Nexthops obtained by recursive resolution.
80 *
81 * If the nexthop struct needs to be resolved recursively,
82 * NEXTHOP_FLAG_RECURSIVE will be set in flags and the nexthops
83 * obtained by recursive resolution will be added to `resolved'.
f9e1b38e 84 */
fb018d25 85 struct nexthop *resolved;
f9e1b38e 86 /* Recursive parent */
87 struct nexthop *rparent;
40c7bdb0 88
ce549947
RW
89 /* Type of label(s), if any */
90 enum lsp_types_t nh_label_type;
91
40c7bdb0 92 /* Label(s) associated with this nexthop. */
93 struct nexthop_label *nh_label;
fb018d25
DS
94};
95
18ff3edd
DS
96extern int zebra_rnh_ip_default_route;
97extern int zebra_rnh_ipv6_default_route;
98
99static inline int
100nh_resolve_via_default(int family)
101{
102 if (((family == AF_INET) && zebra_rnh_ip_default_route) ||
103 ((family == AF_INET6) && zebra_rnh_ipv6_default_route))
104 return 1;
105 else
106 return 0;
107}
108
a399694f
DS
109struct nexthop *nexthop_new (void);
110void nexthop_add (struct nexthop **target, struct nexthop *nexthop);
111
f9e1b38e 112void copy_nexthops (struct nexthop **tnh, struct nexthop *nh, struct nexthop *rparent);
a399694f
DS
113void nexthop_free (struct nexthop *nexthop);
114void nexthops_free (struct nexthop *nexthop);
115
ce549947 116void nexthop_add_labels (struct nexthop *, enum lsp_types_t, u_int8_t, mpls_label_t *);
40c7bdb0 117void nexthop_del_labels (struct nexthop *);
118
fb018d25
DS
119extern const char *nexthop_type_to_str (enum nexthop_types_t nh_type);
120extern int nexthop_same_no_recurse (struct nexthop *next1, struct nexthop *next2);
a64448ba 121extern int nexthop_labels_match (struct nexthop *nh1, struct nexthop *nh2);
fb018d25 122
80c2442a 123extern const char * nexthop2str (struct nexthop *nexthop, char *str, int size);
fb018d25 124#endif /*_LIB_NEXTHOP_H */