]> git.proxmox.com Git - mirror_frr.git/blame - lib/zclient.h
BGP: add addpath RX support
[mirror_frr.git] / lib / zclient.h
CommitLineData
718e3744 1/* Zebra's client header.
2 * Copyright (C) 1999 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
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any 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
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22#ifndef _ZEBRA_ZCLIENT_H
23#define _ZEBRA_ZCLIENT_H
24
5734509c
PJ
25/* For struct zapi_ipv{4,6}. */
26#include "prefix.h"
27
718e3744 28/* For struct interface and struct connected. */
29#include "if.h"
30
31/* For input/output buffer to zebra. */
32#define ZEBRA_MAX_PACKET_SIZ 4096
33
34/* Zebra header size. */
c1b9800a 35#define ZEBRA_HEADER_SIZE 6
718e3744 36
7c8ff89e
DS
37struct redist_proto
38{
39 u_char enabled;
40 struct list *instances;
41};
42
718e3744 43/* Structure for the zebra client. */
44struct zclient
45{
46 /* Socket to zebra daemon. */
47 int sock;
48
49 /* Flag of communication to zebra is enabled or not. Default is on.
50 This flag is disabled by `no router zebra' statement. */
51 int enable;
52
53 /* Connection failure count. */
54 int fail;
55
56 /* Input buffer for zebra message. */
57 struct stream *ibuf;
58
59 /* Output buffer for zebra message. */
60 struct stream *obuf;
61
634f9ea2 62 /* Buffer of data waiting to be written to zebra. */
63 struct buffer *wb;
64
718e3744 65 /* Read and connect thread. */
66 struct thread *t_read;
67 struct thread *t_connect;
68
634f9ea2 69 /* Thread to write buffered data to zebra. */
70 struct thread *t_write;
71
718e3744 72 /* Redistribute information. */
7c8ff89e
DS
73 u_char redist_default; /* clients protocol */
74 u_short instance;
75 struct redist_proto redist[ZEBRA_ROUTE_MAX];
718e3744 76
77 /* Redistribute defauilt. */
78 u_char default_information;
79
80 /* Pointer to the callback functions. */
c1b9800a 81 int (*router_id_update) (int, struct zclient *, uint16_t);
82 int (*interface_add) (int, struct zclient *, uint16_t);
83 int (*interface_delete) (int, struct zclient *, uint16_t);
84 int (*interface_up) (int, struct zclient *, uint16_t);
85 int (*interface_down) (int, struct zclient *, uint16_t);
86 int (*interface_address_add) (int, struct zclient *, uint16_t);
87 int (*interface_address_delete) (int, struct zclient *, uint16_t);
d5a5c8f0 88 int (*interface_bfd_dest_down) (int, struct zclient *, uint16_t);
a80beece
DS
89 int (*interface_nbr_address_add) (int, struct zclient *, uint16_t);
90 int (*interface_nbr_address_delete) (int, struct zclient *, uint16_t);
c1b9800a 91 int (*ipv4_route_add) (int, struct zclient *, uint16_t);
92 int (*ipv4_route_delete) (int, struct zclient *, uint16_t);
93 int (*ipv6_route_add) (int, struct zclient *, uint16_t);
94 int (*ipv6_route_delete) (int, struct zclient *, uint16_t);
fb018d25 95 int (*nexthop_update) (int, struct zclient *, uint16_t);
718e3744 96};
97
98/* Zebra API message flag. */
99#define ZAPI_MESSAGE_NEXTHOP 0x01
100#define ZAPI_MESSAGE_IFINDEX 0x02
101#define ZAPI_MESSAGE_DISTANCE 0x04
102#define ZAPI_MESSAGE_METRIC 0x08
c8a1cb5c
DS
103#define ZAPI_MESSAGE_TAG 0x10
104#define ZAPI_MESSAGE_ONLINK 0x20
718e3744 105
c1b9800a 106/* Zserv protocol message header */
107struct zserv_header
108{
109 uint16_t length;
110 uint8_t marker; /* corresponds to command field in old zserv
111 * always set to 255 in new zserv.
112 */
113 uint8_t version;
8d79efdd 114#define ZSERV_VERSION 2
c1b9800a 115 uint16_t command;
116};
117
718e3744 118/* Zebra IPv4 route message API. */
119struct zapi_ipv4
120{
121 u_char type;
7c8ff89e 122 u_short instance;
718e3744 123
124 u_char flags;
125
126 u_char message;
127
5a616c08
B
128 safi_t safi;
129
718e3744 130 u_char nexthop_num;
131 struct in_addr **nexthop;
132
133 u_char ifindex_num;
134 unsigned int *ifindex;
135
136 u_char distance;
137
138 u_int32_t metric;
0d9551dc
DS
139
140 u_short tag;
718e3744 141};
142
718e3744 143/* Prototypes of zebra client service functions. */
8cc4198f 144extern struct zclient *zclient_new (void);
7c8ff89e 145extern void zclient_init (struct zclient *, int, u_short);
8cc4198f 146extern int zclient_start (struct zclient *);
147extern void zclient_stop (struct zclient *);
148extern void zclient_reset (struct zclient *);
228da428 149extern void zclient_free (struct zclient *);
634f9ea2 150
b5114685
VT
151extern int zclient_socket_connect (struct zclient *);
152extern void zclient_serv_path_set (char *path);
718e3744 153
7c8ff89e
DS
154extern int redist_check_instance (struct redist_proto *, u_short);
155extern void redist_add_instance (struct redist_proto *, u_short);
156extern void redist_del_instance (struct redist_proto *, u_short);
157
634f9ea2 158/* Send redistribute command to zebra daemon. Do not update zclient state. */
7c8ff89e 159extern int zebra_redistribute_send (int command, struct zclient *, int type, u_short instance);
634f9ea2 160
161/* If state has changed, update state and call zebra_redistribute_send. */
7c8ff89e
DS
162extern void zclient_redistribute (int command, struct zclient *, int type,
163 u_short instance);
634f9ea2 164
165/* If state has changed, update state and send the command to zebra. */
8cc4198f 166extern void zclient_redistribute_default (int command, struct zclient *);
718e3744 167
634f9ea2 168/* Send the message in zclient->obuf to the zebra daemon (or enqueue it).
169 Returns 0 for success or -1 on an I/O error. */
170extern int zclient_send_message(struct zclient *);
718e3744 171
d211086a 172/* create header for command, length to be filled in by user later */
173extern void zclient_create_header (struct stream *, uint16_t);
174
8cc4198f 175extern struct interface *zebra_interface_add_read (struct stream *);
176extern struct interface *zebra_interface_state_read (struct stream *s);
177extern struct connected *zebra_interface_address_read (int, struct stream *);
d5a5c8f0 178extern struct interface *zebra_interface_bfd_read (struct stream *s, struct prefix *);
a80beece 179extern struct nbr_connected *zebra_interface_nbr_address_read (int, struct stream *);
8cc4198f 180extern void zebra_interface_if_set_value (struct stream *, struct interface *);
181extern void zebra_router_id_update_read (struct stream *s, struct prefix *rid);
182extern int zapi_ipv4_route (u_char, struct zclient *, struct prefix_ipv4 *,
183 struct zapi_ipv4 *);
718e3744 184
185#ifdef HAVE_IPV6
186/* IPv6 prefix add and delete function prototype. */
187
188struct zapi_ipv6
189{
190 u_char type;
7c8ff89e 191 u_short instance;
718e3744 192
193 u_char flags;
194
195 u_char message;
196
c7ec179a
B
197 safi_t safi;
198
718e3744 199 u_char nexthop_num;
200 struct in6_addr **nexthop;
201
202 u_char ifindex_num;
203 unsigned int *ifindex;
204
205 u_char distance;
206
207 u_int32_t metric;
0d9551dc
DS
208
209 u_short tag;
718e3744 210};
211
8cc4198f 212extern int zapi_ipv6_route (u_char cmd, struct zclient *zclient,
0a589359 213 struct prefix_ipv6 *p, struct zapi_ipv6 *api);
718e3744 214#endif /* HAVE_IPV6 */
215
216#endif /* _ZEBRA_ZCLIENT_H */