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