aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r--epan/tvbuff.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index f1e6bc6045..ae767e519c 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -46,6 +46,7 @@
#endif
#include "pint.h"
+#include "ipv6-utils.h"
#include "tvbuff.h"
#include "strutil.h"
#include "emem.h"
@@ -1386,6 +1387,30 @@ tvb_get_letohieee_double(tvbuff_t *tvb, int offset)
#endif
}
+/* Fetch an IPv4 address, in network byte order.
+ * We do *not* convert them to host byte order; we leave them in
+ * network byte order. */
+guint32
+tvb_get_ipv4(tvbuff_t *tvb, gint offset)
+{
+ const guint8* ptr;
+ guint32 addr;
+
+ ptr = ensure_contiguous(tvb, offset, sizeof(guint32));
+ memcpy(&addr, ptr, sizeof addr);
+ return addr;
+}
+
+/* Fetch an IPv6 address. */
+void
+tvb_get_ipv6(tvbuff_t *tvb, gint offset, struct e_in6_addr *addr)
+{
+ const guint8* ptr;
+
+ ptr = ensure_contiguous(tvb, offset, sizeof(*addr));
+ memcpy(addr, ptr, sizeof *addr);
+}
+
/* Find first occurence of needle in tvbuff, starting at offset. Searches
* at most maxlength number of bytes; if maxlength is -1, searches to
* end of tvbuff.