]> git.proxmox.com Git - mirror_frr.git/blame - lib/zebra.h
bgpd: allow for case where vrf sockets aren't needed (default accepts for vrf)
[mirror_frr.git] / lib / zebra.h
CommitLineData
718e3744 1/* Zebra common header.
896014f4
DL
2 * Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Kunihiro Ishiguro
3 *
4 * This file is part of GNU Zebra.
5 *
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
9 * later version.
10 *
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.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
718e3744 20
21#ifndef _ZEBRA_H
22#define _ZEBRA_H
23
24#ifdef HAVE_CONFIG_H
25#include "config.h"
26#endif /* HAVE_CONFIG_H */
27
ef7eec74
QY
28#include "compiler.h"
29
718e3744 30#ifdef SUNOS_5
31#define _XPG4_2
d7c0a89a
QY
32typedef unsigned int uint32_t;
33typedef unsigned short uint16_t;
34typedef unsigned char uint8_t;
718e3744 35#endif /* SUNOS_5 */
36
37#include <unistd.h>
38#include <stdio.h>
39#include <stdlib.h>
c423d413 40#include <stddef.h>
718e3744 41#include <ctype.h>
42#include <errno.h>
43#include <fcntl.h>
44#include <signal.h>
45#include <string.h>
edd7c245 46#include <pwd.h>
47#include <grp.h>
718e3744 48#ifdef HAVE_STROPTS_H
49#include <stropts.h>
50#endif /* HAVE_STROPTS_H */
718e3744 51#include <sys/select.h>
718e3744 52#include <sys/stat.h>
718e3744 53#include <sys/types.h>
54#include <sys/param.h>
55#ifdef HAVE_SYS_SYSCTL_H
0dc0b708
AS
56#ifdef GNU_LINUX
57#include <linux/types.h>
58#endif
718e3744 59#include <sys/sysctl.h>
60#endif /* HAVE_SYS_SYSCTL_H */
61#include <sys/ioctl.h>
62#ifdef HAVE_SYS_CONF_H
63#include <sys/conf.h>
64#endif /* HAVE_SYS_CONF_H */
65#ifdef HAVE_SYS_KSYM_H
66#include <sys/ksym.h>
67#endif /* HAVE_SYS_KSYM_H */
68#include <syslog.h>
24f5e2fc
DL
69#include <sys/time.h>
70#include <time.h>
718e3744 71#include <sys/uio.h>
72#include <sys/utsname.h>
718e3744 73#include <sys/resource.h>
a58c25b6 74#include <limits.h>
35cfc90c 75#include <inttypes.h>
63a13864 76#include <stdbool.h>
718e3744 77
78/* machine dependent includes */
79#ifdef SUNOS_5
718e3744 80#include <strings.h>
81#endif /* SUNOS_5 */
82
83/* machine dependent includes */
84#ifdef HAVE_LINUX_VERSION_H
85#include <linux/version.h>
86#endif /* HAVE_LINUX_VERSION_H */
87
ba965c6c 88#ifdef HAVE_ASM_TYPES_H
89#include <asm/types.h>
90#endif /* HAVE_ASM_TYPES_H */
91
718e3744 92/* misc include group */
93#include <stdarg.h>
4cf0d0df 94#if !(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
95/* Not C99; do we need to define va_copy? */
e22f5516 96#ifndef va_copy
97#ifdef __va_copy
4cf0d0df 98#define va_copy(DST,SRC) __va_copy(DST,SRC)
e22f5516 99#else
d62a17ae 100/* Now we are desperate; this should work on many typical platforms.
e22f5516 101 But this is slightly dangerous, because the standard does not require
102 va_copy to be a macro. */
103#define va_copy(DST,SRC) memcpy(&(DST), &(SRC), sizeof(va_list))
104#warning "Not C99 and no va_copy macro available, falling back to memcpy"
105#endif /* __va_copy */
106#endif /* !va_copy */
4cf0d0df 107#endif /* !C99 */
db8eaac6 108
718e3744 109
ba3a0bc5 110#ifdef HAVE_LCAPS
111#include <sys/capability.h>
112#include <sys/prctl.h>
113#endif /* HAVE_LCAPS */
114
ceacedba 115#ifdef HAVE_SOLARIS_CAPABILITIES
116#include <priv.h>
117#endif /* HAVE_SOLARIS_CAPABILITIES */
118
718e3744 119/* network include group */
120
121#include <sys/socket.h>
122
123#ifdef HAVE_SYS_SOCKIO_H
124#include <sys/sockio.h>
125#endif /* HAVE_SYS_SOCKIO_H */
126
ea057677
HT
127#ifdef __APPLE__
128#define __APPLE_USE_RFC_3542
129#endif
130
f9e75524 131#ifndef HAVE_LIBCRYPT
996c9314
LB
132#ifdef HAVE_LIBCRYPTO
133#include <openssl/des.h>
f9e75524 134# define crypt DES_crypt
996c9314 135#endif
f9e75524
JAG
136#endif
137
8d8763f4 138#include "openbsd-tree.h"
6021c8d3 139
718e3744 140#include <netinet/in.h>
718e3744 141#include <netinet/in_systm.h>
142#include <netinet/ip.h>
143#include <netinet/tcp.h>
144
145#ifdef HAVE_NET_NETOPT_H
146#include <net/netopt.h>
147#endif /* HAVE_NET_NETOPT_H */
148
149#include <net/if.h>
150
151#ifdef HAVE_NET_IF_DL_H
152#include <net/if_dl.h>
153#endif /* HAVE_NET_IF_DL_H */
154
155#ifdef HAVE_NET_IF_VAR_H
156#include <net/if_var.h>
157#endif /* HAVE_NET_IF_VAR_H */
158
159#include <net/route.h>
160
161#ifdef HAVE_NETLINK
162#include <linux/netlink.h>
163#include <linux/rtnetlink.h>
768a27ea 164#include <linux/filter.h>
718e3744 165#else
166#define RT_TABLE_MAIN 0
167#endif /* HAVE_NETLINK */
168
718e3744 169#include <netdb.h>
718e3744 170#include <arpa/inet.h>
718e3744 171
172#ifdef HAVE_INET_ND_H
173#include <inet/nd.h>
174#endif /* HAVE_INET_ND_H */
175
176#ifdef HAVE_NETINET_IN_VAR_H
177#include <netinet/in_var.h>
178#endif /* HAVE_NETINET_IN_VAR_H */
179
726f9b2b 180#ifdef HAVE_NETINET6_IN6_VAR_H
181#include <netinet6/in6_var.h>
182#endif /* HAVE_NETINET6_IN6_VAR_H */
183
718e3744 184#ifdef HAVE_NETINET_IN6_VAR_H
185#include <netinet/in6_var.h>
186#endif /* HAVE_NETINET_IN6_VAR_H */
187
188#ifdef HAVE_NETINET6_IN_H
189#include <netinet6/in.h>
190#endif /* HAVE_NETINET6_IN_H */
191
192
193#ifdef HAVE_NETINET6_IP6_H
194#include <netinet6/ip6.h>
195#endif /* HAVE_NETINET6_IP6_H */
196
718e3744 197#include <netinet/icmp6.h>
718e3744 198
199#ifdef HAVE_NETINET6_ND6_H
200#include <netinet6/nd6.h>
201#endif /* HAVE_NETINET6_ND6_H */
202
35cfc90c
PJ
203/* Some systems do not define UINT32_MAX, etc.. from inttypes.h
204 * e.g. this makes life easier for FBSD 4.11 users.
205 */
206#ifndef INT8_MAX
207#define INT8_MAX (127)
208#endif
209#ifndef INT16_MAX
210#define INT16_MAX (32767)
211#endif
212#ifndef INT32_MAX
213#define INT32_MAX (2147483647)
214#endif
215#ifndef UINT8_MAX
216#define UINT8_MAX (255U)
217#endif
218#ifndef UINT16_MAX
219#define UINT16_MAX (65535U)
220#endif
3b424979 221#ifndef UINT32_MAX
35cfc90c
PJ
222#define UINT32_MAX (4294967295U)
223#endif
3b424979 224
fb2d1502 225#ifdef HAVE_GLIBC_BACKTRACE
226#include <execinfo.h>
227#endif /* HAVE_GLIBC_BACKTRACE */
228
db8eaac6 229/* Local includes: */
d62a17ae 230#if !(defined(__GNUC__) || defined(VTYSH_EXTRACT_PL))
db8eaac6 231#define __attribute__(x)
d62a17ae 232#endif /* !__GNUC__ || VTYSH_EXTRACT_PL */
db8eaac6 233
234#include "zassert.h"
235
c5d9d3bb 236#ifndef HAVE_STRLCAT
c9a164df
DS
237size_t strlcat(char *__restrict dest,
238 const char *__restrict src, size_t destsize);
c5d9d3bb
DL
239#endif
240#ifndef HAVE_STRLCPY
c9a164df
DS
241size_t strlcpy(char *__restrict dest,
242 const char *__restrict src, size_t destsize);
c5d9d3bb 243#endif
db8eaac6 244
b99760ab 245#ifdef HAVE_BROKEN_CMSG_FIRSTHDR
246/* This bug is present in Solaris 8 and pre-patch Solaris 9 <sys/socket.h>;
247 please refer to http://bugzilla.quagga.net/show_bug.cgi?id=142 */
248
249/* Check that msg_controllen is large enough. */
d62a17ae 250#define ZCMSG_FIRSTHDR(mhdr) \
251 (((size_t)((mhdr)->msg_controllen) >= sizeof(struct cmsghdr)) \
252 ? CMSG_FIRSTHDR(mhdr) \
253 : (struct cmsghdr *)NULL)
b99760ab 254
255#warning "CMSG_FIRSTHDR is broken on this platform, using a workaround"
256
d62a17ae 257#else /* HAVE_BROKEN_CMSG_FIRSTHDR */
b99760ab 258#define ZCMSG_FIRSTHDR(M) CMSG_FIRSTHDR(M)
259#endif /* HAVE_BROKEN_CMSG_FIRSTHDR */
260
261
fe232cf8
QY
262/* GCC have printf type attribute check. */
263#ifdef __GNUC__
264#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
265#else
266#define PRINTF_ATTRIBUTE(a,b)
267#endif /* __GNUC__ */
b99760ab 268
d62a17ae 269/*
69e1325f 270 * RFC 3542 defines several macros for using struct cmsghdr.
271 * Here, we define those that are not present
272 */
273
274/*
275 * Internal defines, for use only in this file.
276 * These are likely wrong on other than ILP32 machines, so warn.
02ff83c5 277 */
278#ifndef _CMSG_DATA_ALIGN
279#define _CMSG_DATA_ALIGN(n) (((n) + 3) & ~3)
280#endif /* _CMSG_DATA_ALIGN */
281
282#ifndef _CMSG_HDR_ALIGN
283#define _CMSG_HDR_ALIGN(n) (((n) + 3) & ~3)
284#endif /* _CMSG_HDR_ALIGN */
285
69e1325f 286/*
287 * CMSG_SPACE and CMSG_LEN are required in RFC3542, but were new in that
288 * version.
289 */
02ff83c5 290#ifndef CMSG_SPACE
d62a17ae 291#define CMSG_SPACE(l) \
292 (_CMSG_DATA_ALIGN(sizeof(struct cmsghdr)) + _CMSG_HDR_ALIGN(l))
69e1325f 293#warning "assuming 4-byte alignment for CMSG_SPACE"
d62a17ae 294#endif /* CMSG_SPACE */
02ff83c5 295
296
297#ifndef CMSG_LEN
298#define CMSG_LEN(l) (_CMSG_DATA_ALIGN(sizeof(struct cmsghdr)) + (l))
69e1325f 299#warning "assuming 4-byte alignment for CMSG_LEN"
02ff83c5 300#endif /* CMSG_LEN */
301
69e1325f 302
718e3744 303/* The definition of struct in_pktinfo is missing in old version of
304 GLIBC 2.1 (Redhat 6.1). */
d62a17ae 305#if defined(GNU_LINUX) && !defined(HAVE_STRUCT_IN_PKTINFO)
306struct in_pktinfo {
307 int ipi_ifindex;
308 struct in_addr ipi_spec_dst;
309 struct in_addr ipi_addr;
718e3744 310};
311#endif
312
d62a17ae 313/*
9172ee0e 314 * IP_HDRINCL / struct ip byte order
315 *
316 * Linux: network byte order
317 * *BSD: network, except for length and offset. (cf Stevens)
318 * SunOS: nominally as per BSD. but bug: network order on LE.
d62a17ae 319 * OpenBSD: network byte order, apart from older versions which are as per
9172ee0e 320 * *BSD
321 */
d62a17ae 322#if defined(__NetBSD__) \
323 || (defined(__FreeBSD__) && (__FreeBSD_version < 1100030)) \
324 || (defined(__OpenBSD__) && (OpenBSD < 200311)) \
325 || (defined(__APPLE__)) \
326 || (defined(SUNOS_5) && defined(WORDS_BIGENDIAN))
9172ee0e 327#define HAVE_IP_HDRINCL_BSD_ORDER
328#endif
329
34204aac 330/* Define BYTE_ORDER, if not defined. Useful for compiler conditional
331 * code, rather than preprocessor conditional.
332 * Not all the world has this BSD define.
333 */
334#ifndef BYTE_ORDER
335#define BIG_ENDIAN 4321 /* least-significant byte first (vax, pc) */
336#define LITTLE_ENDIAN 1234 /* most-significant byte first (IBM, net) */
337#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */
338
339#if defined(WORDS_BIGENDIAN)
340#define BYTE_ORDER BIG_ENDIAN
d62a17ae 341#else /* !WORDS_BIGENDIAN */
34204aac 342#define BYTE_ORDER LITTLE_ENDIAN
343#endif /* WORDS_BIGENDIAN */
344
345#endif /* ndef BYTE_ORDER */
346
efba6ce9 347/* MAX / MIN are not commonly defined, but useful */
6b143a68
DL
348/* note: glibc sys/param.h has #define MIN(a,b) (((a)<(b))?(a):(b)) */
349#ifdef MAX
350#undef MAX
351#endif
d62a17ae 352#define MAX(a, b) \
353 ({ \
354 typeof(a) _a = (a); \
355 typeof(b) _b = (b); \
356 _a > _b ? _a : _b; \
357 })
6b143a68
DL
358#ifdef MIN
359#undef MIN
8a0bebfc 360#endif
d62a17ae 361#define MIN(a, b) \
362 ({ \
363 typeof(a) _a = (a); \
364 typeof(b) _b = (b); \
365 _a < _b ? _a : _b; \
366 })
efba6ce9 367
0915bb0c
AS
368#define ZEBRA_NUM_OF(x) (sizeof (x) / sizeof (x[0]))
369
718e3744 370/* For old definition. */
371#ifndef IN6_ARE_ADDR_EQUAL
372#define IN6_ARE_ADDR_EQUAL IN6_IS_ADDR_EQUAL
373#endif /* IN6_ARE_ADDR_EQUAL */
374
8cc4198f 375/* default zebra TCP port for zclient */
376#define ZEBRA_PORT 2600
377
c1b9800a 378/* Marker value used in new Zserv, in the byte location corresponding
379 * the command value in the old zserv header. To allow old and new
380 * Zserv headers to be distinguished from each other.
381 */
80e71dcd 382#define ZEBRA_HEADER_MARKER 254
c1b9800a 383
e0ca5fde
DL
384/* Zebra route's types are defined in route_types.h */
385#include "route_types.h"
718e3744 386
d6d672aa
PJ
387/* Note: whenever a new route-type or zserv-command is added the
388 * corresponding {command,route}_types[] table in lib/log.c MUST be
389 * updated! */
f52d13cb 390
391/* Map a route type to a string. For example, ZEBRA_ROUTE_RIPNG -> "ripng". */
b6026073 392extern const char *zebra_route_string(unsigned int route_type);
f52d13cb 393/* Map a route type to a char. For example, ZEBRA_ROUTE_RIPNG -> 'R'. */
b6026073 394extern char zebra_route_char(unsigned int route_type);
d62a17ae 395/* Map a zserv command type to the same string,
d6d672aa 396 * e.g. ZEBRA_INTERFACE_ADD -> "ZEBRA_INTERFACE_ADD" */
7514fb77
PJ
397/* Map a protocol name to its number. e.g. ZEBRA_ROUTE_BGP->9*/
398extern int proto_name2num(const char *s);
e0ca5fde
DL
399/* Map redistribute X argument to protocol number.
400 * unlike proto_name2num, this accepts shorthands and takes
401 * an AFI value to restrict input */
402extern int proto_redistnum(int afi, const char *s);
7514fb77 403
d62a17ae 404extern const char *zserv_command_string(unsigned int command);
f52d13cb 405
bf31fc81
DL
406#define strmatch(a,b) (!strcmp((a), (b)))
407
718e3744 408/* Zebra message flags */
4e8b02f4 409#define ZEBRA_FLAG_ALLOW_RECURSION 0x01
718e3744 410#define ZEBRA_FLAG_SELFROUTE 0x02
718e3744 411#define ZEBRA_FLAG_IBGP 0x08
412#define ZEBRA_FLAG_SELECTED 0x10
718e3744 413#define ZEBRA_FLAG_STATIC 0x40
525c1839 414#define ZEBRA_FLAG_SCOPE_LINK 0x100
446bb95e 415#define ZEBRA_FLAG_FIB_OVERRIDE 0x200
90264d64 416#define ZEBRA_FLAG_EVPN_ROUTE 0x400
a8309422
DL
417/* ZEBRA_FLAG_BLACKHOLE was 0x04 */
418/* ZEBRA_FLAG_REJECT was 0x80 */
718e3744 419
28d58fd7
VV
420/* Zebra FEC flags. */
421#define ZEBRA_FEC_REGISTER_LABEL_INDEX 0x1
422
718e3744 423#ifndef INADDR_LOOPBACK
424#define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */
425#endif
426
427/* Address family numbers from RFC1700. */
d62a17ae 428typedef enum { AFI_IP = 1, AFI_IP6 = 2, AFI_L2VPN = 3, AFI_MAX = 4 } afi_t;
718e3744 429
430/* Subsequent Address Family Identifier. */
5c525538
RW
431typedef enum {
432 SAFI_UNICAST = 1,
433 SAFI_MULTICAST = 2,
434 SAFI_MPLS_VPN = 3,
435 SAFI_ENCAP = 4,
436 SAFI_EVPN = 5,
437 SAFI_LABELED_UNICAST = 6,
b98f7728
PG
438 SAFI_FLOWSPEC = 7,
439 SAFI_MAX = 8
5c525538 440} safi_t;
718e3744 441
90d82769
DS
442/*
443 * The above AFI and SAFI definitions are for internal use. The protocol
444 * definitions (IANA values) as for example used in BGP protocol packets
445 * are defined below and these will get mapped to/from the internal values
446 * in the appropriate places.
447 * The rationale is that the protocol (IANA) values may be sparse and are
448 * not optimal for use in data-structure sizing.
449 * Note: Only useful (i.e., supported) values are defined below.
450 */
451typedef enum {
d62a17ae 452 IANA_AFI_RESERVED = 0,
453 IANA_AFI_IPV4 = 1,
454 IANA_AFI_IPV6 = 2,
455 IANA_AFI_L2VPN = 25,
456 IANA_AFI_IPMR = 128,
457 IANA_AFI_IP6MR = 129
90d82769
DS
458} iana_afi_t;
459
5c525538
RW
460typedef enum {
461 IANA_SAFI_RESERVED = 0,
462 IANA_SAFI_UNICAST = 1,
463 IANA_SAFI_MULTICAST = 2,
464 IANA_SAFI_LABELED_UNICAST = 4,
465 IANA_SAFI_ENCAP = 7,
466 IANA_SAFI_EVPN = 70,
7c40bf39 467 IANA_SAFI_MPLS_VPN = 128,
468 IANA_SAFI_FLOWSPEC = 133
5c525538 469} iana_safi_t;
718e3744 470
718e3744 471/* Default Administrative Distance of each protocol. */
472#define ZEBRA_KERNEL_DISTANCE_DEFAULT 0
473#define ZEBRA_CONNECT_DISTANCE_DEFAULT 0
474#define ZEBRA_STATIC_DISTANCE_DEFAULT 1
475#define ZEBRA_RIP_DISTANCE_DEFAULT 120
476#define ZEBRA_RIPNG_DISTANCE_DEFAULT 120
477#define ZEBRA_OSPF_DISTANCE_DEFAULT 110
478#define ZEBRA_OSPF6_DISTANCE_DEFAULT 110
9e867fe6 479#define ZEBRA_ISIS_DISTANCE_DEFAULT 115
718e3744 480#define ZEBRA_IBGP_DISTANCE_DEFAULT 200
481#define ZEBRA_EBGP_DISTANCE_DEFAULT 20
7ab5795a 482#define ZEBRA_TABLE_DISTANCE_DEFAULT 15
718e3744 483
484/* Flag manipulation macros. */
485#define CHECK_FLAG(V,F) ((V) & (F))
548e6f7d 486#define SET_FLAG(V,F) (V) |= (F)
487#define UNSET_FLAG(V,F) (V) &= ~(F)
fb018d25 488#define RESET_FLAG(V) (V) = 0
985aba54 489#define COND_FLAG(V, F, C) ((C) ? (SET_FLAG(V, F)) : (UNSET_FLAG(V, F)))
718e3744 490
f765d422
QY
491/* Atomic flag manipulation macros. */
492#define CHECK_FLAG_ATOMIC(PV, F) \
493 ((atomic_load_explicit(PV, memory_order_seq_cst)) & (F))
494#define SET_FLAG_ATOMIC(PV, F) \
495 ((atomic_fetch_or_explicit(PV, (F), memory_order_seq_cst)))
496#define UNSET_FLAG_ATOMIC(PV, F) \
497 ((atomic_fetch_and_explicit(PV, ~(F), memory_order_seq_cst)))
498#define RESET_FLAG_ATOMIC(PV) \
499 ((atomic_store_explicit(PV, 0, memory_order_seq_cst)))
500
c1b9800a 501/* Zebra types. Used in Zserv message header. */
d7c0a89a
QY
502typedef uint16_t zebra_size_t;
503typedef uint16_t zebra_command_t;
718e3744 504
b72ede27 505/* VRF ID type. */
a9ff90c4 506typedef uint32_t vrf_id_t;
b72ede27 507
dc9ffce8
CF
508typedef uint32_t route_tag_t;
509#define ROUTE_TAG_MAX UINT32_MAX
510#define ROUTE_TAG_PRI PRIu32
511
d62a17ae 512static inline afi_t afi_iana2int(iana_afi_t afi)
9cabb64b 513{
085347cf
RW
514 switch (afi) {
515 case IANA_AFI_IPV4:
d62a17ae 516 return AFI_IP;
085347cf 517 case IANA_AFI_IPV6:
d62a17ae 518 return AFI_IP6;
085347cf 519 case IANA_AFI_L2VPN:
d62a17ae 520 return AFI_L2VPN;
085347cf
RW
521 default:
522 return AFI_MAX;
523 }
9cabb64b 524}
525
d62a17ae 526static inline iana_afi_t afi_int2iana(afi_t afi)
9cabb64b 527{
085347cf
RW
528 switch (afi) {
529 case AFI_IP:
d62a17ae 530 return IANA_AFI_IPV4;
085347cf 531 case AFI_IP6:
d62a17ae 532 return IANA_AFI_IPV6;
085347cf 533 case AFI_L2VPN:
d62a17ae 534 return IANA_AFI_L2VPN;
085347cf
RW
535 default:
536 return IANA_AFI_RESERVED;
537 }
9cabb64b 538}
539
5c525538 540static inline safi_t safi_iana2int(iana_safi_t safi)
9cabb64b 541{
085347cf
RW
542 switch (safi) {
543 case IANA_SAFI_UNICAST:
d62a17ae 544 return SAFI_UNICAST;
085347cf 545 case IANA_SAFI_MULTICAST:
d62a17ae 546 return SAFI_MULTICAST;
085347cf 547 case IANA_SAFI_MPLS_VPN:
d62a17ae 548 return SAFI_MPLS_VPN;
085347cf 549 case IANA_SAFI_ENCAP:
d62a17ae 550 return SAFI_ENCAP;
085347cf 551 case IANA_SAFI_EVPN:
d62a17ae 552 return SAFI_EVPN;
085347cf 553 case IANA_SAFI_LABELED_UNICAST:
d62a17ae 554 return SAFI_LABELED_UNICAST;
7c40bf39 555 case IANA_SAFI_FLOWSPEC:
556 return SAFI_FLOWSPEC;
085347cf
RW
557 default:
558 return SAFI_MAX;
559 }
9cabb64b 560}
561
5c525538 562static inline iana_safi_t safi_int2iana(safi_t safi)
9cabb64b 563{
085347cf
RW
564 switch (safi) {
565 case SAFI_UNICAST:
d62a17ae 566 return IANA_SAFI_UNICAST;
085347cf 567 case SAFI_MULTICAST:
d62a17ae 568 return IANA_SAFI_MULTICAST;
085347cf 569 case SAFI_MPLS_VPN:
d62a17ae 570 return IANA_SAFI_MPLS_VPN;
085347cf 571 case SAFI_ENCAP:
d62a17ae 572 return IANA_SAFI_ENCAP;
085347cf 573 case SAFI_EVPN:
d62a17ae 574 return IANA_SAFI_EVPN;
085347cf 575 case SAFI_LABELED_UNICAST:
d62a17ae 576 return IANA_SAFI_LABELED_UNICAST;
7c40bf39 577 case SAFI_FLOWSPEC:
578 return IANA_SAFI_FLOWSPEC;
085347cf
RW
579 default:
580 return IANA_SAFI_RESERVED;
581 }
9cabb64b 582}
583
718e3744 584#endif /* _ZEBRA_H */