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