diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2020-02-04 10:57:29 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-04 10:57:29 -0500 |
| commit | a6bb6a1fe906cba30b6815a64577fa64964d61ab (patch) | |
| tree | a593deae119bbd23f1aa159513301aa9b0f450f1 /lib/zclient.c | |
| parent | 05d0c66d8faa313038475c3c50624313a4c9361e (diff) | |
| parent | b9e6727acd3b86a196d8bedc06e61b0b3ba8c47b (diff) | |
Merge pull request #5207 from Spantik/ZERBA_GR
Zebra: Adding GR infrastructure for clients.
Diffstat (limited to 'lib/zclient.c')
| -rw-r--r-- | lib/zclient.c | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/lib/zclient.c b/lib/zclient.c index 7ddf0085de..d879063460 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -3300,31 +3300,71 @@ void zclient_interface_set_master(struct zclient *client, zclient_send_message(client); } -/* Process capabilities message from zebra */ -int zapi_capabilities_decode(struct stream *s, struct zapi_cap *api) +/* + * Send capabilities message to zebra + */ +int32_t zclient_capabilities_send(uint32_t cmd, struct zclient *zclient, + struct zapi_cap *api) { + + struct stream *s; + + if (zclient == NULL) + return -1; + + s = zclient->obuf; + stream_reset(s); + zclient_create_header(s, cmd, 0); + stream_putl(s, api->cap); + + switch (api->cap) { + case ZEBRA_CLIENT_GR_CAPABILITIES: + case ZEBRA_CLIENT_RIB_STALE_TIME: + stream_putl(s, api->stale_removal_time); + stream_putl(s, api->vrf_id); + break; + case ZEBRA_CLIENT_ROUTE_UPDATE_COMPLETE: + case ZEBRA_CLIENT_ROUTE_UPDATE_PENDING: + stream_putl(s, api->afi); + stream_putl(s, api->safi); + stream_putl(s, api->vrf_id); + break; + case ZEBRA_CLIENT_GR_DISABLE: + stream_putl(s, api->vrf_id); + break; + } + + /* Put length at the first point of the stream */ + stream_putw_at(s, 0, stream_get_endp(s)); + + return zclient_send_message(zclient); +} + +/* + * Process capabilities message from zebra + */ +int32_t zapi_capabilities_decode(struct stream *s, struct zapi_cap *api) +{ + memset(api, 0, sizeof(*api)); STREAM_GETL(s, api->cap); switch (api->cap) { case ZEBRA_CLIENT_GR_CAPABILITIES: case ZEBRA_CLIENT_RIB_STALE_TIME: - STREAM_GETL(s, api->stale_removal_time); - STREAM_GETL(s, api->vrf_id); - break; + STREAM_GETL(s, api->stale_removal_time); + STREAM_GETL(s, api->vrf_id); + break; case ZEBRA_CLIENT_ROUTE_UPDATE_COMPLETE: case ZEBRA_CLIENT_ROUTE_UPDATE_PENDING: - STREAM_GETL(s, api->afi); - STREAM_GETL(s, api->safi); - STREAM_GETL(s, api->vrf_id); - break; + STREAM_GETL(s, api->afi); + STREAM_GETL(s, api->safi); + STREAM_GETL(s, api->vrf_id); + break; case ZEBRA_CLIENT_GR_DISABLE: - STREAM_GETL(s, api->vrf_id); - break; - default: - break; + STREAM_GETL(s, api->vrf_id); + break; } - stream_failure: return 0; } |
