From 923855bb20845f55472dfe8e62b7b43660f2f63b Mon Sep 17 00:00:00 2001 From: Tomas Kukosa Date: Fri, 10 Mar 2006 11:58:22 +0000 Subject: new FT_GUID handling - big/little endian supported svn path=/trunk/; revision=17566 --- epan/ftypes/Makefile.am | 1 + epan/ftypes/Makefile.nmake | 1 + epan/ftypes/ftype-bytes.c | 119 -------------------------------- epan/ftypes/ftype-guid.c | 167 +++++++++++++++++++++++++++++++++++++++++++++ epan/ftypes/ftypes-int.h | 1 + epan/ftypes/ftypes.c | 1 + epan/ftypes/ftypes.h | 2 + epan/guid-utils.h | 38 +++++++++++ epan/proto.c | 28 ++++---- epan/proto.h | 10 +-- epan/to_str.c | 12 ++-- epan/to_str.h | 4 +- epan/tvbuff.c | 35 ++++++++++ epan/tvbuff.h | 7 ++ 14 files changed, 281 insertions(+), 145 deletions(-) create mode 100644 epan/ftypes/ftype-guid.c create mode 100644 epan/guid-utils.h diff --git a/epan/ftypes/Makefile.am b/epan/ftypes/Makefile.am index ba94e1c035..580970cbb5 100644 --- a/epan/ftypes/Makefile.am +++ b/epan/ftypes/Makefile.am @@ -41,6 +41,7 @@ libftypes_la_SOURCES = \ ftype-double.c \ ftype-integer.c \ ftype-ipv4.c \ + ftype-guid.c \ ftype-none.c \ ftype-pcre.c \ ftype-string.c \ diff --git a/epan/ftypes/Makefile.nmake b/epan/ftypes/Makefile.nmake index 9408c4fba6..8bcbeba2d8 100644 --- a/epan/ftypes/Makefile.nmake +++ b/epan/ftypes/Makefile.nmake @@ -22,6 +22,7 @@ OBJECTS = \ ftype-double.obj \ ftype-integer.obj \ ftype-ipv4.obj \ + ftype-guid.obj \ ftype-none.obj \ ftype-pcre.obj \ ftype-string.obj \ diff --git a/epan/ftypes/ftype-bytes.c b/epan/ftypes/ftype-bytes.c index 38072e519b..6de2616359 100644 --- a/epan/ftypes/ftype-bytes.c +++ b/epan/ftypes/ftype-bytes.c @@ -39,7 +39,6 @@ #define ETHER_LEN 6 #define IPv6_LEN 16 -#define GUID_LEN 16 static void bytes_fvalue_new(fvalue_t *fv) @@ -76,18 +75,6 @@ bytes_repr_len(fvalue_t *fv, ftrepr_t rtype _U_) return fv->value.bytes->len * 3 - 1; } -static int -guid_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_) -{ - return GUID_STR_LEN; -} - -static void -guid_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf) -{ - guid_to_str_buf(fv->value.bytes->data, buf, GUID_STR_LEN); -} - static int oid_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_) { @@ -147,13 +134,6 @@ ipv6_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied) common_fvalue_set(fv, value, IPv6_LEN); } -static void -guid_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied) -{ - g_assert(!already_copied); - common_fvalue_set(fv, value, GUID_LEN); -} - static void oid_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied) { @@ -278,69 +258,6 @@ ipv6_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf) ip6_to_str_buf((struct e_in6_addr *)fv->value.bytes->data, buf); } -static gboolean -get_guid(char *s, guint8 *buf) -{ - size_t i, n; - char *p, two_digits[3]; - static const char fmt[] = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"; - - n = strlen(s); - if (n != strlen(fmt)) - return FALSE; - for (i=0; ivalue.bytes->len > GUID_LEN) { - logfunc("\"%s\" contains too many bytes to be a valid Globally Unique Identifier.", - s); - return FALSE; - } - else if (fv->value.bytes->len < GUID_LEN && !allow_partial_value) { - logfunc("\"%s\" contains too few bytes to be a valid Globally Unique Identifier.", - s); - return FALSE; - } - - return TRUE; - } - - if (!get_guid(s, buffer)) { - logfunc("\"%s\" is not a valid GUID.", s); - return FALSE; - } - - guid_fvalue_set(fv, buffer, FALSE); - return TRUE; -} - static gboolean oid_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc) { @@ -702,41 +619,6 @@ ftype_register_bytes(void) slice, }; - static ftype_t guid_type = { - "GUID", /* name */ - "Globally Unique Identifier", /* pretty_name */ - GUID_LEN, /* wire_size */ - bytes_fvalue_new, /* new_value */ - bytes_fvalue_free, /* free_value */ - guid_from_unparsed, /* val_from_unparsed */ - NULL, /* val_from_string */ - guid_to_repr, /* val_to_string_repr */ - guid_repr_len, /* len_string_repr */ - - guid_fvalue_set, /* set_value */ - NULL, /* set_value_integer */ - NULL, /* set_value_integer64 */ - NULL, /* set_value_floating */ - - value_get, /* get_value */ - NULL, /* get_value_integer */ - NULL, /* get_value_integer64 */ - NULL, /* get_value_floating */ - - cmp_eq, - cmp_ne, - cmp_gt, - cmp_ge, - cmp_lt, - cmp_le, - cmp_bytes_bitwise_and, - cmp_contains, - NULL, /* cmp_matches */ - - len, - slice, - }; - static ftype_t oid_type = { "OID", /* name */ "OBJECT IDENTIFIER", /* pretty_name */ @@ -776,6 +658,5 @@ ftype_register_bytes(void) ftype_register(FT_UINT_BYTES, &uint_bytes_type); ftype_register(FT_ETHER, ðer_type); ftype_register(FT_IPv6, &ipv6_type); - ftype_register(FT_GUID, &guid_type); ftype_register(FT_OID, &oid_type); } diff --git a/epan/ftypes/ftype-guid.c b/epan/ftypes/ftype-guid.c new file mode 100644 index 0000000000..6f229ae81e --- /dev/null +++ b/epan/ftypes/ftype-guid.c @@ -0,0 +1,167 @@ +/* + * $Id$ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs + * Copyright 2001 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include + +#define GUID_LEN 16 + +static void +set_guid(fvalue_t *fv, e_guid_t *value) +{ + fv->value.guid = *value; +} + +static gpointer +value_get(fvalue_t *fv) +{ + return &(fv->value.guid); +} + +static gboolean +get_guid(char *s, e_guid_t *guid) +{ + size_t i, n; + char *p, digits[9]; + static const char fmt[] = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"; + + n = strlen(s); + if (n != strlen(fmt)) + return FALSE; + for (i=0; idata1 = strtoul(digits, NULL, 16); + p += 9; + strncpy(digits, p, 4); + digits[4] = '\0'; + guid->data2 = (guint16)strtoul(digits, NULL, 16); + p += 5; + strncpy(digits, p, 4); + digits[4] = '\0'; + guid->data3 = (guint16)strtoul(digits, NULL, 16); + p += 5; + for (i=0; i < sizeof(guid->data4); i++) { + if (*p == '-') p++; + digits[0] = *(p++); + digits[1] = *(p++); + digits[2] = '\0'; + guid->data4[i] = (guint8)strtoul(digits, NULL, 16); + } + return TRUE; +} + +static gboolean +guid_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value, LogFunc logfunc) +{ + e_guid_t guid; + + if (!get_guid(s, &guid)) { + logfunc("\"%s\" is not a valid GUID.", s); + return FALSE; + } + + set_guid(fv, &guid); + return TRUE; +} + +static int +guid_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_) +{ + return GUID_STR_LEN; +} + +static void +guid_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf) +{ + guid_to_str_buf(&fv->value.guid, buf, GUID_STR_LEN); +} + +static gboolean +cmp_eq(fvalue_t *a, fvalue_t *b) +{ + return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)) == 0; +} + +static gboolean +cmp_ne(fvalue_t *a, fvalue_t *b) +{ + return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)) != 0; +} + +void +ftype_register_guid(void) +{ + + static ftype_t guid_type = { + "GUID", /* name */ + "Globally Unique Identifier", /* pretty_name */ + GUID_LEN, /* wire_size */ + NULL, /* new_value */ + NULL, /* free_value */ + guid_from_unparsed, /* val_from_unparsed */ + NULL, /* val_from_string */ + guid_to_repr, /* val_to_string_repr */ + guid_repr_len, /* len_string_repr */ + + set_guid, /* set_value */ + NULL, /* set_value_integer */ + NULL, /* set_value_integer64 */ + NULL, /* set_value_floating */ + + value_get, /* get_value */ + NULL, /* get_value_integer */ + NULL, /* get_value_integer64 */ + NULL, /* get_value_floating */ + + cmp_eq, + cmp_ne, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* cmp_matches */ + + NULL, + NULL, + }; + + ftype_register(FT_GUID, &guid_type); +} diff --git a/epan/ftypes/ftypes-int.h b/epan/ftypes/ftypes-int.h index c6928b535e..133300369c 100644 --- a/epan/ftypes/ftypes-int.h +++ b/epan/ftypes/ftypes-int.h @@ -51,6 +51,7 @@ void ftype_register_bytes(void); void ftype_register_double(void); void ftype_register_integers(void); void ftype_register_ipv4(void); +void ftype_register_guid(void); void ftype_register_none(void); void ftype_register_string(void); void ftype_register_time(void); diff --git a/epan/ftypes/ftypes.c b/epan/ftypes/ftypes.c index c12c4fe8d2..e40dfc4f06 100644 --- a/epan/ftypes/ftypes.c +++ b/epan/ftypes/ftypes.c @@ -44,6 +44,7 @@ ftypes_initialize(void) ftype_register_double(); ftype_register_integers(); ftype_register_ipv4(); + ftype_register_guid(); ftype_register_none(); ftype_register_string(); ftype_register_time(); diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h index 5fbf163dc9..6a30a4b7b5 100644 --- a/epan/ftypes/ftypes.h +++ b/epan/ftypes/ftypes.h @@ -138,6 +138,7 @@ ftype_can_matches(enum ftenum ftype); /* ---------------- FVALUE ----------------- */ #include +#include #include #include @@ -156,6 +157,7 @@ typedef struct _fvalue_t { GByteArray *bytes; GString *gstring; ipv4_addr ipv4; + e_guid_t guid; nstime_t time; tvbuff_t *tvb; #ifdef HAVE_LIBPCRE diff --git a/epan/guid-utils.h b/epan/guid-utils.h new file mode 100644 index 0000000000..85269818a9 --- /dev/null +++ b/epan/guid-utils.h @@ -0,0 +1,38 @@ +/* guid-utils.h + * Definitions for GUID handling + * + * $Id$ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs + * + * Copyright 1998 Gerald Combs + * + * MobileIPv6 support added by Tomislav Borosa + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __GUID_UTILS_H__ +#define __GUID_UTILS_H__ + +typedef struct _e_guid_t { + guint32 data1; + guint16 data2; + guint16 data3; + guint8 data4[8]; +} e_guid_t; + +#endif /* __GUID_UTILS_H__ */ diff --git a/epan/proto.c b/epan/proto.c index f3411740b5..9cb904c8ef 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -151,9 +151,9 @@ proto_tree_set_ipv6(field_info *fi, const guint8* value_ptr); static void proto_tree_set_ipv6_tvb(field_info *fi, tvbuff_t *tvb, gint start); static void -proto_tree_set_guid(field_info *fi, const guint8* value_ptr); +proto_tree_set_guid(field_info *fi, const e_guid_t *value_ptr); static void -proto_tree_set_guid_tvb(field_info *fi, tvbuff_t *tvb, gint start); +proto_tree_set_guid_tvb(field_info *fi, tvbuff_t *tvb, gint start, gboolean little_endian); static void proto_tree_set_oid(field_info *fi, const guint8* value_ptr, gint length); static void @@ -902,7 +902,7 @@ proto_tree_new_item(field_info *new_fi, proto_tree *tree, int hfindex, case FT_GUID: DISSECTOR_ASSERT(length == 16); - proto_tree_set_guid_tvb(new_fi, tvb, start); + proto_tree_set_guid_tvb(new_fi, tvb, start, little_endian); break; case FT_OID: @@ -1637,7 +1637,7 @@ proto_tree_set_ipv6_tvb(field_info *fi, tvbuff_t *tvb, gint start) /* Add a FT_GUID to a proto_tree */ proto_item * proto_tree_add_guid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length, - const guint8* value_ptr) + const e_guid_t *value_ptr) { proto_item *pi; field_info *new_fi; @@ -1659,7 +1659,7 @@ proto_tree_add_guid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gi proto_item * proto_tree_add_guid_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length, - const guint8* value_ptr) + const e_guid_t *value_ptr) { proto_item *pi; @@ -1674,7 +1674,7 @@ proto_tree_add_guid_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint st proto_item * proto_tree_add_guid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb, - gint start, gint length, const guint8* value_ptr, + gint start, gint length, const e_guid_t *value_ptr, const char *format, ...) { proto_item *pi; @@ -1693,7 +1693,7 @@ proto_tree_add_guid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb, proto_item * proto_tree_add_guid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length, - const guint8* value_ptr, const char *format, ...) + const e_guid_t *value_ptr, const char *format, ...) { proto_item *pi; va_list ap; @@ -1711,16 +1711,19 @@ proto_tree_add_guid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint st /* Set the FT_GUID value */ static void -proto_tree_set_guid(field_info *fi, const guint8* value_ptr) +proto_tree_set_guid(field_info *fi, const e_guid_t *value_ptr) { DISSECTOR_ASSERT(value_ptr != NULL); fvalue_set(&fi->value, (gpointer) value_ptr, FALSE); } static void -proto_tree_set_guid_tvb(field_info *fi, tvbuff_t *tvb, gint start) +proto_tree_set_guid_tvb(field_info *fi, tvbuff_t *tvb, gint start, gboolean little_endian) { - proto_tree_set_guid(fi, tvb_get_ptr(tvb, start, 16)); + e_guid_t guid; + + tvb_get_guid(tvb, start, &guid, little_endian); + proto_tree_set_guid(fi, &guid); } /* Add a FT_OID to a proto_tree */ @@ -3669,6 +3672,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str) guint8 *bytes; guint32 integer; ipv4_addr *ipv4; + e_guid_t *guid; guint32 n_addr; /* network-order IPv4 address */ const gchar *name; int ret; /*tmp return value */ @@ -3827,10 +3831,10 @@ proto_item_fill_label(field_info *fi, gchar *label_str) break; case FT_GUID: - bytes = fvalue_get(&fi->value); + guid = fvalue_get(&fi->value); ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %s", hfinfo->name, - guid_to_str(bytes)); + guid_to_str(guid)); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) label_str[ITEM_LABEL_LENGTH - 1] = '\0'; break; diff --git a/epan/proto.h b/epan/proto.h index 27c9e1bf4d..9ef5801315 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -817,13 +817,13 @@ proto_tree_add_ether_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint s @return the newly created item */ extern proto_item * proto_tree_add_guid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, - gint length, const guint8* value_ptr); + gint length, const e_guid_t *value_ptr); /** Add a hidden FT_GUID to a proto_tree. @deprecated use proto_tree_add_guid() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */ extern proto_item * proto_tree_add_guid_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, - gint length, const guint8* value_ptr); + gint length, const e_guid_t *value_ptr); /** Add a formatted FT_GUID to a proto_tree, with the format generating the string for the value and with the field name being included @@ -839,7 +839,7 @@ proto_tree_add_guid_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint st @return the newly created item */ extern proto_item * proto_tree_add_guid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb, - gint start, gint length, const guint8* value_ptr, const char *format, + gint start, gint length, const e_guid_t *value_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8); /** Add a formatted FT_GUID to a proto_tree, with the format generating @@ -855,7 +855,7 @@ proto_tree_add_guid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb, @return the newly created item */ extern proto_item * proto_tree_add_guid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, - gint length, const guint8* value_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8); + gint length, const e_guid_t *value_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8); /** Add a FT_OID to a proto_tree. @param tree the tree to append this item to @@ -870,7 +870,7 @@ proto_tree_add_oid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length, const guint8* value_ptr); /** Add a hidden FT_OID to a proto_tree. - @deprecated use proto_tree_add_guid() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */ + @deprecated use proto_tree_add_oid() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */ extern proto_item * proto_tree_add_oid_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length, const guint8* value_ptr); diff --git a/epan/to_str.c b/epan/to_str.c index 715e3e1d31..6fffca81da 100644 --- a/epan/to_str.c +++ b/epan/to_str.c @@ -873,19 +873,17 @@ gchar* oid_to_str_buf(const guint8 *oid, gint oid_len, gchar *buf, int buf_len) return buf; } -gchar* guid_to_str(const guint8 *guid) { +gchar* guid_to_str(const e_guid_t *guid) { gchar *buf; buf=ep_alloc(GUID_STR_LEN); return guid_to_str_buf(guid, buf, GUID_STR_LEN); } -gchar* guid_to_str_buf(const guint8 *guid, gchar *buf, int buf_len) { - g_snprintf(buf, buf_len, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", - guid[0], guid[1], guid[2], guid[3], - guid[4], guid[5], - guid[6], guid[7], - guid[8], guid[9], guid[10], guid[11], guid[12], guid[13], guid[14], guid[15]); +gchar* guid_to_str_buf(const e_guid_t *guid, gchar *buf, int buf_len) { + g_snprintf(buf, buf_len, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + guid->data1, guid->data2, guid->data3, + guid->data4[0], guid->data4[1], guid->data4[2], guid->data4[3], guid->data4[4], guid->data4[5], guid->data4[6], guid->data4[7]); return buf; } diff --git a/epan/to_str.h b/epan/to_str.h index 3b741a4ecb..4bbe5e9447 100644 --- a/epan/to_str.h +++ b/epan/to_str.h @@ -76,8 +76,8 @@ extern gchar* rel_time_to_str(nstime_t*); extern gchar* rel_time_to_secs_str(nstime_t*); extern gchar* oid_to_str(const guint8*, gint); extern gchar* oid_to_str_buf(const guint8*, gint, gchar*, int); -extern gchar* guid_to_str(const guint8*); -extern gchar* guid_to_str_buf(const guint8*, gchar*, int); +extern gchar* guid_to_str(const e_guid_t*); +extern gchar* guid_to_str_buf(const e_guid_t*, gchar*, int); void tipc_addr_to_str_buf( const guint8 *data, gchar *buf, int buf_len); diff --git a/epan/tvbuff.c b/epan/tvbuff.c index a31584845c..fd7d0404ed 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -1411,6 +1411,41 @@ tvb_get_ipv6(tvbuff_t *tvb, gint offset, struct e_in6_addr *addr) memcpy(addr, ptr, sizeof *addr); } +/* Fetch a GUID. */ +void +tvb_get_ntohguid(tvbuff_t *tvb, gint offset, e_guid_t *guid) +{ + const guint8* ptr; + + ensure_contiguous(tvb, offset, sizeof(*guid)); + guid->data1 = tvb_get_ntohl(tvb, offset); + guid->data2 = tvb_get_ntohs(tvb, offset + 4); + guid->data3 = tvb_get_ntohs(tvb, offset + 6); + tvb_memcpy(tvb, guid->data4, offset + 8, sizeof guid->data4); +} + +void +tvb_get_letohguid(tvbuff_t *tvb, gint offset, e_guid_t *guid) +{ + const guint8* ptr; + + ensure_contiguous(tvb, offset, sizeof(*guid)); + guid->data1 = tvb_get_letohl(tvb, offset); + guid->data2 = tvb_get_letohs(tvb, offset + 4); + guid->data3 = tvb_get_letohs(tvb, offset + 6); + tvb_memcpy(tvb, guid->data4, offset + 8, sizeof guid->data4); +} + +void +tvb_get_guid(tvbuff_t *tvb, gint offset, e_guid_t *guid, gboolean little_endian) +{ + if (little_endian) { + tvb_get_letohguid(tvb, offset, guid); + } else { + tvb_get_ntohguid(tvb, offset, guid); + } +} + /* 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. diff --git a/epan/tvbuff.h b/epan/tvbuff.h index efe9ef6d4a..144af28666 100644 --- a/epan/tvbuff.h +++ b/epan/tvbuff.h @@ -37,6 +37,7 @@ #include #include +#include #include "exceptions.h" /** @file @@ -330,6 +331,12 @@ extern guint32 tvb_get_ipv4(tvbuff_t*, gint offset); /* Fetch an IPv6 address. */ extern void tvb_get_ipv6(tvbuff_t*, gint offset, struct e_in6_addr *addr); +/* Fetch a GUID. */ +extern void tvb_get_ntohguid(tvbuff_t *tvb, gint offset, e_guid_t *guid); +extern void tvb_get_letohguid(tvbuff_t *tvb, gint offset, e_guid_t *guid); +extern void tvb_get_guid(tvbuff_t *tvb, gint offset, e_guid_t *guid, gboolean little_endian); + + /** Returns target for convenience. Does not suffer from possible * expense of tvb_get_ptr(), since this routine is smart enough * to copy data in chunks if the request range actually exists in -- cgit v1.2.3