diff options
| author | Renato Westphal <renato@openbsd.org> | 2018-02-06 23:34:12 -0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-06 23:34:12 -0200 |
| commit | 2415f045c62747dbd64108d5b9f991a5a8631212 (patch) | |
| tree | 3bb498074d659a4b1d644e34d549e062941c2774 /lib/zclient.c | |
| parent | 90989cfccffce8e593a9c7e77a37c8478bc531ee (diff) | |
| parent | 7d30a95973ee3b5f28ce7315bc331fde694b1305 (diff) | |
Merge pull request #1712 from donaldsharp/nht_updates
Nht updates
Diffstat (limited to 'lib/zclient.c')
| -rw-r--r-- | lib/zclient.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/zclient.c b/lib/zclient.c index 4d5b0f211d..6f770c66e4 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1212,6 +1212,72 @@ stream_failure: return false; } +struct nexthop *nexthop_from_zapi_nexthop(struct zapi_nexthop *znh) +{ + struct nexthop *n = nexthop_new(); + + n->type = znh->type; + n->ifindex = znh->ifindex; + n->gate = znh->gate; + + /* + * This function does not currently handle labels + */ + + return n; +} + +bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr) +{ + uint32_t i; + + memset(nhr, 0, sizeof(*nhr)); + + STREAM_GETW(s, nhr->prefix.family); + STREAM_GETC(s, nhr->prefix.prefixlen); + switch(nhr->prefix.family) { + case AF_INET: + STREAM_GET(&nhr->prefix.u.prefix4.s_addr, s, IPV4_MAX_BYTELEN); + break; + case AF_INET6: + STREAM_GET(&nhr->prefix.u.prefix6, s, IPV6_MAX_BYTELEN); + break; + default: + break; + } + + STREAM_GETC(s, nhr->distance); + STREAM_GETL(s, nhr->metric); + STREAM_GETC(s, nhr->nexthop_num); + + for (i = 0; i < nhr->nexthop_num ; i++) { + STREAM_GETC(s, nhr->nexthops[i].type); + switch (nhr->nexthops[i].type) { + case NEXTHOP_TYPE_IPV4: + case NEXTHOP_TYPE_IPV4_IFINDEX: + STREAM_GET(&nhr->nexthops[i].gate.ipv4.s_addr, + s, IPV4_MAX_BYTELEN); + STREAM_GETL(s, nhr->nexthops[i].ifindex); + break; + case NEXTHOP_TYPE_IFINDEX: + STREAM_GETL(s, nhr->nexthops[i].ifindex); + break; + case NEXTHOP_TYPE_IPV6: + case NEXTHOP_TYPE_IPV6_IFINDEX: + STREAM_GET(&nhr->nexthops[i].gate.ipv6, + s, IPV6_MAX_BYTELEN); + STREAM_GETL(s, nhr->nexthops[i].ifindex); + break; + case NEXTHOP_TYPE_BLACKHOLE: + break; + } + } + + return true; +stream_failure: + return false; +} + /* * send a ZEBRA_REDISTRIBUTE_ADD or ZEBRA_REDISTRIBUTE_DELETE * for the route type (ZEBRA_ROUTE_KERNEL etc.). The zebra server will |
