]>
Commit | Line | Data |
---|---|---|
718e3744 | 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 | * | |
896014f4 DL |
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 | |
718e3744 | 19 | */ |
20 | ||
21 | #ifndef _ZEBRA_ZSERV_H | |
22 | #define _ZEBRA_ZSERV_H | |
23 | ||
5b73a671 | 24 | #include "rib.h" |
ec1a4283 | 25 | #include "if.h" |
4d38fdb4 | 26 | #include "workqueue.h" |
82f97584 | 27 | #include "vrf.h" |
518f0eb1 | 28 | #include "routemap.h" |
4e3afb14 | 29 | #include "vty.h" |
7c8ff89e | 30 | #include "zclient.h" |
5dd0722d | 31 | #include "pbr.h" |
5b73a671 | 32 | |
7c551956 | 33 | #include "zebra/zebra_ns.h" |
6833ae01 | 34 | #include "zebra/zebra_pw.h" |
b6c5d343 | 35 | //#include "zebra/zebra_pbr.h" |
6833ae01 | 36 | |
718e3744 | 37 | /* Default port information. */ |
718e3744 | 38 | #define ZEBRA_VTY_PORT 2601 |
718e3744 | 39 | |
40 | /* Default configuration filename. */ | |
41 | #define DEFAULT_CONFIG_FILE "zebra.conf" | |
42 | ||
518f0eb1 DS |
43 | #define ZEBRA_RMAP_DEFAULT_UPDATE_TIMER 5 /* disabled by default */ |
44 | ||
718e3744 | 45 | /* Client structure. */ |
d62a17ae | 46 | struct zserv { |
47 | /* Client file descriptor. */ | |
48 | int sock; | |
49 | ||
50 | /* Input/output buffer to the client. */ | |
1002497a QY |
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; | |
d62a17ae | 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 | ||
e1a1880d DS |
84 | bool notify_owner; |
85 | ||
d62a17ae | 86 | /* client's protocol */ |
d7c0a89a QY |
87 | uint8_t proto; |
88 | unsigned short instance; | |
89 | uint8_t is_synchronous; | |
d62a17ae | 90 | |
91 | /* Statistics */ | |
d7c0a89a QY |
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; | |
d62a17ae | 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; | |
718e3744 | 135 | }; |
136 | ||
89f4e507 | 137 | #define ZAPI_HANDLER_ARGS \ |
1002497a QY |
138 | struct zserv *client, struct zmsghdr *hdr, struct stream *msg, \ |
139 | struct zebra_vrf *zvrf | |
89f4e507 | 140 | |
b21b19c5 | 141 | /* Zebra instance */ |
d62a17ae | 142 | struct zebra_t { |
143 | /* Thread master */ | |
144 | struct thread_master *master; | |
145 | struct list *client_list; | |
b21b19c5 | 146 | |
d62a17ae | 147 | /* default table */ |
d7c0a89a | 148 | uint32_t rtm_table_default; |
4d38fdb4 | 149 | |
996c9314 LB |
150 | /* rib work queue */ |
151 | #define ZEBRA_RIB_PROCESS_HOLD_TIME 10 | |
d62a17ae | 152 | struct work_queue *ribq; |
153 | struct meta_queue *mq; | |
40c7bdb0 | 154 | |
d62a17ae | 155 | /* LSP work queue */ |
156 | struct work_queue *lsp_process_q; | |
a37ef435 | 157 | |
996c9314 | 158 | #define ZEBRA_ZAPI_PACKETS_TO_PROCESS 10 |
d7c0a89a | 159 | uint32_t packets_to_process; |
b21b19c5 | 160 | }; |
44e9909d | 161 | extern struct zebra_t zebrad; |
37fe7731 | 162 | extern unsigned int multipath_num; |
b21b19c5 | 163 | |
718e3744 | 164 | /* Prototypes. */ |
5f145fb8 | 165 | extern void zserv_init(void); |
d62a17ae | 166 | extern void zebra_zserv_socket_init(char *path); |
d62a17ae | 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 *); | |
6833ae01 | 186 | extern int zsend_pw_update(struct zserv *, struct zebra_pw *); |
16f1b9ee | 187 | |
28610f7e | 188 | extern int zsend_route_notify_owner(struct route_entry *re, struct prefix *p, |
7ea7b86e DS |
189 | enum zapi_route_notify_owner note); |
190 | ||
425bdd6b PG |
191 | struct zebra_pbr_ipset; |
192 | struct zebra_pbr_ipset_entry; | |
7abd6c4f | 193 | struct zebra_pbr_iptable; |
5dd0722d | 194 | struct zebra_pbr_rule; |
b6c5d343 DS |
195 | extern void zsend_rule_notify_owner(struct zebra_pbr_rule *rule, |
196 | enum zapi_rule_notify_owner note); | |
425bdd6b PG |
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); | |
7abd6c4f PG |
203 | extern void zsend_iptable_notify_owner( |
204 | struct zebra_pbr_iptable *iptable, | |
205 | enum zapi_iptable_notify_owner note); | |
b6c5d343 | 206 | |
d62a17ae | 207 | extern void zserv_nexthop_num_warn(const char *, const struct prefix *, |
208 | const unsigned int); | |
1002497a | 209 | extern int zebra_server_send_message(struct zserv *client, struct stream *msg); |
fb018d25 | 210 | |
d7c0a89a | 211 | extern struct zserv *zebra_find_client(uint8_t proto, unsigned short instance); |
8ed6821e | 212 | |
411314ed DS |
213 | #if defined(HANDLE_ZAPI_FUZZING) |
214 | extern void zserv_read_file(char *input); | |
215 | #endif | |
216 | ||
718e3744 | 217 | #endif /* _ZEBRA_ZEBRA_H */ |