]> The Tcpdump Group git mirrors - tcpdump/blobdiff - cpack.c
CARP: NDOize
[tcpdump] / cpack.c
diff --git a/cpack.c b/cpack.c
index 14c0a9ee2a3e06ab1e2391177bf0139255aa0dca..b863d8e71fb55b029ee32bb8e3725bad3aee81d4 100644 (file)
--- a/cpack.c
+++ b/cpack.c
@@ -38,7 +38,7 @@
 #include "cpack.h"
 #include "extract.h"
 
-static u_int8_t *
+u_int8_t *
 cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment)
 {
        size_t misalignment = (size_t)(p - buf) % alignment;
@@ -53,7 +53,7 @@ cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment)
  * wordsize bytes remain in the buffer after the boundary.  Otherwise,
  * return a pointer to the boundary.
  */
-static u_int8_t *
+u_int8_t *
 cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
 {
        u_int8_t *next;
@@ -68,6 +68,17 @@ cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
        return next;
 }
 
+/* Advance by N bytes without returning them. */
+int
+cpack_advance(struct cpack_state *cs, const size_t toskip)
+{
+       /* No space left? */
+       if (cs->c_next - cs->c_buf + toskip > cs->c_len)
+               return -1;
+       cs->c_next += toskip;
+       return 0;
+}
+
 int
 cpack_init(struct cpack_state *cs, u_int8_t *buf, size_t buflen)
 {