]> git.proxmox.com Git - mirror_frr.git/blob - lib/plist.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / lib / plist.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Prefix list functions.
4 * Copyright (C) 1999 Kunihiro Ishiguro
5 */
6
7 #ifndef _QUAGGA_PLIST_H
8 #define _QUAGGA_PLIST_H
9
10 #include <zebra.h>
11
12 #include "stream.h"
13 #include "vty.h"
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 enum prefix_list_type {
20 PREFIX_DENY,
21 PREFIX_PERMIT,
22 };
23
24 struct prefix_list;
25 struct prefix_list_entry;
26
27 struct orf_prefix {
28 uint32_t seq;
29 uint8_t ge;
30 uint8_t le;
31 struct prefix p;
32 };
33
34 /* Prototypes. */
35 extern void prefix_list_init(void);
36 extern void prefix_list_reset(void);
37 extern void prefix_list_add_hook(void (*func)(struct prefix_list *));
38 extern void prefix_list_delete_hook(void (*func)(struct prefix_list *));
39
40 extern const char *prefix_list_name(struct prefix_list *);
41 extern afi_t prefix_list_afi(struct prefix_list *);
42 extern struct prefix_list *prefix_list_lookup(afi_t, const char *);
43
44 /*
45 * prefix_list_apply_which_prefix
46 *
47 * Allow calling function to learn which prefix
48 * caused the DENY or PERMIT.
49 *
50 * If no pointer is sent in, do not return anything.
51 * If it is a empty plist return a NULL pointer.
52 *
53 * address_mode = the "prefix" being passed in is really an address, match
54 * regardless of prefix length (i.e. ge/le are ignored.) prefix->prefixlen
55 * must be /32.
56 */
57 extern enum prefix_list_type
58 prefix_list_apply_ext(struct prefix_list *plist,
59 const struct prefix_list_entry **matches,
60 union prefixconstptr prefix,
61 bool address_mode);
62 #define prefix_list_apply(A, B) \
63 prefix_list_apply_ext((A), NULL, (B), false)
64
65 extern struct prefix_list *prefix_bgp_orf_lookup(afi_t, const char *);
66 extern struct stream *prefix_bgp_orf_entry(struct stream *,
67 struct prefix_list *, uint8_t,
68 uint8_t, uint8_t);
69 extern int prefix_bgp_orf_set(char *, afi_t, struct orf_prefix *, int, int);
70 extern void prefix_bgp_orf_remove_all(afi_t, char *);
71 extern int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name,
72 bool use_json);
73
74 extern struct prefix_list *prefix_list_get(afi_t afi, int orf,
75 const char *name);
76 extern void prefix_list_delete(struct prefix_list *plist);
77 extern int64_t prefix_new_seq_get(struct prefix_list *plist);
78
79 extern struct prefix_list_entry *prefix_list_entry_new(void);
80 extern void prefix_list_entry_delete(struct prefix_list *plist,
81 struct prefix_list_entry *pentry,
82 int update_list);
83 extern struct prefix_list_entry *
84 prefix_list_entry_lookup(struct prefix_list *plist, struct prefix *prefix,
85 enum prefix_list_type type, int64_t seq, int le,
86 int ge);
87
88 #ifdef __cplusplus
89 }
90 #endif
91
92 #endif /* _QUAGGA_PLIST_H */