diff options
author | Guy Harris <guy@alum.mit.edu> | 2005-09-10 19:43:41 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2005-09-10 19:43:41 +0000 |
commit | 266e1a3491de1ff790c326bbffe0d4827af0f24b (patch) | |
tree | 0f7a094370b39116b39a12fcc5d0329738769398 /epan/tvbuff.c | |
parent | c4b2c971fc559ff346c81b782364ff7985110c45 (diff) |
Add "tvb_get_ipv4()" and "tvb_get_ipv6()" addresses, to fetch IPv4 and
IPv6 addresses. Use "tvb_get_ipv4()" in the WINS Replication dissector,
so that it gets the right answer on little-endian *AND* big-endian
machines.
svn path=/trunk/; revision=15753
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r-- | epan/tvbuff.c | 25 |
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. |