summaryrefslogtreecommitdiff
path: root/lib/stream.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2020-03-01 01:20:40 -0500
committerQuentin Young <qlyoung@cumulusnetworks.com>2020-04-13 13:25:25 -0400
commitc2b5a4e5ff6135b9f530dbc5a89611cd61fe6419 (patch)
tree6f342185a8343ab1b00d90539fb7a77a3841cc29 /lib/stream.c
parent3b55aba1958c78b8838ce9ee5eed865d22d2787b (diff)
lib: add STREAM_GETQ, STREAM_GETF
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
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)
{