]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zserv.h
Merge pull request #2069 from donaldsharp/v6_tunnel_crash
[mirror_frr.git] / zebra / zserv.h
1 /* Zebra daemon server header.
2 * Copyright (C) 1997, 98 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 */
20
21 #ifndef _ZEBRA_ZSERV_H
22 #define _ZEBRA_ZSERV_H
23
24 #include "rib.h"
25 #include "if.h"
26 #include "workqueue.h"
27 #include "vrf.h"
28 #include "routemap.h"
29 #include "vty.h"
30 #include "zclient.h"
31 #include "pbr.h"
32
33 #include "zebra/zebra_ns.h"
34 #include "zebra/zebra_pw.h"
35 //#include "zebra/zebra_pbr.h"
36
37 /* Default port information. */
38 #define ZEBRA_VTY_PORT 2601
39
40 /* Default configuration filename. */
41 #define DEFAULT_CONFIG_FILE "zebra.conf"
42
43 #define ZEBRA_RMAP_DEFAULT_UPDATE_TIMER 5 /* disabled by default */
44
45 /* Client structure. */
46 struct zserv {
47 /* Client file descriptor. */
48 int sock;
49
50 /* Input/output buffer to the client. */
51 struct stream_fifo *ibuf_fifo;
52 struct stream_fifo *obuf_fifo;
53
54 /* Private I/O buffers */
55 struct stream *ibuf_work;
56 struct stream *obuf_work;
57
58 /* Buffer of data waiting to be written to client. */
59 struct buffer *wb;
60
61 /* Threads for read/write. */
62 struct thread *t_read;
63 struct thread *t_write;
64
65 /* Thread for delayed close. */
66 struct thread *t_suicide;
67
68 /* default routing table this client munges */
69 int rtm_table;
70
71 /* This client's redistribute flag. */
72 struct redist_proto mi_redist[AFI_MAX][ZEBRA_ROUTE_MAX];
73 vrf_bitmap_t redist[AFI_MAX][ZEBRA_ROUTE_MAX];
74
75 /* Redistribute default route flag. */
76 vrf_bitmap_t redist_default;
77
78 /* Interface information. */
79 vrf_bitmap_t ifinfo;
80
81 /* Router-id information. */
82 vrf_bitmap_t ridinfo;
83
84 bool notify_owner;
85
86 /* client's protocol */
87 uint8_t proto;
88 unsigned short instance;
89 uint8_t is_synchronous;
90
91 /* Statistics */
92 uint32_t redist_v4_add_cnt;
93 uint32_t redist_v4_del_cnt;
94 uint32_t redist_v6_add_cnt;
95 uint32_t redist_v6_del_cnt;
96 uint32_t v4_route_add_cnt;
97 uint32_t v4_route_upd8_cnt;
98 uint32_t v4_route_del_cnt;
99 uint32_t v6_route_add_cnt;
100 uint32_t v6_route_del_cnt;
101 uint32_t v6_route_upd8_cnt;
102 uint32_t connected_rt_add_cnt;
103 uint32_t connected_rt_del_cnt;
104 uint32_t ifup_cnt;
105 uint32_t ifdown_cnt;
106 uint32_t ifadd_cnt;
107 uint32_t ifdel_cnt;
108 uint32_t if_bfd_cnt;
109 uint32_t bfd_peer_add_cnt;
110 uint32_t bfd_peer_upd8_cnt;
111 uint32_t bfd_peer_del_cnt;
112 uint32_t bfd_peer_replay_cnt;
113 uint32_t vrfadd_cnt;
114 uint32_t vrfdel_cnt;
115 uint32_t if_vrfchg_cnt;
116 uint32_t bfd_client_reg_cnt;
117 uint32_t vniadd_cnt;
118 uint32_t vnidel_cnt;
119 uint32_t l3vniadd_cnt;
120 uint32_t l3vnidel_cnt;
121 uint32_t macipadd_cnt;
122 uint32_t macipdel_cnt;
123 uint32_t prefixadd_cnt;
124 uint32_t prefixdel_cnt;
125
126 time_t connect_time;
127 time_t last_read_time;
128 time_t last_write_time;
129 time_t nh_reg_time;
130 time_t nh_dereg_time;
131 time_t nh_last_upd_time;
132
133 int last_read_cmd;
134 int last_write_cmd;
135 };
136
137 #define ZAPI_HANDLER_ARGS \
138 struct zserv *client, struct zmsghdr *hdr, struct stream *msg, \
139 struct zebra_vrf *zvrf
140
141 /* Zebra instance */
142 struct zebra_t {
143 /* Thread master */
144 struct thread_master *master;
145 struct list *client_list;
146
147 /* default table */
148 uint32_t rtm_table_default;
149
150 /* rib work queue */
151 #define ZEBRA_RIB_PROCESS_HOLD_TIME 10
152 struct work_queue *ribq;
153 struct meta_queue *mq;
154
155 /* LSP work queue */
156 struct work_queue *lsp_process_q;
157
158 #define ZEBRA_ZAPI_PACKETS_TO_PROCESS 10
159 uint32_t packets_to_process;
160 };
161 extern struct zebra_t zebrad;
162 extern unsigned int multipath_num;
163
164 /* Prototypes. */
165 extern void zserv_init(void);
166 extern void zebra_zserv_socket_init(char *path);
167
168 extern int zsend_vrf_add(struct zserv *, struct zebra_vrf *);
169 extern int zsend_vrf_delete(struct zserv *, struct zebra_vrf *);
170
171 extern int zsend_interface_add(struct zserv *, struct interface *);
172 extern int zsend_interface_delete(struct zserv *, struct interface *);
173 extern int zsend_interface_addresses(struct zserv *, struct interface *);
174 extern int zsend_interface_address(int, struct zserv *, struct interface *,
175 struct connected *);
176 extern void nbr_connected_add_ipv6(struct interface *, struct in6_addr *);
177 extern void nbr_connected_delete_ipv6(struct interface *, struct in6_addr *);
178 extern int zsend_interface_update(int, struct zserv *, struct interface *);
179 extern int zsend_redistribute_route(int, struct zserv *, struct prefix *,
180 struct prefix *, struct route_entry *);
181 extern int zsend_router_id_update(struct zserv *, struct prefix *, vrf_id_t);
182 extern int zsend_interface_vrf_update(struct zserv *, struct interface *,
183 vrf_id_t);
184
185 extern int zsend_interface_link_params(struct zserv *, struct interface *);
186 extern int zsend_pw_update(struct zserv *, struct zebra_pw *);
187
188 extern int zsend_route_notify_owner(struct route_entry *re, struct prefix *p,
189 enum zapi_route_notify_owner note);
190
191 struct zebra_pbr_ipset;
192 struct zebra_pbr_ipset_entry;
193 struct zebra_pbr_iptable;
194 struct zebra_pbr_rule;
195 extern void zsend_rule_notify_owner(struct zebra_pbr_rule *rule,
196 enum zapi_rule_notify_owner note);
197 extern void zsend_ipset_notify_owner(
198 struct zebra_pbr_ipset *ipset,
199 enum zapi_ipset_notify_owner note);
200 extern void zsend_ipset_entry_notify_owner(
201 struct zebra_pbr_ipset_entry *ipset,
202 enum zapi_ipset_entry_notify_owner note);
203 extern void zsend_iptable_notify_owner(
204 struct zebra_pbr_iptable *iptable,
205 enum zapi_iptable_notify_owner note);
206
207 extern void zserv_nexthop_num_warn(const char *, const struct prefix *,
208 const unsigned int);
209 extern int zebra_server_send_message(struct zserv *client, struct stream *msg);
210
211 extern struct zserv *zebra_find_client(uint8_t proto, unsigned short instance);
212
213 #if defined(HANDLE_ZAPI_FUZZING)
214 extern void zserv_read_file(char *input);
215 #endif
216
217 #endif /* _ZEBRA_ZEBRA_H */