]> git.proxmox.com Git - mirror_frr.git/blame - lib/zclient.h
zebra: handle entry pointfs for ipset creation/destruction
[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.
896014f4 10 *
718e3744 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.
896014f4
DL
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
718e3744 19 */
20
21#ifndef _ZEBRA_ZCLIENT_H
22#define _ZEBRA_ZCLIENT_H
23
74489921 24/* For struct zapi_route. */
5734509c
PJ
25#include "prefix.h"
26
718e3744 27/* For struct interface and struct connected. */
28#include "if.h"
29
7076bb2f
FL
30/* For vrf_bitmap_t. */
31#include "vrf.h"
32
6833ae01 33/* For union g_addr */
34#include "nexthop.h"
35
36/* For union pw_protocol_fields */
37#include "pw.h"
38
718e3744 39/* For input/output buffer to zebra. */
db4a24dd 40#define ZEBRA_MAX_PACKET_SIZ 16384
718e3744 41
42/* Zebra header size. */
a9ff90c4 43#define ZEBRA_HEADER_SIZE 10
718e3744 44
689f5a8c
DL
45/* special socket path name to use TCP
46 * @ is used as first character because that's abstract socket names on Linux
47 */
48#define ZAPI_TCP_PATHNAME "@tcp"
49
7661461a
PG
50/* IPset size name stands for the name of the ipset entry
51 * that can be created by using some zapi interfaces
52 */
53#define ZEBRA_IPSET_NAME_SIZE 32
54
689f5a8c
DL
55extern struct sockaddr_storage zclient_addr;
56extern socklen_t zclient_addr_len;
57
8613585e
DS
58/* Zebra message types. */
59typedef enum {
d62a17ae 60 ZEBRA_INTERFACE_ADD,
61 ZEBRA_INTERFACE_DELETE,
62 ZEBRA_INTERFACE_ADDRESS_ADD,
63 ZEBRA_INTERFACE_ADDRESS_DELETE,
64 ZEBRA_INTERFACE_UP,
65 ZEBRA_INTERFACE_DOWN,
e0ae31b8 66 ZEBRA_INTERFACE_SET_MASTER,
0e51b4a3
RW
67 ZEBRA_ROUTE_ADD,
68 ZEBRA_ROUTE_DELETE,
7ea7b86e 69 ZEBRA_ROUTE_NOTIFY_OWNER,
d62a17ae 70 ZEBRA_IPV4_ROUTE_ADD,
71 ZEBRA_IPV4_ROUTE_DELETE,
72 ZEBRA_IPV6_ROUTE_ADD,
73 ZEBRA_IPV6_ROUTE_DELETE,
74 ZEBRA_REDISTRIBUTE_ADD,
75 ZEBRA_REDISTRIBUTE_DELETE,
76 ZEBRA_REDISTRIBUTE_DEFAULT_ADD,
77 ZEBRA_REDISTRIBUTE_DEFAULT_DELETE,
78 ZEBRA_ROUTER_ID_ADD,
79 ZEBRA_ROUTER_ID_DELETE,
80 ZEBRA_ROUTER_ID_UPDATE,
81 ZEBRA_HELLO,
82 ZEBRA_NEXTHOP_REGISTER,
83 ZEBRA_NEXTHOP_UNREGISTER,
84 ZEBRA_NEXTHOP_UPDATE,
85 ZEBRA_INTERFACE_NBR_ADDRESS_ADD,
86 ZEBRA_INTERFACE_NBR_ADDRESS_DELETE,
87 ZEBRA_INTERFACE_BFD_DEST_UPDATE,
88 ZEBRA_IMPORT_ROUTE_REGISTER,
89 ZEBRA_IMPORT_ROUTE_UNREGISTER,
90 ZEBRA_IMPORT_CHECK_UPDATE,
91 ZEBRA_IPV4_ROUTE_IPV6_NEXTHOP_ADD,
92 ZEBRA_BFD_DEST_REGISTER,
93 ZEBRA_BFD_DEST_DEREGISTER,
94 ZEBRA_BFD_DEST_UPDATE,
95 ZEBRA_BFD_DEST_REPLAY,
74489921
RW
96 ZEBRA_REDISTRIBUTE_ROUTE_ADD,
97 ZEBRA_REDISTRIBUTE_ROUTE_DEL,
d62a17ae 98 ZEBRA_VRF_UNREGISTER,
99 ZEBRA_VRF_ADD,
100 ZEBRA_VRF_DELETE,
c83c5e44 101 ZEBRA_VRF_LABEL,
d62a17ae 102 ZEBRA_INTERFACE_VRF_UPDATE,
103 ZEBRA_BFD_CLIENT_REGISTER,
104 ZEBRA_INTERFACE_ENABLE_RADV,
105 ZEBRA_INTERFACE_DISABLE_RADV,
106 ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB,
107 ZEBRA_INTERFACE_LINK_PARAMS,
108 ZEBRA_MPLS_LABELS_ADD,
109 ZEBRA_MPLS_LABELS_DELETE,
d62a17ae 110 ZEBRA_IPMR_ROUTE_STATS,
111 ZEBRA_LABEL_MANAGER_CONNECT,
112 ZEBRA_GET_LABEL_CHUNK,
113 ZEBRA_RELEASE_LABEL_CHUNK,
114 ZEBRA_FEC_REGISTER,
115 ZEBRA_FEC_UNREGISTER,
116 ZEBRA_FEC_UPDATE,
1a98c087 117 ZEBRA_ADVERTISE_DEFAULT_GW,
31310b25 118 ZEBRA_ADVERTISE_SUBNET,
d62a17ae 119 ZEBRA_ADVERTISE_ALL_VNI,
120 ZEBRA_VNI_ADD,
121 ZEBRA_VNI_DEL,
b7cfce93
MK
122 ZEBRA_L3VNI_ADD,
123 ZEBRA_L3VNI_DEL,
d62a17ae 124 ZEBRA_REMOTE_VTEP_ADD,
125 ZEBRA_REMOTE_VTEP_DEL,
126 ZEBRA_MACIP_ADD,
127 ZEBRA_MACIP_DEL,
31310b25
MK
128 ZEBRA_IP_PREFIX_ROUTE_ADD,
129 ZEBRA_IP_PREFIX_ROUTE_DEL,
d62a17ae 130 ZEBRA_REMOTE_MACIP_ADD,
131 ZEBRA_REMOTE_MACIP_DEL,
6833ae01 132 ZEBRA_PW_ADD,
133 ZEBRA_PW_DELETE,
134 ZEBRA_PW_SET,
135 ZEBRA_PW_UNSET,
136 ZEBRA_PW_STATUS_UPDATE,
e16abbb3
DS
137 ZEBRA_RULE_ADD,
138 ZEBRA_RULE_DELETE,
139 ZEBRA_RULE_NOTIFY_OWNER,
75fb51c1
PG
140 ZEBRA_TABLE_MANAGER_CONNECT,
141 ZEBRA_GET_TABLE_CHUNK,
142 ZEBRA_RELEASE_TABLE_CHUNK,
8613585e
DS
143} zebra_message_types_t;
144
d62a17ae 145struct redist_proto {
d7c0a89a 146 uint8_t enabled;
d62a17ae 147 struct list *instances;
7c8ff89e
DS
148};
149
718e3744 150/* Structure for the zebra client. */
d62a17ae 151struct zclient {
152 /* The thread master we schedule ourselves on */
153 struct thread_master *master;
154
342213ea
DS
155 /* Priviledges to change socket values */
156 struct zebra_privs_t *privs;
157
e1a1880d
DS
158 /* Do we care about failure events for route install? */
159 bool receive_notify;
160
d62a17ae 161 /* Socket to zebra daemon. */
162 int sock;
163
d62a17ae 164 /* Connection failure count. */
165 int fail;
166
167 /* Input buffer for zebra message. */
168 struct stream *ibuf;
169
170 /* Output buffer for zebra message. */
171 struct stream *obuf;
172
173 /* Buffer of data waiting to be written to zebra. */
174 struct buffer *wb;
175
176 /* Read and connect thread. */
177 struct thread *t_read;
178 struct thread *t_connect;
179
180 /* Thread to write buffered data to zebra. */
181 struct thread *t_write;
182
183 /* Redistribute information. */
d7c0a89a
QY
184 uint8_t redist_default; /* clients protocol */
185 unsigned short instance;
d62a17ae 186 struct redist_proto mi_redist[AFI_MAX][ZEBRA_ROUTE_MAX];
187 vrf_bitmap_t redist[AFI_MAX][ZEBRA_ROUTE_MAX];
188
189 /* Redistribute defauilt. */
190 vrf_bitmap_t default_information;
191
192 /* Pointer to the callback functions. */
193 void (*zebra_connected)(struct zclient *);
194 int (*router_id_update)(int, struct zclient *, uint16_t, vrf_id_t);
195 int (*interface_add)(int, struct zclient *, uint16_t, vrf_id_t);
196 int (*interface_delete)(int, struct zclient *, uint16_t, vrf_id_t);
197 int (*interface_up)(int, struct zclient *, uint16_t, vrf_id_t);
198 int (*interface_down)(int, struct zclient *, uint16_t, vrf_id_t);
199 int (*interface_address_add)(int, struct zclient *, uint16_t, vrf_id_t);
200 int (*interface_address_delete)(int, struct zclient *, uint16_t,
201 vrf_id_t);
202 int (*interface_link_params)(int, struct zclient *, uint16_t);
203 int (*interface_bfd_dest_update)(int, struct zclient *, uint16_t,
204 vrf_id_t);
205 int (*interface_nbr_address_add)(int, struct zclient *, uint16_t,
206 vrf_id_t);
207 int (*interface_nbr_address_delete)(int, struct zclient *, uint16_t,
208 vrf_id_t);
209 int (*interface_vrf_update)(int, struct zclient *, uint16_t, vrf_id_t);
210 int (*nexthop_update)(int, struct zclient *, uint16_t, vrf_id_t);
211 int (*import_check_update)(int, struct zclient *, uint16_t, vrf_id_t);
212 int (*bfd_dest_replay)(int, struct zclient *, uint16_t, vrf_id_t);
74489921
RW
213 int (*redistribute_route_add)(int, struct zclient *, uint16_t,
214 vrf_id_t);
215 int (*redistribute_route_del)(int, struct zclient *, uint16_t,
216 vrf_id_t);
d62a17ae 217 int (*fec_update)(int, struct zclient *, uint16_t);
218 int (*local_vni_add)(int, struct zclient *, uint16_t, vrf_id_t);
219 int (*local_vni_del)(int, struct zclient *, uint16_t, vrf_id_t);
b7cfce93
MK
220 int (*local_l3vni_add)(int, struct zclient *, uint16_t, vrf_id_t);
221 int (*local_l3vni_del)(int, struct zclient *, uint16_t, vrf_id_t);
31310b25
MK
222 void (*local_ip_prefix_add)(int, struct zclient *, uint16_t, vrf_id_t);
223 void (*local_ip_prefix_del)(int, struct zclient *, uint16_t, vrf_id_t);
d62a17ae 224 int (*local_macip_add)(int, struct zclient *, uint16_t, vrf_id_t);
225 int (*local_macip_del)(int, struct zclient *, uint16_t, vrf_id_t);
6833ae01 226 int (*pw_status_update)(int, struct zclient *, uint16_t, vrf_id_t);
28b11f81
DS
227 int (*route_notify_owner)(int command, struct zclient *zclient,
228 uint16_t length, vrf_id_t vrf_id);
b6c5d343
DS
229 int (*rule_notify_owner)(int command, struct zclient *zclient,
230 uint16_t length, vrf_id_t vrf_id);
955bfd98
PZ
231 void (*label_chunk)(int command, struct zclient *zclient,
232 uint16_t length, vrf_id_t vrf_id);
718e3744 233};
234
235/* Zebra API message flag. */
236#define ZAPI_MESSAGE_NEXTHOP 0x01
74489921
RW
237#define ZAPI_MESSAGE_DISTANCE 0x02
238#define ZAPI_MESSAGE_METRIC 0x04
239#define ZAPI_MESSAGE_TAG 0x08
240#define ZAPI_MESSAGE_MTU 0x10
241#define ZAPI_MESSAGE_SRCPFX 0x20
242#define ZAPI_MESSAGE_LABEL 0x40
ba1849ef
DS
243/*
244 * This should only be used by a DAEMON that needs to communicate
245 * the table being used is not in the VRF. You must pass the
246 * default vrf, else this will be ignored.
247 */
248#define ZAPI_MESSAGE_TABLEID 0x80
718e3744 249
41903a40 250#define ZSERV_VERSION 5
c1b9800a 251/* Zserv protocol message header */
124ead27 252struct zmsghdr {
d62a17ae 253 uint16_t length;
5530922e 254 /* Always set to 255 in new zserv */
124ead27 255 uint8_t marker;
d62a17ae 256 uint8_t version;
d62a17ae 257 vrf_id_t vrf_id;
258 uint16_t command;
c1b9800a 259};
260
bb1b9c47
RW
261struct zapi_nexthop {
262 enum nexthop_types_t type;
4a7371e9 263 vrf_id_t vrf_id;
bb1b9c47 264 ifindex_t ifindex;
09a484dd
DL
265 union {
266 union g_addr gate;
267 enum blackhole_type bh_type;
268 };
52dd3aa4
RW
269
270 /* MPLS labels for BGP-LU or Segment Routing */
271 uint8_t label_num;
272 mpls_label_t labels[MPLS_MAX_LABELS];
bb1b9c47
RW
273};
274
832d0f56
DS
275/*
276 * Some of these data structures do not map easily to
277 * a actual data structure size giving different compilers
278 * and systems. For those data structures we need
279 * to use the smallest available stream_getX/putX functions
280 * to encode/decode.
281 */
d62a17ae 282struct zapi_route {
d7c0a89a
QY
283 uint8_t type;
284 unsigned short instance;
657cde12 285
d7c0a89a 286 uint32_t flags;
657cde12 287
d7c0a89a 288 uint8_t message;
657cde12 289
832d0f56
DS
290 /*
291 * This is an enum but we are going to treat it as a uint8_t
292 * for purpose of encoding/decoding
293 */
d62a17ae 294 safi_t safi;
657cde12 295
bb1b9c47
RW
296 struct prefix prefix;
297 struct prefix_ipv6 src_prefix;
298
d7c0a89a 299 uint16_t nexthop_num;
bb1b9c47 300 struct zapi_nexthop nexthops[MULTIPATH_NUM];
657cde12 301
d7c0a89a 302 uint8_t distance;
657cde12 303
d7c0a89a 304 uint32_t metric;
657cde12 305
d62a17ae 306 route_tag_t tag;
657cde12 307
d7c0a89a 308 uint32_t mtu;
657cde12 309
d62a17ae 310 vrf_id_t vrf_id;
2dbad57f 311
ba1849ef
DS
312 uint32_t tableid;
313
2dbad57f 314 struct ethaddr rmac;
657cde12
DS
315};
316
718e3744 317/* Zebra IPv4 route message API. */
d62a17ae 318struct zapi_ipv4 {
d7c0a89a
QY
319 uint8_t type;
320 unsigned short instance;
718e3744 321
d7c0a89a 322 uint32_t flags;
718e3744 323
d7c0a89a 324 uint8_t message;
718e3744 325
d62a17ae 326 safi_t safi;
5a616c08 327
d7c0a89a 328 uint8_t nexthop_num;
d62a17ae 329 struct in_addr **nexthop;
718e3744 330
d7c0a89a 331 uint8_t ifindex_num;
d62a17ae 332 ifindex_t *ifindex;
718e3744 333
d7c0a89a 334 uint8_t label_num;
d62a17ae 335 unsigned int *label;
a64448ba 336
d7c0a89a 337 uint8_t distance;
718e3744 338
d7c0a89a 339 uint32_t metric;
0d9551dc 340
d62a17ae 341 route_tag_t tag;
7076bb2f 342
d7c0a89a 343 uint32_t mtu;
c50ca33a 344
d62a17ae 345 vrf_id_t vrf_id;
718e3744 346};
347
6833ae01 348struct zapi_pw {
349 char ifname[IF_NAMESIZE];
350 ifindex_t ifindex;
351 int type;
352 int af;
353 union g_addr nexthop;
354 uint32_t local_label;
355 uint32_t remote_label;
356 uint8_t flags;
357 union pw_protocol_fields data;
358 uint8_t protocol;
359};
360
361struct zapi_pw_status {
362 char ifname[IF_NAMESIZE];
363 ifindex_t ifindex;
364 uint32_t status;
365};
366
7ea7b86e
DS
367enum zapi_route_notify_owner {
368 ZAPI_ROUTE_FAIL_INSTALL,
369 ZAPI_ROUTE_BETTER_ADMIN_WON,
370 ZAPI_ROUTE_INSTALLED,
5e54c602
DS
371 ZAPI_ROUTE_REMOVED,
372 ZAPI_ROUTE_REMOVE_FAIL,
7ea7b86e
DS
373};
374
7661461a
PG
375enum ipset_type {
376 IPSET_NET_NET = 1,
377 IPSET_NET_PORT_NET,
378 IPSET_NET_PORT,
379 IPSET_NET
380};
381
b6c5d343
DS
382enum zapi_rule_notify_owner {
383 ZAPI_RULE_FAIL_INSTALL,
384 ZAPI_RULE_INSTALLED,
385 ZAPI_RULE_REMOVED,
386};
387
1a98c087 388/* Zebra MAC types */
ead40654
MK
389#define ZEBRA_MACIP_TYPE_STICKY 0x01 /* Sticky MAC*/
390#define ZEBRA_MACIP_TYPE_GW 0x02 /* gateway (SVI) mac*/
1a98c087 391
e1a1880d
DS
392struct zclient_options {
393 bool receive_notify;
394};
395
718e3744 396/* Prototypes of zebra client service functions. */
d62a17ae 397extern struct zclient *zclient_new(struct thread_master *);
e1a1880d 398
5530922e 399/* clang-format off */
e24be241 400#if defined(VERSION_TYPE_DEV) && CONFDATE > 20181101
e1a1880d
DS
401CPP_NOTICE("zclient_new_notify can take over or zclient_new now");
402#endif
5530922e 403/* clang-format on */
e1a1880d
DS
404
405extern struct zclient_options zclient_options_default;
406
407extern struct zclient *zclient_new_notify(struct thread_master *m,
408 struct zclient_options *opt);
409
996c9314
LB
410#define zclient_new(A) \
411 zclient_new_notify((A), &zclient_options_default); \
e1a1880d
DS
412 CPP_WARN("Please transition to using zclient_new_notify");
413
d7c0a89a 414extern void zclient_init(struct zclient *, int, unsigned short,
996c9314 415 struct zebra_privs_t *privs);
d62a17ae 416extern int zclient_start(struct zclient *);
417extern void zclient_stop(struct zclient *);
418extern void zclient_reset(struct zclient *);
419extern void zclient_free(struct zclient *);
634f9ea2 420
d62a17ae 421extern int zclient_socket_connect(struct zclient *);
718e3744 422
d7c0a89a
QY
423extern unsigned short *redist_check_instance(struct redist_proto *,
424 unsigned short);
425extern void redist_add_instance(struct redist_proto *, unsigned short);
426extern void redist_del_instance(struct redist_proto *, unsigned short);
7c8ff89e 427
c83c5e44
DS
428/*
429 * Send to zebra that the specified vrf is using label to resolve
430 * itself for L3VPN's. Repeated calls of this function with
431 * different labels will cause an effective update of the
42567e00 432 * label for lookup. If you pass in MPLS_LABEL_NONE
c83c5e44
DS
433 * we will cause a delete action and remove this label pop
434 * operation.
7d061b3c
DS
435 *
436 * The underlying AF_MPLS doesn't care about afi's
437 * but we can make the zebra_vrf keep track of what
438 * we have installed and play some special games
439 * to get them both installed.
c83c5e44
DS
440 */
441extern void zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id,
7d061b3c
DS
442 afi_t afi, mpls_label_t label,
443 enum lsp_types_t ltype);
c83c5e44 444
d62a17ae 445extern void zclient_send_reg_requests(struct zclient *, vrf_id_t);
446extern void zclient_send_dereg_requests(struct zclient *, vrf_id_t);
7076bb2f 447
d62a17ae 448extern void zclient_send_interface_radv_req(struct zclient *zclient,
449 vrf_id_t vrf_id,
450 struct interface *ifp, int enable,
451 int ra_interval);
4a04e5f7 452
634f9ea2 453/* Send redistribute command to zebra daemon. Do not update zclient state. */
d62a17ae 454extern int zebra_redistribute_send(int command, struct zclient *, afi_t,
d7c0a89a
QY
455 int type, unsigned short instance,
456 vrf_id_t vrf_id);
634f9ea2 457
458/* If state has changed, update state and call zebra_redistribute_send. */
d62a17ae 459extern void zclient_redistribute(int command, struct zclient *, afi_t, int type,
d7c0a89a 460 unsigned short instance, vrf_id_t vrf_id);
634f9ea2 461
462/* If state has changed, update state and send the command to zebra. */
d62a17ae 463extern void zclient_redistribute_default(int command, struct zclient *,
464 vrf_id_t vrf_id);
718e3744 465
634f9ea2 466/* Send the message in zclient->obuf to the zebra daemon (or enqueue it).
467 Returns 0 for success or -1 on an I/O error. */
468extern int zclient_send_message(struct zclient *);
718e3744 469
d211086a 470/* create header for command, length to be filled in by user later */
d62a17ae 471extern void zclient_create_header(struct stream *, uint16_t, vrf_id_t);
124ead27
QY
472/*
473 * Read sizeof(struct zmsghdr) bytes from the provided socket and parse the
474 * received data into the specified fields. If this is successful, read the
475 * rest of the packet into the provided stream.
476 *
477 * s
478 * The stream to read into
479 *
480 * sock
481 * The socket to read from
482 *
483 * size
484 * Parsed message size will be placed in the pointed-at integer
485 *
486 * marker
487 * Parsed marker will be placed in the pointed-at byte
488 *
489 * version
490 * Parsed version will be placed in the pointed-at byte
491 *
492 * vrf_id
493 * Parsed VRF ID will be placed in the pointed-at vrf_id_t
494 *
495 * cmd
496 * Parsed command number will be placed in the pointed-at integer
497 *
498 * Returns:
499 * -1 if:
500 * - insufficient data for header was read
501 * - a version mismatch was detected
502 * - a marker mismatch was detected
503 * - header size field specified more data than could be read
504 */
d7c0a89a
QY
505extern int zclient_read_header(struct stream *s, int sock, uint16_t *size,
506 uint8_t *marker, uint8_t *version,
507 vrf_id_t *vrf_id, uint16_t *cmd);
124ead27
QY
508/*
509 * Parse header from ZAPI message stream into struct zmsghdr.
510 * This function assumes the stream getp points at the first byte of the header.
511 * If the function is successful then the stream getp will point to the byte
512 * immediately after the last byte of the header.
513 *
514 * zmsg
515 * The stream containing the header
516 *
517 * hdr
518 * The header struct to parse into.
519 *
520 * Returns:
521 * true if parsing succeeded, false otherwise
522 */
523extern bool zapi_parse_header(struct stream *zmsg, struct zmsghdr *hdr);
d62a17ae 524
e0ae31b8
DS
525extern void zclient_interface_set_master(struct zclient *client,
526 struct interface *master,
527 struct interface *slave);
d62a17ae 528extern struct interface *zebra_interface_add_read(struct stream *, vrf_id_t);
529extern struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t);
530extern struct connected *zebra_interface_address_read(int, struct stream *,
531 vrf_id_t);
532extern struct nbr_connected *
533zebra_interface_nbr_address_read(int, struct stream *, vrf_id_t);
534extern struct interface *zebra_interface_vrf_update_read(struct stream *s,
535 vrf_id_t vrf_id,
536 vrf_id_t *new_vrf_id);
537extern void zebra_interface_if_set_value(struct stream *, struct interface *);
538extern void zebra_router_id_update_read(struct stream *s, struct prefix *rid);
0cb76b9d 539
5530922e 540/* clang-format off */
e24be241 541#if defined(VERSION_TYPE_DEV) && CONFDATE > 20180823
124ead27 542CPP_NOTICE("zapi_ipv4_route, zapi_ipv6_route, zapi_ipv4_route_ipv6_nexthop as well as the zapi_ipv4 and zapi_ipv6 data structures should be removed now");
0cb76b9d 543#endif
5530922e 544/* clang-format on */
0cb76b9d 545
d7c0a89a 546extern int zapi_ipv4_route(uint8_t, struct zclient *, struct prefix_ipv4 *,
f474e08b 547 struct zapi_ipv4 *) __attribute__((deprecated));
d62a17ae 548
549extern struct interface *zebra_interface_link_params_read(struct stream *);
550extern size_t zebra_interface_link_params_write(struct stream *,
551 struct interface *);
955bfd98
PZ
552extern int zclient_send_get_label_chunk(
553 struct zclient *zclient,
554 uint8_t keep,
555 uint32_t chunk_size);
556
d62a17ae 557extern int lm_label_manager_connect(struct zclient *zclient);
d7c0a89a 558extern int lm_get_label_chunk(struct zclient *zclient, uint8_t keep,
d62a17ae 559 uint32_t chunk_size, uint32_t *start,
560 uint32_t *end);
561extern int lm_release_label_chunk(struct zclient *zclient, uint32_t start,
562 uint32_t end);
75fb51c1
PG
563extern int tm_table_manager_connect(struct zclient *zclient);
564extern int tm_get_table_chunk(struct zclient *zclient, uint32_t chunk_size,
565 uint32_t *start, uint32_t *end);
566extern int tm_release_table_chunk(struct zclient *zclient, uint32_t start,
567 uint32_t end);
568
6833ae01 569extern int zebra_send_pw(struct zclient *zclient, int command,
570 struct zapi_pw *pw);
571extern void zebra_read_pw_status_update(int command, struct zclient *zclient,
572 zebra_size_t length, vrf_id_t vrf_id,
573 struct zapi_pw_status *pw);
574
718e3744 575/* IPv6 prefix add and delete function prototype. */
576
d62a17ae 577struct zapi_ipv6 {
d7c0a89a
QY
578 uint8_t type;
579 unsigned short instance;
718e3744 580
d7c0a89a 581 uint32_t flags;
718e3744 582
d7c0a89a 583 uint8_t message;
718e3744 584
d62a17ae 585 safi_t safi;
c7ec179a 586
d7c0a89a 587 uint8_t nexthop_num;
d62a17ae 588 struct in6_addr **nexthop;
718e3744 589
d7c0a89a 590 uint8_t ifindex_num;
d62a17ae 591 ifindex_t *ifindex;
718e3744 592
d7c0a89a 593 uint8_t label_num;
d62a17ae 594 unsigned int *label;
a64448ba 595
d7c0a89a 596 uint8_t distance;
718e3744 597
d7c0a89a 598 uint32_t metric;
0d9551dc 599
d62a17ae 600 route_tag_t tag;
7076bb2f 601
d7c0a89a 602 uint32_t mtu;
c50ca33a 603
d62a17ae 604 vrf_id_t vrf_id;
718e3744 605};
606
d7c0a89a 607extern int zapi_ipv6_route(uint8_t cmd, struct zclient *zclient,
d62a17ae 608 struct prefix_ipv6 *p, struct prefix_ipv6 *src_p,
f474e08b 609 struct zapi_ipv6 *api) __attribute__((deprecated));
d7c0a89a 610extern int zapi_ipv4_route_ipv6_nexthop(uint8_t, struct zclient *,
d62a17ae 611 struct prefix_ipv4 *,
f474e08b
RW
612 struct zapi_ipv6 *)
613 __attribute__((deprecated));
d7c0a89a 614extern int zclient_route_send(uint8_t, struct zclient *, struct zapi_route *);
3c192540
DS
615extern int zclient_send_rnh(struct zclient *zclient, int command,
616 struct prefix *p, bool exact_match,
617 vrf_id_t vrf_id);
d7c0a89a 618extern int zapi_route_encode(uint8_t, struct stream *, struct zapi_route *);
0e51b4a3 619extern int zapi_route_decode(struct stream *, struct zapi_route *);
7ea7b86e 620bool zapi_route_notify_decode(struct stream *s, struct prefix *p,
28610f7e 621 uint32_t *tableid,
7ea7b86e 622 enum zapi_route_notify_owner *note);
b6c5d343
DS
623bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
624 uint32_t *priority, uint32_t *unique,
625 ifindex_t *ifindex,
626 enum zapi_rule_notify_owner *note);
4a749e2c
DS
627extern struct nexthop *nexthop_from_zapi_nexthop(struct zapi_nexthop *znh);
628extern bool zapi_nexthop_update_decode(struct stream *s,
629 struct zapi_route *nhr);
718e3744 630
09a484dd 631static inline void zapi_route_set_blackhole(struct zapi_route *api,
60466a63 632 enum blackhole_type bh_type)
09a484dd
DL
633{
634 api->nexthop_num = 1;
635 api->nexthops[0].type = NEXTHOP_TYPE_BLACKHOLE;
4a7371e9 636 api->nexthops[0].vrf_id = VRF_DEFAULT;
09a484dd
DL
637 api->nexthops[0].bh_type = bh_type;
638 SET_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP);
639};
640
641
718e3744 642#endif /* _ZEBRA_ZCLIENT_H */