summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmol Lad <amol.lad@4rf.com>2021-03-11 15:57:55 +1300
committerReuben Dowle <reuben.dowle@4rf.com>2021-03-18 16:35:41 +1300
commitd5dc926f18eb9a25b2e188e3cf6e4d7b76b15bcc (patch)
tree53ac252d363b148aba73bc8a3cc1763556ae2a03
parent263e82b30895333e9f97892b3f0aca05b46f9fda (diff)
nhrpd: Add zbuf routine to peek at contents
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
-rw-r--r--nhrpd/zbuf.c12
-rw-r--r--nhrpd/zbuf.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/nhrpd/zbuf.c b/nhrpd/zbuf.c
index 7f1475cc69..1a4a7b3996 100644
--- a/nhrpd/zbuf.c
+++ b/nhrpd/zbuf.c
@@ -230,3 +230,15 @@ void zbuf_copy(struct zbuf *zdst, struct zbuf *zsrc, size_t len)
return;
memcpy(dst, src, len);
}
+
+void zbuf_copy_peek(struct zbuf *zdst, struct zbuf *zsrc, size_t len)
+{
+ const void *src;
+ void *dst;
+
+ dst = zbuf_pushn(zdst, len);
+ src = zbuf_pulln(zsrc, 0);
+ if (!dst || !src)
+ return;
+ memcpy(dst, src, len);
+}
diff --git a/nhrpd/zbuf.h b/nhrpd/zbuf.h
index e6f7101d63..d4a7c15a95 100644
--- a/nhrpd/zbuf.h
+++ b/nhrpd/zbuf.h
@@ -190,6 +190,7 @@ static inline void zbuf_put_be32(struct zbuf *zb, uint32_t val)
}
void zbuf_copy(struct zbuf *zb, struct zbuf *src, size_t len);
+void zbuf_copy_peek(struct zbuf *zdst, struct zbuf *zsrc, size_t len);
void zbufq_init(struct zbuf_queue *);
void zbufq_reset(struct zbuf_queue *);