1 /* Zebra's client header.
2 * Copyright (C) 1999 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
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)
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.
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
21 #ifndef _ZEBRA_ZCLIENT_H
22 #define _ZEBRA_ZCLIENT_H
24 /* For struct zapi_route. */
27 /* For struct interface and struct connected. */
30 /* For vrf_bitmap_t. */
33 /* For union g_addr */
36 /* For union pw_protocol_fields */
45 /* Zebra types. Used in Zserv message header. */
46 typedef uint16_t zebra_size_t
;
48 /* Marker value used in new Zserv, in the byte location corresponding
49 * the command value in the old zserv header. To allow old and new
50 * Zserv headers to be distinguished from each other.
52 #define ZEBRA_HEADER_MARKER 254
54 /* For input/output buffer to zebra. */
55 #define ZEBRA_MAX_PACKET_SIZ 16384U
57 /* Zebra header size. */
58 #define ZEBRA_HEADER_SIZE 10
60 /* special socket path name to use TCP
61 * @ is used as first character because that's abstract socket names on Linux
63 #define ZAPI_TCP_PATHNAME "@tcp"
65 /* IPset size name stands for the name of the ipset entry
66 * that can be created by using some zapi interfaces
68 #define ZEBRA_IPSET_NAME_SIZE 32
70 /* IPTable action is defined by two values: either
73 #define ZEBRA_IPTABLES_FORWARD 0
74 #define ZEBRA_IPTABLES_DROP 1
76 /* Zebra FEC register command flags. */
77 #define ZEBRA_FEC_REGISTER_LABEL 0x1
78 #define ZEBRA_FEC_REGISTER_LABEL_INDEX 0x2
80 /* Client capabilities */
81 enum zserv_client_capabilities
{
82 ZEBRA_CLIENT_GR_CAPABILITIES
= 1,
83 ZEBRA_CLIENT_ROUTE_UPDATE_COMPLETE
= 2,
84 ZEBRA_CLIENT_ROUTE_UPDATE_PENDING
= 3,
85 ZEBRA_CLIENT_GR_DISABLE
= 4,
86 ZEBRA_CLIENT_RIB_STALE_TIME
89 /* Macro to check if there GR enabled. */
90 #define ZEBRA_CLIENT_GR_ENABLED(X) (X == ZEBRA_CLIENT_GR_CAPABILITIES)
92 extern struct sockaddr_storage zclient_addr
;
93 extern socklen_t zclient_addr_len
;
95 /* Zebra message types. */
98 ZEBRA_INTERFACE_DELETE
,
99 ZEBRA_INTERFACE_ADDRESS_ADD
,
100 ZEBRA_INTERFACE_ADDRESS_DELETE
,
102 ZEBRA_INTERFACE_DOWN
,
103 ZEBRA_INTERFACE_SET_MASTER
,
104 ZEBRA_INTERFACE_SET_PROTODOWN
,
107 ZEBRA_ROUTE_NOTIFY_OWNER
,
108 ZEBRA_REDISTRIBUTE_ADD
,
109 ZEBRA_REDISTRIBUTE_DELETE
,
110 ZEBRA_REDISTRIBUTE_DEFAULT_ADD
,
111 ZEBRA_REDISTRIBUTE_DEFAULT_DELETE
,
113 ZEBRA_ROUTER_ID_DELETE
,
114 ZEBRA_ROUTER_ID_UPDATE
,
117 ZEBRA_NEXTHOP_REGISTER
,
118 ZEBRA_NEXTHOP_UNREGISTER
,
119 ZEBRA_NEXTHOP_UPDATE
,
120 ZEBRA_INTERFACE_NBR_ADDRESS_ADD
,
121 ZEBRA_INTERFACE_NBR_ADDRESS_DELETE
,
122 ZEBRA_INTERFACE_BFD_DEST_UPDATE
,
123 ZEBRA_IMPORT_ROUTE_REGISTER
,
124 ZEBRA_IMPORT_ROUTE_UNREGISTER
,
125 ZEBRA_IMPORT_CHECK_UPDATE
,
126 ZEBRA_BFD_DEST_REGISTER
,
127 ZEBRA_BFD_DEST_DEREGISTER
,
128 ZEBRA_BFD_DEST_UPDATE
,
129 ZEBRA_BFD_DEST_REPLAY
,
130 ZEBRA_REDISTRIBUTE_ROUTE_ADD
,
131 ZEBRA_REDISTRIBUTE_ROUTE_DEL
,
132 ZEBRA_VRF_UNREGISTER
,
136 ZEBRA_INTERFACE_VRF_UPDATE
,
137 ZEBRA_BFD_CLIENT_REGISTER
,
138 ZEBRA_BFD_CLIENT_DEREGISTER
,
139 ZEBRA_INTERFACE_ENABLE_RADV
,
140 ZEBRA_INTERFACE_DISABLE_RADV
,
141 ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB
,
142 ZEBRA_INTERFACE_LINK_PARAMS
,
143 ZEBRA_MPLS_LABELS_ADD
,
144 ZEBRA_MPLS_LABELS_DELETE
,
145 ZEBRA_MPLS_LABELS_REPLACE
,
146 ZEBRA_IPMR_ROUTE_STATS
,
147 ZEBRA_LABEL_MANAGER_CONNECT
,
148 ZEBRA_LABEL_MANAGER_CONNECT_ASYNC
,
149 ZEBRA_GET_LABEL_CHUNK
,
150 ZEBRA_RELEASE_LABEL_CHUNK
,
152 ZEBRA_FEC_UNREGISTER
,
154 ZEBRA_ADVERTISE_DEFAULT_GW
,
155 ZEBRA_ADVERTISE_SVI_MACIP
,
156 ZEBRA_ADVERTISE_SUBNET
,
157 ZEBRA_ADVERTISE_ALL_VNI
,
164 ZEBRA_REMOTE_VTEP_ADD
,
165 ZEBRA_REMOTE_VTEP_DEL
,
168 ZEBRA_IP_PREFIX_ROUTE_ADD
,
169 ZEBRA_IP_PREFIX_ROUTE_DEL
,
170 ZEBRA_REMOTE_MACIP_ADD
,
171 ZEBRA_REMOTE_MACIP_DEL
,
172 ZEBRA_DUPLICATE_ADDR_DETECTION
,
177 ZEBRA_PW_STATUS_UPDATE
,
180 ZEBRA_RULE_NOTIFY_OWNER
,
181 ZEBRA_TABLE_MANAGER_CONNECT
,
182 ZEBRA_GET_TABLE_CHUNK
,
183 ZEBRA_RELEASE_TABLE_CHUNK
,
186 ZEBRA_IPSET_ENTRY_ADD
,
187 ZEBRA_IPSET_ENTRY_DELETE
,
188 ZEBRA_IPSET_NOTIFY_OWNER
,
189 ZEBRA_IPSET_ENTRY_NOTIFY_OWNER
,
191 ZEBRA_IPTABLE_DELETE
,
192 ZEBRA_IPTABLE_NOTIFY_OWNER
,
193 ZEBRA_VXLAN_FLOOD_CONTROL
,
196 ZEBRA_VXLAN_SG_REPLAY
,
197 ZEBRA_MLAG_PROCESS_UP
,
198 ZEBRA_MLAG_PROCESS_DOWN
,
199 ZEBRA_MLAG_CLIENT_REGISTER
,
200 ZEBRA_MLAG_CLIENT_UNREGISTER
,
201 ZEBRA_MLAG_FORWARD_MSG
,
203 ZEBRA_CLIENT_CAPABILITIES
204 } zebra_message_types_t
;
206 enum zebra_error_types
{
207 ZEBRA_UNKNOWN_ERROR
, /* Error of unknown type */
208 ZEBRA_NO_VRF
, /* Vrf in header was not found */
209 ZEBRA_INVALID_MSG_TYPE
, /* No handler found for msg type */
212 static inline const char *zebra_error_type2str(enum zebra_error_types type
)
214 const char *ret
= "UNKNOWN";
217 case ZEBRA_UNKNOWN_ERROR
:
218 ret
= "ZEBRA_UNKNOWN_ERROR";
221 ret
= "ZEBRA_NO_VRF";
223 case ZEBRA_INVALID_MSG_TYPE
:
224 ret
= "ZEBRA_INVALID_MSG_TYPE";
231 struct redist_proto
{
233 struct list
*instances
;
236 struct zclient_capabilities
{
242 /* Graceful Restart Capabilities message */
244 enum zserv_client_capabilities cap
;
245 uint32_t stale_removal_time
;
251 /* Structure for the zebra client. */
253 /* The thread master we schedule ourselves on */
254 struct thread_master
*master
;
256 /* Priviledges to change socket values */
257 struct zebra_privs_t
*privs
;
259 /* Do we care about failure events for route install? */
262 /* Is this a synchronous client? */
265 /* Session id (optional) to support clients with multiple sessions */
268 /* Socket to zebra daemon. */
271 /* Connection failure count. */
274 /* Input buffer for zebra message. */
277 /* Output buffer for zebra message. */
280 /* Buffer of data waiting to be written to zebra. */
283 /* Read and connect thread. */
284 struct thread
*t_read
;
285 struct thread
*t_connect
;
287 /* Thread to write buffered data to zebra. */
288 struct thread
*t_write
;
290 /* Redistribute information. */
291 uint8_t redist_default
; /* clients protocol */
292 unsigned short instance
;
293 struct redist_proto mi_redist
[AFI_MAX
][ZEBRA_ROUTE_MAX
];
294 vrf_bitmap_t redist
[AFI_MAX
][ZEBRA_ROUTE_MAX
];
296 /* Redistribute defauilt. */
297 vrf_bitmap_t default_information
[AFI_MAX
];
299 #define ZAPI_CALLBACK_ARGS \
300 int cmd, struct zclient *zclient, uint16_t length, vrf_id_t vrf_id
302 /* Pointer to the callback functions. */
303 void (*zebra_connected
)(struct zclient
*);
304 void (*zebra_capabilities
)(struct zclient_capabilities
*cap
);
305 int (*router_id_update
)(ZAPI_CALLBACK_ARGS
);
306 int (*interface_address_add
)(ZAPI_CALLBACK_ARGS
);
307 int (*interface_address_delete
)(ZAPI_CALLBACK_ARGS
);
308 int (*interface_link_params
)(ZAPI_CALLBACK_ARGS
);
309 int (*interface_bfd_dest_update
)(ZAPI_CALLBACK_ARGS
);
310 int (*interface_nbr_address_add
)(ZAPI_CALLBACK_ARGS
);
311 int (*interface_nbr_address_delete
)(ZAPI_CALLBACK_ARGS
);
312 int (*interface_vrf_update
)(ZAPI_CALLBACK_ARGS
);
313 int (*nexthop_update
)(ZAPI_CALLBACK_ARGS
);
314 int (*import_check_update
)(ZAPI_CALLBACK_ARGS
);
315 int (*bfd_dest_replay
)(ZAPI_CALLBACK_ARGS
);
316 int (*redistribute_route_add
)(ZAPI_CALLBACK_ARGS
);
317 int (*redistribute_route_del
)(ZAPI_CALLBACK_ARGS
);
318 int (*fec_update
)(int, struct zclient
*, uint16_t);
319 int (*local_es_add
)(ZAPI_CALLBACK_ARGS
);
320 int (*local_es_del
)(ZAPI_CALLBACK_ARGS
);
321 int (*local_vni_add
)(ZAPI_CALLBACK_ARGS
);
322 int (*local_vni_del
)(ZAPI_CALLBACK_ARGS
);
323 int (*local_l3vni_add
)(ZAPI_CALLBACK_ARGS
);
324 int (*local_l3vni_del
)(ZAPI_CALLBACK_ARGS
);
325 void (*local_ip_prefix_add
)(ZAPI_CALLBACK_ARGS
);
326 void (*local_ip_prefix_del
)(ZAPI_CALLBACK_ARGS
);
327 int (*local_macip_add
)(ZAPI_CALLBACK_ARGS
);
328 int (*local_macip_del
)(ZAPI_CALLBACK_ARGS
);
329 int (*pw_status_update
)(ZAPI_CALLBACK_ARGS
);
330 int (*route_notify_owner
)(ZAPI_CALLBACK_ARGS
);
331 int (*rule_notify_owner
)(ZAPI_CALLBACK_ARGS
);
332 void (*label_chunk
)(ZAPI_CALLBACK_ARGS
);
333 int (*ipset_notify_owner
)(ZAPI_CALLBACK_ARGS
);
334 int (*ipset_entry_notify_owner
)(ZAPI_CALLBACK_ARGS
);
335 int (*iptable_notify_owner
)(ZAPI_CALLBACK_ARGS
);
336 int (*vxlan_sg_add
)(ZAPI_CALLBACK_ARGS
);
337 int (*vxlan_sg_del
)(ZAPI_CALLBACK_ARGS
);
338 int (*mlag_process_up
)(void);
339 int (*mlag_process_down
)(void);
340 int (*mlag_handle_msg
)(struct stream
*msg
, int len
);
341 int (*handle_error
)(enum zebra_error_types error
);
344 /* Zebra API message flag. */
345 #define ZAPI_MESSAGE_NEXTHOP 0x01
346 #define ZAPI_MESSAGE_DISTANCE 0x02
347 #define ZAPI_MESSAGE_METRIC 0x04
348 #define ZAPI_MESSAGE_TAG 0x08
349 #define ZAPI_MESSAGE_MTU 0x10
350 #define ZAPI_MESSAGE_SRCPFX 0x20
351 /* Backup nexthops are present */
352 #define ZAPI_MESSAGE_BACKUP_NEXTHOPS 0x40
355 * This should only be used by a DAEMON that needs to communicate
356 * the table being used is not in the VRF. You must pass the
357 * default vrf, else this will be ignored.
359 #define ZAPI_MESSAGE_TABLEID 0x80
361 #define ZSERV_VERSION 6
362 /* Zserv protocol message header */
365 /* Always set to 255 in new zserv */
370 } __attribute__((packed
));
371 #define ZAPI_HEADER_CMD_LOCATION offsetof(struct zmsghdr, command)
373 struct zapi_nexthop
{
374 enum nexthop_types_t type
;
380 enum blackhole_type bh_type
;
383 /* MPLS labels for BGP-LU or Segment Routing */
385 mpls_label_t labels
[MPLS_MAX_LABELS
];
391 /* Index of backup nexthop */
396 * ZAPI nexthop flags values - we're encoding a single octet
397 * initially, so ensure that the on-the-wire encoding continues
398 * to match the number of valid flags.
401 #define ZAPI_NEXTHOP_FLAG_ONLINK 0x01
402 #define ZAPI_NEXTHOP_FLAG_LABEL 0x02
403 #define ZAPI_NEXTHOP_FLAG_WEIGHT 0x04
404 #define ZAPI_NEXTHOP_FLAG_HAS_BACKUP 0x08 /* Nexthop has a backup */
407 * Some of these data structures do not map easily to
408 * a actual data structure size giving different compilers
409 * and systems. For those data structures we need
410 * to use the smallest available stream_getX/putX functions
415 unsigned short instance
;
419 * Cause Zebra to consider this routes nexthops recursively
421 #define ZEBRA_FLAG_ALLOW_RECURSION 0x01
423 * This is a route that is read in on startup that was left around
424 * from a previous run of FRR
426 #define ZEBRA_FLAG_SELFROUTE 0x02
428 * This flag is used to tell Zebra that the BGP route being passed
429 * down is a IBGP route
431 #define ZEBRA_FLAG_IBGP 0x04
433 * This is a route that has been selected for FIB installation.
434 * This flag is set in zebra and can be passed up to routing daemons
436 #define ZEBRA_FLAG_SELECTED 0x08
438 * This is a route that we are telling Zebra that this route *must*
439 * win and will be installed even over ZEBRA_FLAG_SELECTED
441 #define ZEBRA_FLAG_FIB_OVERRIDE 0x10
443 * This flag tells Zebra that the route is a EVPN route and should
444 * be treated specially
446 #define ZEBRA_FLAG_EVPN_ROUTE 0x20
448 * This flag tells Zebra that it should treat the distance passed
449 * down as an additional discriminator for route selection of the
450 * route entry. This mainly is used for backup static routes.
452 #define ZEBRA_FLAG_RR_USE_DISTANCE 0x40
457 * This is an enum but we are going to treat it as a uint8_t
458 * for purpose of encoding/decoding
462 struct prefix prefix
;
463 struct prefix_ipv6 src_prefix
;
465 uint16_t nexthop_num
;
466 struct zapi_nexthop nexthops
[MULTIPATH_NUM
];
468 /* Support backup routes for IP FRR, TI-LFA, traffic engineering */
469 uint16_t backup_nexthop_num
;
470 struct zapi_nexthop backup_nexthops
[MULTIPATH_NUM
];
487 #define ZAPI_LABELS_FTN 0x01
488 enum lsp_types_t type
;
489 mpls_label_t local_label
;
491 struct prefix prefix
;
493 unsigned short instance
;
496 uint16_t nexthop_num
;
497 struct zapi_nexthop nexthops
[MULTIPATH_NUM
];
501 char ifname
[IF_NAMESIZE
];
505 union g_addr nexthop
;
506 uint32_t local_label
;
507 uint32_t remote_label
;
509 union pw_protocol_fields data
;
513 struct zapi_pw_status
{
514 char ifname
[IF_NAMESIZE
];
519 enum zapi_route_notify_owner
{
520 ZAPI_ROUTE_FAIL_INSTALL
,
521 ZAPI_ROUTE_BETTER_ADMIN_WON
,
522 ZAPI_ROUTE_INSTALLED
,
524 ZAPI_ROUTE_REMOVE_FAIL
,
527 enum zapi_rule_notify_owner
{
528 ZAPI_RULE_FAIL_INSTALL
,
531 ZAPI_RULE_FAIL_REMOVE
,
541 enum zapi_ipset_notify_owner
{
542 ZAPI_IPSET_FAIL_INSTALL
,
543 ZAPI_IPSET_INSTALLED
,
545 ZAPI_IPSET_FAIL_REMOVE
,
548 enum zapi_ipset_entry_notify_owner
{
549 ZAPI_IPSET_ENTRY_FAIL_INSTALL
,
550 ZAPI_IPSET_ENTRY_INSTALLED
,
551 ZAPI_IPSET_ENTRY_REMOVED
,
552 ZAPI_IPSET_ENTRY_FAIL_REMOVE
,
555 enum zapi_iptable_notify_owner
{
556 ZAPI_IPTABLE_FAIL_INSTALL
,
557 ZAPI_IPTABLE_INSTALLED
,
558 ZAPI_IPTABLE_REMOVED
,
559 ZAPI_IPTABLE_FAIL_REMOVE
,
562 static inline const char *
563 zapi_rule_notify_owner2str(enum zapi_rule_notify_owner note
)
565 const char *ret
= "UNKNOWN";
568 case ZAPI_RULE_FAIL_INSTALL
:
569 ret
= "ZAPI_RULE_FAIL_INSTALL";
571 case ZAPI_RULE_INSTALLED
:
572 ret
= "ZAPI_RULE_INSTALLED";
574 case ZAPI_RULE_FAIL_REMOVE
:
575 ret
= "ZAPI_RULE_FAIL_REMOVE";
577 case ZAPI_RULE_REMOVED
:
578 ret
= "ZAPI_RULE_REMOVED";
585 /* Zebra MAC types */
586 #define ZEBRA_MACIP_TYPE_STICKY 0x01 /* Sticky MAC*/
587 #define ZEBRA_MACIP_TYPE_GW 0x02 /* gateway (SVI) mac*/
588 #define ZEBRA_MACIP_TYPE_ROUTER_FLAG 0x04 /* Router Flag - proxy NA */
589 #define ZEBRA_MACIP_TYPE_OVERRIDE_FLAG 0x08 /* Override Flag */
590 #define ZEBRA_MACIP_TYPE_SVI_IP 0x10 /* SVI MAC-IP */
592 enum zebra_neigh_state
{ ZEBRA_NEIGH_INACTIVE
= 0, ZEBRA_NEIGH_ACTIVE
= 1 };
594 struct zclient_options
{
599 extern struct zclient_options zclient_options_default
;
601 extern struct zclient
*zclient_new(struct thread_master
*m
,
602 struct zclient_options
*opt
);
604 extern void zclient_init(struct zclient
*, int, unsigned short,
605 struct zebra_privs_t
*privs
);
606 extern int zclient_start(struct zclient
*);
607 extern void zclient_stop(struct zclient
*);
608 extern void zclient_reset(struct zclient
*);
609 extern void zclient_free(struct zclient
*);
611 extern int zclient_socket_connect(struct zclient
*);
613 extern unsigned short *redist_check_instance(struct redist_proto
*,
615 extern void redist_add_instance(struct redist_proto
*, unsigned short);
616 extern void redist_del_instance(struct redist_proto
*, unsigned short);
617 extern void redist_del_all_instances(struct redist_proto
*red
);
620 * Send to zebra that the specified vrf is using label to resolve
621 * itself for L3VPN's. Repeated calls of this function with
622 * different labels will cause an effective update of the
623 * label for lookup. If you pass in MPLS_LABEL_NONE
624 * we will cause a delete action and remove this label pop
627 * The underlying AF_MPLS doesn't care about afi's
628 * but we can make the zebra_vrf keep track of what
629 * we have installed and play some special games
630 * to get them both installed.
632 extern void zclient_send_vrf_label(struct zclient
*zclient
, vrf_id_t vrf_id
,
633 afi_t afi
, mpls_label_t label
,
634 enum lsp_types_t ltype
);
636 extern void zclient_send_reg_requests(struct zclient
*, vrf_id_t
);
637 extern void zclient_send_dereg_requests(struct zclient
*, vrf_id_t
);
639 extern void zclient_send_interface_radv_req(struct zclient
*zclient
,
641 struct interface
*ifp
, int enable
,
643 extern int zclient_send_interface_protodown(struct zclient
*zclient
,
645 struct interface
*ifp
, bool down
);
647 /* Send redistribute command to zebra daemon. Do not update zclient state. */
648 extern int zebra_redistribute_send(int command
, struct zclient
*, afi_t
,
649 int type
, unsigned short instance
,
652 extern int zebra_redistribute_default_send(int command
, struct zclient
*zclient
,
653 afi_t afi
, vrf_id_t vrf_id
);
655 /* If state has changed, update state and call zebra_redistribute_send. */
656 extern void zclient_redistribute(int command
, struct zclient
*, afi_t
, int type
,
657 unsigned short instance
, vrf_id_t vrf_id
);
659 /* If state has changed, update state and send the command to zebra. */
660 extern void zclient_redistribute_default(int command
, struct zclient
*,
661 afi_t
, vrf_id_t vrf_id
);
663 /* Send the message in zclient->obuf to the zebra daemon (or enqueue it).
664 Returns 0 for success or -1 on an I/O error. */
665 extern int zclient_send_message(struct zclient
*);
667 /* create header for command, length to be filled in by user later */
668 extern void zclient_create_header(struct stream
*, uint16_t, vrf_id_t
);
670 * Read sizeof(struct zmsghdr) bytes from the provided socket and parse the
671 * received data into the specified fields. If this is successful, read the
672 * rest of the packet into the provided stream.
675 * The stream to read into
678 * The socket to read from
681 * Parsed message size will be placed in the pointed-at integer
684 * Parsed marker will be placed in the pointed-at byte
687 * Parsed version will be placed in the pointed-at byte
690 * Parsed VRF ID will be placed in the pointed-at vrf_id_t
693 * Parsed command number will be placed in the pointed-at integer
697 * - insufficient data for header was read
698 * - a version mismatch was detected
699 * - a marker mismatch was detected
700 * - header size field specified more data than could be read
702 extern int zclient_read_header(struct stream
*s
, int sock
, uint16_t *size
,
703 uint8_t *marker
, uint8_t *version
,
704 vrf_id_t
*vrf_id
, uint16_t *cmd
);
706 * Parse header from ZAPI message stream into struct zmsghdr.
707 * This function assumes the stream getp points at the first byte of the header.
708 * If the function is successful then the stream getp will point to the byte
709 * immediately after the last byte of the header.
712 * The stream containing the header
715 * The header struct to parse into.
718 * true if parsing succeeded, false otherwise
720 extern bool zapi_parse_header(struct stream
*zmsg
, struct zmsghdr
*hdr
);
722 extern void zclient_interface_set_master(struct zclient
*client
,
723 struct interface
*master
,
724 struct interface
*slave
);
725 extern struct interface
*zebra_interface_state_read(struct stream
*s
, vrf_id_t
);
726 extern struct connected
*zebra_interface_address_read(int, struct stream
*,
728 extern struct nbr_connected
*
729 zebra_interface_nbr_address_read(int, struct stream
*, vrf_id_t
);
730 extern struct interface
*zebra_interface_vrf_update_read(struct stream
*s
,
732 vrf_id_t
*new_vrf_id
);
733 extern int zebra_router_id_update_read(struct stream
*s
, struct prefix
*rid
);
735 extern struct interface
*zebra_interface_link_params_read(struct stream
*s
,
737 extern size_t zebra_interface_link_params_write(struct stream
*,
739 extern int zclient_send_get_label_chunk(struct zclient
*zclient
, uint8_t keep
,
740 uint32_t chunk_size
, uint32_t base
);
742 extern int lm_label_manager_connect(struct zclient
*zclient
, int async
);
743 extern int lm_get_label_chunk(struct zclient
*zclient
, uint8_t keep
,
744 uint32_t base
, uint32_t chunk_size
,
745 uint32_t *start
, uint32_t *end
);
746 extern int lm_release_label_chunk(struct zclient
*zclient
, uint32_t start
,
748 extern int tm_table_manager_connect(struct zclient
*zclient
);
749 extern int tm_get_table_chunk(struct zclient
*zclient
, uint32_t chunk_size
,
750 uint32_t *start
, uint32_t *end
);
751 extern int tm_release_table_chunk(struct zclient
*zclient
, uint32_t start
,
754 extern int zebra_send_mpls_labels(struct zclient
*zclient
, int cmd
,
755 struct zapi_labels
*zl
);
756 extern int zapi_labels_encode(struct stream
*s
, int cmd
,
757 struct zapi_labels
*zl
);
758 extern int zapi_labels_decode(struct stream
*s
, struct zapi_labels
*zl
);
760 extern int zebra_send_pw(struct zclient
*zclient
, int command
,
762 extern int zebra_read_pw_status_update(ZAPI_CALLBACK_ARGS
,
763 struct zapi_pw_status
*pw
);
765 extern int zclient_route_send(uint8_t, struct zclient
*, struct zapi_route
*);
766 extern int zclient_send_rnh(struct zclient
*zclient
, int command
,
767 const struct prefix
*p
, bool exact_match
,
769 int zapi_nexthop_encode(struct stream
*s
, const struct zapi_nexthop
*api_nh
,
771 extern int zapi_route_encode(uint8_t, struct stream
*, struct zapi_route
*);
772 extern int zapi_route_decode(struct stream
*, struct zapi_route
*);
773 bool zapi_route_notify_decode(struct stream
*s
, struct prefix
*p
,
775 enum zapi_route_notify_owner
*note
);
776 bool zapi_rule_notify_decode(struct stream
*s
, uint32_t *seqno
,
777 uint32_t *priority
, uint32_t *unique
,
779 enum zapi_rule_notify_owner
*note
);
780 bool zapi_ipset_notify_decode(struct stream
*s
,
782 enum zapi_ipset_notify_owner
*note
);
784 #define ZEBRA_IPSET_NAME_SIZE 32
786 bool zapi_ipset_entry_notify_decode(struct stream
*s
,
789 enum zapi_ipset_entry_notify_owner
*note
);
790 bool zapi_iptable_notify_decode(struct stream
*s
,
792 enum zapi_iptable_notify_owner
*note
);
794 extern struct nexthop
*
795 nexthop_from_zapi_nexthop(const struct zapi_nexthop
*znh
);
796 int zapi_nexthop_from_nexthop(struct zapi_nexthop
*znh
,
797 const struct nexthop
*nh
);
798 int zapi_backup_nexthop_from_nexthop(struct zapi_nexthop
*znh
,
799 const struct nexthop
*nh
);
800 extern bool zapi_nexthop_update_decode(struct stream
*s
,
801 struct zapi_route
*nhr
);
803 /* Decode the zebra error message */
804 extern bool zapi_error_decode(struct stream
*s
, enum zebra_error_types
*error
);
806 /* Encode and decode restart capabilities */
807 extern int32_t zclient_capabilities_send(uint32_t cmd
, struct zclient
*zclient
,
808 struct zapi_cap
*api
);
809 extern int32_t zapi_capabilities_decode(struct stream
*s
, struct zapi_cap
*api
);
811 static inline void zapi_route_set_blackhole(struct zapi_route
*api
,
812 enum blackhole_type bh_type
)
814 api
->nexthop_num
= 1;
815 api
->nexthops
[0].type
= NEXTHOP_TYPE_BLACKHOLE
;
816 api
->nexthops
[0].vrf_id
= VRF_DEFAULT
;
817 api
->nexthops
[0].bh_type
= bh_type
;
818 SET_FLAG(api
->message
, ZAPI_MESSAGE_NEXTHOP
);
821 extern void zclient_send_mlag_register(struct zclient
*client
,
823 extern void zclient_send_mlag_deregister(struct zclient
*client
);
825 extern void zclient_send_mlag_data(struct zclient
*client
,
826 struct stream
*client_s
);
828 /* Send the hello message.
829 * Returns 0 for success or -1 on an I/O error.
831 extern int zclient_send_hello(struct zclient
*client
);
837 #endif /* _ZEBRA_ZCLIENT_H */