]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zserv.h
Merge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga into cmaster
[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 "routemap.h"
29 #include "vty.h"
30 #include "zclient.h"
31 #include "vrf.h"
32
33 /* Default port information. */
34 #define ZEBRA_VTY_PORT 2601
35
36 /* Default configuration filename. */
37 #define DEFAULT_CONFIG_FILE "zebra.conf"
38
39 #define ZEBRA_RMAP_DEFAULT_UPDATE_TIMER 5 /* disabled by default */
40
41 /* Client structure. */
42 struct zserv
43 {
44 /* Client file descriptor. */
45 int sock;
46
47 /* Input/output buffer to the client. */
48 struct stream *ibuf;
49 struct stream *obuf;
50
51 /* Buffer of data waiting to be written to client. */
52 struct buffer *wb;
53
54 /* Threads for read/write. */
55 struct thread *t_read;
56 struct thread *t_write;
57
58 /* Thread for delayed close. */
59 struct thread *t_suicide;
60
61 /* default routing table this client munges */
62 int rtm_table;
63
64 /* This client's redistribute flag. */
65 struct redist_proto mi_redist[AFI_MAX][ZEBRA_ROUTE_MAX];
66 vrf_bitmap_t redist[AFI_MAX][ZEBRA_ROUTE_MAX];
67
68 /* Redistribute default route flag. */
69 vrf_bitmap_t redist_default;
70
71 /* Interface information. */
72 vrf_bitmap_t ifinfo;
73
74 /* Router-id information. */
75 vrf_bitmap_t ridinfo;
76
77 /* client's protocol */
78 u_char proto;
79 u_short instance;
80
81 /* Statistics */
82 u_int32_t redist_v4_add_cnt;
83 u_int32_t redist_v4_del_cnt;
84 u_int32_t redist_v6_add_cnt;
85 u_int32_t redist_v6_del_cnt;
86 u_int32_t v4_route_add_cnt;
87 u_int32_t v4_route_upd8_cnt;
88 u_int32_t v4_route_del_cnt;
89 u_int32_t v6_route_add_cnt;
90 u_int32_t v6_route_del_cnt;
91 u_int32_t v6_route_upd8_cnt;
92 u_int32_t connected_rt_add_cnt;
93 u_int32_t connected_rt_del_cnt;
94 u_int32_t ifup_cnt;
95 u_int32_t ifdown_cnt;
96 u_int32_t ifadd_cnt;
97 u_int32_t ifdel_cnt;
98 u_int32_t if_bfd_cnt;
99 u_int32_t bfd_peer_add_cnt;
100 u_int32_t bfd_peer_upd8_cnt;
101 u_int32_t bfd_peer_del_cnt;
102 u_int32_t bfd_peer_replay_cnt;
103 u_int32_t vrfadd_cnt;
104 u_int32_t vrfdel_cnt;
105 u_int32_t if_vrfchg_cnt;
106 u_int32_t bfd_client_reg_cnt;
107
108 time_t connect_time;
109 time_t last_read_time;
110 time_t last_write_time;
111 time_t nh_reg_time;
112 time_t nh_dereg_time;
113 time_t nh_last_upd_time;
114
115 int last_read_cmd;
116 int last_write_cmd;
117 };
118
119 /* Zebra instance */
120 struct zebra_t
121 {
122 /* Thread master */
123 struct thread_master *master;
124 struct list *client_list;
125
126 /* default table */
127 u_int32_t rtm_table_default;
128
129 /* rib work queue */
130 struct work_queue *ribq;
131 struct meta_queue *mq;
132 };
133
134 /* Prototypes. */
135 extern void zebra_init (void);
136 extern void zebra_if_init (void);
137 extern void zebra_zserv_socket_init (char *path);
138 extern void hostinfo_get (void);
139 extern void rib_init (void);
140 extern void interface_list (struct zebra_ns *);
141 extern void route_read (struct zebra_ns *);
142 extern void kernel_init (struct zebra_ns *);
143 extern void kernel_terminate (struct zebra_ns *);
144 extern void zebra_route_map_init (void);
145 extern void zebra_snmp_init (void);
146 extern void zebra_vty_init (void);
147
148 extern int zsend_vrf_add (struct zserv *, struct zebra_vrf *);
149 extern int zsend_vrf_delete (struct zserv *, struct zebra_vrf *);
150
151 extern int zsend_interface_add (struct zserv *, struct interface *);
152 extern int zsend_interface_delete (struct zserv *, struct interface *);
153 extern int zsend_interface_addresses (struct zserv *, struct interface *);
154 extern int zsend_interface_address (int, struct zserv *, struct interface *,
155 struct connected *);
156 extern void nbr_connected_replacement_add_ipv6 (struct interface *,
157 struct in6_addr *, u_char);
158 extern void nbr_connected_delete_ipv6 (struct interface *, struct in6_addr *, u_char);
159 extern int zsend_interface_update (int, struct zserv *, struct interface *);
160 extern int zsend_redistribute_route (int, struct zserv *, struct prefix *,
161 struct rib *);
162 extern int zsend_router_id_update (struct zserv *, struct prefix *,
163 vrf_id_t);
164 extern int zsend_interface_vrf_update (struct zserv *, struct interface *,
165 vrf_id_t);
166
167 extern pid_t pid;
168
169 extern void zserv_create_header(struct stream *s, uint16_t cmd, vrf_id_t vrf_id);
170 extern void zserv_nexthop_num_warn(const char *, const struct prefix *, const u_char);
171 extern int zebra_server_send_message(struct zserv *client);
172
173 extern void zebra_route_map_write_delay_timer(struct vty *);
174 extern route_map_result_t zebra_route_map_check (int family, int rib_type,
175 struct prefix *p,
176 struct nexthop *nexthop,
177 vrf_id_t vrf_id,
178 u_short tag);
179 extern route_map_result_t zebra_nht_route_map_check (int family,
180 int client_proto,
181 struct prefix *p,
182 struct rib *,
183 struct nexthop *nexthop);
184
185 #endif /* _ZEBRA_ZEBRA_H */