]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Pass the safi as a uint8_t
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 6 Nov 2017 18:04:19 +0000 (13:04 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 13 Nov 2017 19:18:43 +0000 (14:18 -0500)
The safi encode/decode is using 2 bytes, which
may cause problems on some platforms.  Let's assume
that a safi is a uint8_t and work accordingly.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/zclient.c
lib/zclient.h

index ce4886efdc5e425e80f293ba6c5619e03a3e9a12..6d6d44fb12afe255c00d62b8c5eed839a6df0e98 100644 (file)
@@ -901,7 +901,7 @@ int zapi_route_encode(u_char cmd, struct stream *s, struct zapi_route *api)
        stream_putw(s, api->instance);
        stream_putl(s, api->flags);
        stream_putc(s, api->message);
-       stream_putw(s, api->safi);
+       stream_putc(s, api->safi);
 
        /* Put prefix information. */
        stream_putc(s, api->prefix.family);
@@ -1021,7 +1021,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
        STREAM_GETW(s, api->instance);
        STREAM_GETL(s, api->flags);
        STREAM_GETC(s, api->message);
-       STREAM_GETW(s, api->safi);
+       STREAM_GETC(s, api->safi);
 
        /* Prefix. */
        STREAM_GETC(s, api->prefix.family);
index 23fe0e41f406a306f06900a4c6ed3381d003d4b7..e9b2cb89560d5b5a618fdc70f0f4da58b89af6ba 100644 (file)
@@ -235,6 +235,13 @@ struct zapi_nexthop {
        mpls_label_t labels[MPLS_MAX_LABELS];
 };
 
+/*
+ * Some of these data structures do not map easily to
+ * a actual data structure size giving different compilers
+ * and systems.  For those data structures we need
+ * to use the smallest available stream_getX/putX functions
+ * to encode/decode.
+ */
 struct zapi_route {
        u_char type;
        u_short instance;
@@ -243,6 +250,10 @@ struct zapi_route {
 
        u_char message;
 
+       /*
+        * This is an enum but we are going to treat it as a uint8_t
+        * for purpose of encoding/decoding
+        */
        safi_t safi;
 
        struct prefix prefix;