aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2006-03-19 20:45:45 +0000
committerGuy Harris <guy@alum.mit.edu>2006-03-19 20:45:45 +0000
commit7db8eea5c68284a468924639eecc2ca8959225d0 (patch)
tree8615d9607a760ce4721551cd031660083076cd49 /epan
parent624db0dc41ab9bad1bacbd95462d6dffa4afba61 (diff)
Make the GUIDs in various data structures e_guid_t's rather than arrays
of 16 bytes. Use "sizeof" for the size of e_guid_t's, and use structure assignment to copy GUID values. Make functions such as append_h225ras_call() and new_h225ras_call() take pointers to e_guid_t's as arguments. Define GUID_LEN in epan/guid-utils.h and use it as the length of a GUID in a packet. (Note that "sizeof e_guid_t" is not guaranteed to be 16, although it is guaranteed to be the size of an e_guid_t.) When constructing a display filter that matches a GUID, use guid_to_str() to construct the string for the GUID. svn path=/trunk/; revision=17676
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-h225.c14
-rw-r--r--epan/dissectors/packet-h225.h2
-rw-r--r--epan/ftypes/ftype-guid.c165
-rw-r--r--epan/guid-utils.h4
-rw-r--r--epan/h225-persistentdata.c8
-rw-r--r--epan/h225-persistentdata.h6
6 files changed, 101 insertions, 98 deletions
diff --git a/epan/dissectors/packet-h225.c b/epan/dissectors/packet-h225.c
index 4c3e94033d..d44488088f 100644
--- a/epan/dissectors/packet-h225.c
+++ b/epan/dissectors/packet-h225.c
@@ -4173,8 +4173,8 @@ dissect_h225_T_guid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tre
#line 450 "h225.cnf"
tvbuff_t *guid_tvb;
- offset = dissect_per_octet_string(tvb,offset,pinfo,tree,hf_index,16,16,&guid_tvb);
- tvb_memcpy(guid_tvb,h225_pi->guid,0,tvb_length(guid_tvb));
+ offset = dissect_per_octet_string(tvb,offset,pinfo,tree,hf_index,GUID_LEN,GUID_LEN,&guid_tvb);
+ tvb_memcpy(guid_tvb,(guint8 *)&h225_pi->guid,0,GUID_LEN);
return offset;
@@ -12815,7 +12815,7 @@ static void reset_h225_packet_info(h225_packet_info *pi)
pi->msg_tag = -1;
pi->reason = -1;
pi->requestSeqNum = 0;
- memset(pi->guid,0,16);
+ memset(&pi->guid,0,sizeof pi->guid);
pi->is_duplicate = FALSE;
pi->request_available = FALSE;
pi->is_faststart = FALSE;
@@ -12914,7 +12914,7 @@ static void ras_call_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
and last request occured more than 1800 seconds ago,
we decide that we have a new request */
/* Append new ras call to list */
- h225ras_call = append_h225ras_call(h225ras_call, pinfo, pi->guid, msg_category);
+ h225ras_call = append_h225ras_call(h225ras_call, pinfo, &pi->guid, msg_category);
} else {
/* No, so it's a duplicate request.
Mark it as such. */
@@ -12927,7 +12927,7 @@ static void ras_call_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
} while (h225ras_call != NULL );
}
else {
- h225ras_call = new_h225ras_call(&h225ras_call_key, pinfo, pi->guid, msg_category);
+ h225ras_call = new_h225ras_call(&h225ras_call_key, pinfo, &pi->guid, msg_category);
}
/* add link to response frame, if available */
@@ -12968,8 +12968,8 @@ static void ras_call_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
/* if this is an ACF, ARJ or DCF, DRJ, give guid to tap and make it filterable */
if (msg_category == 3 || msg_category == 5) {
- memcpy(pi->guid, h225ras_call->guid,16);
- proto_tree_add_guid_hidden(tree, hf_h225_guid, tvb, 0, 16, pi->guid);
+ pi->guid = h225ras_call->guid;
+ proto_tree_add_guid_hidden(tree, hf_h225_guid, tvb, 0, GUID_LEN, &pi->guid);
}
if (h225ras_call->rsp_num == 0) {
diff --git a/epan/dissectors/packet-h225.h b/epan/dissectors/packet-h225.h
index d7b73f64b7..903f4a543d 100644
--- a/epan/dissectors/packet-h225.h
+++ b/epan/dissectors/packet-h225.h
@@ -63,7 +63,7 @@ typedef struct _h225_packet_info {
gint msg_tag; /* message tag*/
gint reason; /* reason tag, if available */
guint requestSeqNum; /* request sequence number of ras-message, if available */
- guint8 guid[16]; /* globally unique call id */
+ e_guid_t guid; /* globally unique call id */
gboolean is_duplicate; /* true, if this is a repeated message */
gboolean request_available; /* true, if response matches to a request */
nstime_t delta_time; /* this is the RAS response time delay */
diff --git a/epan/ftypes/ftype-guid.c b/epan/ftypes/ftype-guid.c
index 6c78fe9cea..08104453c8 100644
--- a/epan/ftypes/ftype-guid.c
+++ b/epan/ftypes/ftype-guid.c
@@ -30,139 +30,138 @@
#include <ftypes-int.h>
#include <epan/guid-utils.h>
-#define GUID_LEN 16
-
static void
guid_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
{
- fv->value.guid = *(e_guid_t*)value;
+ g_assert(!already_copied);
+ fv->value.guid = *(e_guid_t*)value;
}
static gpointer
value_get(fvalue_t *fv)
{
- return &(fv->value.guid);
+ 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; i<n; i++) {
- if (fmt[i] == 'X') {
- if (!isxdigit((guchar)s[i]))
- return FALSE;
- } else {
- if (s[i] != fmt[i])
- return FALSE;
- }
- }
-
- p = s;
- strncpy(digits, p, 8);
+ 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; i<n; i++) {
+ if (fmt[i] == 'X') {
+ if (!isxdigit((guchar)s[i]))
+ return FALSE;
+ } else {
+ if (s[i] != fmt[i])
+ return FALSE;
+ }
+ }
+
+ p = s;
+ strncpy(digits, p, 8);
digits[8] = '\0';
- guid->data1 = strtoul(digits, NULL, 16);
+ guid->data1 = strtoul(digits, NULL, 16);
p += 9;
- strncpy(digits, p, 4);
+ strncpy(digits, p, 4);
digits[4] = '\0';
- guid->data2 = (guint16)strtoul(digits, NULL, 16);
+ guid->data2 = (guint16)strtoul(digits, NULL, 16);
p += 5;
- strncpy(digits, p, 4);
+ strncpy(digits, p, 4);
digits[4] = '\0';
- guid->data3 = (guint16)strtoul(digits, NULL, 16);
+ 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;
+ 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 _U_, LogFunc logfunc)
{
- e_guid_t guid;
+ e_guid_t guid;
- if (!get_guid(s, &guid)) {
- logfunc("\"%s\" is not a valid GUID.", s);
- return FALSE;
- }
+ if (!get_guid(s, &guid)) {
+ logfunc("\"%s\" is not a valid GUID.", s);
+ return FALSE;
+ }
- fv->value.guid = guid;
- return TRUE;
+ fv->value.guid = guid;
+ return TRUE;
}
static int
guid_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_)
{
- return GUID_STR_LEN;
+ 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);
+ 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;
+ 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;
+ 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 */
-
- 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,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL, /* cmp_matches */
-
- NULL,
- NULL,
- };
-
- ftype_register(FT_GUID, &guid_type);
+ 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 */
+
+ 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,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, /* cmp_matches */
+
+ NULL,
+ NULL,
+ };
+
+ ftype_register(FT_GUID, &guid_type);
}
diff --git a/epan/guid-utils.h b/epan/guid-utils.h
index d80e2a6458..1448ec4ddb 100644
--- a/epan/guid-utils.h
+++ b/epan/guid-utils.h
@@ -28,6 +28,10 @@
#ifndef __GUID_UTILS_H__
#define __GUID_UTILS_H__
+#define GUID_LEN 16
+
+/* Note: this might be larger than GUID_LEN, so don't overlay data in packets
+ with this. */
typedef struct _e_guid_t {
guint32 data1;
guint16 data2;
diff --git a/epan/h225-persistentdata.c b/epan/h225-persistentdata.c
index f9ae7539a9..4fa043a983 100644
--- a/epan/h225-persistentdata.c
+++ b/epan/h225-persistentdata.c
@@ -75,7 +75,7 @@ h225ras_call_t * find_h225ras_call(h225ras_call_info_key *h225ras_call_key ,int
return h225ras_call;
}
-h225ras_call_t * new_h225ras_call(h225ras_call_info_key *h225ras_call_key, packet_info *pinfo, guint8 *guid, int category)
+h225ras_call_t * new_h225ras_call(h225ras_call_info_key *h225ras_call_key, packet_info *pinfo, e_guid_t *guid, int category)
{
h225ras_call_info_key *new_h225ras_call_key;
h225ras_call_t *h225ras_call = NULL;
@@ -96,14 +96,14 @@ h225ras_call_t * new_h225ras_call(h225ras_call_info_key *h225ras_call_key, packe
h225ras_call->responded = FALSE;
h225ras_call->next_call = NULL;
h225ras_call->req_time=pinfo->fd->abs_ts;
- memcpy(h225ras_call->guid, guid,16);
+ h225ras_call->guid=*guid;
/* store it */
g_hash_table_insert(ras_calls[category], new_h225ras_call_key, h225ras_call);
return h225ras_call;
}
-h225ras_call_t * append_h225ras_call(h225ras_call_t *prev_call, packet_info *pinfo, guint8 *guid, int category _U_)
+h225ras_call_t * append_h225ras_call(h225ras_call_t *prev_call, packet_info *pinfo, e_guid_t *guid, int category _U_)
{
h225ras_call_t *h225ras_call = NULL;
@@ -119,7 +119,7 @@ h225ras_call_t * append_h225ras_call(h225ras_call_t *prev_call, packet_info *pin
h225ras_call->responded = FALSE;
h225ras_call->next_call = NULL;
h225ras_call->req_time=pinfo->fd->abs_ts;
- memcpy(h225ras_call->guid, guid,16);
+ h225ras_call->guid=*guid;
prev_call->next_call = h225ras_call;
return h225ras_call;
diff --git a/epan/h225-persistentdata.h b/epan/h225-persistentdata.h
index aed7972c5f..5defb14874 100644
--- a/epan/h225-persistentdata.h
+++ b/epan/h225-persistentdata.h
@@ -37,7 +37,7 @@
/* Item of ras request list*/
typedef struct _h225ras_call_t {
guint32 requestSeqNum;
- guint8 guid[16];
+ e_guid_t guid;
guint32 req_num; /* frame number request seen */
guint32 rsp_num; /* frame number response seen */
nstime_t req_time; /* arrival time of request */
@@ -54,8 +54,8 @@ typedef struct _h225ras_call_info_key {
/* functions, needed using ras-request and halfcall matching*/
h225ras_call_t * find_h225ras_call(h225ras_call_info_key *h225ras_call_key ,int category);
-h225ras_call_t * new_h225ras_call(h225ras_call_info_key *h225ras_call_key, packet_info *pinfo, guint8 *guid, int category);
-h225ras_call_t * append_h225ras_call(h225ras_call_t *prev_call, packet_info *pinfo, guint8 *guid, int category);
+h225ras_call_t * new_h225ras_call(h225ras_call_info_key *h225ras_call_key, packet_info *pinfo, e_guid_t *guid, int category);
+h225ras_call_t * append_h225ras_call(h225ras_call_t *prev_call, packet_info *pinfo, e_guid_t *guid, int category);
void h225_init_routine(void); /* init routine, used by ethereal */