mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 06:34:51 +00:00
zebra: add struct zmsghdr
Formalize the ZAPI header by documenting it in code and providing it to message handlers free of charge to reduce complexity. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
8068a649a7
commit
9bcbcae2e4
@ -2681,10 +2681,31 @@ stream_failure:
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reads header from zmsg stream.
|
||||
*
|
||||
* Note this advances the stream getp by the size of the header.
|
||||
*/
|
||||
static bool zserv_read_header(struct stream *msg, struct zmsghdr *hdr)
|
||||
{
|
||||
STREAM_GETW(msg, hdr->length);
|
||||
STREAM_GETC(msg, hdr->marker);
|
||||
STREAM_GETC(msg, hdr->version);
|
||||
STREAM_GETL(msg, hdr->vrf_id);
|
||||
STREAM_GETW(msg, hdr->command);
|
||||
return true;
|
||||
stream_failure:
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void zserv_handle_commands(struct zserv *client, uint16_t command,
|
||||
uint16_t length,
|
||||
struct zebra_vrf *zvrf)
|
||||
{
|
||||
struct zmsghdr hdr;
|
||||
stream_set_getp(client->ibuf, 0);
|
||||
zserv_read_header(client->ibuf, &hdr);
|
||||
|
||||
switch (command) {
|
||||
case ZEBRA_ROUTER_ID_ADD:
|
||||
zread_router_id_add(client, length, zvrf);
|
||||
|
@ -129,6 +129,15 @@ struct zserv {
|
||||
int last_write_cmd;
|
||||
};
|
||||
|
||||
/* ZAPI protocol message header */
|
||||
struct zmsghdr {
|
||||
uint16_t length;
|
||||
uint8_t marker;
|
||||
uint8_t version;
|
||||
uint32_t vrf_id;
|
||||
uint16_t command;
|
||||
};
|
||||
|
||||
/* Zebra instance */
|
||||
struct zebra_t {
|
||||
/* Thread master */
|
||||
|
Loading…
Reference in New Issue
Block a user