summaryrefslogtreecommitdiffstats
path: root/lib/zclient.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2020-02-18 15:57:22 +0100
committerGitHub <noreply@github.com>2020-02-18 15:57:22 +0100
commit0d60f61f18549c72e7c4182c536ee2856ab77fe0 (patch)
treecc4ab80d47957fe8e7b786fb6e4bd7ef3b8a35cf /lib/zclient.c
parentMerge pull request #5801 from donaldsharp/bgp_peer_sort (diff)
parent*: encode zapi labels message using nexthops (diff)
downloadfrr-0d60f61f18549c72e7c4182c536ee2856ab77fe0.tar.xz
frr-0d60f61f18549c72e7c4182c536ee2856ab77fe0.zip
Merge pull request #5813 from mjstapp/zapi_labels_use_nh
*: encode zapi labels message using nexthops
Diffstat (limited to 'lib/zclient.c')
-rw-r--r--lib/zclient.c37
1 files changed, 6 insertions, 31 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index 4f2ad959d..b0d2ea43a 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -2602,7 +2602,7 @@ int zebra_send_mpls_labels(struct zclient *zclient, int cmd,
int zapi_labels_encode(struct stream *s, int cmd, struct zapi_labels *zl)
{
- struct zapi_nexthop_label *znh;
+ struct zapi_nexthop *znh;
stream_reset(s);
@@ -2631,20 +2631,8 @@ int zapi_labels_encode(struct stream *s, int cmd, struct zapi_labels *zl)
for (int i = 0; i < zl->nexthop_num; i++) {
znh = &zl->nexthops[i];
- stream_putc(s, znh->type);
- stream_putw(s, znh->family);
- switch (znh->family) {
- case AF_INET:
- stream_put_in_addr(s, &znh->address.ipv4);
- break;
- case AF_INET6:
- stream_write(s, (uint8_t *)&znh->address.ipv6, 16);
- break;
- default:
- break;
- }
- stream_putl(s, znh->ifindex);
- stream_putl(s, znh->label);
+ if (zapi_nexthop_encode(s, znh, 0) < 0)
+ return -1;
}
/* Put length at the first point of the stream. */
@@ -2655,7 +2643,7 @@ int zapi_labels_encode(struct stream *s, int cmd, struct zapi_labels *zl)
int zapi_labels_decode(struct stream *s, struct zapi_labels *zl)
{
- struct zapi_nexthop_label *znh;
+ struct zapi_nexthop *znh;
memset(zl, 0, sizeof(*zl));
@@ -2719,21 +2707,8 @@ int zapi_labels_decode(struct stream *s, struct zapi_labels *zl)
for (int i = 0; i < zl->nexthop_num; i++) {
znh = &zl->nexthops[i];
- STREAM_GETC(s, znh->type);
- STREAM_GETW(s, znh->family);
- switch (znh->family) {
- case AF_INET:
- STREAM_GET(&znh->address.ipv4.s_addr, s,
- IPV4_MAX_BYTELEN);
- break;
- case AF_INET6:
- STREAM_GET(&znh->address.ipv6, s, 16);
- break;
- default:
- break;
- }
- STREAM_GETL(s, znh->ifindex);
- STREAM_GETL(s, znh->label);
+ if (zapi_nexthop_decode(s, znh, 0) < 0)
+ return -1;
}
return 0;