summaryrefslogtreecommitdiff
path: root/lib/stream.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2020-04-13 22:48:28 -0300
committerGitHub <noreply@github.com>2020-04-13 22:48:28 -0300
commit1b0f1cb4d7ca196db89f14cd23d794c02f234cd6 (patch)
tree4f9c1b1422f345afacaf0e2ff9d9eaef2e19efe4 /lib/stream.c
parent4b010cf44dd90ad7f33243f3e800812184940ca3 (diff)
parentcff0de128d10f1f78144c8c0ca2d2251099d0241 (diff)
Merge pull request #5892 from qlyoung/fix-zclient-many
assorted lib / zclient fixes
Diffstat (limited to 'lib/stream.c')
-rw-r--r--lib/stream.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/stream.c b/lib/stream.c
index f046572f41..683a130e44 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -543,6 +543,27 @@ uint64_t stream_getq(struct stream *s)
return q;
}
+bool stream_getq2(struct stream *s, uint64_t *q)
+{
+ STREAM_VERIFY_SANE(s);
+
+ if (STREAM_READABLE(s) < sizeof(uint64_t)) {
+ STREAM_BOUND_WARN2(s, "get uint64");
+ return false;
+ }
+
+ *q = ((uint64_t)s->data[s->getp++]) << 56;
+ *q |= ((uint64_t)s->data[s->getp++]) << 48;
+ *q |= ((uint64_t)s->data[s->getp++]) << 40;
+ *q |= ((uint64_t)s->data[s->getp++]) << 32;
+ *q |= ((uint64_t)s->data[s->getp++]) << 24;
+ *q |= ((uint64_t)s->data[s->getp++]) << 16;
+ *q |= ((uint64_t)s->data[s->getp++]) << 8;
+ *q |= ((uint64_t)s->data[s->getp++]);
+
+ return true;
+}
+
/* Get next long word from the stream. */
uint32_t stream_get_ipv4(struct stream *s)
{