#.FN_BODY CallIdentifier/guid
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);
#.END
#----------------------------------------------------------------------------------------
#.FN_PARS RequestSeqNum VAL_PTR = &(h225_pi->requestSeqNum)
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;
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. */
} 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 */
/* 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) {
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 */
#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;
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;
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. */
} 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 */
/* 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) {
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 */
#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);
}
#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;
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;
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;
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;
/* 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 */
/* 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 */
/* ***************************TAP for Q931 **********************************/
/****************************************************************************/
void h245_add_to_graph(guint32 new_frame_num);
-#define GUID_LEN 16
-static const guint8 guid_allzero[GUID_LEN] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+static const e_guid_t guid_allzero = {0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
/* defines specific H323 data */
static gchar *q931_calling_number;
/* check if the called number match a LRQ/LCF */
if ( (strcmp(strinfo->to_identity, tmp_listinfo->to_identity)==0)
- && (memcmp(tmp2_h323info->guid, guid_allzero, GUID_LEN) == 0) ){
+ && (memcmp(&tmp2_h323info->guid, &guid_allzero, GUID_LEN) == 0) ){
/* change the call graph to the LRQ/LCF to belong to this call */
strinfo->npackets += change_call_num_graph(tapinfo, tmp_listinfo->call_num, strinfo->call_num);
/* if not guid and RAS and not LRQ, LCF or LRJ return because did not belong to a call */
/* OR, if not guid and is H225 return because doesn't belong to a call */
- if ((memcmp(pi->guid, guid_allzero, GUID_LEN) == 0))
+ if ((memcmp(&pi->guid, &guid_allzero, GUID_LEN) == 0))
if ( ((pi->msg_type == H225_RAS) && ((pi->msg_tag < 18) || (pi->msg_tag > 20))) || (pi->msg_type != H225_RAS) )
return 0;
tmp_listinfo=list->data;
if (tmp_listinfo->protocol == VOIP_H323){
tmp_h323info = tmp_listinfo->prot_info;
- if ( (memcmp(tmp_h323info->guid, guid_allzero, GUID_LEN) != 0) && (memcmp(tmp_h323info->guid, pi->guid,GUID_LEN)==0) ){
+ if ( (memcmp(&tmp_h323info->guid, &guid_allzero, GUID_LEN) != 0) && (memcmp(&tmp_h323info->guid, &pi->guid,GUID_LEN)==0) ){
strinfo = (voip_calls_info_t*)(list->data);
break;
}
strinfo->protocol=VOIP_H323;
strinfo->prot_info=g_malloc(sizeof(h323_calls_info_t));
tmp_h323info = strinfo->prot_info;
- tmp_h323info->guid = (guint8 *) g_memdup(pi->guid,GUID_LEN);
+ tmp_h323info->guid = g_memdup(&pi->guid, sizeof pi->guid);
tmp_h323info->h225SetupAddr.type = AT_NONE;
tmp_h323info->h225SetupAddr.len = 0;
tmp_h323info->h245_list = NULL;
#include <glib.h>
#include <stdio.h>
#include <epan/address.h>
+#include <epan/guid-utils.h>
/****************************************************************************/
/* defines voip call state */
/* defines specific H323 data */
typedef struct _h323_calls_info {
- guint8 *guid; /* Call ID to identify a H225 */
+ e_guid_t *guid; /* Call ID to identify a H225 */
GList* h245_list; /* list of H245 Address and ports for tunneling off calls*/
address h225SetupAddr; /* we use the SETUP H225 IP to determine if packets are forward or reverse */
gboolean is_h245;
case VOIP_H323:
tmp_h323info = selected_call_fwd->prot_info;
g_string_sprintfa(filter_string_fwd,
- "((h225.guid == %x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x || q931.call_ref == %x:%x || q931.call_ref == %x:%x) ",
- (guint8)tmp_h323info->guid[0], (guint8)tmp_h323info->guid[1], (guint8)tmp_h323info->guid[2],
- (guint8)tmp_h323info->guid[3], (guint8)tmp_h323info->guid[4], (guint8)tmp_h323info->guid[5], (guint8)tmp_h323info->guid[6],
- (guint8)tmp_h323info->guid[7], (guint8)tmp_h323info->guid[8], (guint8)tmp_h323info->guid[9], (guint8)tmp_h323info->guid[10],
- (guint8)tmp_h323info->guid[11], (guint8)tmp_h323info->guid[12], (guint8)tmp_h323info->guid[13], (guint8)tmp_h323info->guid[14],
- (guint8)tmp_h323info->guid[15], (guint8)(tmp_h323info->q931_crv & 0xff), (guint8)((tmp_h323info->q931_crv & 0xff00)>>8)
- , (guint8)(tmp_h323info->q931_crv2 & 0xff), (guint8)((tmp_h323info->q931_crv2 & 0xff00)>>8));
+ "((h225.guid == %s || q931.call_ref == %x:%x || q931.call_ref == %x:%x) ",
+ guid_to_str(&tmp_h323info->guid[0]),
+ (guint8)(tmp_h323info->q931_crv & 0xff),
+ (guint8)((tmp_h323info->q931_crv & 0xff00)>>8),
+ (guint8)(tmp_h323info->q931_crv2 & 0xff),
+ (guint8)((tmp_h323info->q931_crv2 & 0xff00)>>8));
list = g_list_first(tmp_h323info->h245_list);
while (list)
{