]> git.proxmox.com Git - mirror_frr.git/blob - lib/distribute.h
*: auto-convert to SPDX License IDs
[mirror_frr.git] / lib / distribute.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Distribute list functions header
3 * Copyright (C) 1999 Kunihiro Ishiguro
4 */
5
6 #ifndef _ZEBRA_DISTRIBUTE_H
7 #define _ZEBRA_DISTRIBUTE_H
8
9 #include <zebra.h>
10 #include "if.h"
11 #include "filter.h"
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 /* Distribute list types. */
18 enum distribute_type {
19 DISTRIBUTE_V4_IN,
20 DISTRIBUTE_V6_IN,
21 DISTRIBUTE_V4_OUT,
22 DISTRIBUTE_V6_OUT,
23 DISTRIBUTE_MAX
24 };
25
26 struct distribute {
27 /* Name of the interface. */
28 char *ifname;
29
30 /* Filter name of `in' and `out' */
31 char *list[DISTRIBUTE_MAX];
32
33 /* prefix-list name of `in' and `out' */
34 char *prefix[DISTRIBUTE_MAX];
35 };
36
37 struct distribute_ctx {
38 /* Hash of distribute list. */
39 struct hash *disthash;
40
41 /* Hook functions. */
42 void (*distribute_add_hook)(struct distribute_ctx *ctx,
43 struct distribute *dist);
44 void (*distribute_delete_hook)(struct distribute_ctx *ctx,
45 struct distribute *dist);
46
47 /* vrf information */
48 struct vrf *vrf;
49 };
50
51 /* Prototypes for distribute-list. */
52 extern struct distribute_ctx *distribute_list_ctx_create(struct vrf *vrf);
53 extern void distribute_list_delete(struct distribute_ctx **ctx);
54 extern void distribute_list_add_hook(struct distribute_ctx *ctx,
55 void (*)(struct distribute_ctx *ctx,
56 struct distribute *));
57 extern void distribute_list_delete_hook(struct distribute_ctx *ctx,
58 void (*)(struct distribute_ctx *ctx,
59 struct distribute *));
60 extern struct distribute *distribute_lookup(struct distribute_ctx *ctx,
61 const char *ifname);
62 extern int config_write_distribute(struct vty *vty,
63 struct distribute_ctx *ctx);
64 extern int config_show_distribute(struct vty *vty,
65 struct distribute_ctx *ctx);
66
67 extern enum filter_type distribute_apply_in(struct interface *,
68 struct prefix *);
69 extern enum filter_type distribute_apply_out(struct interface *,
70 struct prefix *);
71
72 extern int distribute_list_parser(bool prefix, bool v4, const char *dir,
73 const char *list, const char *ifname);
74 extern int distribute_list_no_parser(struct vty *vty, bool prefix, bool v4,
75 const char *dir, const char *list,
76 const char *ifname);
77 #ifdef __cplusplus
78 }
79 #endif
80
81 #endif /* _ZEBRA_DISTRIBUTE_H */