]> git.proxmox.com Git - mirror_frr.git/blob - lib/prefix.h
Merge pull request #6989 from xThaid/remove_fuzzing
[mirror_frr.git] / lib / prefix.h
1 /*
2 * Prefix structure.
3 * Copyright (C) 1998 Kunihiro Ishiguro
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 along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #ifndef _ZEBRA_PREFIX_H
23 #define _ZEBRA_PREFIX_H
24
25 #ifdef SUNOS_5
26 #include <sys/ethernet.h>
27 #else
28 #ifdef GNU_LINUX
29 #include <net/ethernet.h>
30 #else
31 #include <netinet/if_ether.h>
32 #endif
33 #endif
34 #include "sockunion.h"
35 #include "ipaddr.h"
36 #include "compiler.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 #ifndef ETH_ALEN
43 #define ETH_ALEN 6
44 #endif
45
46 /* EVPN route types. */
47 typedef enum {
48 BGP_EVPN_AD_ROUTE = 1, /* Ethernet Auto-Discovery (A-D) route */
49 BGP_EVPN_MAC_IP_ROUTE, /* MAC/IP Advertisement route */
50 BGP_EVPN_IMET_ROUTE, /* Inclusive Multicast Ethernet Tag route */
51 BGP_EVPN_ES_ROUTE, /* Ethernet Segment route */
52 BGP_EVPN_IP_PREFIX_ROUTE, /* IP Prefix route */
53 } bgp_evpn_route_type;
54
55 /* value of first byte of ESI */
56 #define ESI_TYPE_ARBITRARY 0 /* */
57 #define ESI_TYPE_LACP 1 /* <> */
58 #define ESI_TYPE_BRIDGE 2 /* <Root bridge Mac-6B>:<Root Br Priority-2B>:00 */
59 #define ESI_TYPE_MAC 3 /* <Syst Mac Add-6B>:<Local Discriminator Value-3B> */
60 #define ESI_TYPE_ROUTER 4 /* <RouterId-4B>:<Local Discriminator Value-4B> */
61 #define ESI_TYPE_AS 5 /* <AS-4B>:<Local Discriminator Value-4B> */
62
63 #define MAX_ESI {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
64
65
66 #define EVPN_ETH_TAG_BYTES 4
67 #define ESI_BYTES 10
68 #define ESI_STR_LEN (3 * ESI_BYTES)
69
70 /* Maximum number of VTEPs per-ES -
71 * XXX - temporary limit for allocating strings etc.
72 */
73 #define ES_VTEP_MAX_CNT 10
74 #define ES_VTEP_LIST_STR_SZ (ES_VTEP_MAX_CNT * 16)
75
76 #define ETHER_ADDR_STRLEN (3*ETH_ALEN)
77 /*
78 * there isn't a portable ethernet address type. We define our
79 * own to simplify internal handling
80 */
81 struct ethaddr {
82 uint8_t octet[ETH_ALEN];
83 } __attribute__((packed));
84
85
86 /* length is the number of valuable bits of prefix structure
87 * 18 bytes is current length in structure, if address is ipv4
88 * 30 bytes is in case of ipv6
89 */
90 #define PREFIX_LEN_ROUTE_TYPE_5_IPV4 (18*8)
91 #define PREFIX_LEN_ROUTE_TYPE_5_IPV6 (30*8)
92
93 typedef struct esi_t_ {
94 uint8_t val[ESI_BYTES];
95 } esi_t;
96
97 struct evpn_ead_addr {
98 esi_t esi;
99 uint32_t eth_tag;
100 struct ipaddr ip;
101 };
102
103 struct evpn_macip_addr {
104 uint32_t eth_tag;
105 uint8_t ip_prefix_length;
106 struct ethaddr mac;
107 struct ipaddr ip;
108 };
109
110 struct evpn_imet_addr {
111 uint32_t eth_tag;
112 uint8_t ip_prefix_length;
113 struct ipaddr ip;
114 };
115
116 struct evpn_es_addr {
117 esi_t esi;
118 uint8_t ip_prefix_length;
119 struct ipaddr ip;
120 };
121
122 struct evpn_prefix_addr {
123 uint32_t eth_tag;
124 uint8_t ip_prefix_length;
125 struct ipaddr ip;
126 };
127
128 /* EVPN address (RFC 7432) */
129 struct evpn_addr {
130 uint8_t route_type;
131 union {
132 struct evpn_ead_addr _ead_addr;
133 struct evpn_macip_addr _macip_addr;
134 struct evpn_imet_addr _imet_addr;
135 struct evpn_es_addr _es_addr;
136 struct evpn_prefix_addr _prefix_addr;
137 } u;
138 #define ead_addr u._ead_addr
139 #define macip_addr u._macip_addr
140 #define imet_addr u._imet_addr
141 #define es_addr u._es_addr
142 #define prefix_addr u._prefix_addr
143 };
144
145 /*
146 * A struct prefix contains an address family, a prefix length, and an
147 * address. This can represent either a 'network prefix' as defined
148 * by CIDR, where the 'host bits' of the prefix are 0
149 * (e.g. AF_INET:10.0.0.0/8), or an address and netmask
150 * (e.g. AF_INET:10.0.0.9/8), such as might be configured on an
151 * interface.
152 */
153
154 /* different OSes use different names */
155 #if defined(AF_PACKET)
156 #define AF_ETHERNET AF_PACKET
157 #else
158 #if defined(AF_LINK)
159 #define AF_ETHERNET AF_LINK
160 #endif
161 #endif
162
163 /* The 'family' in the prefix structure is internal to FRR and need not
164 * map to standard OS AF_ definitions except where needed for interacting
165 * with the kernel. However, AF_ definitions are currently in use and
166 * prevalent across the code. Define a new FRR-specific AF for EVPN to
167 * distinguish between 'ethernet' (MAC-only) and 'evpn' prefixes and
168 * ensure it does not conflict with any OS AF_ definition.
169 */
170 #if !defined(AF_EVPN)
171 #define AF_EVPN (AF_MAX + 1)
172 #endif
173
174 #if !defined(AF_FLOWSPEC)
175 #define AF_FLOWSPEC (AF_MAX + 2)
176 #endif
177
178 struct flowspec_prefix {
179 uint8_t family;
180 uint16_t prefixlen; /* length in bytes */
181 uintptr_t ptr;
182 };
183
184 /* FRR generic prefix structure. */
185 struct prefix {
186 uint8_t family;
187 uint16_t prefixlen;
188 union {
189 uint8_t prefix;
190 struct in_addr prefix4;
191 struct in6_addr prefix6;
192 struct {
193 struct in_addr id;
194 struct in_addr adv_router;
195 } lp;
196 struct ethaddr prefix_eth; /* AF_ETHERNET */
197 uint8_t val[16];
198 uint32_t val32[4];
199 uintptr_t ptr;
200 struct evpn_addr prefix_evpn; /* AF_EVPN */
201 struct flowspec_prefix prefix_flowspec; /* AF_FLOWSPEC */
202 } u __attribute__((aligned(8)));
203 };
204
205 /* IPv4 prefix structure. */
206 struct prefix_ipv4 {
207 uint8_t family;
208 uint16_t prefixlen;
209 struct in_addr prefix __attribute__((aligned(8)));
210 };
211
212 /* IPv6 prefix structure. */
213 struct prefix_ipv6 {
214 uint8_t family;
215 uint16_t prefixlen;
216 struct in6_addr prefix __attribute__((aligned(8)));
217 };
218
219 struct prefix_ls {
220 uint8_t family;
221 uint16_t prefixlen;
222 struct in_addr id __attribute__((aligned(8)));
223 struct in_addr adv_router;
224 };
225
226 /* Prefix for routing distinguisher. */
227 struct prefix_rd {
228 uint8_t family;
229 uint16_t prefixlen;
230 uint8_t val[8] __attribute__((aligned(8)));
231 };
232
233 /* Prefix for ethernet. */
234 struct prefix_eth {
235 uint8_t family;
236 uint16_t prefixlen;
237 struct ethaddr eth_addr __attribute__((aligned(8))); /* AF_ETHERNET */
238 };
239
240 /* EVPN prefix structure. */
241 struct prefix_evpn {
242 uint8_t family;
243 uint16_t prefixlen;
244 struct evpn_addr prefix __attribute__((aligned(8)));
245 };
246
247 static inline int is_evpn_prefix_ipaddr_none(const struct prefix_evpn *evp)
248 {
249 if (evp->prefix.route_type == BGP_EVPN_AD_ROUTE)
250 return IS_IPADDR_NONE(&(evp)->prefix.ead_addr.ip);
251 if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE)
252 return IS_IPADDR_NONE(&(evp)->prefix.macip_addr.ip);
253 if (evp->prefix.route_type == BGP_EVPN_IMET_ROUTE)
254 return IS_IPADDR_NONE(&(evp)->prefix.imet_addr.ip);
255 if (evp->prefix.route_type == BGP_EVPN_ES_ROUTE)
256 return IS_IPADDR_NONE(&(evp)->prefix.es_addr.ip);
257 if (evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE)
258 return IS_IPADDR_NONE(&(evp)->prefix.prefix_addr.ip);
259 return 0;
260 }
261
262 static inline int is_evpn_prefix_ipaddr_v4(const struct prefix_evpn *evp)
263 {
264 if (evp->prefix.route_type == BGP_EVPN_AD_ROUTE)
265 return IS_IPADDR_V4(&(evp)->prefix.ead_addr.ip);
266 if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE)
267 return IS_IPADDR_V4(&(evp)->prefix.macip_addr.ip);
268 if (evp->prefix.route_type == BGP_EVPN_IMET_ROUTE)
269 return IS_IPADDR_V4(&(evp)->prefix.imet_addr.ip);
270 if (evp->prefix.route_type == BGP_EVPN_ES_ROUTE)
271 return IS_IPADDR_V4(&(evp)->prefix.es_addr.ip);
272 if (evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE)
273 return IS_IPADDR_V4(&(evp)->prefix.prefix_addr.ip);
274 return 0;
275 }
276
277 static inline int is_evpn_prefix_ipaddr_v6(const struct prefix_evpn *evp)
278 {
279 if (evp->prefix.route_type == BGP_EVPN_AD_ROUTE)
280 return IS_IPADDR_V6(&(evp)->prefix.ead_addr.ip);
281 if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE)
282 return IS_IPADDR_V6(&(evp)->prefix.macip_addr.ip);
283 if (evp->prefix.route_type == BGP_EVPN_IMET_ROUTE)
284 return IS_IPADDR_V6(&(evp)->prefix.imet_addr.ip);
285 if (evp->prefix.route_type == BGP_EVPN_ES_ROUTE)
286 return IS_IPADDR_V6(&(evp)->prefix.es_addr.ip);
287 if (evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE)
288 return IS_IPADDR_V6(&(evp)->prefix.prefix_addr.ip);
289 return 0;
290 }
291
292 /* Prefix for a generic pointer */
293 struct prefix_ptr {
294 uint8_t family;
295 uint16_t prefixlen;
296 uintptr_t prefix __attribute__((aligned(8)));
297 };
298
299 /* Prefix for a Flowspec entry */
300 struct prefix_fs {
301 uint8_t family;
302 uint16_t prefixlen; /* unused */
303 struct flowspec_prefix prefix __attribute__((aligned(8)));
304 };
305
306 struct prefix_sg {
307 uint8_t family;
308 uint16_t prefixlen;
309 struct in_addr src __attribute__((aligned(8)));
310 struct in_addr grp;
311 };
312
313 /* helper to get type safety/avoid casts on calls
314 * (w/o this, functions accepting all prefix types need casts on the caller
315 * side, which strips type safety since the cast will accept any pointer
316 * type.)
317 */
318 #ifndef __cplusplus
319 #define prefixtype(uname, typename, fieldname) \
320 typename *fieldname;
321 #else
322 #define prefixtype(uname, typename, fieldname) \
323 typename *fieldname; \
324 uname(typename *x) { this->fieldname = x; }
325 #endif
326
327 union prefixptr {
328 prefixtype(prefixptr, struct prefix, p)
329 prefixtype(prefixptr, struct prefix_ipv4, p4)
330 prefixtype(prefixptr, struct prefix_ipv6, p6)
331 prefixtype(prefixptr, struct prefix_evpn, evp)
332 prefixtype(prefixptr, struct prefix_fs, fs)
333 prefixtype(prefixptr, struct prefix_rd, rd)
334 } __attribute__((transparent_union));
335
336 union prefixconstptr {
337 prefixtype(prefixconstptr, const struct prefix, p)
338 prefixtype(prefixconstptr, const struct prefix_ipv4, p4)
339 prefixtype(prefixconstptr, const struct prefix_ipv6, p6)
340 prefixtype(prefixconstptr, const struct prefix_evpn, evp)
341 prefixtype(prefixconstptr, const struct prefix_fs, fs)
342 prefixtype(prefixconstptr, const struct prefix_rd, rd)
343 } __attribute__((transparent_union));
344
345 #ifndef INET_ADDRSTRLEN
346 #define INET_ADDRSTRLEN 16
347 #endif /* INET_ADDRSTRLEN */
348
349 #ifndef INET6_ADDRSTRLEN
350 /* dead:beef:dead:beef:dead:beef:dead:beef + \0 */
351 #define INET6_ADDRSTRLEN 46
352 #endif /* INET6_ADDRSTRLEN */
353
354 #ifndef INET6_BUFSIZ
355 #define INET6_BUFSIZ 53
356 #endif /* INET6_BUFSIZ */
357
358 /* Maximum string length of the result of prefix2str */
359 #define PREFIX_STRLEN 80
360
361 /*
362 * Longest possible length of a (S,G) string is 36 bytes
363 * 123.123.123.123 = 15 * 2
364 * (,) = 3
365 * NULL Character at end = 1
366 * (123.123.123.123,123.123.123.123)
367 */
368 #define PREFIX_SG_STR_LEN 34
369
370 /* Max bit/byte length of IPv4 address. */
371 #define IPV4_MAX_BYTELEN 4
372 #define IPV4_MAX_BITLEN 32
373 #define IPV4_MAX_PREFIXLEN 32
374 #define IPV4_ADDR_CMP(D,S) memcmp ((D), (S), IPV4_MAX_BYTELEN)
375
376 static inline bool ipv4_addr_same(const struct in_addr *a,
377 const struct in_addr *b)
378 {
379 return (a->s_addr == b->s_addr);
380 }
381 #define IPV4_ADDR_SAME(A,B) ipv4_addr_same((A), (B))
382
383 static inline void ipv4_addr_copy(struct in_addr *dst,
384 const struct in_addr *src)
385 {
386 dst->s_addr = src->s_addr;
387 }
388 #define IPV4_ADDR_COPY(D,S) ipv4_addr_copy((D), (S))
389
390 #define IPV4_NET0(a) ((((uint32_t)(a)) & 0xff000000) == 0x00000000)
391 #define IPV4_NET127(a) ((((uint32_t)(a)) & 0xff000000) == 0x7f000000)
392 #define IPV4_LINKLOCAL(a) ((((uint32_t)(a)) & 0xffff0000) == 0xa9fe0000)
393 #define IPV4_CLASS_DE(a) ((((uint32_t)(a)) & 0xe0000000) == 0xe0000000)
394 #define IPV4_MC_LINKLOCAL(a) ((((uint32_t)(a)) & 0xffffff00) == 0xe0000000)
395
396 /* Max bit/byte length of IPv6 address. */
397 #define IPV6_MAX_BYTELEN 16
398 #define IPV6_MAX_BITLEN 128
399 #define IPV6_MAX_PREFIXLEN 128
400 #define IPV6_ADDR_CMP(D,S) memcmp ((D), (S), IPV6_MAX_BYTELEN)
401 #define IPV6_ADDR_SAME(D,S) (memcmp ((D), (S), IPV6_MAX_BYTELEN) == 0)
402 #define IPV6_ADDR_COPY(D,S) memcpy ((D), (S), IPV6_MAX_BYTELEN)
403
404 /* Count prefix size from mask length */
405 #define PSIZE(a) (((a) + 7) / (8))
406
407 #define BSIZE(a) ((a) * (8))
408
409 /* Prefix's family member. */
410 #define PREFIX_FAMILY(p) ((p)->family)
411
412 /* glibc defines s6_addr32 to __in6_u.__u6_addr32 if __USE_{MISC || GNU} */
413 #ifndef s6_addr32
414 #if defined(SUNOS_5)
415 /* Some SunOS define s6_addr32 only to kernel */
416 #define s6_addr32 _S6_un._S6_u32
417 #else
418 #define s6_addr32 __u6_addr.__u6_addr32
419 #endif /* SUNOS_5 */
420 #endif /*s6_addr32*/
421
422 /* Prototypes. */
423 extern int str2family(const char *);
424 extern int afi2family(afi_t);
425 extern afi_t family2afi(int);
426 extern const char *family2str(int family);
427 extern const char *safi2str(safi_t safi);
428 extern const char *afi2str(afi_t afi);
429
430 /*
431 * Check bit of the prefix.
432 *
433 * prefix
434 * byte buffer
435 *
436 * bit_index
437 * which bit to fetch from byte buffer, 0 indexed.
438 */
439 extern unsigned int prefix_bit(const uint8_t *prefix, const uint16_t bit_index);
440
441 extern struct prefix *prefix_new(void);
442 extern void prefix_free(struct prefix **p);
443 /*
444 * Function to handle prefix_free being used as a del function.
445 */
446 extern void prefix_free_lists(void *arg);
447 extern const char *prefix_family_str(const struct prefix *);
448 extern int prefix_blen(const struct prefix *);
449 extern int str2prefix(const char *, struct prefix *);
450
451 #define PREFIX2STR_BUFFER PREFIX_STRLEN
452
453 extern void prefix_mcast_inet4_dump(const char *onfail, struct in_addr addr,
454 char *buf, int buf_size);
455 extern const char *prefix_sg2str(const struct prefix_sg *sg, char *str);
456 extern const char *prefix2str(union prefixconstptr, char *, int);
457 extern int evpn_type5_prefix_match(const struct prefix *evpn_pfx,
458 const struct prefix *match_pfx);
459 extern int prefix_match(const struct prefix *, const struct prefix *);
460 extern int prefix_match_network_statement(const struct prefix *,
461 const struct prefix *);
462 extern int prefix_same(union prefixconstptr, union prefixconstptr);
463 extern int prefix_cmp(union prefixconstptr, union prefixconstptr);
464 extern int prefix_common_bits(const struct prefix *, const struct prefix *);
465 extern void prefix_copy(union prefixptr, union prefixconstptr);
466 extern void apply_mask(struct prefix *);
467
468 #ifdef __clang_analyzer__
469 /* clang-SA doesn't understand transparent unions, making it think that the
470 * target of prefix_copy is uninitialized. So just memset the target.
471 * cf. https://bugs.llvm.org/show_bug.cgi?id=42811
472 */
473 #define prefix_copy(a, b) ({ memset(a, 0, sizeof(*a)); prefix_copy(a, b); })
474 #endif
475
476 extern struct prefix *sockunion2hostprefix(const union sockunion *,
477 struct prefix *p);
478 extern void prefix2sockunion(const struct prefix *, union sockunion *);
479
480 extern int str2prefix_eth(const char *, struct prefix_eth *);
481
482 extern struct prefix_ipv4 *prefix_ipv4_new(void);
483 extern void prefix_ipv4_free(struct prefix_ipv4 **p);
484 extern int str2prefix_ipv4(const char *, struct prefix_ipv4 *);
485 extern void apply_mask_ipv4(struct prefix_ipv4 *);
486
487 #define PREFIX_COPY(DST, SRC) \
488 *((struct prefix *)(DST)) = *((const struct prefix *)(SRC))
489 #define PREFIX_COPY_IPV4(DST, SRC) \
490 *((struct prefix_ipv4 *)(DST)) = *((const struct prefix_ipv4 *)(SRC));
491
492 extern int prefix_ipv4_any(const struct prefix_ipv4 *);
493 extern void apply_classful_mask_ipv4(struct prefix_ipv4 *);
494
495 extern uint8_t ip_masklen(struct in_addr);
496 extern void masklen2ip(const int, struct in_addr *);
497 /* given the address of a host on a network and the network mask length,
498 * calculate the broadcast address for that network;
499 * special treatment for /31 according to RFC3021 section 3.3 */
500 extern in_addr_t ipv4_broadcast_addr(in_addr_t hostaddr, int masklen);
501
502 extern int netmask_str2prefix_str(const char *, const char *, char *);
503
504 extern struct prefix_ipv6 *prefix_ipv6_new(void);
505 extern void prefix_ipv6_free(struct prefix_ipv6 **p);
506 extern int str2prefix_ipv6(const char *, struct prefix_ipv6 *);
507 extern void apply_mask_ipv6(struct prefix_ipv6 *);
508
509 #define PREFIX_COPY_IPV6(DST, SRC) \
510 *((struct prefix_ipv6 *)(DST)) = *((const struct prefix_ipv6 *)(SRC));
511
512 extern int ip6_masklen(struct in6_addr);
513 extern void masklen2ip6(const int, struct in6_addr *);
514
515 extern const char *inet6_ntoa(struct in6_addr);
516
517 extern int is_zero_mac(const struct ethaddr *mac);
518 extern bool is_mcast_mac(const struct ethaddr *mac);
519 extern bool is_bcast_mac(const struct ethaddr *mac);
520 extern int prefix_str2mac(const char *str, struct ethaddr *mac);
521 extern char *prefix_mac2str(const struct ethaddr *mac, char *buf, int size);
522
523 extern unsigned prefix_hash_key(const void *pp);
524
525 extern int str_to_esi(const char *str, esi_t *esi);
526 extern char *esi_to_str(const esi_t *esi, char *buf, int size);
527 extern void prefix_evpn_hexdump(const struct prefix_evpn *p);
528
529 static inline int ipv6_martian(struct in6_addr *addr)
530 {
531 struct in6_addr localhost_addr;
532
533 inet_pton(AF_INET6, "::1", &localhost_addr);
534
535 if (IPV6_ADDR_SAME(&localhost_addr, addr))
536 return 1;
537
538 return 0;
539 }
540
541 extern int macstr2prefix_evpn(const char *str, struct prefix_evpn *p);
542
543 /* NOTE: This routine expects the address argument in network byte order. */
544 static inline int ipv4_martian(struct in_addr *addr)
545 {
546 in_addr_t ip = ntohl(addr->s_addr);
547
548 if (IPV4_NET0(ip) || IPV4_NET127(ip) || IPV4_CLASS_DE(ip)) {
549 return 1;
550 }
551 return 0;
552 }
553
554 static inline int is_default_prefix(const struct prefix *p)
555 {
556 if (!p)
557 return 0;
558
559 if ((p->family == AF_INET) && (p->u.prefix4.s_addr == INADDR_ANY)
560 && (p->prefixlen == 0))
561 return 1;
562
563 if ((p->family == AF_INET6) && (p->prefixlen == 0)
564 && (!memcmp(&p->u.prefix6, &in6addr_any, sizeof(struct in6_addr))))
565 return 1;
566
567 return 0;
568 }
569
570 static inline int is_host_route(const struct prefix *p)
571 {
572 if (p->family == AF_INET)
573 return (p->prefixlen == IPV4_MAX_BITLEN);
574 else if (p->family == AF_INET6)
575 return (p->prefixlen == IPV6_MAX_BITLEN);
576 return 0;
577 }
578
579 static inline int is_default_host_route(const struct prefix *p)
580 {
581 if (p->family == AF_INET) {
582 return (p->u.prefix4.s_addr == INADDR_ANY &&
583 p->prefixlen == IPV4_MAX_BITLEN);
584 } else if (p->family == AF_INET6) {
585 return ((!memcmp(&p->u.prefix6, &in6addr_any,
586 sizeof(struct in6_addr))) &&
587 p->prefixlen == IPV6_MAX_BITLEN);
588 }
589 return 0;
590 }
591
592 #ifdef _FRR_ATTRIBUTE_PRINTFRR
593 #pragma FRR printfrr_ext "%pEA" (struct ethaddr *)
594
595 #pragma FRR printfrr_ext "%pI4" (struct in_addr *)
596 #pragma FRR printfrr_ext "%pI4" (in_addr_t *)
597
598 #pragma FRR printfrr_ext "%pI6" (struct in6_addr *)
599
600 #pragma FRR printfrr_ext "%pFX" (struct prefix *)
601 #pragma FRR printfrr_ext "%pFX" (struct prefix_ipv4 *)
602 #pragma FRR printfrr_ext "%pFX" (struct prefix_ipv6 *)
603 #pragma FRR printfrr_ext "%pFX" (struct prefix_eth *)
604 #pragma FRR printfrr_ext "%pFX" (struct prefix_evpn *)
605 #pragma FRR printfrr_ext "%pFX" (struct prefix_fs *)
606
607 #pragma FRR printfrr_ext "%pSG4" (struct prefix_sg *)
608 #endif
609
610 #ifdef __cplusplus
611 }
612 #endif
613
614 #endif /* _ZEBRA_PREFIX_H */