]> git.proxmox.com Git - mirror_frr.git/blob - lib/zclient.h
Merge pull request #11454 from routingrocks/evpn_clag_frrlogs
[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_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 #define ZAPI_NEXTHOP_FLAG_EVPN 0x40
456
457 /*
458 * ZAPI Nexthop Group. For use with protocol creation of nexthop groups.
459 */
460 struct zapi_nhg {
461 uint16_t proto;
462 uint32_t id;
463
464 uint16_t nexthop_num;
465 struct zapi_nexthop nexthops[MULTIPATH_NUM];
466
467 uint16_t backup_nexthop_num;
468 struct zapi_nexthop backup_nexthops[MULTIPATH_NUM];
469 };
470
471 /*
472 * Some of these data structures do not map easily to
473 * a actual data structure size giving different compilers
474 * and systems. For those data structures we need
475 * to use the smallest available stream_getX/putX functions
476 * to encode/decode.
477 */
478 struct zapi_route {
479 uint8_t type;
480 unsigned short instance;
481
482 /* If you add flags, update zclient_dump_route_flags */
483 uint32_t flags;
484 /*
485 * Cause Zebra to consider this routes nexthops recursively
486 */
487 #define ZEBRA_FLAG_ALLOW_RECURSION 0x01
488 /*
489 * This is a route that is read in on startup that was left around
490 * from a previous run of FRR
491 */
492 #define ZEBRA_FLAG_SELFROUTE 0x02
493 /*
494 * This flag is used to tell Zebra that the BGP route being passed
495 * down is a IBGP route
496 */
497 #define ZEBRA_FLAG_IBGP 0x04
498 /*
499 * This is a route that has been selected for FIB installation.
500 * This flag is set in zebra and can be passed up to routing daemons
501 */
502 #define ZEBRA_FLAG_SELECTED 0x08
503 /*
504 * This is a route that we are telling Zebra that this route *must*
505 * win and will be installed even over ZEBRA_FLAG_SELECTED
506 */
507 #define ZEBRA_FLAG_FIB_OVERRIDE 0x10
508 /*
509 * This flag tells Zebra that the route is a EVPN route and should
510 * be treated specially
511 */
512 #define ZEBRA_FLAG_EVPN_ROUTE 0x20
513 /*
514 * This flag tells Zebra that it should treat the distance passed
515 * down as an additional discriminator for route selection of the
516 * route entry. This mainly is used for backup static routes.
517 */
518 #define ZEBRA_FLAG_RR_USE_DISTANCE 0x40
519 /*
520 * This flag tells everyone that the route was intentionally
521 * not offloaded and the route will be sent to the cpu for
522 * forwarding. This flag makes no sense unless you are in
523 * an asic offload situation
524 */
525 #define ZEBRA_FLAG_TRAPPED 0x80
526 /*
527 * This flag tells everyone that the route has been
528 * successfully offloaded to an asic for forwarding.
529 * This flag makes no sense unless you are in an asic
530 * offload situation.
531 */
532 #define ZEBRA_FLAG_OFFLOADED 0x100
533 /*
534 * This flag tells everyone that the route has
535 * failed offloading.
536 * This flag makes no sense unless you are in an asic
537 * offload situation.
538 */
539 #define ZEBRA_FLAG_OFFLOAD_FAILED 0x200
540
541 /* The older XXX_MESSAGE flags live here */
542 uint32_t message;
543
544 /*
545 * This is an enum but we are going to treat it as a uint8_t
546 * for purpose of encoding/decoding
547 */
548 safi_t safi;
549
550 struct prefix prefix;
551 struct prefix_ipv6 src_prefix;
552
553 uint16_t nexthop_num;
554 struct zapi_nexthop nexthops[MULTIPATH_NUM];
555
556 /* Support backup routes for IP FRR, TI-LFA, traffic engineering */
557 uint16_t backup_nexthop_num;
558 struct zapi_nexthop backup_nexthops[MULTIPATH_NUM];
559
560 uint32_t nhgid;
561
562 uint8_t distance;
563
564 uint32_t metric;
565
566 route_tag_t tag;
567
568 uint32_t mtu;
569
570 vrf_id_t vrf_id;
571
572 uint32_t tableid;
573
574 /* SR-TE color (used for nexthop updates only). */
575 uint32_t srte_color;
576
577 #define ZAPI_MESSAGE_OPAQUE_LENGTH 1024
578 struct {
579 uint16_t length;
580 uint8_t data[ZAPI_MESSAGE_OPAQUE_LENGTH];
581 } opaque;
582 };
583
584 extern char *zclient_dump_route_flags(uint32_t flags, char *buf, size_t len);
585
586 struct zapi_labels {
587 uint8_t message;
588 #define ZAPI_LABELS_FTN 0x01
589 #define ZAPI_LABELS_HAS_BACKUPS 0x02
590 enum lsp_types_t type;
591 mpls_label_t local_label;
592 struct {
593 struct prefix prefix;
594 uint8_t type;
595 unsigned short instance;
596 } route;
597
598 uint16_t nexthop_num;
599 struct zapi_nexthop nexthops[MULTIPATH_NUM];
600
601 /* Backup nexthops, if present */
602 uint16_t backup_nexthop_num;
603 struct zapi_nexthop backup_nexthops[MULTIPATH_NUM];
604 };
605
606 struct zapi_srte_tunnel {
607 enum lsp_types_t type;
608 mpls_label_t local_label;
609 uint8_t label_num;
610 mpls_label_t labels[MPLS_MAX_LABELS];
611 };
612
613 struct zapi_sr_policy {
614 uint32_t color;
615 struct ipaddr endpoint;
616 char name[SRTE_POLICY_NAME_MAX_LENGTH];
617 struct zapi_srte_tunnel segment_list;
618 int status;
619 };
620
621 struct zapi_pw {
622 char ifname[INTERFACE_NAMSIZ];
623 ifindex_t ifindex;
624 int type;
625 int af;
626 union g_addr nexthop;
627 uint32_t local_label;
628 uint32_t remote_label;
629 uint8_t flags;
630 union pw_protocol_fields data;
631 uint8_t protocol;
632 };
633
634 struct zapi_pw_status {
635 char ifname[INTERFACE_NAMSIZ];
636 ifindex_t ifindex;
637 uint32_t status;
638 };
639
640 /* IGP instance data associated to a RLFA. */
641 struct zapi_rlfa_igp {
642 vrf_id_t vrf_id;
643 int protocol;
644 union {
645 struct {
646 char area_tag[32];
647 struct {
648 int tree_id;
649 int level;
650 unsigned int run_id;
651 } spf;
652 } isis;
653 };
654 };
655
656 /* IGP -> LDP RLFA (un)registration message. */
657 struct zapi_rlfa_request {
658 /* IGP instance data. */
659 struct zapi_rlfa_igp igp;
660
661 /* Destination prefix. */
662 struct prefix destination;
663
664 /* PQ node address. */
665 struct in_addr pq_address;
666 };
667
668 /* LDP -> IGP RLFA label update. */
669 struct zapi_rlfa_response {
670 /* IGP instance data. */
671 struct zapi_rlfa_igp igp;
672
673 /* Destination prefix. */
674 struct prefix destination;
675
676 /* Resolved LDP labels. */
677 mpls_label_t pq_label;
678 uint16_t nexthop_num;
679 struct {
680 int family;
681 union g_addr gate;
682 mpls_label_t label;
683 } nexthops[MULTIPATH_NUM];
684 };
685
686 enum zapi_route_notify_owner {
687 ZAPI_ROUTE_FAIL_INSTALL,
688 ZAPI_ROUTE_BETTER_ADMIN_WON,
689 ZAPI_ROUTE_INSTALLED,
690 ZAPI_ROUTE_REMOVED,
691 ZAPI_ROUTE_REMOVE_FAIL,
692 };
693
694 enum zapi_nhg_notify_owner {
695 ZAPI_NHG_FAIL_INSTALL,
696 ZAPI_NHG_INSTALLED,
697 ZAPI_NHG_REMOVED,
698 ZAPI_NHG_REMOVE_FAIL,
699 };
700
701 enum zapi_rule_notify_owner {
702 ZAPI_RULE_FAIL_INSTALL,
703 ZAPI_RULE_INSTALLED,
704 ZAPI_RULE_REMOVED,
705 ZAPI_RULE_FAIL_REMOVE,
706 };
707
708 enum ipset_type {
709 IPSET_NET_NET = 1,
710 IPSET_NET_PORT_NET,
711 IPSET_NET_PORT,
712 IPSET_NET
713 };
714
715 enum zapi_ipset_notify_owner {
716 ZAPI_IPSET_FAIL_INSTALL = 0,
717 ZAPI_IPSET_INSTALLED,
718 ZAPI_IPSET_REMOVED,
719 ZAPI_IPSET_FAIL_REMOVE,
720 };
721
722 enum zapi_ipset_entry_notify_owner {
723 ZAPI_IPSET_ENTRY_FAIL_INSTALL = 0,
724 ZAPI_IPSET_ENTRY_INSTALLED,
725 ZAPI_IPSET_ENTRY_REMOVED,
726 ZAPI_IPSET_ENTRY_FAIL_REMOVE,
727 };
728
729 enum zapi_iptable_notify_owner {
730 ZAPI_IPTABLE_FAIL_INSTALL = 0,
731 ZAPI_IPTABLE_INSTALLED,
732 ZAPI_IPTABLE_REMOVED,
733 ZAPI_IPTABLE_FAIL_REMOVE,
734 };
735
736 enum zclient_send_status {
737 ZCLIENT_SEND_FAILURE = -1,
738 ZCLIENT_SEND_SUCCESS = 0,
739 ZCLIENT_SEND_BUFFERED = 1
740 };
741
742 static inline const char *
743 zapi_nhg_notify_owner2str(enum zapi_nhg_notify_owner note)
744 {
745 const char *ret = "UNKNOWN";
746
747 switch (note) {
748 case ZAPI_NHG_FAIL_INSTALL:
749 ret = "ZAPI_NHG_FAIL_INSTALL";
750 break;
751 case ZAPI_NHG_INSTALLED:
752 ret = "ZAPI_NHG_INSTALLED";
753 break;
754 case ZAPI_NHG_REMOVE_FAIL:
755 ret = "ZAPI_NHG_REMOVE_FAIL";
756 break;
757 case ZAPI_NHG_REMOVED:
758 ret = "ZAPI_NHG_REMOVED";
759 break;
760 }
761
762 return ret;
763 }
764
765 static inline const char *
766 zapi_rule_notify_owner2str(enum zapi_rule_notify_owner note)
767 {
768 const char *ret = "UNKNOWN";
769
770 switch (note) {
771 case ZAPI_RULE_FAIL_INSTALL:
772 ret = "ZAPI_RULE_FAIL_INSTALL";
773 break;
774 case ZAPI_RULE_INSTALLED:
775 ret = "ZAPI_RULE_INSTALLED";
776 break;
777 case ZAPI_RULE_FAIL_REMOVE:
778 ret = "ZAPI_RULE_FAIL_REMOVE";
779 break;
780 case ZAPI_RULE_REMOVED:
781 ret = "ZAPI_RULE_REMOVED";
782 break;
783 }
784
785 return ret;
786 }
787
788 /* Zebra MAC types */
789 #define ZEBRA_MACIP_TYPE_STICKY 0x01 /* Sticky MAC*/
790 #define ZEBRA_MACIP_TYPE_GW 0x02 /* gateway (SVI) mac*/
791 #define ZEBRA_MACIP_TYPE_ROUTER_FLAG 0x04 /* Router Flag - proxy NA */
792 #define ZEBRA_MACIP_TYPE_OVERRIDE_FLAG 0x08 /* Override Flag */
793 #define ZEBRA_MACIP_TYPE_SVI_IP 0x10 /* SVI MAC-IP */
794 #define ZEBRA_MACIP_TYPE_PROXY_ADVERT 0x20 /* Not locally active */
795 #define ZEBRA_MACIP_TYPE_SYNC_PATH 0x40 /* sync path */
796 /* XXX - flags is an u8; that needs to be changed to u32 if you need
797 * to allocate past 0x80. Additionally touch zclient_evpn_dump_macip_flags
798 */
799 #define MACIP_BUF_SIZE 128
800 extern char *zclient_evpn_dump_macip_flags(uint8_t flags, char *buf,
801 size_t len);
802
803 /* Zebra ES VTEP flags (ZEBRA_REMOTE_ES_VTEP_ADD) */
804 /* ESR has been rxed from the VTEP. Only VTEPs that have advertised the
805 * Type-4 route can participate in DF election.
806 */
807 #define ZAPI_ES_VTEP_FLAG_ESR_RXED (1 << 0)
808
809 enum zebra_neigh_state { ZEBRA_NEIGH_INACTIVE = 0, ZEBRA_NEIGH_ACTIVE = 1 };
810
811 struct zclient_options {
812 bool receive_notify;
813 bool synchronous;
814 };
815
816 extern struct zclient_options zclient_options_default;
817
818 /* link layer representation for GRE like interfaces
819 * ip_in is the underlay IP, ip_out is the tunnel dest
820 * index stands for the index of the interface
821 * ndm state stands for the NDM value in netlink
822 * (see linux/neighbour.h)
823 */
824 #define ZEBRA_NEIGH_STATE_INCOMPLETE (0x01)
825 #define ZEBRA_NEIGH_STATE_REACHABLE (0x02)
826 #define ZEBRA_NEIGH_STATE_STALE (0x04)
827 #define ZEBRA_NEIGH_STATE_DELAY (0x08)
828 #define ZEBRA_NEIGH_STATE_PROBE (0x10)
829 #define ZEBRA_NEIGH_STATE_FAILED (0x20)
830 #define ZEBRA_NEIGH_STATE_NOARP (0x40)
831 #define ZEBRA_NEIGH_STATE_PERMANENT (0x80)
832 #define ZEBRA_NEIGH_STATE_NONE (0x00)
833
834 struct zapi_neigh_ip {
835 int cmd;
836 struct ipaddr ip_in;
837 struct ipaddr ip_out;
838 ifindex_t index;
839 uint32_t ndm_state;
840 };
841 int zclient_neigh_ip_decode(struct stream *s, struct zapi_neigh_ip *api);
842 int zclient_neigh_ip_encode(struct stream *s, uint16_t cmd, union sockunion *in,
843 union sockunion *out, struct interface *ifp,
844 int ndm_state);
845
846 /*
847 * We reserve the top 4 bits for l2-NHG, everything else
848 * is for zebra/proto l3-NHG.
849 *
850 * Each client is going to get it's own nexthop group space
851 * and we'll separate them, we'll figure out where to start based upon
852 * the route_types.h
853 */
854 #define ZEBRA_NHG_PROTO_UPPER \
855 ((uint32_t)250000000) /* Bottom 28 bits then rounded down */
856 #define ZEBRA_NHG_PROTO_SPACING (ZEBRA_NHG_PROTO_UPPER / ZEBRA_ROUTE_MAX)
857 #define ZEBRA_NHG_PROTO_LOWER \
858 (ZEBRA_NHG_PROTO_SPACING * (ZEBRA_ROUTE_CONNECT + 1))
859
860 extern uint32_t zclient_get_nhg_start(uint32_t proto);
861
862 extern struct zclient *zclient_new(struct thread_master *m,
863 struct zclient_options *opt,
864 zclient_handler *const *handlers,
865 size_t n_handlers);
866
867 extern void zclient_init(struct zclient *, int, unsigned short,
868 struct zebra_privs_t *privs);
869 extern int zclient_start(struct zclient *);
870 extern void zclient_stop(struct zclient *);
871 extern void zclient_reset(struct zclient *);
872 extern void zclient_free(struct zclient *);
873
874 extern int zclient_socket_connect(struct zclient *);
875
876 extern unsigned short *redist_check_instance(struct redist_proto *,
877 unsigned short);
878 extern void redist_add_instance(struct redist_proto *, unsigned short);
879 extern void redist_del_instance(struct redist_proto *, unsigned short);
880 extern void redist_del_all_instances(struct redist_proto *red);
881
882 /*
883 * Send to zebra that the specified vrf is using label to resolve
884 * itself for L3VPN's. Repeated calls of this function with
885 * different labels will cause an effective update of the
886 * label for lookup. If you pass in MPLS_LABEL_NONE
887 * we will cause a delete action and remove this label pop
888 * operation.
889 *
890 * The underlying AF_MPLS doesn't care about afi's
891 * but we can make the zebra_vrf keep track of what
892 * we have installed and play some special games
893 * to get them both installed.
894 */
895 extern enum zclient_send_status
896 zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, afi_t afi,
897 mpls_label_t label, enum lsp_types_t ltype);
898
899 extern enum zclient_send_status
900 zclient_send_localsid(struct zclient *zclient, const struct in6_addr *sid,
901 ifindex_t oif, enum seg6local_action_t action,
902 const struct seg6local_context *context);
903
904 extern void zclient_send_reg_requests(struct zclient *, vrf_id_t);
905 extern void zclient_send_dereg_requests(struct zclient *, vrf_id_t);
906 extern enum zclient_send_status
907 zclient_send_router_id_update(struct zclient *zclient,
908 zebra_message_types_t type, afi_t afi,
909 vrf_id_t vrf_id);
910
911 extern enum zclient_send_status
912 zclient_send_interface_radv_req(struct zclient *zclient, vrf_id_t vrf_id,
913 struct interface *ifp, int enable,
914 uint32_t ra_interval);
915 extern enum zclient_send_status
916 zclient_send_interface_protodown(struct zclient *zclient, vrf_id_t vrf_id,
917 struct interface *ifp, bool down);
918
919 /* Send redistribute command to zebra daemon. Do not update zclient state. */
920 extern enum zclient_send_status
921 zebra_redistribute_send(int command, struct zclient *, afi_t, int type,
922 unsigned short instance, vrf_id_t vrf_id);
923
924 extern enum zclient_send_status
925 zebra_redistribute_default_send(int command, struct zclient *zclient, afi_t afi,
926 vrf_id_t vrf_id);
927
928 /* Send route notify request to zebra */
929 extern int zebra_route_notify_send(int command, struct zclient *zclient,
930 bool set);
931
932 /* If state has changed, update state and call zebra_redistribute_send. */
933 extern void zclient_redistribute(int command, struct zclient *, afi_t, int type,
934 unsigned short instance, vrf_id_t vrf_id);
935
936 /* If state has changed, update state and send the command to zebra. */
937 extern void zclient_redistribute_default(int command, struct zclient *,
938 afi_t, vrf_id_t vrf_id);
939
940 /*
941 * Send the message in zclient->obuf to the zebra daemon (or enqueue it).
942 * Returns:
943 * -1 on a I/O error
944 * 0 data was successfully sent
945 * 1 data was buffered for future usage
946 */
947 extern enum zclient_send_status zclient_send_message(struct zclient *);
948
949 /* create header for command, length to be filled in by user later */
950 extern void zclient_create_header(struct stream *, uint16_t, vrf_id_t);
951 /*
952 * Read sizeof(struct zmsghdr) bytes from the provided socket and parse the
953 * received data into the specified fields. If this is successful, read the
954 * rest of the packet into the provided stream.
955 *
956 * s
957 * The stream to read into
958 *
959 * sock
960 * The socket to read from
961 *
962 * size
963 * Parsed message size will be placed in the pointed-at integer
964 *
965 * marker
966 * Parsed marker will be placed in the pointed-at byte
967 *
968 * version
969 * Parsed version will be placed in the pointed-at byte
970 *
971 * vrf_id
972 * Parsed VRF ID will be placed in the pointed-at vrf_id_t
973 *
974 * cmd
975 * Parsed command number will be placed in the pointed-at integer
976 *
977 * Returns:
978 * -1 if:
979 * - insufficient data for header was read
980 * - a version mismatch was detected
981 * - a marker mismatch was detected
982 * - header size field specified more data than could be read
983 */
984 extern int zclient_read_header(struct stream *s, int sock, uint16_t *size,
985 uint8_t *marker, uint8_t *version,
986 vrf_id_t *vrf_id, uint16_t *cmd);
987 /*
988 * Parse header from ZAPI message stream into struct zmsghdr.
989 * This function assumes the stream getp points at the first byte of the header.
990 * If the function is successful then the stream getp will point to the byte
991 * immediately after the last byte of the header.
992 *
993 * zmsg
994 * The stream containing the header
995 *
996 * hdr
997 * The header struct to parse into.
998 *
999 * Returns:
1000 * true if parsing succeeded, false otherwise
1001 */
1002 extern bool zapi_parse_header(struct stream *zmsg, struct zmsghdr *hdr);
1003
1004 extern enum zclient_send_status
1005 zclient_interface_set_master(struct zclient *client, struct interface *master,
1006 struct interface *slave);
1007 extern struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t);
1008 extern struct connected *zebra_interface_address_read(int, struct stream *,
1009 vrf_id_t);
1010 extern struct nbr_connected *
1011 zebra_interface_nbr_address_read(int, struct stream *, vrf_id_t);
1012 extern struct interface *zebra_interface_vrf_update_read(struct stream *s,
1013 vrf_id_t vrf_id,
1014 vrf_id_t *new_vrf_id);
1015 extern int zebra_router_id_update_read(struct stream *s, struct prefix *rid);
1016
1017 extern struct interface *zebra_interface_link_params_read(struct stream *s,
1018 vrf_id_t vrf_id,
1019 bool *changed);
1020 extern size_t zebra_interface_link_params_write(struct stream *,
1021 struct interface *);
1022 extern enum zclient_send_status
1023 zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
1024 uint32_t chunk_size, uint32_t base);
1025
1026 extern int lm_label_manager_connect(struct zclient *zclient, int async);
1027 extern int lm_get_label_chunk(struct zclient *zclient, uint8_t keep,
1028 uint32_t base, uint32_t chunk_size,
1029 uint32_t *start, uint32_t *end);
1030 extern int lm_release_label_chunk(struct zclient *zclient, uint32_t start,
1031 uint32_t end);
1032 extern int tm_table_manager_connect(struct zclient *zclient);
1033 extern int tm_get_table_chunk(struct zclient *zclient, uint32_t chunk_size,
1034 uint32_t *start, uint32_t *end);
1035 extern int tm_release_table_chunk(struct zclient *zclient, uint32_t start,
1036 uint32_t end);
1037 extern int srv6_manager_get_locator_chunk(struct zclient *zclient,
1038 const char *locator_name);
1039 extern int srv6_manager_release_locator_chunk(struct zclient *zclient,
1040 const char *locator_name);
1041
1042 extern enum zclient_send_status zebra_send_sr_policy(struct zclient *zclient,
1043 int cmd,
1044 struct zapi_sr_policy *zp);
1045 extern int zapi_sr_policy_encode(struct stream *s, int cmd,
1046 struct zapi_sr_policy *zp);
1047 extern int zapi_sr_policy_decode(struct stream *s, struct zapi_sr_policy *zp);
1048 extern int zapi_sr_policy_notify_status_decode(struct stream *s,
1049 struct zapi_sr_policy *zp);
1050
1051 extern enum zclient_send_status zebra_send_mpls_labels(struct zclient *zclient,
1052 int cmd,
1053 struct zapi_labels *zl);
1054 extern int zapi_labels_encode(struct stream *s, int cmd,
1055 struct zapi_labels *zl);
1056 extern int zapi_labels_decode(struct stream *s, struct zapi_labels *zl);
1057
1058 extern int zapi_srv6_locator_encode(struct stream *s,
1059 const struct srv6_locator *l);
1060 extern int zapi_srv6_locator_decode(struct stream *s, struct srv6_locator *l);
1061 extern int zapi_srv6_locator_chunk_encode(struct stream *s,
1062 const struct srv6_locator_chunk *c);
1063 extern int zapi_srv6_locator_chunk_decode(struct stream *s,
1064 struct srv6_locator_chunk *c);
1065
1066 extern enum zclient_send_status zebra_send_pw(struct zclient *zclient,
1067 int command, struct zapi_pw *pw);
1068 extern int zebra_read_pw_status_update(ZAPI_CALLBACK_ARGS,
1069 struct zapi_pw_status *pw);
1070
1071 extern enum zclient_send_status zclient_route_send(uint8_t, struct zclient *,
1072 struct zapi_route *);
1073 extern enum zclient_send_status
1074 zclient_send_rnh(struct zclient *zclient, int command, const struct prefix *p,
1075 safi_t safi, bool connected, bool resolve_via_default,
1076 vrf_id_t vrf_id);
1077 int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh,
1078 uint32_t api_flags, uint32_t api_message);
1079 extern int zapi_route_encode(uint8_t, struct stream *, struct zapi_route *);
1080 extern int zapi_route_decode(struct stream *s, struct zapi_route *api);
1081 extern int zapi_nexthop_decode(struct stream *s, struct zapi_nexthop *api_nh,
1082 uint32_t api_flags, uint32_t api_message);
1083 bool zapi_nhg_notify_decode(struct stream *s, uint32_t *id,
1084 enum zapi_nhg_notify_owner *note);
1085 bool zapi_route_notify_decode(struct stream *s, struct prefix *p,
1086 uint32_t *tableid,
1087 enum zapi_route_notify_owner *note,
1088 afi_t *afi, safi_t *safi);
1089 bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
1090 uint32_t *priority, uint32_t *unique, char *ifname,
1091 enum zapi_rule_notify_owner *note);
1092 bool zapi_ipset_notify_decode(struct stream *s,
1093 uint32_t *unique,
1094 enum zapi_ipset_notify_owner *note);
1095
1096 /* Nexthop-group message apis */
1097 extern enum zclient_send_status
1098 zclient_nhg_send(struct zclient *zclient, int cmd, struct zapi_nhg *api_nhg);
1099
1100 #define ZEBRA_IPSET_NAME_SIZE 32
1101
1102 bool zapi_ipset_entry_notify_decode(struct stream *s,
1103 uint32_t *unique,
1104 char *ipset_name,
1105 enum zapi_ipset_entry_notify_owner *note);
1106 bool zapi_iptable_notify_decode(struct stream *s,
1107 uint32_t *unique,
1108 enum zapi_iptable_notify_owner *note);
1109
1110 extern struct nexthop *
1111 nexthop_from_zapi_nexthop(const struct zapi_nexthop *znh);
1112 int zapi_nexthop_from_nexthop(struct zapi_nexthop *znh,
1113 const struct nexthop *nh);
1114 int zapi_backup_nexthop_from_nexthop(struct zapi_nexthop *znh,
1115 const struct nexthop *nh);
1116 /*
1117 * match -> is the prefix that the calling daemon asked to be matched
1118 * against.
1119 * nhr->prefix -> is the actual prefix that was matched against in the
1120 * rib itself.
1121 *
1122 * This distinction is made because a LPM can be made if there is a
1123 * covering route. This way the upper level protocol can make a decision
1124 * point about whether or not it wants to use the match or not.
1125 */
1126 extern bool zapi_nexthop_update_decode(struct stream *s, struct prefix *match,
1127 struct zapi_route *nhr);
1128 const char *zapi_nexthop2str(const struct zapi_nexthop *znh, char *buf,
1129 int bufsize);
1130
1131 /* Decode the zebra error message */
1132 extern bool zapi_error_decode(struct stream *s, enum zebra_error_types *error);
1133
1134 /* Encode and decode restart capabilities */
1135 extern enum zclient_send_status
1136 zclient_capabilities_send(uint32_t cmd, struct zclient *zclient,
1137 struct zapi_cap *api);
1138 extern int32_t zapi_capabilities_decode(struct stream *s, struct zapi_cap *api);
1139
1140 static inline void zapi_route_set_blackhole(struct zapi_route *api,
1141 enum blackhole_type bh_type)
1142 {
1143 api->nexthop_num = 1;
1144 api->nexthops[0].type = NEXTHOP_TYPE_BLACKHOLE;
1145 api->nexthops[0].vrf_id = VRF_DEFAULT;
1146 api->nexthops[0].bh_type = bh_type;
1147 SET_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP);
1148 };
1149
1150 extern enum zclient_send_status
1151 zclient_send_mlag_register(struct zclient *client, uint32_t bit_map);
1152 extern enum zclient_send_status
1153 zclient_send_mlag_deregister(struct zclient *client);
1154
1155 extern enum zclient_send_status zclient_send_mlag_data(struct zclient *client,
1156 struct stream *client_s);
1157
1158 /*
1159 * Send an OPAQUE message, contents opaque to zebra - but note that
1160 * the length of the payload is restricted by the zclient's
1161 * outgoing message buffer.
1162 * The message header is a message subtype; please use the registry
1163 * below to avoid sub-type collisions. Clients use the registration
1164 * apis to manage the specific opaque subtypes they want to receive.
1165 */
1166 enum zclient_send_status zclient_send_opaque(struct zclient *zclient,
1167 uint32_t type, const uint8_t *data,
1168 size_t datasize);
1169
1170 enum zclient_send_status
1171 zclient_send_opaque_unicast(struct zclient *zclient, uint32_t type,
1172 uint8_t proto, uint16_t instance,
1173 uint32_t session_id, const uint8_t *data,
1174 size_t datasize);
1175
1176 /* Struct representing the decoded opaque header info */
1177 struct zapi_opaque_msg {
1178 uint32_t type; /* Subtype */
1179 uint16_t len; /* len after zapi header and this info */
1180 uint16_t flags;
1181
1182 /* Client-specific info - *if* UNICAST flag is set */
1183 uint8_t proto;
1184 uint16_t instance;
1185 uint32_t session_id;
1186 };
1187
1188 #define ZAPI_OPAQUE_FLAG_UNICAST 0x01
1189
1190 /* Simple struct to convey registration/unreg requests */
1191 struct zapi_opaque_reg_info {
1192 /* Message subtype */
1193 uint32_t type;
1194
1195 /* Client session tuple */
1196 uint8_t proto;
1197 uint16_t instance;
1198 uint32_t session_id;
1199 };
1200
1201 /* Decode incoming opaque */
1202 int zclient_opaque_decode(struct stream *msg, struct zapi_opaque_msg *info);
1203
1204 enum zclient_send_status zclient_register_opaque(struct zclient *zclient,
1205 uint32_t type);
1206 enum zclient_send_status zclient_unregister_opaque(struct zclient *zclient,
1207 uint32_t type);
1208 int zapi_opaque_reg_decode(struct stream *msg,
1209 struct zapi_opaque_reg_info *info);
1210
1211 /*
1212 * Registry of opaque message types. Please do not reuse an in-use
1213 * type code; some daemons are likely relying on it.
1214 */
1215 enum zapi_opaque_registry {
1216 /* Request link-state database dump, at restart for example */
1217 LINK_STATE_SYNC = 1,
1218 /* Update containing link-state db info */
1219 LINK_STATE_UPDATE = 2,
1220 /* Request LDP-SYNC state from LDP */
1221 LDP_IGP_SYNC_IF_STATE_REQUEST = 3,
1222 /* Update containing LDP IGP Sync State info */
1223 LDP_IGP_SYNC_IF_STATE_UPDATE = 4,
1224 /* Announce that LDP is up */
1225 LDP_IGP_SYNC_ANNOUNCE_UPDATE = 5,
1226 /* Register RLFA with LDP */
1227 LDP_RLFA_REGISTER = 7,
1228 /* Unregister all RLFAs with LDP */
1229 LDP_RLFA_UNREGISTER_ALL = 8,
1230 /* Announce LDP labels associated to a previously registered RLFA */
1231 LDP_RLFA_LABELS = 9,
1232 };
1233
1234 /* Send the hello message.
1235 * Returns 0 for success or -1 on an I/O error.
1236 */
1237 extern enum zclient_send_status zclient_send_hello(struct zclient *client);
1238
1239 extern enum zclient_send_status
1240 zclient_send_neigh_discovery_req(struct zclient *zclient,
1241 const struct interface *ifp,
1242 const struct prefix *p);
1243
1244 struct zapi_client_close_info {
1245 /* Client session tuple */
1246 uint8_t proto;
1247 uint16_t instance;
1248 uint32_t session_id;
1249 };
1250
1251 /* Decode incoming client close notify */
1252 extern int zapi_client_close_notify_decode(struct stream *s,
1253 struct zapi_client_close_info *info);
1254
1255 extern int zclient_send_zebra_gre_request(struct zclient *client,
1256 struct interface *ifp);
1257 #ifdef __cplusplus
1258 }
1259 #endif
1260
1261 #endif /* _ZEBRA_ZCLIENT_H */