diff options
| author | Mark Stapp <mjs@voltanet.io> | 2020-04-06 16:10:13 -0400 |
|---|---|---|
| committer | Mark Stapp <mjs@voltanet.io> | 2020-06-02 08:20:54 -0400 |
| commit | ff491140956129580a7d68ea8510b521cce80c9d (patch) | |
| tree | 076b1f5d5ab772763c5727e8c5f48a22fdb7fdfd /lib/zclient.h | |
| parent | f8c511cddb9bc54d190d8bfcded339ed7f3ec219 (diff) | |
lib: add OPAQUE zapi message
Add a zapi message type designed to carry opaque data. Add
'send' api, and prototype for client handler function. Also
add registration/unreg messages, so that clients can 'subscribe'
to receive these messages as they're passing through zebra.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'lib/zclient.h')
| -rw-r--r-- | lib/zclient.h | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/lib/zclient.h b/lib/zclient.h index feaabc0549..4682216d89 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -200,7 +200,10 @@ typedef enum { ZEBRA_MLAG_CLIENT_UNREGISTER, ZEBRA_MLAG_FORWARD_MSG, ZEBRA_ERROR, - ZEBRA_CLIENT_CAPABILITIES + ZEBRA_CLIENT_CAPABILITIES, + ZEBRA_OPAQUE_MESSAGE, + ZEBRA_OPAQUE_REGISTER, + ZEBRA_OPAQUE_UNREGISTER, } zebra_message_types_t; enum zebra_error_types { @@ -339,6 +342,9 @@ struct zclient { int (*mlag_process_down)(void); int (*mlag_handle_msg)(struct stream *msg, int len); int (*handle_error)(enum zebra_error_types error); + int (*opaque_msg_handler)(ZAPI_CALLBACK_ARGS); + int (*opaque_register_handler)(ZAPI_CALLBACK_ARGS); + int (*opaque_unregister_handler)(ZAPI_CALLBACK_ARGS); }; /* Zebra API message flag. */ @@ -833,6 +839,44 @@ extern void zclient_send_mlag_deregister(struct zclient *client); extern void zclient_send_mlag_data(struct zclient *client, struct stream *client_s); +/* + * Send an OPAQUE message, contents opaque to zebra - but note that + * the length of the payload is restricted by the zclient's + * outgoing message buffer. + * The message header is a message subtype; please use the registry + * below to avoid sub-type collisions. Clients use the registration + * apis to manage the specific opaque subtypes they want to receive. + */ +int zclient_send_opaque(struct zclient *zclient, uint32_t type, + const uint8_t *data, size_t datasize); + +/* Simple struct to convey registration/unreg requests */ +struct zapi_opaque_reg_info { + /* Message subtype */ + uint32_t type; + + /* Client session tuple */ + uint8_t proto; + uint16_t instance; + uint32_t session_id; +}; + +int zclient_register_opaque(struct zclient *zclient, uint32_t type); +int zclient_unregister_opaque(struct zclient *zclient, uint32_t type); +int zapi_parse_opaque_reg(struct stream *msg, + struct zapi_opaque_reg_info *info); + +/* + * Registry of opaque message types. Please do not reuse an in-use + * type code; some daemons are likely relying on it. + */ +enum zapi_opaque_registry { + /* Request link-state database dump, at restart for example */ + LINK_STATE_REQUEST = 1, + /* Update containing link-state db info */ + LINK_STATE_UPDATE = 2, +}; + /* Send the hello message. * Returns 0 for success or -1 on an I/O error. */ |
