]> git.puffer.fish Git - matthieu/frr.git/commitdiff
nhrpd: Add zbuf routine to peek at contents
authorAmol Lad <amol.lad@4rf.com>
Thu, 11 Mar 2021 02:57:55 +0000 (15:57 +1300)
committerReuben Dowle <reuben.dowle@4rf.com>
Thu, 18 Mar 2021 03:35:41 +0000 (16:35 +1300)
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
nhrpd/zbuf.c
nhrpd/zbuf.h

index 7f1475cc69e1a2eb19f49e73f27534951b2c92fb..1a4a7b39964b08a3e9f7c7f38b87196d195dfb73 100644 (file)
@@ -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);
+}
index e6f7101d635572f351646bb53231d491fb75f08e..d4a7c15a95a07a49fb2a26c23a6f0589946cee77 100644 (file)
@@ -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 *);