]> git.proxmox.com Git - mirror_frr.git/blame - lib/nexthop.h
Quagga: Basic definitions for MPLS
[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 *
18 * You should have received a copy of the GNU General Public License
a399694f 19 * along with Quagga; see the file COPYING. If not, write to the Free
fb018d25
DS
20 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 * 02111-1307, USA.
22 */
23
24#ifndef _LIB_NEXTHOP_H
25#define _LIB_NEXTHOP_H
26
27#include "prefix.h"
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
47/* Nexthop structure. */
48struct nexthop
49{
50 struct nexthop *next;
51 struct nexthop *prev;
52
53 /* Interface index. */
b892f1dd 54 ifindex_t ifindex;
fb018d25
DS
55
56 enum nexthop_types_t type;
57
58 u_char flags;
59#define NEXTHOP_FLAG_ACTIVE (1 << 0) /* This nexthop is alive. */
60#define NEXTHOP_FLAG_FIB (1 << 1) /* FIB nexthop. */
61#define NEXTHOP_FLAG_RECURSIVE (1 << 2) /* Recursive nexthop. */
62#define NEXTHOP_FLAG_ONLINK (1 << 3) /* Nexthop should be installed onlink. */
63#define NEXTHOP_FLAG_MATCHED (1 << 4) /* Already matched vs a nexthop */
6e26278c 64#define NEXTHOP_FLAG_FILTERED (1 << 5) /* rmap filtered, used by static only */
fb018d25
DS
65
66 /* Nexthop address */
67 union g_addr gate;
68 union g_addr src;
c52ef59f 69 union g_addr rmap_src; /* Src is set via routemap */
fb018d25
DS
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
18ff3edd
DS
80extern int zebra_rnh_ip_default_route;
81extern int zebra_rnh_ipv6_default_route;
82
83static inline int
84nh_resolve_via_default(int family)
85{
86 if (((family == AF_INET) && zebra_rnh_ip_default_route) ||
87 ((family == AF_INET6) && zebra_rnh_ipv6_default_route))
88 return 1;
89 else
90 return 0;
91}
92
a399694f
DS
93struct nexthop *nexthop_new (void);
94void nexthop_add (struct nexthop **target, struct nexthop *nexthop);
95
96void copy_nexthops (struct nexthop **tnh, struct nexthop *nh);
97void nexthop_free (struct nexthop *nexthop);
98void nexthops_free (struct nexthop *nexthop);
99
fb018d25
DS
100extern const char *nexthop_type_to_str (enum nexthop_types_t nh_type);
101extern int nexthop_same_no_recurse (struct nexthop *next1, struct nexthop *next2);
102
80c2442a 103extern const char * nexthop2str (struct nexthop *nexthop, char *str, int size);
fb018d25 104#endif /*_LIB_NEXTHOP_H */