4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 2001 Gerald Combs
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <ftypes-int.h>
30 #include <epan/guid-utils.h>
31 #include <epan/to_str.h>
34 guid_fvalue_set_guid(fvalue_t *fv, const e_guid_t *value)
36 fv->value.guid = *value;
40 value_get(fvalue_t *fv)
42 return &(fv->value.guid);
46 get_guid(const char *s, e_guid_t *guid)
51 static const char fmt[] = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
58 if (!isxdigit((guchar)s[i]))
67 strncpy(digits, p, 8);
69 guid->data1 = (guint32)strtoul(digits, NULL, 16);
71 strncpy(digits, p, 4);
73 guid->data2 = (guint16)strtoul(digits, NULL, 16);
75 strncpy(digits, p, 4);
77 guid->data3 = (guint16)strtoul(digits, NULL, 16);
79 for (i=0; i < sizeof(guid->data4); i++) {
84 guid->data4[i] = (guint8)strtoul(digits, NULL, 16);
90 guid_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_, LogFunc logfunc)
94 if (!get_guid(s, &guid)) {
95 logfunc("\"%s\" is not a valid GUID.", s);
99 fv->value.guid = guid;
104 guid_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_)
110 guid_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf)
112 guid_to_str_buf(&fv->value.guid, buf, GUID_STR_LEN);
116 cmp_eq(const fvalue_t *a, const fvalue_t *b)
118 return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)) == 0;
122 cmp_ne(const fvalue_t *a, const fvalue_t *b)
124 return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)) != 0;
128 ftype_register_guid(void)
131 static ftype_t guid_type = {
133 "FT_GUID", /* name */
134 "Globally Unique Identifier", /* pretty_name */
135 GUID_LEN, /* wire_size */
136 NULL, /* new_value */
137 NULL, /* free_value */
138 guid_from_unparsed, /* val_from_unparsed */
139 NULL, /* val_from_string */
140 guid_to_repr, /* val_to_string_repr */
141 guid_repr_len, /* len_string_repr */
143 NULL, /* set_value_byte_array */
144 NULL, /* set_value_bytes */
145 guid_fvalue_set_guid, /* set_value_guid */
146 NULL, /* set_value_time */
147 NULL, /* set_value_string */
148 NULL, /* set_value_tvbuff */
149 NULL, /* set_value_uinteger */
150 NULL, /* set_value_sinteger */
151 NULL, /* set_value_integer64 */
152 NULL, /* set_value_floating */
154 value_get, /* get_value */
155 NULL, /* get_value_uinteger */
156 NULL, /* get_value_sinteger */
157 NULL, /* get_value_integer64 */
158 NULL, /* get_value_floating */
168 NULL, /* cmp_matches */
174 ftype_register(FT_GUID, &guid_type);