lib: add zapi encode/decode func for srv6 locator

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
This commit is contained in:
Hiroki Shirokura 2021-09-05 02:22:21 +00:00
parent b44f7c3f6d
commit 15588d7b63
2 changed files with 30 additions and 0 deletions

View File

@ -1105,6 +1105,33 @@ stream_failure:
return -1; return -1;
} }
int zapi_srv6_locator_encode(struct stream *s, const struct srv6_locator *l)
{
stream_putw(s, strlen(l->name));
stream_put(s, l->name, strlen(l->name));
stream_putw(s, l->prefix.prefixlen);
stream_put(s, &l->prefix.prefix, sizeof(l->prefix.prefix));
return 0;
}
int zapi_srv6_locator_decode(struct stream *s, struct srv6_locator *l)
{
uint16_t len = 0;
STREAM_GETW(s, len);
if (len > SRV6_LOCNAME_SIZE)
goto stream_failure;
STREAM_GET(l->name, s, len);
STREAM_GETW(s, l->prefix.prefixlen);
STREAM_GET(&l->prefix.prefix, s, sizeof(l->prefix.prefix));
l->prefix.family = AF_INET6;
return 0;
stream_failure:
return -1;
}
static int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg) static int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg)
{ {
int i; int i;

View File

@ -1090,6 +1090,9 @@ extern int zapi_labels_encode(struct stream *s, int cmd,
struct zapi_labels *zl); struct zapi_labels *zl);
extern int zapi_labels_decode(struct stream *s, struct zapi_labels *zl); extern int zapi_labels_decode(struct stream *s, struct zapi_labels *zl);
extern int zapi_srv6_locator_encode(struct stream *s,
const struct srv6_locator *l);
extern int zapi_srv6_locator_decode(struct stream *s, struct srv6_locator *l);
extern int zapi_srv6_locator_chunk_encode(struct stream *s, extern int zapi_srv6_locator_chunk_encode(struct stream *s,
const struct srv6_locator_chunk *c); const struct srv6_locator_chunk *c);
extern int zapi_srv6_locator_chunk_decode(struct stream *s, extern int zapi_srv6_locator_chunk_decode(struct stream *s,