lib/zclient: Consolidate error reporting for zclient_read_header
All functions that call zclient_read_header immediately turn around
and check to ensure that the version and marker fields are correct
Move this code into zclient_read_header
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
diff --git a/lib/zclient.c b/lib/zclient.c
index a095632..0ce46fe 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -315,6 +315,13 @@
*vrf_id = stream_getw (s);
*cmd = stream_getw (s);
+ if (*version != ZSERV_VERSION || *marker != ZEBRA_HEADER_MARKER)
+ {
+ zlog_err("%s: socket %d version mismatch, marker %d, version %d",
+ __func__, sock, *marker, *version);
+ return -1;
+ }
+
if (*size && stream_read (s, sock, *size) != *size)
return -1;