]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zserv.h
release: FRR 3.0-rc1
[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
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21
22 #ifndef _ZEBRA_ZSERV_H
23 #define _ZEBRA_ZSERV_H
24
25 #include "rib.h"
26 #include "if.h"
27 #include "workqueue.h"
28 #include "vrf.h"
29 #include "routemap.h"
30 #include "vty.h"
31 #include "zclient.h"
32
33 #include "zebra/zebra_ns.h"
34 #include "zebra/zebra_pw.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 *ibuf;
51 struct stream *obuf;
52
53 /* Buffer of data waiting to be written to client. */
54 struct buffer *wb;
55
56 /* Threads for read/write. */
57 struct thread *t_read;
58 struct thread *t_write;
59
60 /* Thread for delayed close. */
61 struct thread *t_suicide;
62
63 /* default routing table this client munges */
64 int rtm_table;
65
66 /* This client's redistribute flag. */
67 struct redist_proto mi_redist[AFI_MAX][ZEBRA_ROUTE_MAX];
68 vrf_bitmap_t redist[AFI_MAX][ZEBRA_ROUTE_MAX];
69
70 /* Redistribute default route flag. */
71 vrf_bitmap_t redist_default;
72
73 /* Interface information. */
74 vrf_bitmap_t ifinfo;
75
76 /* Router-id information. */
77 vrf_bitmap_t ridinfo;
78
79 /* client's protocol */
80 u_char proto;
81 u_short instance;
82 u_char is_synchronous;
83
84 /* Statistics */
85 u_int32_t redist_v4_add_cnt;
86 u_int32_t redist_v4_del_cnt;
87 u_int32_t redist_v6_add_cnt;
88 u_int32_t redist_v6_del_cnt;
89 u_int32_t v4_route_add_cnt;
90 u_int32_t v4_route_upd8_cnt;
91 u_int32_t v4_route_del_cnt;
92 u_int32_t v6_route_add_cnt;
93 u_int32_t v6_route_del_cnt;
94 u_int32_t v6_route_upd8_cnt;
95 u_int32_t connected_rt_add_cnt;
96 u_int32_t connected_rt_del_cnt;
97 u_int32_t ifup_cnt;
98 u_int32_t ifdown_cnt;
99 u_int32_t ifadd_cnt;
100 u_int32_t ifdel_cnt;
101 u_int32_t if_bfd_cnt;
102 u_int32_t bfd_peer_add_cnt;
103 u_int32_t bfd_peer_upd8_cnt;
104 u_int32_t bfd_peer_del_cnt;
105 u_int32_t bfd_peer_replay_cnt;
106 u_int32_t vrfadd_cnt;
107 u_int32_t vrfdel_cnt;
108 u_int32_t if_vrfchg_cnt;
109 u_int32_t bfd_client_reg_cnt;
110
111 time_t connect_time;
112 time_t last_read_time;
113 time_t last_write_time;
114 time_t nh_reg_time;
115 time_t nh_dereg_time;
116 time_t nh_last_upd_time;
117
118 int last_read_cmd;
119 int last_write_cmd;
120 };
121
122 /* Zebra instance */
123 struct zebra_t {
124 /* Thread master */
125 struct thread_master *master;
126 struct list *client_list;
127
128 /* default table */
129 u_int32_t rtm_table_default;
130
131 /* rib work queue */
132 struct work_queue *ribq;
133 struct meta_queue *mq;
134
135 /* LSP work queue */
136 struct work_queue *lsp_process_q;
137 };
138 extern struct zebra_t zebrad;
139 extern unsigned int multipath_num;
140
141 /* Prototypes. */
142 extern void zebra_init(void);
143 extern void zebra_if_init(void);
144 extern void zebra_zserv_socket_init(char *path);
145 extern void hostinfo_get(void);
146 extern void rib_init(void);
147 extern void interface_list(struct zebra_ns *);
148 extern void route_read(struct zebra_ns *);
149 extern void kernel_init(struct zebra_ns *);
150 extern void kernel_terminate(struct zebra_ns *);
151 extern void zebra_route_map_init(void);
152 extern void zebra_vty_init(void);
153
154 extern int zsend_vrf_add(struct zserv *, struct zebra_vrf *);
155 extern int zsend_vrf_delete(struct zserv *, struct zebra_vrf *);
156
157 extern int zsend_interface_add(struct zserv *, struct interface *);
158 extern int zsend_interface_delete(struct zserv *, struct interface *);
159 extern int zsend_interface_addresses(struct zserv *, struct interface *);
160 extern int zsend_interface_address(int, struct zserv *, struct interface *,
161 struct connected *);
162 extern void nbr_connected_add_ipv6(struct interface *, struct in6_addr *);
163 extern void nbr_connected_delete_ipv6(struct interface *, struct in6_addr *);
164 extern int zsend_interface_update(int, struct zserv *, struct interface *);
165 extern int zsend_redistribute_route(int, struct zserv *, struct prefix *,
166 struct prefix *, struct rib *);
167 extern int zsend_router_id_update(struct zserv *, struct prefix *, vrf_id_t);
168 extern int zsend_interface_vrf_update(struct zserv *, struct interface *,
169 vrf_id_t);
170
171 extern int zsend_interface_link_params(struct zserv *, struct interface *);
172 extern int zsend_pw_update(struct zserv *, struct zebra_pw *);
173
174 extern pid_t pid;
175
176 extern void zserv_create_header(struct stream *s, uint16_t cmd,
177 vrf_id_t vrf_id);
178 extern void zserv_nexthop_num_warn(const char *, const struct prefix *,
179 const unsigned int);
180 extern int zebra_server_send_message(struct zserv *client);
181
182 extern struct zserv *zebra_find_client(u_char proto);
183
184 #endif /* _ZEBRA_ZEBRA_H */