summaryrefslogtreecommitdiffstats
path: root/lib/stream.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2020-03-01 07:20:40 +0100
committerQuentin Young <qlyoung@cumulusnetworks.com>2020-04-13 19:25:25 +0200
commitc2b5a4e5ff6135b9f530dbc5a89611cd61fe6419 (patch)
tree6f342185a8343ab1b00d90539fb7a77a3841cc29 /lib/stream.c
parentlib: remove unnecessary null checks (diff)
downloadfrr-c2b5a4e5ff6135b9f530dbc5a89611cd61fe6419.tar.xz
frr-c2b5a4e5ff6135b9f530dbc5a89611cd61fe6419.zip
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 f046572f4..683a130e4 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)
{