diff options
author | Jeff Morriss <jeff.morriss@ulticom.com> | 2011-01-13 15:53:30 +0000 |
---|---|---|
committer | Jeff Morriss <jeff.morriss@ulticom.com> | 2011-01-13 15:53:30 +0000 |
commit | a167206685d96ec2f601ddca81529e60a5822810 (patch) | |
tree | ab37d05388aa0483bd3c43e36ad614f9fee2863f /epan/address_to_str.c | |
parent | d9520dc09c237743a11275c28d0c0c76ec051dc3 (diff) |
Introduce, and start using, tvb_ip_to_str() and tvb_ip6_to_str(). These
do the same as the non-tvb equivalents but take a TVB and an offset instead
of a pointer to an array of bytes.
Their purpose is to prevent (many) dissectors from doing:
ip_to_str(tvb_get_ptr(...)).
(About the names and the location: I like the names as they are but the names
imply that they should live in tvbuff.c. That would make some sense but
I didn't want to pull to_str.h into tvbuff.c...)
svn path=/trunk/; revision=35519
Diffstat (limited to 'epan/address_to_str.c')
-rw-r--r-- | epan/address_to_str.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/epan/address_to_str.c b/epan/address_to_str.c index 4aefbd523c..7f4691a66a 100644 --- a/epan/address_to_str.c +++ b/epan/address_to_str.c @@ -104,6 +104,17 @@ ip_to_str(const guint8 *ad) { return buf; } +#define IPV4_LENGTH 4 +const gchar * +tvb_ip_to_str(tvbuff_t *tvb, const gint offset) +{ + gchar *buf; + + buf=ep_alloc(MAX_IP_STR_LEN); + ip_to_str_buf(tvb_get_ptr(tvb, offset, IPV4_LENGTH), buf, MAX_IP_STR_LEN); + return buf; +} + /* XXX FIXME remove this one later when every call has been converted to ep_address_to_str() */ @@ -112,7 +123,7 @@ ip6_to_str(const struct e_in6_addr *ad) { #ifndef INET6_ADDRSTRLEN #define INET6_ADDRSTRLEN 46 #endif - static gchar *str; + gchar *str; str=ep_alloc(INET6_ADDRSTRLEN+1); @@ -120,6 +131,17 @@ ip6_to_str(const struct e_in6_addr *ad) { return str; } +#define IPV6_LENGTH 16 +gchar * +tvb_ip6_to_str(tvbuff_t *tvb, const gint offset) +{ + gchar *buf; + + buf=ep_alloc(INET6_ADDRSTRLEN+1); + ip6_to_str_buf((const struct e_in6_addr *)tvb_get_ptr(tvb, offset, IPV6_LENGTH), buf); + return buf; +} + void ip6_to_str_buf(const struct e_in6_addr *ad, gchar *buf) { |