]> git.proxmox.com Git - mirror_frr.git/blob - lib/zclient.h
Merge pull request #10447 from ton31337/fix/json_with_whitespaces
[mirror_frr.git] / lib / zclient.h
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 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
19 */
20
21 #ifndef _ZEBRA_ZCLIENT_H
22 #define _ZEBRA_ZCLIENT_H
23
24 struct zclient;
25
26 /* For struct zapi_route. */
27 #include "prefix.h"
28 #include "ipaddr.h"
29
30 /* For struct interface and struct connected. */
31 #include "if.h"
32
33 /* For vrf_bitmap_t. */
34 #include "vrf.h"
35
36 /* For union g_addr */
37 #include "nexthop.h"
38
39 /* For union pw_protocol_fields */
40 #include "pw.h"
41
42 #include "mlag.h"
43 #include "srte.h"
44 #include "srv6.h"
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50 /* Zebra types. Used in Zserv message header. */
51 typedef uint16_t zebra_size_t;
52
53 /* Marker value used in new Zserv, in the byte location corresponding
54 * the command value in the old zserv header. To allow old and new
55 * Zserv headers to be distinguished from each other.
56 */
57 #define ZEBRA_HEADER_MARKER 254
58
59 /* For input/output buffer to zebra. */
60 #define ZEBRA_MAX_PACKET_SIZ 16384U
61 #define ZEBRA_SMALL_PACKET_SIZE 200U
62
63 /* Zebra header size. */
64 #define ZEBRA_HEADER_SIZE 10
65
66 /* special socket path name to use TCP
67 * @ is used as first character because that's abstract socket names on Linux
68 */
69 #define ZAPI_TCP_PATHNAME "@tcp"
70
71 /* IPset size name stands for the name of the ipset entry
72 * that can be created by using some zapi interfaces
73 */
74 #define ZEBRA_IPSET_NAME_SIZE 32
75
76 /* IPTable action is defined by two values: either
77 * forward or drop
78 */
79 #define ZEBRA_IPTABLES_FORWARD 0
80 #define ZEBRA_IPTABLES_DROP 1
81
82 /* Zebra FEC register command flags. */
83 #define ZEBRA_FEC_REGISTER_LABEL 0x1
84 #define ZEBRA_FEC_REGISTER_LABEL_INDEX 0x2
85
86 /* Client capabilities */
87 enum zserv_client_capabilities {
88 ZEBRA_CLIENT_GR_CAPABILITIES = 1,
89 ZEBRA_CLIENT_ROUTE_UPDATE_COMPLETE = 2,
90 ZEBRA_CLIENT_ROUTE_UPDATE_PENDING = 3,
91 ZEBRA_CLIENT_GR_DISABLE = 4,
92 ZEBRA_CLIENT_RIB_STALE_TIME
93 };
94
95 /* Macro to check if there GR enabled. */
96 #define ZEBRA_CLIENT_GR_ENABLED(X) (X == ZEBRA_CLIENT_GR_CAPABILITIES)
97
98 #define ZEBRA_SR_POLICY_NAME_MAX_LENGTH 100
99
100 extern struct sockaddr_storage zclient_addr;
101 extern socklen_t zclient_addr_len;
102
103 /* Zebra message types. */
104 typedef enum {
105 ZEBRA_INTERFACE_ADD,
106 ZEBRA_INTERFACE_DELETE,
107 ZEBRA_INTERFACE_ADDRESS_ADD,
108 ZEBRA_INTERFACE_ADDRESS_DELETE,
109 ZEBRA_INTERFACE_UP,
110 ZEBRA_INTERFACE_DOWN,
111 ZEBRA_INTERFACE_SET_MASTER,
112 ZEBRA_INTERFACE_SET_PROTODOWN,
113 ZEBRA_ROUTE_ADD,
114 ZEBRA_ROUTE_DELETE,
115 ZEBRA_ROUTE_NOTIFY_OWNER,
116 ZEBRA_REDISTRIBUTE_ADD,
117 ZEBRA_REDISTRIBUTE_DELETE,
118 ZEBRA_REDISTRIBUTE_DEFAULT_ADD,
119 ZEBRA_REDISTRIBUTE_DEFAULT_DELETE,
120 ZEBRA_ROUTER_ID_ADD,
121 ZEBRA_ROUTER_ID_DELETE,
122 ZEBRA_ROUTER_ID_UPDATE,
123 ZEBRA_HELLO,
124 ZEBRA_CAPABILITIES,
125 ZEBRA_NEXTHOP_REGISTER,
126 ZEBRA_NEXTHOP_UNREGISTER,
127 ZEBRA_NEXTHOP_UPDATE,
128 ZEBRA_INTERFACE_NBR_ADDRESS_ADD,
129 ZEBRA_INTERFACE_NBR_ADDRESS_DELETE,
130 ZEBRA_INTERFACE_BFD_DEST_UPDATE,
131 ZEBRA_BFD_DEST_REGISTER,
132 ZEBRA_BFD_DEST_DEREGISTER,
133 ZEBRA_BFD_DEST_UPDATE,
134 ZEBRA_BFD_DEST_REPLAY,
135 ZEBRA_REDISTRIBUTE_ROUTE_ADD,
136 ZEBRA_REDISTRIBUTE_ROUTE_DEL,
137 ZEBRA_VRF_UNREGISTER,
138 ZEBRA_VRF_ADD,
139 ZEBRA_VRF_DELETE,
140 ZEBRA_VRF_LABEL,
141 ZEBRA_INTERFACE_VRF_UPDATE,
142 ZEBRA_BFD_CLIENT_REGISTER,
143 ZEBRA_BFD_CLIENT_DEREGISTER,
144 ZEBRA_INTERFACE_ENABLE_RADV,
145 ZEBRA_INTERFACE_DISABLE_RADV,
146 ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB,
147 ZEBRA_INTERFACE_LINK_PARAMS,
148 ZEBRA_MPLS_LABELS_ADD,
149 ZEBRA_MPLS_LABELS_DELETE,
150 ZEBRA_MPLS_LABELS_REPLACE,
151 ZEBRA_SR_POLICY_SET,
152 ZEBRA_SR_POLICY_DELETE,
153 ZEBRA_SR_POLICY_NOTIFY_STATUS,
154 ZEBRA_IPMR_ROUTE_STATS,
155 ZEBRA_LABEL_MANAGER_CONNECT,
156 ZEBRA_LABEL_MANAGER_CONNECT_ASYNC,
157 ZEBRA_GET_LABEL_CHUNK,
158 ZEBRA_RELEASE_LABEL_CHUNK,
159 ZEBRA_FEC_REGISTER,
160 ZEBRA_FEC_UNREGISTER,
161 ZEBRA_FEC_UPDATE,
162 ZEBRA_ADVERTISE_DEFAULT_GW,
163 ZEBRA_ADVERTISE_SVI_MACIP,
164 ZEBRA_ADVERTISE_SUBNET,
165 ZEBRA_ADVERTISE_ALL_VNI,
166 ZEBRA_LOCAL_ES_ADD,
167 ZEBRA_LOCAL_ES_DEL,
168 ZEBRA_REMOTE_ES_VTEP_ADD,
169 ZEBRA_REMOTE_ES_VTEP_DEL,
170 ZEBRA_LOCAL_ES_EVI_ADD,
171 ZEBRA_LOCAL_ES_EVI_DEL,
172 ZEBRA_VNI_ADD,
173 ZEBRA_VNI_DEL,
174 ZEBRA_L3VNI_ADD,
175 ZEBRA_L3VNI_DEL,
176 ZEBRA_REMOTE_VTEP_ADD,
177 ZEBRA_REMOTE_VTEP_DEL,
178 ZEBRA_MACIP_ADD,
179 ZEBRA_MACIP_DEL,
180 ZEBRA_IP_PREFIX_ROUTE_ADD,
181 ZEBRA_IP_PREFIX_ROUTE_DEL,
182 ZEBRA_REMOTE_MACIP_ADD,
183 ZEBRA_REMOTE_MACIP_DEL,
184 ZEBRA_DUPLICATE_ADDR_DETECTION,
185 ZEBRA_PW_ADD,
186 ZEBRA_PW_DELETE,
187 ZEBRA_PW_SET,
188 ZEBRA_PW_UNSET,
189 ZEBRA_PW_STATUS_UPDATE,
190 ZEBRA_RULE_ADD,
191 ZEBRA_RULE_DELETE,
192 ZEBRA_RULE_NOTIFY_OWNER,
193 ZEBRA_TABLE_MANAGER_CONNECT,
194 ZEBRA_GET_TABLE_CHUNK,
195 ZEBRA_RELEASE_TABLE_CHUNK,
196 ZEBRA_IPSET_CREATE,
197 ZEBRA_IPSET_DESTROY,
198 ZEBRA_IPSET_ENTRY_ADD,
199 ZEBRA_IPSET_ENTRY_DELETE,
200 ZEBRA_IPSET_NOTIFY_OWNER,
201 ZEBRA_IPSET_ENTRY_NOTIFY_OWNER,
202 ZEBRA_IPTABLE_ADD,
203 ZEBRA_IPTABLE_DELETE,
204 ZEBRA_IPTABLE_NOTIFY_OWNER,
205 ZEBRA_VXLAN_FLOOD_CONTROL,
206 ZEBRA_VXLAN_SG_ADD,
207 ZEBRA_VXLAN_SG_DEL,
208 ZEBRA_VXLAN_SG_REPLAY,
209 ZEBRA_MLAG_PROCESS_UP,
210 ZEBRA_MLAG_PROCESS_DOWN,
211 ZEBRA_MLAG_CLIENT_REGISTER,
212 ZEBRA_MLAG_CLIENT_UNREGISTER,
213 ZEBRA_MLAG_FORWARD_MSG,
214 ZEBRA_NHG_ADD,
215 ZEBRA_NHG_DEL,
216 ZEBRA_NHG_NOTIFY_OWNER,
217 ZEBRA_EVPN_REMOTE_NH_ADD,
218 ZEBRA_EVPN_REMOTE_NH_DEL,
219 ZEBRA_SRV6_LOCATOR_ADD,
220 ZEBRA_SRV6_LOCATOR_DELETE,
221 ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK,
222 ZEBRA_SRV6_MANAGER_RELEASE_LOCATOR_CHUNK,
223 ZEBRA_ERROR,
224 ZEBRA_CLIENT_CAPABILITIES,
225 ZEBRA_OPAQUE_MESSAGE,
226 ZEBRA_OPAQUE_REGISTER,
227 ZEBRA_OPAQUE_UNREGISTER,
228 ZEBRA_NEIGH_DISCOVER,
229 ZEBRA_ROUTE_NOTIFY_REQUEST,
230 ZEBRA_CLIENT_CLOSE_NOTIFY,
231 ZEBRA_NHRP_NEIGH_ADDED,
232 ZEBRA_NHRP_NEIGH_REMOVED,
233 ZEBRA_NHRP_NEIGH_GET,
234 ZEBRA_NHRP_NEIGH_REGISTER,
235 ZEBRA_NHRP_NEIGH_UNREGISTER,
236 ZEBRA_NEIGH_IP_ADD,
237 ZEBRA_NEIGH_IP_DEL,
238 ZEBRA_CONFIGURE_ARP,
239 ZEBRA_GRE_GET,
240 ZEBRA_GRE_UPDATE,
241 ZEBRA_GRE_SOURCE_SET,
242 } zebra_message_types_t;
243
244 enum zebra_error_types {
245 ZEBRA_UNKNOWN_ERROR, /* Error of unknown type */
246 ZEBRA_NO_VRF, /* Vrf in header was not found */
247 ZEBRA_INVALID_MSG_TYPE, /* No handler found for msg type */
248 };
249
250 static inline const char *zebra_error_type2str(enum zebra_error_types type)
251 {
252 const char *ret = "UNKNOWN";
253
254 switch (type) {
255 case ZEBRA_UNKNOWN_ERROR:
256 ret = "ZEBRA_UNKNOWN_ERROR";
257 break;
258 case ZEBRA_NO_VRF:
259 ret = "ZEBRA_NO_VRF";
260 break;
261 case ZEBRA_INVALID_MSG_TYPE:
262 ret = "ZEBRA_INVALID_MSG_TYPE";
263 break;
264 }
265
266 return ret;
267 }
268
269 struct redist_proto {
270 uint8_t enabled;
271 struct list *instances;
272 };
273
274 struct zclient_capabilities {
275 uint32_t ecmp;
276 bool mpls_enabled;
277 enum mlag_role role;
278 };
279
280 /* Graceful Restart Capabilities message */
281 struct zapi_cap {
282 enum zserv_client_capabilities cap;
283 uint32_t stale_removal_time;
284 afi_t afi;
285 safi_t safi;
286 vrf_id_t vrf_id;
287 };
288
289 /* clang-format off */
290 #define ZAPI_CALLBACK_ARGS \
291 int cmd, struct zclient *zclient, uint16_t length, vrf_id_t vrf_id
292
293 /* function-type typedef (pointer not included) */
294 typedef int (zclient_handler)(ZAPI_CALLBACK_ARGS);
295 /* clang-format on */
296
297 /* Structure for the zebra client. */
298 struct zclient {
299 /* The thread master we schedule ourselves on */
300 struct thread_master *master;
301
302 /* Privileges to change socket values */
303 struct zebra_privs_t *privs;
304
305 /* Do we care about failure events for route install? */
306 bool receive_notify;
307
308 /* Is this a synchronous client? */
309 bool synchronous;
310
311 /* BFD enabled with bfd_protocol_integration_init() */
312 bool bfd_integration;
313
314 /* Session id (optional) to support clients with multiple sessions */
315 uint32_t session_id;
316
317 /* Socket to zebra daemon. */
318 int sock;
319
320 /* Connection failure count. */
321 int fail;
322
323 /* Input buffer for zebra message. */
324 struct stream *ibuf;
325
326 /* Output buffer for zebra message. */
327 struct stream *obuf;
328
329 /* Buffer of data waiting to be written to zebra. */
330 struct buffer *wb;
331
332 /* Read and connect thread. */
333 struct thread *t_read;
334 struct thread *t_connect;
335
336 /* Thread to write buffered data to zebra. */
337 struct thread *t_write;
338
339 /* Redistribute information. */
340 uint8_t redist_default; /* clients protocol */
341 unsigned short instance;
342 struct redist_proto mi_redist[AFI_MAX][ZEBRA_ROUTE_MAX];
343 vrf_bitmap_t redist[AFI_MAX][ZEBRA_ROUTE_MAX];
344
345 /* Redistribute default. */
346 vrf_bitmap_t default_information[AFI_MAX];
347
348 /* Pointer to the callback functions. */
349 void (*zebra_connected)(struct zclient *);
350 void (*zebra_capabilities)(struct zclient_capabilities *cap);
351
352 int (*handle_error)(enum zebra_error_types error);
353
354 /*
355 * When the zclient attempts to write the stream data to
356 * it's named pipe to/from zebra, we may have a situation
357 * where the other daemon has not fully drained the data
358 * from the socket. In this case provide a mechanism
359 * where we will *still* buffer the data to be sent
360 * and also provide a callback mechanism to the appropriate
361 * place where we can signal that we're ready to receive
362 * more data.
363 */
364 void (*zebra_buffer_write_ready)(void);
365
366 zclient_handler *const *handlers;
367 size_t n_handlers;
368 };
369
370 /* lib handlers added in bfd.c */
371 extern int zclient_bfd_session_replay(ZAPI_CALLBACK_ARGS);
372 extern int zclient_bfd_session_update(ZAPI_CALLBACK_ARGS);
373
374 /* Zebra API message flag. */
375 #define ZAPI_MESSAGE_NEXTHOP 0x01
376 #define ZAPI_MESSAGE_DISTANCE 0x02
377 #define ZAPI_MESSAGE_METRIC 0x04
378 #define ZAPI_MESSAGE_TAG 0x08
379 #define ZAPI_MESSAGE_MTU 0x10
380 #define ZAPI_MESSAGE_SRCPFX 0x20
381 /* Backup nexthops are present */
382 #define ZAPI_MESSAGE_BACKUP_NEXTHOPS 0x40
383 #define ZAPI_MESSAGE_NHG 0x80
384 /*
385 * This should only be used by a DAEMON that needs to communicate
386 * the table being used is not in the VRF. You must pass the
387 * default vrf, else this will be ignored.
388 */
389 #define ZAPI_MESSAGE_TABLEID 0x0100
390 #define ZAPI_MESSAGE_SRTE 0x0200
391 #define ZAPI_MESSAGE_OPAQUE 0x0400
392
393 #define ZSERV_VERSION 6
394 /* Zserv protocol message header */
395 struct zmsghdr {
396 uint16_t length;
397 /* Always set to 255 in new zserv */
398 uint8_t marker;
399 uint8_t version;
400 vrf_id_t vrf_id;
401 uint16_t command;
402 } __attribute__((packed));
403 #define ZAPI_HEADER_CMD_LOCATION offsetof(struct zmsghdr, command)
404
405 /*
406 * ZAPI nexthop. Note that these are sorted when associated with ZAPI routes,
407 * and that sorting must be aligned with the sorting of nexthops in
408 * lib/nexthop.c. Any new fields must be accounted for in zapi_nexthop_cmp().
409 */
410 struct zapi_nexthop {
411 enum nexthop_types_t type;
412 vrf_id_t vrf_id;
413 ifindex_t ifindex;
414 uint8_t flags;
415 union {
416 union g_addr gate;
417 enum blackhole_type bh_type;
418 };
419
420 /* MPLS labels for BGP-LU or Segment Routing */
421 uint8_t label_num;
422 mpls_label_t labels[MPLS_MAX_LABELS];
423
424 struct ethaddr rmac;
425
426 uint32_t weight;
427
428 /* Backup nexthops, for IP-FRR, TI-LFA, etc */
429 uint8_t backup_num;
430 uint8_t backup_idx[NEXTHOP_MAX_BACKUPS];
431
432 /* SR-TE color. */
433 uint32_t srte_color;
434
435 /* SRv6 localsid info for Endpoint-behaviour */
436 uint32_t seg6local_action;
437 struct seg6local_context seg6local_ctx;
438
439 /* SRv6 Headend-behaviour */
440 struct in6_addr seg6_segs;
441 };
442
443 /*
444 * ZAPI nexthop flags values - we're encoding a single octet
445 * initially, so ensure that the on-the-wire encoding continues
446 * to match the number of valid flags.
447 */
448
449 #define ZAPI_NEXTHOP_FLAG_ONLINK 0x01
450 #define ZAPI_NEXTHOP_FLAG_LABEL 0x02
451 #define ZAPI_NEXTHOP_FLAG_WEIGHT 0x04
452 #define ZAPI_NEXTHOP_FLAG_HAS_BACKUP 0x08 /* Nexthop has a backup */
453 #define ZAPI_NEXTHOP_FLAG_SEG6 0x10
454 #define ZAPI_NEXTHOP_FLAG_SEG6LOCAL 0x20
455
456 /*
457 * ZAPI Nexthop Group. For use with protocol creation of nexthop groups.
458 */
459 struct zapi_nhg {
460 uint16_t proto;
461 uint32_t id;
462
463 uint16_t nexthop_num;
464 struct zapi_nexthop nexthops[MULTIPATH_NUM];
465
466 uint16_t backup_nexthop_num;
467 struct zapi_nexthop backup_nexthops[MULTIPATH_NUM];
468 };
469
470 /*
471 * Some of these data structures do not map easily to
472 * a actual data structure size giving different compilers
473 * and systems. For those data structures we need
474 * to use the smallest available stream_getX/putX functions
475 * to encode/decode.
476 */
477 struct zapi_route {
478 uint8_t type;
479 unsigned short instance;
480
481 /* If you add flags, update zclient_dump_route_flags */
482 uint32_t flags;
483 /*
484 * Cause Zebra to consider this routes nexthops recursively
485 */
486 #define ZEBRA_FLAG_ALLOW_RECURSION 0x01
487 /*
488 * This is a route that is read in on startup that was left around
489 * from a previous run of FRR
490 */
491 #define ZEBRA_FLAG_SELFROUTE 0x02
492 /*
493 * This flag is used to tell Zebra that the BGP route being passed
494 * down is a IBGP route
495 */
496 #define ZEBRA_FLAG_IBGP 0x04
497 /*
498 * This is a route that has been selected for FIB installation.
499 * This flag is set in zebra and can be passed up to routing daemons
500 */
501 #define ZEBRA_FLAG_SELECTED 0x08
502 /*
503 * This is a route that we are telling Zebra that this route *must*
504 * win and will be installed even over ZEBRA_FLAG_SELECTED
505 */
506 #define ZEBRA_FLAG_FIB_OVERRIDE 0x10
507 /*
508 * This flag tells Zebra that the route is a EVPN route and should
509 * be treated specially
510 */
511 #define ZEBRA_FLAG_EVPN_ROUTE 0x20
512 /*
513 * This flag tells Zebra that it should treat the distance passed
514 * down as an additional discriminator for route selection of the
515 * route entry. This mainly is used for backup static routes.
516 */
517 #define ZEBRA_FLAG_RR_USE_DISTANCE 0x40
518 /*
519 * This flag tells everyone that the route was intentionally
520 * not offloaded and the route will be sent to the cpu for
521 * forwarding. This flag makes no sense unless you are in
522 * an asic offload situation
523 */
524 #define ZEBRA_FLAG_TRAPPED 0x80
525 /*
526 * This flag tells everyone that the route has been
527 * successfully offloaded to an asic for forwarding.
528 * This flag makes no sense unless you are in an asic
529 * offload situation.
530 */
531 #define ZEBRA_FLAG_OFFLOADED 0x100
532 /*
533 * This flag tells everyone that the route has
534 * failed offloading.
535 * This flag makes no sense unless you are in an asic
536 * offload situation.
537 */
538 #define ZEBRA_FLAG_OFFLOAD_FAILED 0x200
539
540 /* The older XXX_MESSAGE flags live here */
541 uint32_t message;
542
543 /*
544 * This is an enum but we are going to treat it as a uint8_t
545 * for purpose of encoding/decoding
546 */
547 safi_t safi;
548
549 struct prefix prefix;
550 struct prefix_ipv6 src_prefix;
551
552 uint16_t nexthop_num;
553 struct zapi_nexthop nexthops[MULTIPATH_NUM];
554
555 /* Support backup routes for IP FRR, TI-LFA, traffic engineering */
556 uint16_t backup_nexthop_num;
557 struct zapi_nexthop backup_nexthops[MULTIPATH_NUM];
558
559 uint32_t nhgid;
560
561 uint8_t distance;
562
563 uint32_t metric;
564
565 route_tag_t tag;
566
567 uint32_t mtu;
568
569 vrf_id_t vrf_id;
570
571 uint32_t tableid;
572
573 /* SR-TE color (used for nexthop updates only). */
574 uint32_t srte_color;
575
576 #define ZAPI_MESSAGE_OPAQUE_LENGTH 1024
577 struct {
578 uint16_t length;
579 uint8_t data[ZAPI_MESSAGE_OPAQUE_LENGTH];
580 } opaque;
581 };
582
583 extern char *zclient_dump_route_flags(uint32_t flags, char *buf, size_t len);
584
585 struct zapi_labels {
586 uint8_t message;
587 #define ZAPI_LABELS_FTN 0x01
588 #define ZAPI_LABELS_HAS_BACKUPS 0x02
589 enum lsp_types_t type;
590 mpls_label_t local_label;
591 struct {
592 struct prefix prefix;
593 uint8_t type;
594 unsigned short instance;
595 } route;
596
597 uint16_t nexthop_num;
598 struct zapi_nexthop nexthops[MULTIPATH_NUM];
599
600 /* Backup nexthops, if present */
601 uint16_t backup_nexthop_num;
602 struct zapi_nexthop backup_nexthops[MULTIPATH_NUM];
603 };
604
605 struct zapi_srte_tunnel {
606 enum lsp_types_t type;
607 mpls_label_t local_label;
608 uint8_t label_num;
609 mpls_label_t labels[MPLS_MAX_LABELS];
610 };
611
612 struct zapi_sr_policy {
613 uint32_t color;
614 struct ipaddr endpoint;
615 char name[SRTE_POLICY_NAME_MAX_LENGTH];
616 struct zapi_srte_tunnel segment_list;
617 int status;
618 };
619
620 struct zapi_pw {
621 char ifname[IF_NAMESIZE];
622 ifindex_t ifindex;
623 int type;
624 int af;
625 union g_addr nexthop;
626 uint32_t local_label;
627 uint32_t remote_label;
628 uint8_t flags;
629 union pw_protocol_fields data;
630 uint8_t protocol;
631 };
632
633 struct zapi_pw_status {
634 char ifname[IF_NAMESIZE];
635 ifindex_t ifindex;
636 uint32_t status;
637 };
638
639 /* IGP instance data associated to a RLFA. */
640 struct zapi_rlfa_igp {
641 vrf_id_t vrf_id;
642 int protocol;
643 union {
644 struct {
645 char area_tag[32];
646 struct {
647 int tree_id;
648 int level;
649 unsigned int run_id;
650 } spf;
651 } isis;
652 };
653 };
654
655 /* IGP -> LDP RLFA (un)registration message. */
656 struct zapi_rlfa_request {
657 /* IGP instance data. */
658 struct zapi_rlfa_igp igp;
659
660 /* Destination prefix. */
661 struct prefix destination;
662
663 /* PQ node address. */
664 struct in_addr pq_address;
665 };
666
667 /* LDP -> IGP RLFA label update. */
668 struct zapi_rlfa_response {
669 /* IGP instance data. */
670 struct zapi_rlfa_igp igp;
671
672 /* Destination prefix. */
673 struct prefix destination;
674
675 /* Resolved LDP labels. */
676 mpls_label_t pq_label;
677 uint16_t nexthop_num;
678 struct {
679 int family;
680 union g_addr gate;
681 mpls_label_t label;
682 } nexthops[MULTIPATH_NUM];
683 };
684
685 enum zapi_route_notify_owner {
686 ZAPI_ROUTE_FAIL_INSTALL,
687 ZAPI_ROUTE_BETTER_ADMIN_WON,
688 ZAPI_ROUTE_INSTALLED,
689 ZAPI_ROUTE_REMOVED,
690 ZAPI_ROUTE_REMOVE_FAIL,
691 };
692
693 enum zapi_nhg_notify_owner {
694 ZAPI_NHG_FAIL_INSTALL,
695 ZAPI_NHG_INSTALLED,
696 ZAPI_NHG_REMOVED,
697 ZAPI_NHG_REMOVE_FAIL,
698 };
699
700 enum zapi_rule_notify_owner {
701 ZAPI_RULE_FAIL_INSTALL,
702 ZAPI_RULE_INSTALLED,
703 ZAPI_RULE_REMOVED,
704 ZAPI_RULE_FAIL_REMOVE,
705 };
706
707 enum ipset_type {
708 IPSET_NET_NET = 1,
709 IPSET_NET_PORT_NET,
710 IPSET_NET_PORT,
711 IPSET_NET
712 };
713
714 enum zapi_ipset_notify_owner {
715 ZAPI_IPSET_FAIL_INSTALL = 0,
716 ZAPI_IPSET_INSTALLED,
717 ZAPI_IPSET_REMOVED,
718 ZAPI_IPSET_FAIL_REMOVE,
719 };
720
721 enum zapi_ipset_entry_notify_owner {
722 ZAPI_IPSET_ENTRY_FAIL_INSTALL = 0,
723 ZAPI_IPSET_ENTRY_INSTALLED,
724 ZAPI_IPSET_ENTRY_REMOVED,
725 ZAPI_IPSET_ENTRY_FAIL_REMOVE,
726 };
727
728 enum zapi_iptable_notify_owner {
729 ZAPI_IPTABLE_FAIL_INSTALL = 0,
730 ZAPI_IPTABLE_INSTALLED,
731 ZAPI_IPTABLE_REMOVED,
732 ZAPI_IPTABLE_FAIL_REMOVE,
733 };
734
735 enum zclient_send_status {
736 ZCLIENT_SEND_FAILURE = -1,
737 ZCLIENT_SEND_SUCCESS = 0,
738 ZCLIENT_SEND_BUFFERED = 1
739 };
740
741 static inline const char *
742 zapi_nhg_notify_owner2str(enum zapi_nhg_notify_owner note)
743 {
744 const char *ret = "UNKNOWN";
745
746 switch (note) {
747 case ZAPI_NHG_FAIL_INSTALL:
748 ret = "ZAPI_NHG_FAIL_INSTALL";
749 break;
750 case ZAPI_NHG_INSTALLED:
751 ret = "ZAPI_NHG_INSTALLED";
752 break;
753 case ZAPI_NHG_REMOVE_FAIL:
754 ret = "ZAPI_NHG_REMOVE_FAIL";
755 break;
756 case ZAPI_NHG_REMOVED:
757 ret = "ZAPI_NHG_REMOVED";
758 break;
759 }
760
761 return ret;
762 }
763
764 static inline const char *
765 zapi_rule_notify_owner2str(enum zapi_rule_notify_owner note)
766 {
767 const char *ret = "UNKNOWN";
768
769 switch (note) {
770 case ZAPI_RULE_FAIL_INSTALL:
771 ret = "ZAPI_RULE_FAIL_INSTALL";
772 break;
773 case ZAPI_RULE_INSTALLED:
774 ret = "ZAPI_RULE_INSTALLED";
775 break;
776 case ZAPI_RULE_FAIL_REMOVE:
777 ret = "ZAPI_RULE_FAIL_REMOVE";
778 break;
779 case ZAPI_RULE_REMOVED:
780 ret = "ZAPI_RULE_REMOVED";
781 break;
782 }
783
784 return ret;
785 }
786
787 /* Zebra MAC types */
788 #define ZEBRA_MACIP_TYPE_STICKY 0x01 /* Sticky MAC*/
789 #define ZEBRA_MACIP_TYPE_GW 0x02 /* gateway (SVI) mac*/
790 #define ZEBRA_MACIP_TYPE_ROUTER_FLAG 0x04 /* Router Flag - proxy NA */
791 #define ZEBRA_MACIP_TYPE_OVERRIDE_FLAG 0x08 /* Override Flag */
792 #define ZEBRA_MACIP_TYPE_SVI_IP 0x10 /* SVI MAC-IP */
793 #define ZEBRA_MACIP_TYPE_PROXY_ADVERT 0x20 /* Not locally active */
794 #define ZEBRA_MACIP_TYPE_SYNC_PATH 0x40 /* sync path */
795 /* XXX - flags is an u8; that needs to be changed to u32 if you need
796 * to allocate past 0x80. Additionally touch zclient_evpn_dump_macip_flags
797 */
798 #define MACIP_BUF_SIZE 128
799 extern char *zclient_evpn_dump_macip_flags(uint8_t flags, char *buf,
800 size_t len);
801
802 /* Zebra ES VTEP flags (ZEBRA_REMOTE_ES_VTEP_ADD) */
803 /* ESR has been rxed from the VTEP. Only VTEPs that have advertised the
804 * Type-4 route can participate in DF election.
805 */
806 #define ZAPI_ES_VTEP_FLAG_ESR_RXED (1 << 0)
807
808 enum zebra_neigh_state { ZEBRA_NEIGH_INACTIVE = 0, ZEBRA_NEIGH_ACTIVE = 1 };
809
810 struct zclient_options {
811 bool receive_notify;
812 bool synchronous;
813 };
814
815 extern struct zclient_options zclient_options_default;
816
817 /* link layer representation for GRE like interfaces
818 * ip_in is the underlay IP, ip_out is the tunnel dest
819 * index stands for the index of the interface
820 * ndm state stands for the NDM value in netlink
821 * (see linux/neighbour.h)
822 */
823 #define ZEBRA_NEIGH_STATE_INCOMPLETE (0x01)
824 #define ZEBRA_NEIGH_STATE_REACHABLE (0x02)
825 #define ZEBRA_NEIGH_STATE_STALE (0x04)
826 #define ZEBRA_NEIGH_STATE_DELAY (0x08)
827 #define ZEBRA_NEIGH_STATE_PROBE (0x10)
828 #define ZEBRA_NEIGH_STATE_FAILED (0x20)
829 #define ZEBRA_NEIGH_STATE_NOARP (0x40)
830 #define ZEBRA_NEIGH_STATE_PERMANENT (0x80)
831 #define ZEBRA_NEIGH_STATE_NONE (0x00)
832
833 struct zapi_neigh_ip {
834 int cmd;
835 struct ipaddr ip_in;
836 struct ipaddr ip_out;
837 ifindex_t index;
838 uint32_t ndm_state;
839 };
840 int zclient_neigh_ip_decode(struct stream *s, struct zapi_neigh_ip *api);
841 int zclient_neigh_ip_encode(struct stream *s, uint16_t cmd, union sockunion *in,
842 union sockunion *out, struct interface *ifp,
843 int ndm_state);
844
845 /*
846 * We reserve the top 4 bits for l2-NHG, everything else
847 * is for zebra/proto l3-NHG.
848 *
849 * Each client is going to get it's own nexthop group space
850 * and we'll separate them, we'll figure out where to start based upon
851 * the route_types.h
852 */
853 #define ZEBRA_NHG_PROTO_UPPER \
854 ((uint32_t)250000000) /* Bottom 28 bits then rounded down */
855 #define ZEBRA_NHG_PROTO_SPACING (ZEBRA_NHG_PROTO_UPPER / ZEBRA_ROUTE_MAX)
856 #define ZEBRA_NHG_PROTO_LOWER \
857 (ZEBRA_NHG_PROTO_SPACING * (ZEBRA_ROUTE_CONNECT + 1))
858
859 extern uint32_t zclient_get_nhg_start(uint32_t proto);
860
861 extern struct zclient *zclient_new(struct thread_master *m,
862 struct zclient_options *opt,
863 zclient_handler *const *handlers,
864 size_t n_handlers);
865
866 extern void zclient_init(struct zclient *, int, unsigned short,
867 struct zebra_privs_t *privs);
868 extern int zclient_start(struct zclient *);
869 extern void zclient_stop(struct zclient *);
870 extern void zclient_reset(struct zclient *);
871 extern void zclient_free(struct zclient *);
872
873 extern int zclient_socket_connect(struct zclient *);
874
875 extern unsigned short *redist_check_instance(struct redist_proto *,
876 unsigned short);
877 extern void redist_add_instance(struct redist_proto *, unsigned short);
878 extern void redist_del_instance(struct redist_proto *, unsigned short);
879 extern void redist_del_all_instances(struct redist_proto *red);
880
881 /*
882 * Send to zebra that the specified vrf is using label to resolve
883 * itself for L3VPN's. Repeated calls of this function with
884 * different labels will cause an effective update of the
885 * label for lookup. If you pass in MPLS_LABEL_NONE
886 * we will cause a delete action and remove this label pop
887 * operation.
888 *
889 * The underlying AF_MPLS doesn't care about afi's
890 * but we can make the zebra_vrf keep track of what
891 * we have installed and play some special games
892 * to get them both installed.
893 */
894 extern enum zclient_send_status
895 zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, afi_t afi,
896 mpls_label_t label, enum lsp_types_t ltype);
897
898 extern enum zclient_send_status
899 zclient_send_localsid(struct zclient *zclient, const struct in6_addr *sid,
900 ifindex_t oif, enum seg6local_action_t action,
901 const struct seg6local_context *context);
902
903 extern void zclient_send_reg_requests(struct zclient *, vrf_id_t);
904 extern void zclient_send_dereg_requests(struct zclient *, vrf_id_t);
905 extern enum zclient_send_status
906 zclient_send_router_id_update(struct zclient *zclient,
907 zebra_message_types_t type, afi_t afi,
908 vrf_id_t vrf_id);
909
910 extern enum zclient_send_status
911 zclient_send_interface_radv_req(struct zclient *zclient, vrf_id_t vrf_id,
912 struct interface *ifp, int enable,
913 uint32_t ra_interval);
914 extern enum zclient_send_status
915 zclient_send_interface_protodown(struct zclient *zclient, vrf_id_t vrf_id,
916 struct interface *ifp, bool down);
917
918 /* Send redistribute command to zebra daemon. Do not update zclient state. */
919 extern enum zclient_send_status
920 zebra_redistribute_send(int command, struct zclient *, afi_t, int type,
921 unsigned short instance, vrf_id_t vrf_id);
922
923 extern enum zclient_send_status
924 zebra_redistribute_default_send(int command, struct zclient *zclient, afi_t afi,
925 vrf_id_t vrf_id);
926
927 /* Send route notify request to zebra */
928 extern int zebra_route_notify_send(int command, struct zclient *zclient,
929 bool set);
930
931 /* If state has changed, update state and call zebra_redistribute_send. */
932 extern void zclient_redistribute(int command, struct zclient *, afi_t, int type,
933 unsigned short instance, vrf_id_t vrf_id);
934
935 /* If state has changed, update state and send the command to zebra. */
936 extern void zclient_redistribute_default(int command, struct zclient *,
937 afi_t, vrf_id_t vrf_id);
938
939 /*
940 * Send the message in zclient->obuf to the zebra daemon (or enqueue it).
941 * Returns:
942 * -1 on a I/O error
943 * 0 data was successfully sent
944 * 1 data was buffered for future usage
945 */
946 extern enum zclient_send_status zclient_send_message(struct zclient *);
947
948 /* create header for command, length to be filled in by user later */
949 extern void zclient_create_header(struct stream *, uint16_t, vrf_id_t);
950 /*
951 * Read sizeof(struct zmsghdr) bytes from the provided socket and parse the
952 * received data into the specified fields. If this is successful, read the
953 * rest of the packet into the provided stream.
954 *
955 * s
956 * The stream to read into
957 *
958 * sock
959 * The socket to read from
960 *
961 * size
962 * Parsed message size will be placed in the pointed-at integer
963 *
964 * marker
965 * Parsed marker will be placed in the pointed-at byte
966 *
967 * version
968 * Parsed version will be placed in the pointed-at byte
969 *
970 * vrf_id
971 * Parsed VRF ID will be placed in the pointed-at vrf_id_t
972 *
973 * cmd
974 * Parsed command number will be placed in the pointed-at integer
975 *
976 * Returns:
977 * -1 if:
978 * - insufficient data for header was read
979 * - a version mismatch was detected
980 * - a marker mismatch was detected
981 * - header size field specified more data than could be read
982 */
983 extern int zclient_read_header(struct stream *s, int sock, uint16_t *size,
984 uint8_t *marker, uint8_t *version,
985 vrf_id_t *vrf_id, uint16_t *cmd);
986 /*
987 * Parse header from ZAPI message stream into struct zmsghdr.
988 * This function assumes the stream getp points at the first byte of the header.
989 * If the function is successful then the stream getp will point to the byte
990 * immediately after the last byte of the header.
991 *
992 * zmsg
993 * The stream containing the header
994 *
995 * hdr
996 * The header struct to parse into.
997 *
998 * Returns:
999 * true if parsing succeeded, false otherwise
1000 */
1001 extern bool zapi_parse_header(struct stream *zmsg, struct zmsghdr *hdr);
1002
1003 extern enum zclient_send_status
1004 zclient_interface_set_master(struct zclient *client, struct interface *master,
1005 struct interface *slave);
1006 extern struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t);
1007 extern struct connected *zebra_interface_address_read(int, struct stream *,
1008 vrf_id_t);
1009 extern struct nbr_connected *
1010 zebra_interface_nbr_address_read(int, struct stream *, vrf_id_t);
1011 extern struct interface *zebra_interface_vrf_update_read(struct stream *s,
1012 vrf_id_t vrf_id,
1013 vrf_id_t *new_vrf_id);
1014 extern int zebra_router_id_update_read(struct stream *s, struct prefix *rid);
1015
1016 extern struct interface *zebra_interface_link_params_read(struct stream *s,
1017 vrf_id_t vrf_id,
1018 bool *changed);
1019 extern size_t zebra_interface_link_params_write(struct stream *,
1020 struct interface *);
1021 extern enum zclient_send_status
1022 zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
1023 uint32_t chunk_size, uint32_t base);
1024
1025 extern int lm_label_manager_connect(struct zclient *zclient, int async);
1026 extern int lm_get_label_chunk(struct zclient *zclient, uint8_t keep,
1027 uint32_t base, uint32_t chunk_size,
1028 uint32_t *start, uint32_t *end);
1029 extern int lm_release_label_chunk(struct zclient *zclient, uint32_t start,
1030 uint32_t end);
1031 extern int tm_table_manager_connect(struct zclient *zclient);
1032 extern int tm_get_table_chunk(struct zclient *zclient, uint32_t chunk_size,
1033 uint32_t *start, uint32_t *end);
1034 extern int tm_release_table_chunk(struct zclient *zclient, uint32_t start,
1035 uint32_t end);
1036 extern int srv6_manager_get_locator_chunk(struct zclient *zclient,
1037 const char *locator_name);
1038 extern int srv6_manager_release_locator_chunk(struct zclient *zclient,
1039 const char *locator_name);
1040
1041 extern enum zclient_send_status zebra_send_sr_policy(struct zclient *zclient,
1042 int cmd,
1043 struct zapi_sr_policy *zp);
1044 extern int zapi_sr_policy_encode(struct stream *s, int cmd,
1045 struct zapi_sr_policy *zp);
1046 extern int zapi_sr_policy_decode(struct stream *s, struct zapi_sr_policy *zp);
1047 extern int zapi_sr_policy_notify_status_decode(struct stream *s,
1048 struct zapi_sr_policy *zp);
1049
1050 extern enum zclient_send_status zebra_send_mpls_labels(struct zclient *zclient,
1051 int cmd,
1052 struct zapi_labels *zl);
1053 extern int zapi_labels_encode(struct stream *s, int cmd,
1054 struct zapi_labels *zl);
1055 extern int zapi_labels_decode(struct stream *s, struct zapi_labels *zl);
1056
1057 extern int zapi_srv6_locator_encode(struct stream *s,
1058 const struct srv6_locator *l);
1059 extern int zapi_srv6_locator_decode(struct stream *s, struct srv6_locator *l);
1060 extern int zapi_srv6_locator_chunk_encode(struct stream *s,
1061 const struct srv6_locator_chunk *c);
1062 extern int zapi_srv6_locator_chunk_decode(struct stream *s,
1063 struct srv6_locator_chunk *c);
1064
1065 extern enum zclient_send_status zebra_send_pw(struct zclient *zclient,
1066 int command, struct zapi_pw *pw);
1067 extern int zebra_read_pw_status_update(ZAPI_CALLBACK_ARGS,
1068 struct zapi_pw_status *pw);
1069
1070 extern enum zclient_send_status zclient_route_send(uint8_t, struct zclient *,
1071 struct zapi_route *);
1072 extern enum zclient_send_status
1073 zclient_send_rnh(struct zclient *zclient, int command, const struct prefix *p,
1074 bool connected, bool resolve_via_default, vrf_id_t vrf_id);
1075 int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh,
1076 uint32_t api_flags, uint32_t api_message);
1077 extern int zapi_route_encode(uint8_t, struct stream *, struct zapi_route *);
1078 extern int zapi_route_decode(struct stream *s, struct zapi_route *api);
1079 extern int zapi_nexthop_decode(struct stream *s, struct zapi_nexthop *api_nh,
1080 uint32_t api_flags, uint32_t api_message);
1081 bool zapi_nhg_notify_decode(struct stream *s, uint32_t *id,
1082 enum zapi_nhg_notify_owner *note);
1083 bool zapi_route_notify_decode(struct stream *s, struct prefix *p,
1084 uint32_t *tableid,
1085 enum zapi_route_notify_owner *note,
1086 afi_t *afi, safi_t *safi);
1087 bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
1088 uint32_t *priority, uint32_t *unique, char *ifname,
1089 enum zapi_rule_notify_owner *note);
1090 bool zapi_ipset_notify_decode(struct stream *s,
1091 uint32_t *unique,
1092 enum zapi_ipset_notify_owner *note);
1093
1094 /* Nexthop-group message apis */
1095 extern enum zclient_send_status
1096 zclient_nhg_send(struct zclient *zclient, int cmd, struct zapi_nhg *api_nhg);
1097
1098 #define ZEBRA_IPSET_NAME_SIZE 32
1099
1100 bool zapi_ipset_entry_notify_decode(struct stream *s,
1101 uint32_t *unique,
1102 char *ipset_name,
1103 enum zapi_ipset_entry_notify_owner *note);
1104 bool zapi_iptable_notify_decode(struct stream *s,
1105 uint32_t *unique,
1106 enum zapi_iptable_notify_owner *note);
1107
1108 extern struct nexthop *
1109 nexthop_from_zapi_nexthop(const struct zapi_nexthop *znh);
1110 int zapi_nexthop_from_nexthop(struct zapi_nexthop *znh,
1111 const struct nexthop *nh);
1112 int zapi_backup_nexthop_from_nexthop(struct zapi_nexthop *znh,
1113 const struct nexthop *nh);
1114 /*
1115 * match -> is the prefix that the calling daemon asked to be matched
1116 * against.
1117 * nhr->prefix -> is the actual prefix that was matched against in the
1118 * rib itself.
1119 *
1120 * This distinction is made because a LPM can be made if there is a
1121 * covering route. This way the upper level protocol can make a decision
1122 * point about whether or not it wants to use the match or not.
1123 */
1124 extern bool zapi_nexthop_update_decode(struct stream *s, struct prefix *match,
1125 struct zapi_route *nhr);
1126 const char *zapi_nexthop2str(const struct zapi_nexthop *znh, char *buf,
1127 int bufsize);
1128
1129 /* Decode the zebra error message */
1130 extern bool zapi_error_decode(struct stream *s, enum zebra_error_types *error);
1131
1132 /* Encode and decode restart capabilities */
1133 extern enum zclient_send_status
1134 zclient_capabilities_send(uint32_t cmd, struct zclient *zclient,
1135 struct zapi_cap *api);
1136 extern int32_t zapi_capabilities_decode(struct stream *s, struct zapi_cap *api);
1137
1138 static inline void zapi_route_set_blackhole(struct zapi_route *api,
1139 enum blackhole_type bh_type)
1140 {
1141 api->nexthop_num = 1;
1142 api->nexthops[0].type = NEXTHOP_TYPE_BLACKHOLE;
1143 api->nexthops[0].vrf_id = VRF_DEFAULT;
1144 api->nexthops[0].bh_type = bh_type;
1145 SET_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP);
1146 };
1147
1148 extern enum zclient_send_status
1149 zclient_send_mlag_register(struct zclient *client, uint32_t bit_map);
1150 extern enum zclient_send_status
1151 zclient_send_mlag_deregister(struct zclient *client);
1152
1153 extern enum zclient_send_status zclient_send_mlag_data(struct zclient *client,
1154 struct stream *client_s);
1155
1156 /*
1157 * Send an OPAQUE message, contents opaque to zebra - but note that
1158 * the length of the payload is restricted by the zclient's
1159 * outgoing message buffer.
1160 * The message header is a message subtype; please use the registry
1161 * below to avoid sub-type collisions. Clients use the registration
1162 * apis to manage the specific opaque subtypes they want to receive.
1163 */
1164 enum zclient_send_status zclient_send_opaque(struct zclient *zclient,
1165 uint32_t type, const uint8_t *data,
1166 size_t datasize);
1167
1168 enum zclient_send_status
1169 zclient_send_opaque_unicast(struct zclient *zclient, uint32_t type,
1170 uint8_t proto, uint16_t instance,
1171 uint32_t session_id, const uint8_t *data,
1172 size_t datasize);
1173
1174 /* Struct representing the decoded opaque header info */
1175 struct zapi_opaque_msg {
1176 uint32_t type; /* Subtype */
1177 uint16_t len; /* len after zapi header and this info */
1178 uint16_t flags;
1179
1180 /* Client-specific info - *if* UNICAST flag is set */
1181 uint8_t proto;
1182 uint16_t instance;
1183 uint32_t session_id;
1184 };
1185
1186 #define ZAPI_OPAQUE_FLAG_UNICAST 0x01
1187
1188 /* Simple struct to convey registration/unreg requests */
1189 struct zapi_opaque_reg_info {
1190 /* Message subtype */
1191 uint32_t type;
1192
1193 /* Client session tuple */
1194 uint8_t proto;
1195 uint16_t instance;
1196 uint32_t session_id;
1197 };
1198
1199 /* Decode incoming opaque */
1200 int zclient_opaque_decode(struct stream *msg, struct zapi_opaque_msg *info);
1201
1202 enum zclient_send_status zclient_register_opaque(struct zclient *zclient,
1203 uint32_t type);
1204 enum zclient_send_status zclient_unregister_opaque(struct zclient *zclient,
1205 uint32_t type);
1206 int zapi_opaque_reg_decode(struct stream *msg,
1207 struct zapi_opaque_reg_info *info);
1208
1209 /*
1210 * Registry of opaque message types. Please do not reuse an in-use
1211 * type code; some daemons are likely relying on it.
1212 */
1213 enum zapi_opaque_registry {
1214 /* Request link-state database dump, at restart for example */
1215 LINK_STATE_SYNC = 1,
1216 /* Update containing link-state db info */
1217 LINK_STATE_UPDATE = 2,
1218 /* Request LDP-SYNC state from LDP */
1219 LDP_IGP_SYNC_IF_STATE_REQUEST = 3,
1220 /* Update containing LDP IGP Sync State info */
1221 LDP_IGP_SYNC_IF_STATE_UPDATE = 4,
1222 /* Announce that LDP is up */
1223 LDP_IGP_SYNC_ANNOUNCE_UPDATE = 5,
1224 /* Register RLFA with LDP */
1225 LDP_RLFA_REGISTER = 7,
1226 /* Unregister all RLFAs with LDP */
1227 LDP_RLFA_UNREGISTER_ALL = 8,
1228 /* Announce LDP labels associated to a previously registered RLFA */
1229 LDP_RLFA_LABELS = 9,
1230 };
1231
1232 /* Send the hello message.
1233 * Returns 0 for success or -1 on an I/O error.
1234 */
1235 extern enum zclient_send_status zclient_send_hello(struct zclient *client);
1236
1237 extern enum zclient_send_status
1238 zclient_send_neigh_discovery_req(struct zclient *zclient,
1239 const struct interface *ifp,
1240 const struct prefix *p);
1241
1242 struct zapi_client_close_info {
1243 /* Client session tuple */
1244 uint8_t proto;
1245 uint16_t instance;
1246 uint32_t session_id;
1247 };
1248
1249 /* Decode incoming client close notify */
1250 extern int zapi_client_close_notify_decode(struct stream *s,
1251 struct zapi_client_close_info *info);
1252
1253 extern int zclient_send_zebra_gre_request(struct zclient *client,
1254 struct interface *ifp);
1255 #ifdef __cplusplus
1256 }
1257 #endif
1258
1259 #endif /* _ZEBRA_ZCLIENT_H */