2 * Wireshark - Network traffic analyzer
3 * By Gerald Combs <gerald@wireshark.org>
4 * Copyright 2001 Gerald Combs
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <ftypes-int.h>
27 #include <epan/guid-utils.h>
28 #include <epan/to_str.h>
31 guid_fvalue_set_guid(fvalue_t *fv, const e_guid_t *value)
33 fv->value.guid = *value;
37 value_get(fvalue_t *fv)
39 return &(fv->value.guid);
43 get_guid(const char *s, e_guid_t *guid)
48 static const char fmt[] = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
55 if (!g_ascii_isxdigit(s[i]))
64 g_strlcpy(digits, p, 9);
65 guid->data1 = (guint32)strtoul(digits, NULL, 16);
67 g_strlcpy(digits, p, 5);
68 guid->data2 = (guint16)strtoul(digits, NULL, 16);
70 g_strlcpy(digits, p, 5);
71 guid->data3 = (guint16)strtoul(digits, NULL, 16);
73 for (i=0; i < sizeof(guid->data4); i++) {
78 guid->data4[i] = (guint8)strtoul(digits, NULL, 16);
84 guid_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_, gchar **err_msg)
88 if (!get_guid(s, &guid)) {
90 *err_msg = g_strdup_printf("\"%s\" is not a valid GUID.", s);
94 fv->value.guid = guid;
99 guid_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_, int field_display _U_)
105 guid_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_, char *buf, unsigned int size)
107 guid_to_str_buf(&fv->value.guid, buf, size);
111 cmp_eq(const fvalue_t *a, const fvalue_t *b)
113 return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)) == 0;
117 cmp_ne(const fvalue_t *a, const fvalue_t *b)
119 return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)) != 0;
123 ftype_register_guid(void)
126 static ftype_t guid_type = {
128 "FT_GUID", /* name */
129 "Globally Unique Identifier", /* pretty_name */
130 GUID_LEN, /* wire_size */
131 NULL, /* new_value */
132 NULL, /* free_value */
133 guid_from_unparsed, /* val_from_unparsed */
134 NULL, /* val_from_string */
135 guid_to_repr, /* val_to_string_repr */
136 guid_repr_len, /* len_string_repr */
138 { .set_value_guid = guid_fvalue_set_guid }, /* union set_value */
139 { NULL }, /* union get_value */
141 value_get, /* get_value_ptr */
142 NULL, /* get_value_uinteger */
143 NULL, /* get_value_sinteger */
144 NULL, /* get_value_uinteger64 */
154 NULL, /* cmp_matches */
160 ftype_register(FT_GUID, &guid_type);
164 * Editor modelines - http://www.wireshark.org/tools/modelines.html
169 * indent-tabs-mode: nil
172 * vi: set shiftwidth=4 tabstop=8 expandtab:
173 * :indentSize=4:tabSize=8:noTabs=true: