#include "globals.h"
#include <epan/tap.h>
+#include <epan/tap-voip.h>
#include <epan/dissectors/packet-sip.h>
#include <epan/dissectors/packet-mtp3.h>
#include <epan/dissectors/packet-isup.h>
#include <epan/dissectors/packet-h245.h>
#include <epan/dissectors/packet-q931.h>
#include <epan/dissectors/packet-sdp.h>
-#include <plugins/mgcp/packet-mgcp.h>
+#include <epan/dissectors/packet-mgcp.h>
#include <epan/dissectors/packet-actrace.h>
#include <epan/dissectors/packet-rtp.h>
#include <epan/dissectors/packet-rtp-events.h>
#include <epan/dissectors/packet-t38.h>
+#include <epan/dissectors/packet-t30.h>
#include <epan/dissectors/packet-h248.h>
+#include <epan/dissectors/packet-sccp.h>
+#include <plugins/unistim/packet-unistim.h>
#include <epan/conversation.h>
#include <epan/rtp_pt.h>
#include <epan/ws_strsplit.h>
#include "simple_dialog.h"
#ifdef HAVE_LIBPORTAUDIO
-#if GTK_MAJOR_VERSION >= 2
#include "rtp_player.h"
-#endif /* GTK_MAJOR_VERSION >= 2 */
#endif /* HAVE_LIBPORTAUDIO */
-const char *voip_call_state_name[7]={
+#ifdef NEED_G_ASCII_STRCASECMP_H
+#include "../epan/g_ascii_strcasecmp.h"
+#endif
+
+const char *voip_call_state_name[8]={
+ "",
"CALL SETUP",
"RINGING",
"IN CALL",
"AC_ISDN",
"AC_CAS",
"T.38",
- "H.248"
+ "H.248",
+ "SCCP",
+ "BSSMAP",
+ "RANAP",
+ "UNISTIM",
+ "VoIP"
};
typedef struct {
/****************************************************************************/
/* the one and only global voip_calls_tapinfo_t structure */
static voip_calls_tapinfo_t the_tapinfo_struct =
- {0, NULL, 0, NULL, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ {0, NULL, 0, NULL, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
/* the one and only global voip_rtp_tapinfo_t structure */
static voip_rtp_tapinfo_t the_tapinfo_rtp_struct =
/* when there is a [re]reading of packet's */
void voip_calls_reset(voip_calls_tapinfo_t *tapinfo)
{
- voip_calls_info_t *strinfo;
- sip_calls_info_t *tmp_sipinfo;
- h323_calls_info_t *tmp_h323info;
- h245_address_t *h245_add;
-
+ voip_calls_info_t *callsinfo;
+ voip_rtp_tapinfo_t *rtp_tapinfo = &the_tapinfo_rtp_struct;
+ voip_rtp_stream_info_t *strinfo;
graph_analysis_item_t *graph_item;
-
GList* list;
- GList* list2;
#ifdef HAVE_LIBPORTAUDIO
-#if GTK_MAJOR_VERSION >= 2
/* reset the RTP player */
reset_rtp_player();
-#endif
#endif
/* free the data items first */
- list = g_list_first(tapinfo->strinfo_list);
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
- strinfo = list->data;
- g_free(strinfo->from_identity);
- g_free(strinfo->to_identity);
- g_free((void *)(strinfo->initial_speaker.data));
+ callsinfo = list->data;
+ if (callsinfo->call_id)
+ g_free(callsinfo->call_id);
+ g_free(callsinfo->from_identity);
+ g_free(callsinfo->to_identity);
+ g_free((void *)(callsinfo->initial_speaker.data));
+ if (callsinfo->protocol_name)
+ g_free(callsinfo->protocol_name);
+ if (callsinfo->call_comment)
+ g_free(callsinfo->call_comment);
- if (strinfo->free_prot_info && strinfo->prot_info)
- strinfo->free_prot_info(strinfo->prot_info);
+ if (callsinfo->free_prot_info && callsinfo->prot_info)
+ callsinfo->free_prot_info(callsinfo->prot_info);
g_free(list->data);
list = g_list_next(list);
}
- g_list_free(tapinfo->strinfo_list);
- tapinfo->strinfo_list = NULL;
+ g_list_free(tapinfo->callsinfo_list);
+ tapinfo->callsinfo_list = NULL;
tapinfo->ncalls = 0;
tapinfo->npackets = 0;
tapinfo->start_packets = 0;
++(tapinfo->launch_count);
+ /* free the strinfo data items first */
+ list = g_list_first(rtp_tapinfo->list);
+ while(list)
+ {
+ strinfo = list->data;
+ g_free(strinfo->pt_str);
+ list = g_list_next(list);
+
+ }
+ g_list_free(rtp_tapinfo->list);
+ rtp_tapinfo->list = NULL;
+
return;
}
}
/* add this RTP for future listening using the RTP Player*/
-#if GTK_MAJOR_VERSION >= 2
#ifdef HAVE_LIBPORTAUDIO
add_rtp_packet(pi, pinfo);
-#endif
#endif
/* check wether we already have a RTP stream with this setup frame and ssrc in the list */
strinfo->end_stream = FALSE;
strinfo->pt = pi->info_payload_type;
strinfo->pt_str = NULL;
+ strinfo->is_srtp = pi->info_is_srtp;
/* if it is dynamic payload, let use the conv data to see if it is defined */
if ( (strinfo->pt>95) && (strinfo->pt<128) ) {
/* Use existing packet info if available */
if (!strinfo->pt_str) strinfo->pt_str = g_strdup(val_to_str(strinfo->pt, rtp_payload_type_short_vals, "%u"));
strinfo->npackets = 0;
strinfo->first_frame_num = pinfo->fd->num;
- strinfo->start_rel_sec = pinfo->fd->rel_ts.secs;
+ strinfo->start_rel_sec = (guint32) (pinfo->fd->rel_ts.secs);
strinfo->start_rel_usec = pinfo->fd->rel_ts.nsecs/1000;
strinfo->setup_frame_number = pi->info_setup_frame_num;
strinfo->rtp_event = -1;
if (strinfo!=NULL){
/* Add the info to the existing RTP stream */
strinfo->npackets++;
- strinfo->stop_rel_sec = pinfo->fd->rel_ts.secs;
+ strinfo->stop_rel_sec = (guint32) (pinfo->fd->rel_ts.secs);
strinfo->stop_rel_usec = pinfo->fd->rel_ts.nsecs/1000;
/* process RTP Event */
if (rtp_listinfo->first_frame_num == gai->frame_num){
duration = (rtp_listinfo->stop_rel_sec*1000000 + rtp_listinfo->stop_rel_usec) - (rtp_listinfo->start_rel_sec*1000000 + rtp_listinfo->start_rel_usec);
g_free(gai->comment);
- gai->comment = g_strdup_printf("RTP Num packets:%u Duration:%u.%03us ssrc:%u", rtp_listinfo->npackets, duration/1000000,(duration%1000000)/1000, rtp_listinfo->ssrc);
+ gai->comment = g_strdup_printf("%s Num packets:%u Duration:%u.%03us SSRC:0x%X",
+ (rtp_listinfo->is_srtp)?"SRTP":"RTP", rtp_listinfo->npackets,
+ duration/1000000,(duration%1000000)/1000, rtp_listinfo->ssrc);
break;
}
new_gai->port_src = rtp_listinfo->src_port;
new_gai->port_dst = rtp_listinfo->dest_port;
duration = (rtp_listinfo->stop_rel_sec*1000000 + rtp_listinfo->stop_rel_usec) - (rtp_listinfo->start_rel_sec*1000000 + rtp_listinfo->start_rel_usec);
- new_gai->frame_label = g_strdup_printf("RTP (%s) %s", rtp_listinfo->pt_str, (rtp_listinfo->rtp_event == -1)?"":val_to_str(rtp_listinfo->rtp_event, rtp_event_type_values, "Unknown RTP Event"));
- g_free(rtp_listinfo->pt_str);
- new_gai->comment = g_strdup_printf("RTP Num packets:%u Duration:%u.%03us ssrc:%u", rtp_listinfo->npackets, duration/1000000,(duration%1000000)/1000, rtp_listinfo->ssrc);
+ new_gai->frame_label = g_strdup_printf("%s (%s) %s", (rtp_listinfo->is_srtp)?"SRTP":"RTP", rtp_listinfo->pt_str, (rtp_listinfo->rtp_event == -1)?"":val_to_str(rtp_listinfo->rtp_event, rtp_event_type_values, "Unknown RTP Event"));
+ new_gai->comment = g_strdup_printf("%s Num packets:%u Duration:%u.%03us SSRC:0x%X",
+ (rtp_listinfo->is_srtp)?"SRTP":"RTP", rtp_listinfo->npackets,
+ duration/1000000,(duration%1000000)/1000, rtp_listinfo->ssrc);
new_gai->conv_num = conv_num;
new_gai->display=FALSE;
new_gai->line_style = 2; /* the arrow line will be 2 pixels width */
{
voip_calls_tapinfo_t *tapinfo = &the_tapinfo_struct;
- voip_calls_info_t *strinfo = NULL;
+ voip_calls_info_t *callsinfo = NULL;
voip_calls_info_t *tmp_listinfo;
GList* voip_calls_graph_list;
GList* list;
*/
if ( (pi->setup_frame_number == 0) || (gai == NULL) ){
/* check whether we already have a call with these parameters in the list */
- list = g_list_first(tapinfo->strinfo_list);
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
tmp_listinfo=list->data;
if (tmp_listinfo->protocol == MEDIA_T38){
- strinfo = (voip_calls_info_t*)(list->data);
+ callsinfo = (voip_calls_info_t*)(list->data);
break;
}
list = g_list_next (list);
}
/* not in the list? then create a new entry */
- if (strinfo==NULL){
- strinfo = g_malloc(sizeof(voip_calls_info_t));
- strinfo->call_active_state = VOIP_ACTIVE;
- strinfo->call_state = VOIP_UNKNOWN;
- strinfo->from_identity=g_strdup("T38 Media only");
- strinfo->to_identity=g_strdup("T38 Media only");
- COPY_ADDRESS(&(strinfo->initial_speaker),&(pinfo->src));
- strinfo->first_frame_num=pinfo->fd->num;
- strinfo->selected=FALSE;
- strinfo->start_sec=pinfo->fd->rel_ts.secs;
- strinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
- strinfo->protocol=MEDIA_T38;
- strinfo->prot_info=NULL;
- strinfo->free_prot_info = NULL;
- strinfo->npackets = 0;
- strinfo->call_num = tapinfo->ncalls++;
- tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, strinfo);
- }
- ++(strinfo->npackets);
+ if (callsinfo==NULL){
+ callsinfo = g_malloc0(sizeof(voip_calls_info_t));
+ callsinfo->call_active_state = VOIP_ACTIVE;
+ callsinfo->call_state = VOIP_UNKNOWN;
+ callsinfo->from_identity=g_strdup("T38 Media only");
+ callsinfo->to_identity=g_strdup("T38 Media only");
+ COPY_ADDRESS(&(callsinfo->initial_speaker),&(pinfo->src));
+ callsinfo->first_frame_num=pinfo->fd->num;
+ callsinfo->selected=FALSE;
+ callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->protocol=MEDIA_T38;
+ callsinfo->prot_info=NULL;
+ callsinfo->free_prot_info = NULL;
+ callsinfo->npackets = 0;
+ callsinfo->call_num = tapinfo->ncalls++;
+ tapinfo->callsinfo_list = g_list_append(tapinfo->callsinfo_list, callsinfo);
+ }
+ ++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
- conv_num = (int) strinfo->call_num;
+ conv_num = (int) callsinfo->call_num;
}
/* at this point we should have found the call num for this t38 packets belong */
/* add the item to the graph list */
if (pi->type_msg == 0) { /* 0=t30-indicator */
- frame_label = g_strdup(val_to_str(pi->t30ind_value, t30_indicator_vals, "Ukn (0x%02X)") );
- comment = g_strdup_printf("t38:t30 Ind:%s",val_to_str(pi->t30ind_value, t30_indicator_vals, "Ukn (0x%02X)") );
+ frame_label = g_strdup(val_to_str(pi->t30ind_value, t38_T30_indicator_vals, "Ukn (0x%02X)") );
+ comment = g_strdup_printf("t38:t30 Ind:%s",val_to_str(pi->t30ind_value, t38_T30_indicator_vals, "Ukn (0x%02X)") );
line_style = 1;
} else if (pi->type_msg == 1) { /* 1=data */
switch(pi->Data_Field_field_type_value){
case 2: /* hdlc-fcs-OK */
case 4: /* hdlc-fcs-OK-sig-end */
frame_label = g_strdup_printf("%s %s", val_to_str(pi->t30_Facsimile_Control & 0x7F, t30_facsimile_control_field_vals_short, "Ukn (0x%02X)"), pi->desc);
- comment = g_strdup_printf("t38:%s:HDLC:%s",val_to_str(pi->data_value, t30_data_vals, "Ukn (0x%02X)"), val_to_str(pi->t30_Facsimile_Control & 0x7F, t30_facsimile_control_field_vals, "Ukn (0x%02X)"));
+ comment = g_strdup_printf("t38:%s:HDLC:%s",val_to_str(pi->data_value, t38_T30_data_vals, "Ukn (0x%02X)"), val_to_str(pi->t30_Facsimile_Control & 0x7F, t30_facsimile_control_field_vals, "Ukn (0x%02X)"));
break;
case 3: /* hdlc-fcs-BAD */
case 5: /* hdlc-fcs-BAD-sig-end */
frame_label = g_strdup(pi->Data_Field_field_type_value == 3 ? "fcs-BAD" : "fcs-BAD-sig-end");
- comment = g_strdup_printf("WARNING: received t38:%s:HDLC:%s", val_to_str(pi->data_value, t30_data_vals, "Ukn (0x%02X)"), pi->Data_Field_field_type_value == 3 ? "fcs-BAD" : "fcs-BAD-sig-end");
+ comment = g_strdup_printf("WARNING: received t38:%s:HDLC:%s", val_to_str(pi->data_value, t38_T30_data_vals, "Ukn (0x%02X)"), pi->Data_Field_field_type_value == 3 ? "fcs-BAD" : "fcs-BAD-sig-end");
break;
case 7: /* t4-non-ecm-sig-end */
duration = nstime_to_sec(&pinfo->fd->rel_ts) - pi->time_first_t4_data;
- frame_label = g_strdup_printf("t4-non-ecm-data:%s",val_to_str(pi->data_value, t30_data_vals, "Ukn (0x%02X)") );
- comment = g_strdup_printf("t38:t4-non-ecm-data:%s Duration: %.2fs %s",val_to_str(pi->data_value, t30_data_vals, "Ukn (0x%02X)"), duration, pi->desc_comment );
+ frame_label = g_strdup_printf("t4-non-ecm-data:%s",val_to_str(pi->data_value, t38_T30_data_vals, "Ukn (0x%02X)") );
+ comment = g_strdup_printf("t38:t4-non-ecm-data:%s Duration: %.2fs %s",val_to_str(pi->data_value, t38_T30_data_vals, "Ukn (0x%02X)"), duration, pi->desc_comment );
insert_to_graph(tapinfo, pinfo, frame_label, comment, (guint16)conv_num, &(pinfo->src), &(pinfo->dst), line_style, pi->time_first_t4_data, pi->frame_num_first_t4_data);
break;
}
be compared with existing calls */
voip_calls_info_t *tmp_listinfo;
- voip_calls_info_t *strinfo = NULL;
+ voip_calls_info_t *callsinfo = NULL;
sip_calls_info_t *tmp_sipinfo = NULL;
GList* list;
address tmp_src, tmp_dst;
}
/* check whether we already have a call with these parameters in the list */
- list = g_list_first(tapinfo->strinfo_list);
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
tmp_listinfo=list->data;
if (tmp_listinfo->protocol == VOIP_SIP){
tmp_sipinfo = tmp_listinfo->prot_info;
if (strcmp(tmp_sipinfo->call_identifier,pi->tap_call_id)==0){
- strinfo = (voip_calls_info_t*)(list->data);
+ callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
}
/* not in the list? then create a new entry if the message is INVITE -i.e. if this session is a call*/
- if ((strinfo==NULL) &&(pi->request_method!=NULL)){
+ if ((callsinfo==NULL) &&(pi->request_method!=NULL)){
if (strcmp(pi->request_method,"INVITE")==0){
- strinfo = g_malloc(sizeof(voip_calls_info_t));
- strinfo->call_active_state = VOIP_ACTIVE;
- strinfo->call_state = VOIP_CALL_SETUP;
- strinfo->from_identity=g_strdup(pi->tap_from_addr);
- strinfo->to_identity=g_strdup(pi->tap_to_addr);
- COPY_ADDRESS(&(strinfo->initial_speaker),&(pinfo->src));
- strinfo->first_frame_num=pinfo->fd->num;
- strinfo->selected=FALSE;
- strinfo->start_sec=pinfo->fd->rel_ts.secs;
- strinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
- strinfo->protocol=VOIP_SIP;
- strinfo->prot_info=g_malloc(sizeof(sip_calls_info_t));
- strinfo->free_prot_info = free_sip_info;
- tmp_sipinfo = strinfo->prot_info;
+ callsinfo = g_malloc0(sizeof(voip_calls_info_t));
+ callsinfo->call_active_state = VOIP_ACTIVE;
+ callsinfo->call_state = VOIP_CALL_SETUP;
+ callsinfo->from_identity=g_strdup(pi->tap_from_addr);
+ callsinfo->to_identity=g_strdup(pi->tap_to_addr);
+ COPY_ADDRESS(&(callsinfo->initial_speaker),&(pinfo->src));
+ callsinfo->first_frame_num=pinfo->fd->num;
+ callsinfo->selected=FALSE;
+ callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->protocol=VOIP_SIP;
+ callsinfo->prot_info=g_malloc(sizeof(sip_calls_info_t));
+ callsinfo->free_prot_info = free_sip_info;
+ tmp_sipinfo = callsinfo->prot_info;
tmp_sipinfo->call_identifier = g_strdup(pi->tap_call_id);
tmp_sipinfo->sip_state = SIP_INVITE_SENT;
tmp_sipinfo->invite_cseq = pi->tap_cseq_number;
- strinfo->npackets = 0;
- strinfo->call_num = tapinfo->ncalls++;
- tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, strinfo);
+ callsinfo->npackets = 0;
+ callsinfo->call_num = tapinfo->ncalls++;
+ tapinfo->callsinfo_list = g_list_append(tapinfo->callsinfo_list, callsinfo);
}
}
- if (strinfo!=NULL){
+ if (callsinfo!=NULL){
/* let's analyze the call state */
frame_label = g_strdup_printf("%u %s", pi->response_code, pi->reason_phrase );
comment = g_strdup_printf("SIP Status");
- if ((tmp_sipinfo && pi->tap_cseq_number == tmp_sipinfo->invite_cseq)&&(ADDRESSES_EQUAL(&tmp_dst,&(strinfo->initial_speaker)))){
+ if ((tmp_sipinfo && pi->tap_cseq_number == tmp_sipinfo->invite_cseq)&&(ADDRESSES_EQUAL(&tmp_dst,&(callsinfo->initial_speaker)))){
if ((pi->response_code > 199) && (pi->response_code<300) && (tmp_sipinfo->sip_state == SIP_INVITE_SENT)){
tmp_sipinfo->sip_state = SIP_200_REC;
}
else if ((pi->response_code>299)&&(tmp_sipinfo->sip_state == SIP_INVITE_SENT)){
- strinfo->call_state = VOIP_REJECTED;
+ callsinfo->call_state = VOIP_REJECTED;
tapinfo->rejected_calls++;
}
}
else{
frame_label = g_strdup(pi->request_method);
- if ((strcmp(pi->request_method,"INVITE")==0)&&(ADDRESSES_EQUAL(&tmp_src,&(strinfo->initial_speaker)))){
+ if ((strcmp(pi->request_method,"INVITE")==0)&&(ADDRESSES_EQUAL(&tmp_src,&(callsinfo->initial_speaker)))){
tmp_sipinfo->invite_cseq = pi->tap_cseq_number;
- strinfo->call_state = VOIP_CALL_SETUP;
- comment = g_strdup_printf("SIP From: %s To:%s", strinfo->from_identity, strinfo->to_identity);
+ callsinfo->call_state = VOIP_CALL_SETUP;
+ comment = g_strdup_printf("SIP From: %s To:%s", callsinfo->from_identity, callsinfo->to_identity);
}
else if ((strcmp(pi->request_method,"ACK")==0)&&(pi->tap_cseq_number == tmp_sipinfo->invite_cseq)
- &&(ADDRESSES_EQUAL(&tmp_src,&(strinfo->initial_speaker)))&&(tmp_sipinfo->sip_state==SIP_200_REC)
- &&(strinfo->call_state == VOIP_CALL_SETUP)){
- strinfo->call_state = VOIP_IN_CALL;
+ &&(ADDRESSES_EQUAL(&tmp_src,&(callsinfo->initial_speaker)))&&(tmp_sipinfo->sip_state==SIP_200_REC)
+ &&(callsinfo->call_state == VOIP_CALL_SETUP)){
+ callsinfo->call_state = VOIP_IN_CALL;
comment = g_strdup_printf("SIP Request");
}
else if (strcmp(pi->request_method,"BYE")==0){
- strinfo->call_state = VOIP_COMPLETED;
+ callsinfo->call_state = VOIP_COMPLETED;
tapinfo->completed_calls++;
comment = g_strdup_printf("SIP Request");
}
else if ((strcmp(pi->request_method,"CANCEL")==0)&&(pi->tap_cseq_number == tmp_sipinfo->invite_cseq)
- &&(ADDRESSES_EQUAL(&tmp_src,&(strinfo->initial_speaker)))&&(strinfo->call_state==VOIP_CALL_SETUP)){
- strinfo->call_state = VOIP_CANCELLED;
+ &&(ADDRESSES_EQUAL(&tmp_src,&(callsinfo->initial_speaker)))&&(callsinfo->call_state==VOIP_CALL_SETUP)){
+ callsinfo->call_state = VOIP_CANCELLED;
tmp_sipinfo->sip_state = SIP_CANCEL_SENT;
comment = g_strdup_printf("SIP Request");
} else {
}
}
- strinfo->stop_sec=pinfo->fd->rel_ts.secs;
- strinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
- strinfo->last_frame_num=pinfo->fd->num;
- ++(strinfo->npackets);
+ callsinfo->stop_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->last_frame_num=pinfo->fd->num;
+ ++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
/* add to the graph */
- add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+ add_to_graph(tapinfo, pinfo, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
g_free(comment);
g_free(frame_label);
g_free((void *)tmp_src.data);
{
voip_calls_tapinfo_t *tapinfo = &the_tapinfo_struct;
voip_calls_info_t *tmp_listinfo;
- voip_calls_info_t *strinfo = NULL;
+ voip_calls_info_t *callsinfo = NULL;
isup_calls_info_t *tmp_isupinfo;
gboolean found = FALSE;
gboolean forward = FALSE;
/*voip_calls_tapinfo_t *tapinfo = &the_tapinfo_struct; unused */
const isup_tap_rec_t *pi = isup_info;
-
-
+
/* check if the lower layer is MTP matching the frame number */
if (mtp3_frame_num != pinfo->fd->num) return 0;
-
+
/* check whether we already have a call with these parameters in the list */
- list = g_list_first(tapinfo->strinfo_list);
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
right_pair = TRUE;
if ((tmp_isupinfo->cic == pinfo->circuit_id)&&(tmp_isupinfo->ni == mtp3_ni)) {
if ((tmp_isupinfo->opc == mtp3_opc)&&(tmp_isupinfo->dpc == mtp3_dpc)){
forward = TRUE;
- }
- else if ((tmp_isupinfo->dpc == mtp3_opc)&&(tmp_isupinfo->opc == mtp3_dpc)){
+ } else if ((tmp_isupinfo->dpc == mtp3_opc)&&(tmp_isupinfo->opc == mtp3_dpc)){
forward = FALSE;
- }
- else{
- right_pair = FALSE;
- }
+ } else{
+ right_pair = FALSE;
+ }
+
if (right_pair){
/* if there is an IAM for a call that is not in setup state, that means the previous call in the same
cic is no longer active */
if (tmp_listinfo->call_state == VOIP_CALL_SETUP){
found = TRUE;
- }
- else if (pi->message_type != 1){
+ } else if (pi->message_type != 1){
found = TRUE;
- }
- else{
+ } else{
tmp_listinfo->call_active_state=VOIP_INACTIVE;
}
}
+
if (found){
- strinfo = (voip_calls_info_t*)(list->data);
+ callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
-i.e. if this session is a call*/
- if ((strinfo==NULL) &&(pi->message_type==1)){
-
- strinfo = g_malloc(sizeof(voip_calls_info_t));
- strinfo->call_active_state = VOIP_ACTIVE;
- strinfo->call_state = VOIP_UNKNOWN;
- COPY_ADDRESS(&(strinfo->initial_speaker),&(pinfo->src));
- strinfo->selected=FALSE;
- strinfo->first_frame_num=pinfo->fd->num;
- strinfo->start_sec=pinfo->fd->rel_ts.secs;
- strinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
- strinfo->protocol=VOIP_ISUP;
+ if ((callsinfo==NULL) &&(pi->message_type==1)){
+ callsinfo = g_malloc0(sizeof(voip_calls_info_t));
+ callsinfo->call_active_state = VOIP_ACTIVE;
+ callsinfo->call_state = VOIP_UNKNOWN;
+ COPY_ADDRESS(&(callsinfo->initial_speaker),&(pinfo->src));
+ callsinfo->selected=FALSE;
+ callsinfo->first_frame_num=pinfo->fd->num;
+ callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->protocol=VOIP_ISUP;
if (pi->calling_number!=NULL){
- strinfo->from_identity=g_strdup(pi->calling_number);
+ callsinfo->from_identity=g_strdup(pi->calling_number);
}
if (pi->called_number!=NULL){
- strinfo->to_identity=g_strdup(pi->called_number);
+ callsinfo->to_identity=g_strdup(pi->called_number);
}
- strinfo->prot_info=g_malloc(sizeof(isup_calls_info_t));
- strinfo->free_prot_info = g_free;
- tmp_isupinfo=strinfo->prot_info;
+ callsinfo->prot_info=g_malloc(sizeof(isup_calls_info_t));
+ callsinfo->free_prot_info = g_free;
+ tmp_isupinfo=callsinfo->prot_info;
tmp_isupinfo->opc = mtp3_opc;
tmp_isupinfo->dpc = mtp3_dpc;
tmp_isupinfo->ni = mtp3_ni;
tmp_isupinfo->cic = pinfo->circuit_id;
- strinfo->npackets = 0;
- strinfo->call_num = tapinfo->ncalls++;
- tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, strinfo);
+ callsinfo->npackets = 0;
+ callsinfo->call_num = tapinfo->ncalls++;
+ tapinfo->callsinfo_list = g_list_append(tapinfo->callsinfo_list, callsinfo);
}
- if (strinfo!=NULL){
- strinfo->stop_sec=pinfo->fd->rel_ts.secs;
- strinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
- strinfo->last_frame_num=pinfo->fd->num;
- ++(strinfo->npackets);
+
+ if (callsinfo!=NULL){
+ callsinfo->stop_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->last_frame_num=pinfo->fd->num;
+ ++(callsinfo->npackets);
/* Let's analyze the call state */
frame_label = g_strdup_printf("Unknown");
}
- if (strinfo->npackets == 1){ /* this is the first packet, that must be an IAM */
+ if (callsinfo->npackets == 1){ /* this is the first packet, that must be an IAM */
+
if ((pi->calling_number!=NULL)&&(pi->called_number !=NULL)){
comment = g_strdup_printf("Call from %s to %s",
pi->calling_number, pi->called_number);
}
- }
- else if (strinfo->npackets == 2){ /* in the second packet we show the SPs */
+ } else if (callsinfo->npackets == 2){ /* in the second packet we show the SPs */
if (forward){
comment = g_strdup_printf("%i-%i -> %i-%i. Cic:%i",
mtp3_ni, mtp3_opc,
mtp3_ni, mtp3_dpc, pinfo->circuit_id);
-
- }
- else{
+ } else {
comment = g_strdup_printf("%i-%i -> %i-%i. Cic:%i",
mtp3_ni, mtp3_dpc,
mtp3_ni, mtp3_opc, pinfo->circuit_id);
-
}
}
+
switch(pi->message_type){
case 1: /* IAM */
- strinfo->call_state=VOIP_CALL_SETUP;
+ callsinfo->call_state=VOIP_CALL_SETUP;
break;
case 7: /* CONNECT */
case 9: /* ANSWER */
- strinfo->call_state=VOIP_IN_CALL;
+ callsinfo->call_state=VOIP_IN_CALL;
break;
case 12: /* RELEASE */
- if (strinfo->call_state==VOIP_CALL_SETUP){
+ if (callsinfo->call_state==VOIP_CALL_SETUP){
if (forward){
- strinfo->call_state=VOIP_CANCELLED;
+ callsinfo->call_state=VOIP_CANCELLED;
}
else{
- strinfo->call_state=VOIP_REJECTED;
+ callsinfo->call_state=VOIP_REJECTED;
tapinfo->rejected_calls++;
}
}
- else if (strinfo->call_state == VOIP_IN_CALL){
- strinfo->call_state = VOIP_COMPLETED;
+ else if (callsinfo->call_state == VOIP_IN_CALL){
+ callsinfo->call_state = VOIP_COMPLETED;
tapinfo->completed_calls++;
}
for (i=0;(q931_cause_code_vals[i].strptr!=NULL)&& (q931_cause_code_vals[i].value!=pi->cause_value);i++);
++(tapinfo->npackets);
/* add to the graph */
- add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+ add_to_graph(tapinfo, pinfo, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
g_free(comment);
g_free(frame_label);
}
/****************************************************************************/
static gboolean have_mtp3_tap_listener=FALSE;
+static gboolean have_m3ua_tap_listener=FALSE;
void
mtp3_calls_init_tap(void)
}
have_mtp3_tap_listener=TRUE;
}
+
+ if(have_m3ua_tap_listener==FALSE)
+ {
+ error_string = register_tap_listener("m3ua", &(the_tapinfo_struct.mtp3_dummy),
+ NULL,
+ voip_calls_dlg_reset,
+ mtp3_calls_packet,
+ voip_calls_dlg_draw
+ );
+
+ if (error_string != NULL) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ error_string->str);
+ g_string_free(error_string, TRUE);
+ exit(1);
+ }
+ have_m3ua_tap_listener=TRUE;
+ }
+
}
/****************************************************************************/
{
protect_thread_critical_region();
remove_tap_listener(&(the_tapinfo_struct.mtp3_dummy));
+ remove_tap_listener(&(the_tapinfo_struct.m3ua_dummy));
unprotect_thread_critical_region();
have_mtp3_tap_listener=FALSE;
+ have_m3ua_tap_listener=FALSE;
}
/****************************************************************************/
h323_calls_info_t *tmp_h323info,*tmp2_h323info;
actrace_isdn_calls_info_t *tmp_actrace_isdn_info;
voip_calls_info_t *tmp_listinfo;
- voip_calls_info_t *strinfo = NULL;
+ voip_calls_info_t *callsinfo = NULL;
h245_address_t *h245_add = NULL;
gchar *comment;
/* add staff to H323 calls */
if (h225_frame_num == q931_frame_num) {
tmp_h323info = NULL;
- list = g_list_first(tapinfo->strinfo_list);
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
tmp_listinfo=list->data;
if ( (tmp_listinfo->protocol == VOIP_H323) && (tmp_listinfo->call_num == h225_call_num) ){
tmp_h323info = tmp_listinfo->prot_info;
- strinfo = (voip_calls_info_t*)(list->data);
+ callsinfo = (voip_calls_info_t*)(list->data);
/* Add the CRV to the h323 call */
if (tmp_h323info->q931_crv == -1) {
list = g_list_next (list);
}
- if (strinfo != NULL) {
+ if (callsinfo != NULL) {
comment = NULL;
if (h225_cstype == H225_SETUP) {
/* set te calling and called number from the Q931 packet */
if (q931_calling_number != NULL){
- g_free(strinfo->from_identity);
- strinfo->from_identity=g_strdup(q931_calling_number);
+ g_free(callsinfo->from_identity);
+ callsinfo->from_identity=g_strdup(q931_calling_number);
}
if (q931_called_number != NULL){
- g_free(strinfo->to_identity);
- strinfo->to_identity=g_strdup(q931_called_number);
+ g_free(callsinfo->to_identity);
+ callsinfo->to_identity=g_strdup(q931_called_number);
}
/* check if there is an LRQ/LCF that match this Setup */
/* TODO: we are just checking the DialedNumer in LRQ/LCF agains the Setup
we should also check if the h225 signaling IP and port match the destination
Setup ip and port */
- list = g_list_first(tapinfo->strinfo_list);
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
tmp_listinfo=list->data;
tmp2_h323info = tmp_listinfo->prot_info;
/* check if the called number match a LRQ/LCF */
- if ( (strcmp(strinfo->to_identity, tmp_listinfo->to_identity)==0)
+ if ( (strcmp(callsinfo->to_identity, tmp_listinfo->to_identity)==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);
+ callsinfo->npackets += change_call_num_graph(tapinfo, tmp_listinfo->call_num, callsinfo->call_num);
/* remove this LRQ/LCF call entry because we have found the Setup that match them */
g_free(tmp_listinfo->from_identity);
g_list_free(tmp_h323info->h245_list);
tmp_h323info->h245_list = NULL;
g_free(tmp_listinfo->prot_info);
- tapinfo->strinfo_list = g_list_remove(tapinfo->strinfo_list, tmp_listinfo);
+ tapinfo->callsinfo_list = g_list_remove(tapinfo->callsinfo_list, tmp_listinfo);
break;
}
}
list = g_list_next (list);
}
- comment = g_strdup_printf("H225 From: %s To:%s TunnH245:%s FS:%s", strinfo->from_identity, strinfo->to_identity, (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"),
+ comment = g_strdup_printf("H225 From: %s To:%s TunnH245:%s FS:%s", callsinfo->from_identity, callsinfo->to_identity, (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"),
(h225_is_faststart==TRUE?"on":"off"));
} else if (h225_cstype == H225_RELEASE_COMPLET) {
/* get the Q931 Release cause code */
} else if (h245_labels.frame_num == q931_frame_num) {
/* there are empty H225 frames that don't have guid (guaid=0) but they have h245 info,
so the only way to match those frames is with the Q931 CRV number */
- list = g_list_first(tapinfo->strinfo_list);
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
tmp_listinfo=list->data;
address pstn_add;
gchar *comment = NULL;
- strinfo = NULL;
- list = g_list_first(tapinfo->strinfo_list);
+ callsinfo = NULL;
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
tmp_listinfo=list->data;
tmp_actrace_isdn_info = tmp_listinfo->prot_info;
/* TODO: Also check the IP of the Blade, and if the call is complete (no active) */
if ( (tmp_actrace_isdn_info->crv == q931_crv) && (tmp_actrace_isdn_info->trunk == actrace_trunk) ) {
- strinfo = (voip_calls_info_t*)(list->data);
+ callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
SET_ADDRESS(&pstn_add, AT_STRINGZ, 5, g_strdup("PSTN"));
/* if it is a new call, add it to the list */
- if (!strinfo) {
- strinfo = g_malloc(sizeof(voip_calls_info_t));
- strinfo->call_active_state = VOIP_ACTIVE;
- strinfo->call_state = VOIP_CALL_SETUP;
- strinfo->from_identity=g_strdup(q931_calling_number);
- strinfo->to_identity=g_strdup(q931_called_number);
- COPY_ADDRESS(&(strinfo->initial_speaker),actrace_direction?&pstn_add:&(pinfo->src));
- strinfo->first_frame_num=pinfo->fd->num;
- strinfo->selected=FALSE;
- strinfo->start_sec=pinfo->fd->rel_ts.secs;
- strinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
- strinfo->protocol=VOIP_AC_ISDN;
- strinfo->prot_info=g_malloc(sizeof(actrace_isdn_calls_info_t));
- strinfo->free_prot_info = g_free;
- tmp_actrace_isdn_info=strinfo->prot_info;
+ if (!callsinfo) {
+ callsinfo = g_malloc0(sizeof(voip_calls_info_t));
+ callsinfo->call_active_state = VOIP_ACTIVE;
+ callsinfo->call_state = VOIP_CALL_SETUP;
+ callsinfo->from_identity=g_strdup(q931_calling_number);
+ callsinfo->to_identity=g_strdup(q931_called_number);
+ COPY_ADDRESS(&(callsinfo->initial_speaker),actrace_direction?&pstn_add:&(pinfo->src));
+ callsinfo->first_frame_num=pinfo->fd->num;
+ callsinfo->selected=FALSE;
+ callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->protocol=VOIP_AC_ISDN;
+ callsinfo->prot_info=g_malloc(sizeof(actrace_isdn_calls_info_t));
+ callsinfo->free_prot_info = g_free;
+ tmp_actrace_isdn_info=callsinfo->prot_info;
tmp_actrace_isdn_info->crv=q931_crv;
tmp_actrace_isdn_info->trunk=actrace_trunk;
- strinfo->npackets = 0;
- strinfo->call_num = tapinfo->ncalls++;
- tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, strinfo);
+ callsinfo->npackets = 0;
+ callsinfo->call_num = tapinfo->ncalls++;
+ tapinfo->callsinfo_list = g_list_append(tapinfo->callsinfo_list, callsinfo);
}
- strinfo->stop_sec=pinfo->fd->rel_ts.secs;
- strinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
- strinfo->last_frame_num=pinfo->fd->num;
- ++(strinfo->npackets);
+ callsinfo->stop_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->last_frame_num=pinfo->fd->num;
+ ++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
switch(pi->message_type){
case Q931_SETUP:
comment = g_strdup_printf("AC_ISDN trunk:%u Calling: %s Called:%s", actrace_trunk, q931_calling_number, q931_called_number);
- strinfo->call_state=VOIP_CALL_SETUP;
+ callsinfo->call_state=VOIP_CALL_SETUP;
break;
case Q931_CONNECT:
- strinfo->call_state=VOIP_IN_CALL;
+ callsinfo->call_state=VOIP_IN_CALL;
break;
case Q931_RELEASE_COMPLETE:
case Q931_RELEASE:
case Q931_DISCONNECT:
- if (strinfo->call_state==VOIP_CALL_SETUP){
- if (ADDRESSES_EQUAL(&(strinfo->initial_speaker), actrace_direction?&pstn_add:&(pinfo->src) )){ /* forward direction */
- strinfo->call_state=VOIP_CANCELLED;
+ if (callsinfo->call_state==VOIP_CALL_SETUP){
+ if (ADDRESSES_EQUAL(&(callsinfo->initial_speaker), actrace_direction?&pstn_add:&(pinfo->src) )){ /* forward direction */
+ callsinfo->call_state=VOIP_CANCELLED;
}
else{ /* reverse */
- strinfo->call_state=VOIP_REJECTED;
+ callsinfo->call_state=VOIP_REJECTED;
tapinfo->rejected_calls++;
}
- } else if ( (strinfo->call_state!=VOIP_CANCELLED) && (strinfo->call_state!=VOIP_REJECTED) ){
- strinfo->call_state=VOIP_COMPLETED;
+ } else if ( (callsinfo->call_state!=VOIP_CANCELLED) && (callsinfo->call_state!=VOIP_REJECTED) ){
+ callsinfo->call_state=VOIP_COMPLETED;
tapinfo->completed_calls++;
}
if (q931_cause_value != 0xFF){
if (!comment)
comment = g_strdup_printf("AC_ISDN trunk:%u", actrace_trunk );
- add_to_graph(tapinfo, pinfo, val_to_str(pi->message_type, q931_message_type_vals, "<unknown>") , comment, strinfo->call_num,
+ add_to_graph(tapinfo, pinfo, val_to_str(pi->message_type, q931_message_type_vals, "<unknown>") , comment, callsinfo->call_num,
actrace_direction?&pstn_add:&(pinfo->src),
actrace_direction?&(pinfo->src):&pstn_add,
1 );
{
voip_calls_tapinfo_t *tapinfo = &the_tapinfo_struct;
voip_calls_info_t *tmp_listinfo;
- voip_calls_info_t *strinfo = NULL;
+ voip_calls_info_t *callsinfo = NULL;
h323_calls_info_t *tmp_h323info = NULL;
gchar *frame_label;
gchar *comment;
if (!pi->request_available) return 0;
/* check whether we already have a call with this request SeqNum */
- list = g_list_first(tapinfo->strinfo_list);
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
tmp_listinfo=list->data;
if (tmp_listinfo->protocol == VOIP_H323){
tmp_h323info = tmp_listinfo->prot_info;
if (tmp_h323info->requestSeqNum == pi->requestSeqNum) {
- strinfo = (voip_calls_info_t*)(list->data);
+ callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
}
} else {
/* check whether we already have a call with this guid in the list */
- list = g_list_first(tapinfo->strinfo_list);
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
tmp_listinfo=list->data;
tmp_h323info = tmp_listinfo->prot_info;
g_assert(tmp_h323info != NULL);
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);
+ callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
h225_is_faststart = pi->is_faststart;
/* not in the list? then create a new entry */
- if ((strinfo==NULL)){
- strinfo = g_malloc(sizeof(voip_calls_info_t));
- strinfo->call_active_state = VOIP_ACTIVE;
- strinfo->call_state = VOIP_UNKNOWN;
- strinfo->from_identity=g_strdup("");
- strinfo->to_identity=g_strdup("");
- COPY_ADDRESS(&(strinfo->initial_speaker),&(pinfo->src));
- strinfo->selected=FALSE;
- strinfo->first_frame_num=pinfo->fd->num;
- strinfo->start_sec=pinfo->fd->rel_ts.secs;
- strinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
- strinfo->protocol=VOIP_H323;
- strinfo->prot_info=g_malloc(sizeof(h323_calls_info_t));
- strinfo->free_prot_info = free_h225_info;
+ if ((callsinfo==NULL)){
+ callsinfo = g_malloc0(sizeof(voip_calls_info_t));
+ callsinfo->call_active_state = VOIP_ACTIVE;
+ callsinfo->call_state = VOIP_UNKNOWN;
+ callsinfo->from_identity=g_strdup("");
+ callsinfo->to_identity=g_strdup("");
+ COPY_ADDRESS(&(callsinfo->initial_speaker),&(pinfo->src));
+ callsinfo->selected=FALSE;
+ callsinfo->first_frame_num=pinfo->fd->num;
+ callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->protocol=VOIP_H323;
+ callsinfo->prot_info=g_malloc(sizeof(h323_calls_info_t));
+ callsinfo->free_prot_info = free_h225_info;
- tmp_h323info = strinfo->prot_info;
+ tmp_h323info = callsinfo->prot_info;
g_assert(tmp_h323info != NULL);
tmp_h323info->guid = g_memdup(&pi->guid, sizeof pi->guid);
tmp_h323info->h225SetupAddr.type = AT_NONE;
tmp_h323info->q931_crv = -1;
tmp_h323info->q931_crv2 = -1;
tmp_h323info->requestSeqNum = 0;
- strinfo->call_num = tapinfo->ncalls++;
- strinfo->npackets = 0;
+ callsinfo->call_num = tapinfo->ncalls++;
+ callsinfo->npackets = 0;
- tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, strinfo);
+ tapinfo->callsinfo_list = g_list_append(tapinfo->callsinfo_list, callsinfo);
}
- if (strinfo!=NULL){
+ if (callsinfo!=NULL){
h225_frame_num = pinfo->fd->num;
- h225_call_num = strinfo->call_num;
+ h225_call_num = callsinfo->call_num;
/* let's analyze the call state */
COPY_ADDRESS(&(tmp_src),&(pinfo->src));
COPY_ADDRESS(&(tmp_dst),&(pinfo->dst));
- strinfo->stop_sec=pinfo->fd->rel_ts.secs;
- strinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
- strinfo->last_frame_num=pinfo->fd->num;
- ++(strinfo->npackets);
+ callsinfo->stop_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->last_frame_num=pinfo->fd->num;
+ ++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
h245_add->h245_address.type=AT_IPv4;
h245_add->h245_address.len=4;
h245_add->h245_address.data = g_malloc(sizeof(pi->h245_address));
- g_memmove((void *)(h245_add->h245_address.data), &(pi->h245_address), 4);
+ memcpy((void *)(h245_add->h245_address.data), &(pi->h245_address), 4);
h245_add->h245_port = pi->h245_port;
add_h245_Address(tmp_h323info, h245_add);
}
/* Set the Setup address if it was not set */
if (tmp_h323info->h225SetupAddr.type == AT_NONE)
COPY_ADDRESS(&(tmp_h323info->h225SetupAddr), &(pinfo->src));
- strinfo->call_state=VOIP_CALL_SETUP;
+ callsinfo->call_state=VOIP_CALL_SETUP;
comment = g_strdup_printf("H225 TunnH245:%s FS:%s", (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"),
(pi->is_faststart==TRUE?"on":"off"));
break;
case H225_CONNECT:
- strinfo->call_state=VOIP_IN_CALL;
+ callsinfo->call_state=VOIP_IN_CALL;
if (pi->is_faststart == TRUE) tmp_h323info->is_faststart_Proc = TRUE;
comment = g_strdup_printf("H225 TunnH245:%s FS:%s", (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"),
(pi->is_faststart==TRUE?"on":"off"));
break;
case H225_RELEASE_COMPLET:
COPY_ADDRESS(&tmp_src,&(pinfo->src));
- if (strinfo->call_state==VOIP_CALL_SETUP){
+ if (callsinfo->call_state==VOIP_CALL_SETUP){
if (ADDRESSES_EQUAL(&(tmp_h323info->h225SetupAddr),&tmp_src)){ /* forward direction */
- strinfo->call_state=VOIP_CANCELLED;
+ callsinfo->call_state=VOIP_CANCELLED;
}
else{ /* reverse */
- strinfo->call_state=VOIP_REJECTED;
+ callsinfo->call_state=VOIP_REJECTED;
tapinfo->rejected_calls++;
}
} else {
- strinfo->call_state=VOIP_COMPLETED;
+ callsinfo->call_state=VOIP_COMPLETED;
tapinfo->completed_calls++;
}
comment = g_strdup("H225 No Q931 Rel Cause");
switch(pi->msg_tag){
case 18: /* LRQ */
if (!pi->is_duplicate){
- g_free(strinfo->to_identity);
- strinfo->to_identity=g_strdup(pi->dialedDigits);
+ g_free(callsinfo->to_identity);
+ callsinfo->to_identity=g_strdup(pi->dialedDigits);
tmp_h323info->requestSeqNum = pi->requestSeqNum;
}
case 19: /* LCF */
default:
comment = g_strdup("H225 RAS");
}
- frame_label = g_strdup_printf("%s", val_to_str(pi->msg_tag, RasMessage_vals, "<unknown>"));
+ frame_label = g_strdup_printf("%s", val_to_str(pi->msg_tag, h225_RasMessage_vals, "<unknown>"));
} else {
frame_label = g_strdup("H225: Unknown");
comment = g_strdup("");
/* if the frame number exists in graph, append to it*/
if (!append_to_frame_graph(tapinfo, pinfo->fd->num, pi->frame_label, comment)) {
/* if not exist, add to the graph */
- add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+ add_to_graph(tapinfo, pinfo, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
g_free((void *)tmp_src.data);
g_free((void *)tmp_dst.data);
}
}
/* add the frame_label and comment to h245_labels and free the actual one if it is different frame num */
-static void h245_add_label(guint32 new_frame_num, gchar *frame_label, gchar *comment)
+static void h245_add_label(guint32 new_frame_num, const gchar *frame_label, const gchar *comment)
{
h245_free_labels(new_frame_num);
{
voip_calls_tapinfo_t *tapinfo = &the_tapinfo_struct;
voip_calls_info_t *tmp_listinfo;
- voip_calls_info_t *strinfo = NULL;
+ voip_calls_info_t *callsinfo = NULL;
h323_calls_info_t *tmp_h323info;
gchar *frame_label;
gchar *comment;
const h245_packet_info *pi = H245info;
/* check if Tunneling is OFF and we have a call with this H245 add */
- list = g_list_first(tapinfo->strinfo_list);
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
tmp_listinfo=list->data;
h245_add=list2->data;
if ( (ADDRESSES_EQUAL(&(h245_add->h245_address),&tmp_src) && (h245_add->h245_port == pinfo->srcport))
|| (ADDRESSES_EQUAL(&(h245_add->h245_address),&tmp_dst) && (h245_add->h245_port == pinfo->destport)) ){
- strinfo = (voip_calls_info_t*)(list->data);
+ callsinfo = (voip_calls_info_t*)(list->data);
- ++(strinfo->npackets);
+ ++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
}
list2 = g_list_next(list2);
}
- if (strinfo!=NULL) break;
+ if (callsinfo!=NULL) break;
g_free((void *)tmp_src.data);
g_free((void *)tmp_dst.data);
}
}
/* Tunnel is OFF, and we matched the h245 add so we add it to graph */
- if (strinfo!=NULL){
- ++(strinfo->npackets);
+ if (callsinfo!=NULL){
+ ++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
frame_label = g_strdup(pi->frame_label);
/* if the frame number exists in graph, append to it*/
if (!append_to_frame_graph(tapinfo, pinfo->fd->num, frame_label, comment)) {
/* if not exist, add to the graph */
- add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+ add_to_graph(tapinfo, pinfo, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
}
g_free(frame_label);
g_free(comment);
voip_calls_tapinfo_t *tapinfo = &the_tapinfo_struct;
voip_calls_info_t *tmp_listinfo;
- voip_calls_info_t *strinfo = NULL;
+ voip_calls_info_t *callsinfo = NULL;
mgcp_calls_info_t *tmp_mgcpinfo = NULL;
GList* list;
GList* listGraph;
if ((pi->mgcp_type == MGCP_REQUEST) && !pi->is_duplicate ){
/* check whether we already have a call with this Endpoint and it is active*/
- list = g_list_first(tapinfo->strinfo_list);
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
tmp_listinfo=list->data;
if ((tmp_listinfo->protocol == VOIP_MGCP) && (tmp_listinfo->call_active_state == VOIP_ACTIVE)){
tmp_mgcpinfo = tmp_listinfo->prot_info;
if (pi->endpointId != NULL){
- if (g_strcasecmp(tmp_mgcpinfo->endpointId,pi->endpointId) == 0){
+ if (g_ascii_strcasecmp(tmp_mgcpinfo->endpointId,pi->endpointId) == 0){
/*
check first if it is an ended call. We can still match packets to this Endpoint 2 seconds
after the call has been released
{
tmp_listinfo->call_active_state = VOIP_INACTIVE;
} else {
- strinfo = (voip_calls_info_t*)(list->data);
+ callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
}
/* there is no call with this Endpoint, lets see if this a new call or not */
- if (strinfo == NULL){
+ if (callsinfo == NULL){
if ( (strcmp(pi->code, "NTFY") == 0) && isSignal("hd", pi->observedEvents) ){ /* off hook transition */
/* this is a new call from the Endpoint */
fromEndpoint = TRUE;
gai = listGraph->data;
if (gai->frame_num == pi->req_num){
/* there is a request that match, so look the associated call with this call_num */
- list = g_list_first(tapinfo->strinfo_list);
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
tmp_listinfo=list->data;
if (tmp_listinfo->protocol == VOIP_MGCP){
if (tmp_listinfo->call_num == gai->conv_num){
tmp_mgcpinfo = tmp_listinfo->prot_info;
- strinfo = (voip_calls_info_t*)(list->data);
+ callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
list = g_list_next (list);
}
- if (strinfo != NULL) break;
+ if (callsinfo != NULL) break;
}
listGraph = g_list_next(listGraph);
}
/* if there is not a matching request, just return */
- if (strinfo == NULL) return 0;
+ if (callsinfo == NULL) return 0;
} else return 0;
/* not in the list? then create a new entry */
- if (strinfo==NULL){
- strinfo = g_malloc(sizeof(voip_calls_info_t));
- strinfo->call_active_state = VOIP_ACTIVE;
- strinfo->call_state = VOIP_CALL_SETUP;
+ if (callsinfo==NULL){
+ callsinfo = g_malloc0(sizeof(voip_calls_info_t));
+ callsinfo->call_active_state = VOIP_ACTIVE;
+ callsinfo->call_state = VOIP_CALL_SETUP;
if (fromEndpoint) {
- strinfo->from_identity=g_strdup(pi->endpointId);
- strinfo->to_identity=g_strdup("");
+ callsinfo->from_identity=g_strdup(pi->endpointId);
+ callsinfo->to_identity=g_strdup("");
} else {
- strinfo->from_identity=g_strdup("");
- strinfo->to_identity=g_strdup(pi->endpointId);
- }
- COPY_ADDRESS(&(strinfo->initial_speaker),&(pinfo->src));
- strinfo->first_frame_num=pinfo->fd->num;
- strinfo->selected=FALSE;
- strinfo->start_sec=pinfo->fd->rel_ts.secs;
- strinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
- strinfo->protocol=VOIP_MGCP;
- strinfo->prot_info=g_malloc(sizeof(mgcp_calls_info_t));
- strinfo->free_prot_info = g_free;
- tmp_mgcpinfo=strinfo->prot_info;
+ callsinfo->from_identity=g_strdup("");
+ callsinfo->to_identity=g_strdup(pi->endpointId);
+ }
+ COPY_ADDRESS(&(callsinfo->initial_speaker),&(pinfo->src));
+ callsinfo->first_frame_num=pinfo->fd->num;
+ callsinfo->selected=FALSE;
+ callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->protocol=VOIP_MGCP;
+ callsinfo->prot_info=g_malloc(sizeof(mgcp_calls_info_t));
+ callsinfo->free_prot_info = g_free;
+ tmp_mgcpinfo=callsinfo->prot_info;
tmp_mgcpinfo->endpointId = g_strdup(pi->endpointId);
tmp_mgcpinfo->fromEndpoint = fromEndpoint;
- strinfo->npackets = 0;
- strinfo->call_num = tapinfo->ncalls++;
- tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, strinfo);
+ callsinfo->npackets = 0;
+ callsinfo->call_num = tapinfo->ncalls++;
+ tapinfo->callsinfo_list = g_list_append(tapinfo->callsinfo_list, callsinfo);
}
g_assert(tmp_mgcpinfo != NULL);
if (tmp_mgcpinfo->fromEndpoint){
/* use the Dialed digits to fill the "To" for the call, but use the first NTFY */
- if (strinfo->to_identity[0] == '\0') mgcpDialedDigits(pi->observedEvents, &(strinfo->to_identity));
+ if (callsinfo->to_identity[0] == '\0') mgcpDialedDigits(pi->observedEvents, &(callsinfo->to_identity));
/* from MGC and the user picked up, the call is connected */
} else if (isSignal("hd", pi->observedEvents))
- strinfo->call_state=VOIP_IN_CALL;
+ callsinfo->call_state=VOIP_IN_CALL;
/* hung up signal */
if (isSignal("hu", pi->observedEvents)) {
- if ((strinfo->call_state == VOIP_CALL_SETUP) || (strinfo->call_state == VOIP_RINGING)){
- strinfo->call_state = VOIP_CANCELLED;
+ if ((callsinfo->call_state == VOIP_CALL_SETUP) || (callsinfo->call_state == VOIP_RINGING)){
+ callsinfo->call_state = VOIP_CANCELLED;
} else {
- strinfo->call_state = VOIP_COMPLETED;
+ callsinfo->call_state = VOIP_COMPLETED;
}
}
} else if (strcmp(pi->code, "RQNT") == 0) {
/* for calls from Endpoint: if there is a "no signal" RQNT and the call was RINGING, we assume this is the CONNECT */
- if ( tmp_mgcpinfo->fromEndpoint && isSignal("", pi->signalReq) && (strinfo->call_state == VOIP_RINGING) ) {
- strinfo->call_state = VOIP_IN_CALL;
+ if ( tmp_mgcpinfo->fromEndpoint && isSignal("", pi->signalReq) && (callsinfo->call_state == VOIP_RINGING) ) {
+ callsinfo->call_state = VOIP_IN_CALL;
}
/* if there is ringback or ring tone, change state to ringing */
if ( isSignal("rg", pi->signalReq) || isSignal("rt", pi->signalReq) ) {
- strinfo->call_state = VOIP_RINGING;
+ callsinfo->call_state = VOIP_RINGING;
}
/* if there is a Busy or ReorderTone, and the call was Ringing or Setup the call is Rejected */
- if ( (isSignal("ro", pi->signalReq) || isSignal("bz", pi->signalReq)) && ((strinfo->call_state == VOIP_CALL_SETUP) || (strinfo->call_state = VOIP_RINGING)) ) {
- strinfo->call_state = VOIP_REJECTED;
+ if ( (isSignal("ro", pi->signalReq) || isSignal("bz", pi->signalReq)) && ((callsinfo->call_state == VOIP_CALL_SETUP) || (callsinfo->call_state = VOIP_RINGING)) ) {
+ callsinfo->call_state = VOIP_REJECTED;
}
if (pi->signalReq != NULL)
frame_label = g_strdup_printf("%s%s",pi->code, (pi->hasDigitMap == TRUE)?" DigitMap ":"");
/* use the CallerID info to fill the "From" for the call */
- if (!tmp_mgcpinfo->fromEndpoint) mgcpCallerID(pi->signalReq, &(strinfo->from_identity));
+ if (!tmp_mgcpinfo->fromEndpoint) mgcpCallerID(pi->signalReq, &(callsinfo->from_identity));
} else if (strcmp(pi->code, "DLCX") == 0) {
/*
the DLCX as the end of the call
*/
if (!tmp_mgcpinfo->fromEndpoint){
- if ((strinfo->call_state == VOIP_CALL_SETUP) || (strinfo->call_state == VOIP_RINGING)){
- strinfo->call_state = VOIP_CANCELLED;
+ if ((callsinfo->call_state == VOIP_CALL_SETUP) || (callsinfo->call_state == VOIP_RINGING)){
+ callsinfo->call_state = VOIP_CANCELLED;
}
}
}
comment = g_strdup_printf("MGCP %s %s%s", tmp_mgcpinfo->endpointId, (pi->mgcp_type == MGCP_REQUEST)?"Request":"Response", pi->is_duplicate?" Duplicate":"");
- strinfo->stop_sec=pinfo->fd->rel_ts.secs;
- strinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
- strinfo->last_frame_num=pinfo->fd->num;
- ++(strinfo->npackets);
+ callsinfo->stop_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->last_frame_num=pinfo->fd->num;
+ ++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
/* add to the graph */
- add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+ add_to_graph(tapinfo, pinfo, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
g_free(comment);
g_free(frame_label);
GList *list;
actrace_cas_calls_info_t *tmp_actrace_cas_info;
voip_calls_info_t *tmp_listinfo;
- voip_calls_info_t *strinfo = NULL;
+ voip_calls_info_t *callsinfo = NULL;
actrace_frame_num = pinfo->fd->num;
address pstn_add;
gchar *comment = NULL;
- strinfo = NULL;
- list = g_list_first(tapinfo->strinfo_list);
+ callsinfo = NULL;
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
tmp_listinfo=list->data;
tmp_actrace_cas_info = tmp_listinfo->prot_info;
/* TODO: Also check the IP of the Blade, and if the call is complete (no active) */
if ( (tmp_actrace_cas_info->bchannel == pi->cas_bchannel) && (tmp_actrace_cas_info->trunk == actrace_trunk) ) {
- strinfo = (voip_calls_info_t*)(list->data);
+ callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
SET_ADDRESS(&pstn_add, AT_STRINGZ, 5, g_strdup("PSTN"));
/* if it is a new call, add it to the list */
- if (!strinfo) {
- strinfo = g_malloc(sizeof(voip_calls_info_t));
- strinfo->call_active_state = VOIP_ACTIVE;
- strinfo->call_state = VOIP_CALL_SETUP;
- strinfo->from_identity=g_strdup("N/A");
- strinfo->to_identity=g_strdup("N/A");
- COPY_ADDRESS(&(strinfo->initial_speaker),actrace_direction?&pstn_add:&(pinfo->src));
- strinfo->first_frame_num=pinfo->fd->num;
- strinfo->selected=FALSE;
- strinfo->start_sec=pinfo->fd->rel_ts.secs;
- strinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
- strinfo->protocol=VOIP_AC_CAS;
- strinfo->prot_info=g_malloc(sizeof(actrace_cas_calls_info_t));
- strinfo->free_prot_info = g_free;
+ if (!callsinfo) {
+ callsinfo = g_malloc0(sizeof(voip_calls_info_t));
+ callsinfo->call_active_state = VOIP_ACTIVE;
+ callsinfo->call_state = VOIP_CALL_SETUP;
+ callsinfo->from_identity=g_strdup("N/A");
+ callsinfo->to_identity=g_strdup("N/A");
+ COPY_ADDRESS(&(callsinfo->initial_speaker),actrace_direction?&pstn_add:&(pinfo->src));
+ callsinfo->first_frame_num=pinfo->fd->num;
+ callsinfo->selected=FALSE;
+ callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->protocol=VOIP_AC_CAS;
+ callsinfo->prot_info=g_malloc(sizeof(actrace_cas_calls_info_t));
+ callsinfo->free_prot_info = g_free;
- tmp_actrace_cas_info=strinfo->prot_info;
+ tmp_actrace_cas_info=callsinfo->prot_info;
tmp_actrace_cas_info->bchannel=pi->cas_bchannel;
tmp_actrace_cas_info->trunk=actrace_trunk;
- strinfo->npackets = 0;
- strinfo->call_num = tapinfo->ncalls++;
- tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, strinfo);
+ callsinfo->npackets = 0;
+ callsinfo->call_num = tapinfo->ncalls++;
+ tapinfo->callsinfo_list = g_list_append(tapinfo->callsinfo_list, callsinfo);
}
- strinfo->stop_sec=pinfo->fd->rel_ts.secs;
- strinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
- strinfo->last_frame_num=pinfo->fd->num;
- ++(strinfo->npackets);
+ callsinfo->stop_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->last_frame_num=pinfo->fd->num;
+ ++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
if (!comment)
comment = g_strdup_printf("AC_CAS trunk:%u", actrace_trunk );
- add_to_graph(tapinfo, pinfo, pi->cas_frame_label , comment, strinfo->call_num,
+ add_to_graph(tapinfo, pinfo, pi->cas_frame_label , comment, callsinfo->call_num,
actrace_direction?&pstn_add:&(pinfo->src),
actrace_direction?&(pinfo->src):&pstn_add,
1 );
-/**************************** TAP for H248 **********************************/
+/**************************** TAP for H248/MEGACO **********************************/
static gboolean have_h248_tap_listener = FALSE;
-static guint16 h248_call_num = 0;
+static gboolean have_megaco_tap_listener = FALSE;
-#define h248_is_req(type) ( type == H248_CMD_ADD_REQ || type == H248_CMD_MOVE_REQ || type == H248_CMD_MOD_REQ || \
- type == H248_CMD_SUB_REQ || type == H248_CMD_AUDITCAP_REQ || type == H248_CMD_AUDITVAL_REQ || \
- type == H248_CMD_NOTIFY_REQ || type == H248_CMD_SVCCHG_REQ || type == H248_CMD_TOPOLOGY_REQ || \
- type == H248_CMD_CTX_ATTR_AUDIT_REQ )
+#define gcp_is_req(type) ( type == GCP_CMD_ADD_REQ || type == GCP_CMD_MOVE_REQ || type == GCP_CMD_MOD_REQ || \
+ type == GCP_CMD_SUB_REQ || type == GCP_CMD_AUDITCAP_REQ || type == GCP_CMD_AUDITVAL_REQ || \
+ type == GCP_CMD_NOTIFY_REQ || type == GCP_CMD_SVCCHG_REQ || type == GCP_CMD_TOPOLOGY_REQ || \
+ type == GCP_CMD_CTX_ATTR_AUDIT_REQ )
static int h248_calls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prot_info) {
voip_calls_tapinfo_t *tapinfo = &the_tapinfo_struct;
- const h248_cmd_t* cmd = prot_info;
+ const gcp_cmd_t* cmd = prot_info;
GList* list;
- voip_calls_info_t *strinfo = NULL;
+ voip_calls_info_t *callsinfo = NULL;
address* mgw;
address* mgc;
gchar mgw_addr[128];
if (cmd->ctx->id == NULL_CONTEXT || cmd->ctx->id == ALL_CONTEXTS ) {
- tapinfo->redraw = FALSE;
-
return 0;
}
- if ( h248_is_req(cmd->type) ) {
+ if ( gcp_is_req(cmd->type) ) {
mgw = &(pinfo->dst);
mgc = &(pinfo->src);
} else {
address_to_str_buf(mgw, mgw_addr, 128);
/* check whether we already have this context in the list */
- list = g_list_first(tapinfo->strinfo_list);
+ list = g_list_first(tapinfo->callsinfo_list);
while (list)
{
voip_calls_info_t* tmp_listinfo = list->data;
if (tmp_listinfo->protocol == TEL_H248){
if (tmp_listinfo->prot_info == cmd->ctx){
- strinfo = (voip_calls_info_t*)(list->data);
+ callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
list = g_list_next (list);
}
- if (strinfo==NULL){
+ if (callsinfo==NULL){
- strinfo = g_malloc(sizeof(voip_calls_info_t));
- strinfo->call_state = VOIP_UNKNOWN;
- strinfo->call_active_state = VOIP_ACTIVE;
- strinfo->from_identity = g_strdup_printf("%s : %.8x", mgw_addr, cmd->ctx->id);
- strinfo->to_identity = g_strdup("");
- strinfo->prot_info = cmd->ctx;
- strinfo->free_prot_info = NULL;
+ callsinfo = g_malloc0(sizeof(voip_calls_info_t));
+ callsinfo->call_state = VOIP_NO_STATE;
+ callsinfo->call_active_state = VOIP_ACTIVE;
+ callsinfo->from_identity = g_strdup_printf("%s : %.8x", mgw_addr, cmd->ctx->id);
+ callsinfo->to_identity = g_strdup("");
+ callsinfo->prot_info = cmd->ctx;
+ callsinfo->free_prot_info = NULL;
- strinfo->npackets = 1;
- strinfo->first_frame_num=pinfo->fd->num;
- strinfo->last_frame_num=pinfo->fd->num;
+ callsinfo->npackets = 1;
+ callsinfo->first_frame_num=pinfo->fd->num;
+ callsinfo->last_frame_num=pinfo->fd->num;
- COPY_ADDRESS(&(strinfo->initial_speaker), mgc);
+ COPY_ADDRESS(&(callsinfo->initial_speaker), mgc);
- strinfo->protocol = TEL_H248;
- strinfo->call_num = h248_call_num++;
- strinfo->start_sec=pinfo->fd->rel_ts.secs;
- strinfo->start_usec=pinfo->fd->rel_ts.nsecs;
- strinfo->stop_sec=pinfo->fd->rel_ts.secs;
- strinfo->stop_usec=pinfo->fd->rel_ts.nsecs;
-
- strinfo->selected = FALSE;
+ callsinfo->protocol = TEL_H248;
+ callsinfo->call_num = tapinfo->ncalls++;
+ callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->start_usec=pinfo->fd->rel_ts.nsecs;
+ callsinfo->stop_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs;
+
+ callsinfo->selected = FALSE;
- tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, strinfo);
+ tapinfo->callsinfo_list = g_list_append(tapinfo->callsinfo_list, callsinfo);
} else {
GString* s = g_string_new("");
- h248_terms_t *ctx_term;
+ gcp_terms_t *ctx_term;
- g_free(strinfo->from_identity);
- strinfo->from_identity = g_strdup_printf("%s : %.8x", mgw_addr, ((h248_ctx_t*)strinfo->prot_info)->id);
+ g_free(callsinfo->from_identity);
+ callsinfo->from_identity = g_strdup_printf("%s : %.8x", mgw_addr, ((gcp_ctx_t*)callsinfo->prot_info)->id);
- g_free(strinfo->to_identity);
+ g_free(callsinfo->to_identity);
- for (ctx_term = ((h248_ctx_t*)strinfo->prot_info)->terms.next;
+ for (ctx_term = ((gcp_ctx_t*)callsinfo->prot_info)->terms.next;
ctx_term;
ctx_term = ctx_term->next ) {
if ( ctx_term->term && ctx_term->term->str) {
}
}
- strinfo->to_identity = s->str;
+ callsinfo->to_identity = s->str;
g_string_free(s,FALSE);
- strinfo->stop_sec=pinfo->fd->rel_ts.secs;
- strinfo->stop_usec=pinfo->fd->rel_ts.nsecs;
- strinfo->last_frame_num=pinfo->fd->num;
- ++(strinfo->npackets);
- ++(tapinfo->npackets);
+ callsinfo->stop_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs;
+ callsinfo->last_frame_num=pinfo->fd->num;
+ ++(callsinfo->npackets);
}
- add_to_graph(tapinfo, pinfo, cmd->str, "", strinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+ add_to_graph(tapinfo, pinfo, cmd->str ? cmd->str : "unknown Msg",
+ ep_strdup_printf("TrxId = %u, CtxId = %.8x",cmd->trx->id,cmd->ctx->id),
+ callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+
+ ++(tapinfo->npackets);
tapinfo->redraw = TRUE;
{
GString *error_string;
+
+ if(have_megaco_tap_listener==FALSE)
+ {
+ error_string = register_tap_listener("megaco", &(the_tapinfo_struct.megaco_dummy),
+ NULL,
+ voip_calls_dlg_reset,
+ h248_calls_packet,
+ voip_calls_dlg_draw);
+
+ if (error_string != NULL) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ error_string->str);
+ g_string_free(error_string, TRUE);
+ exit(1);
+ }
+
+ have_megaco_tap_listener=TRUE;
+ }
+
if(have_h248_tap_listener==FALSE)
{
error_string = register_tap_listener("h248", &(the_tapinfo_struct.h248_dummy),
have_h248_tap_listener=TRUE;
}
-
- h248_call_num = 0;
}
void
{
protect_thread_critical_region();
remove_tap_listener(&(the_tapinfo_struct.h248_dummy));
+ remove_tap_listener(&(the_tapinfo_struct.megaco_dummy));
unprotect_thread_critical_region();
+ have_megaco_tap_listener=FALSE;
have_h248_tap_listener=FALSE;
}
+/**************************** TAP for SCCP and SUA **********************************/
+/**************************** ( RANAP and BSSAP ) **********************************/
+static gboolean have_sccp_tap_listener = FALSE;
+static gboolean have_sua_tap_listener = FALSE;
+
+static const voip_protocol sccp_proto_map[] = {
+ TEL_SCCP,
+ TEL_BSSMAP,
+ TEL_RANAP
+};
+#define SP2VP(ap) ((ap) < SCCP_PLOAD_NUM_PLOADS ? sccp_proto_map[(ap)] : TEL_SCCP)
+const value_string* sccp_payload_values;
+
+static int sccp_calls(packet_info *pinfo, const void *prot_info) {
+ voip_calls_tapinfo_t *tapinfo = &the_tapinfo_struct;
+ const sccp_msg_info_t* msg = prot_info;
+ sccp_assoc_info_t* assoc = msg->data.co.assoc;
+ GList* list;
+ voip_calls_info_t *callsinfo = NULL;
+ const gchar* label = NULL;
+ const gchar* comment = NULL;
+ /* check whether we already have this assoc in the list */
+
+ for(list = g_list_first(tapinfo->callsinfo_list) ; list ; list = g_list_next (list) ) {
+ if ( ((voip_calls_info_t*)(list->data))->prot_info == assoc ){
+ callsinfo = (voip_calls_info_t*)(list->data);
+ break;
+ }
+ }
+
+ if (callsinfo==NULL){
+ callsinfo = g_malloc0(sizeof(voip_calls_info_t));
+ callsinfo->call_state = VOIP_CALL_SETUP;
+ callsinfo->call_active_state = VOIP_ACTIVE;
+ if ( assoc->calling_party ) {
+ callsinfo->from_identity = g_strdup(assoc->calling_party);
+ } else {
+ callsinfo->from_identity = g_strdup("Unknown");
+ }
+
+ if ( assoc->called_party ) {
+ callsinfo->to_identity = g_strdup(assoc->called_party);
+ } else {
+ callsinfo->to_identity = g_strdup("Unknown");
+ }
+
+ callsinfo->prot_info = (void*)assoc;
+ callsinfo->free_prot_info = NULL;
+
+ callsinfo->npackets = 1;
+ callsinfo->first_frame_num=pinfo->fd->num;
+ callsinfo->last_frame_num=pinfo->fd->num;
+
+ COPY_ADDRESS(&(callsinfo->initial_speaker), &(pinfo->src));
+
+ callsinfo->protocol = SP2VP(assoc->payload);
+ callsinfo->start_sec=(gint32) pinfo->fd->rel_ts.secs;
+ callsinfo->start_usec=pinfo->fd->rel_ts.nsecs;
+ callsinfo->stop_sec=(gint32) pinfo->fd->rel_ts.secs;
+ callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs;
+
+ callsinfo->selected = FALSE;
+ callsinfo->call_num = tapinfo->ncalls++;
+
+ tapinfo->callsinfo_list = g_list_append(tapinfo->callsinfo_list, callsinfo);
+ } else {
+
+ if ( assoc->calling_party ) {
+ if (callsinfo->from_identity) g_free(callsinfo->from_identity );
+ callsinfo->from_identity = g_strdup(assoc->calling_party);
+ }
+
+ if ( assoc->called_party ) {
+ if (callsinfo->to_identity) g_free(callsinfo->to_identity );
+ callsinfo->to_identity = g_strdup(assoc->called_party);
+ }
+
+ callsinfo->protocol = SP2VP(assoc->payload);
+ callsinfo->stop_sec=(gint32) pinfo->fd->rel_ts.secs;
+ callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs;
+ callsinfo->last_frame_num=pinfo->fd->num;
+ ++(callsinfo->npackets);
+
+ switch (msg->type) {
+ case SCCP_MSG_TYPE_CC:
+ callsinfo->call_state = VOIP_IN_CALL;
+ break;
+ case SCCP_MSG_TYPE_RLC:
+ callsinfo->call_state = VOIP_COMPLETED;
+ callsinfo->call_active_state = VOIP_INACTIVE;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (msg->data.co.label) {
+ label = msg->data.co.label;
+ } else {
+ label = val_to_str(msg->type, sccp_payload_values, "Unknown(%d)");
+ }
+
+ if (msg->data.co.comment) {
+ comment = msg->data.co.comment;
+ } else {
+ comment = "";
+ }
+
+ add_to_graph(tapinfo, pinfo, label,(void*) comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+
+ ++(tapinfo->npackets);
+
+ tapinfo->redraw = TRUE;
+
+ return 1;
+}
+
+static int sccp_calls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prot_info) {
+ sccp_payload_values = sccp_message_type_acro_values;
+ return sccp_calls(pinfo, prot_info);
+}
+
+
+static int sua_calls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prot_info) {
+ sccp_payload_values = sua_co_class_type_acro_values;
+ return sccp_calls(pinfo, prot_info);
+}
+
+
+void sccp_calls_init_tap(void)
+{
+ GString *error_string;
+
+ if(have_sccp_tap_listener==FALSE)
+ {
+ error_string = register_tap_listener("sccp", &(the_tapinfo_struct.sccp_dummy),
+ NULL,
+ voip_calls_dlg_reset,
+ sccp_calls_packet,
+ voip_calls_dlg_draw);
+
+ if (error_string != NULL) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ error_string->str);
+ g_string_free(error_string, TRUE);
+ exit(1);
+ }
+
+ have_sccp_tap_listener=TRUE;
+ }
+
+ if(have_sua_tap_listener==FALSE)
+ {
+ error_string = register_tap_listener("sua", &(the_tapinfo_struct.sua_dummy),
+ NULL,
+ voip_calls_dlg_reset,
+ sua_calls_packet,
+ voip_calls_dlg_draw);
+
+ if (error_string != NULL) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ error_string->str);
+ g_string_free(error_string, TRUE);
+ exit(1);
+ }
+
+ have_sua_tap_listener=TRUE;
+ }
+
+}
+
+void
+remove_tap_listener_sccp_calls(void)
+{
+ protect_thread_critical_region();
+ remove_tap_listener(&(the_tapinfo_struct.sccp_dummy));
+ unprotect_thread_critical_region();
+
+ have_sccp_tap_listener=FALSE;
+ have_sua_tap_listener=FALSE;
+}
+
+
+/****************************************************************************/
+/****************************TAP for UNISTIM ********************************/
+/****************************************************************************/
+
+static int
+unistim_calls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *unistim_info)
+{
+ voip_calls_tapinfo_t *tapinfo = &the_tapinfo_struct;
+ voip_calls_info_t *tmp_listinfo;
+ voip_calls_info_t *callsinfo = NULL;
+ unistim_info_t *tmp_unistim_info = NULL;
+ GList *list = NULL;
+ GString *g_tmp = NULL;
+ gchar *frame_label = NULL;
+ gchar *comment = NULL;
+
+ /* Fetch specific packet infos */
+ const unistim_info_t *pi = unistim_info;
+
+ /* Init gstring */
+ g_tmp = g_string_new(NULL);
+
+ /* Check to see if this is a dup */
+ list = g_list_first(tapinfo->callsinfo_list);
+
+ while(list)
+ {
+ tmp_listinfo = list->data;
+
+ if(tmp_listinfo->protocol == VOIP_UNISTIM){
+
+ tmp_unistim_info = tmp_listinfo->prot_info;
+
+ /* Search by termid if possible, otherwise use ni/it ip + port.. */
+ if(pi->termid != 0){
+ if(tmp_unistim_info->termid == pi->termid){
+ /* If the call has ended, then we can reuse it.. */
+ if(tmp_listinfo->call_state == VOIP_COMPLETED || tmp_listinfo->call_state == VOIP_UNKNOWN){
+ /* Do nothing */
+ } else {
+ callsinfo = (voip_calls_info_t*)(list->data);
+ break;
+ }
+ }
+ } else {
+ /* If no term id use ips / port to find entry */
+ if(ADDRESSES_EQUAL(&tmp_unistim_info->it_ip, &pinfo->dst) && ADDRESSES_EQUAL(&tmp_unistim_info->ni_ip,&pinfo->src) && (tmp_unistim_info->it_port == pinfo->destport)){
+ if(tmp_listinfo->call_state == VOIP_COMPLETED || tmp_listinfo->call_state == VOIP_UNKNOWN){
+ /* Do nothing previous call */
+ } else {
+ callsinfo = (voip_calls_info_t*)(list->data);
+ break;
+ }
+ }
+ else if(ADDRESSES_EQUAL(&tmp_unistim_info->it_ip, &pinfo->src) && ADDRESSES_EQUAL(&tmp_unistim_info->ni_ip,&pinfo->dst) && (tmp_unistim_info->it_port == pinfo->srcport)) {
+ if(tmp_listinfo->call_state == VOIP_COMPLETED || tmp_listinfo->call_state == VOIP_UNKNOWN){
+ /* Do nothing, it ain't our call.. */
+ } else {
+ callsinfo = (voip_calls_info_t*)(list->data);
+ break;
+ }
+ }
+ }
+ }
+
+ /* Otherwise, go to the next one.. */
+ list = g_list_next(list);
+ }
+
+ if(pi->payload_type == 2 || pi->payload_type == 1){
+
+ if(pi->key_state == 1 || pi->hook_state == 1){
+
+ /* If the user hits a button,
+ Session will be SETUP */
+
+ /* If new add to list */
+ if (callsinfo==NULL){
+
+ callsinfo = g_malloc0(sizeof(voip_calls_info_t));
+ callsinfo->call_active_state = VOIP_ACTIVE;
+ callsinfo->call_state = VOIP_CALL_SETUP;
+ callsinfo->from_identity=g_strdup_printf("%x",pi->termid);
+ callsinfo->to_identity=g_strdup_printf("UNKNOWN");
+ COPY_ADDRESS(&(callsinfo->initial_speaker),&(pinfo->src));
+ callsinfo->first_frame_num=pinfo->fd->num;
+ callsinfo->selected=FALSE;
+
+ /* Set this on init of struct so in case the call doesn't complete, we'll have a ref. */
+ /* Otherwise if the call is completed we'll have the open/close streams to ref actual call duration */
+ callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
+
+ callsinfo->protocol=VOIP_UNISTIM;
+ callsinfo->prot_info=g_malloc(sizeof(unistim_info_t));
+
+ tmp_unistim_info = callsinfo->prot_info;
+
+ /* Clear tap struct */
+ tmp_unistim_info->rudp_type = 0;
+ tmp_unistim_info->payload_type = 0;
+ tmp_unistim_info->sequence = pi->sequence;
+ tmp_unistim_info->termid = pi->termid;
+ tmp_unistim_info->key_val = -1;
+ tmp_unistim_info->key_state = -1;
+ tmp_unistim_info->hook_state = -1;
+ tmp_unistim_info->stream_connect = -1;
+ tmp_unistim_info->trans_connect = -1;
+ tmp_unistim_info->set_termid = -1;
+ tmp_unistim_info->string_data = NULL;
+ tmp_unistim_info->key_buffer = NULL;
+
+ COPY_ADDRESS(&(tmp_unistim_info->it_ip),&(pi->it_ip));
+ COPY_ADDRESS(&(tmp_unistim_info->ni_ip),&(pi->ni_ip));
+ tmp_unistim_info->it_port = pi->it_port;
+
+ callsinfo->free_prot_info = g_free;
+ callsinfo->npackets = 0;
+ callsinfo->call_num = tapinfo->ncalls++;
+ tapinfo->callsinfo_list = g_list_append(tapinfo->callsinfo_list, callsinfo);
+
+ } else {
+
+ /* Set up call wide info struct */
+ tmp_unistim_info = callsinfo->prot_info;
+ tmp_unistim_info->sequence = pi->sequence;
+ }
+
+ /* Each packet COULD BE OUR LAST!!!! */
+ callsinfo->stop_sec=(gint32)(pinfo->fd->rel_ts.secs);
+ callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->last_frame_num=pinfo->fd->num;
+
+ /* This is a valid packet so increment counter */
+ ++(callsinfo->npackets);
+
+ /* increment the packets counter of all calls */
+ ++(tapinfo->npackets);
+
+ /* Key was depressed.. update key buffer.. */
+ if(pi->key_val >= 0 && pi->key_val <= 11){
+
+ if(tmp_unistim_info->key_buffer != NULL){
+
+ /* assign to temp variable */
+ g_string_assign(g_tmp,tmp_unistim_info->key_buffer);
+
+ /* Manipulate the data */
+ if(pi->key_val == 10) {
+ tmp_unistim_info->key_buffer = g_strdup_printf("%s*",g_tmp->str);
+ } else if(pi->key_val == 11) {
+ tmp_unistim_info->key_buffer = g_strdup_printf("%s#",g_tmp->str);
+ } else {
+ tmp_unistim_info->key_buffer = g_strdup_printf("%s%d",g_tmp->str,pi->key_val);
+ }
+
+ } else {
+
+ /* Create new string */
+ if(pi->key_val == 10) {
+ tmp_unistim_info->key_buffer = g_strdup_printf("*");
+ } else if(pi->key_val == 11) {
+ tmp_unistim_info->key_buffer = g_strdup_printf("#");
+ } else {
+ tmp_unistim_info->key_buffer = g_strdup_printf("%d",pi->key_val);
+ }
+
+ }
+
+ /* Select for non-digit characters */
+ if(pi->key_val == 10) {
+ comment = g_strdup_printf("Key Input Sent: * (%d)", pi->sequence);
+ } else if(pi->key_val == 11) {
+ comment = g_strdup_printf("Key Input Sent: # (%d)", pi->sequence);
+ } else {
+ comment = g_strdup_printf("Key Input Sent: %d (%d)",pi->key_val, pi->sequence);
+ }
+ } else if(pi->key_val == 12) {
+ /* Set label and comment for graph */
+ comment = g_strdup_printf("Key Input Sent: UP (%d)", pi->sequence);
+ } else if(pi->key_val == 13) {
+ /* Set label and comment for graph */
+ comment = g_strdup_printf("Key Input Sent: DOWN (%d)", pi->sequence);
+ } else if(pi->key_val == 14) {
+ /* Set label and comment for graph */
+ comment = g_strdup_printf("Key Input Sent: RIGHT (%d)", pi->sequence);
+ } else if(pi->key_val == 15) {
+ if(pi->key_buffer != NULL){
+ /* Get data */
+ g_string_assign(g_tmp,pi->key_buffer);
+
+ /* Manipulate the data */
+ g_string_truncate(g_tmp,g_tmp->len-1);
+
+ /* Insert new data */
+ tmp_unistim_info->key_buffer = g_strdup_printf("%s",g_tmp->str);
+ }
+
+ /* Set label and comment for graph */
+ comment = g_strdup_printf("Key Input Sent: LEFT (%d)", pi->sequence);
+ } else if(pi->key_val == 20) {
+ /* User pressed the soft key 0 probably dial */
+ comment = g_strdup_printf("Key Input Sent: S0 (%d)", pi->sequence);
+ } else if(pi->key_val == 21) {
+ /* User pressed the soft key 1 */
+ comment = g_strdup_printf("Key Input Sent: S1 (%d)", pi->sequence);
+ } else if(pi->key_val == 22) {
+ /* User pressed the soft key 2 */
+ /* On cs2k phones, soft key 2 is backspace. */
+ if(pi->key_buffer != NULL) {
+
+ /* Get data */
+ g_string_assign(g_tmp,pi->key_buffer);
+
+ /* Manipulate the data */
+ g_string_truncate(g_tmp,g_tmp->len-1);
+
+ /* Insert new data */
+ tmp_unistim_info->key_buffer = g_strdup_printf("%s",g_tmp->str);
+ }
+
+ /* add label and comment */
+ comment = g_strdup_printf("Key Input Sent: S2 (%d)", pi->sequence);
+ } else if(pi->key_val == 28) {
+ /* User pressed something */
+ comment = g_strdup_printf("Key Input Sent: Release (%d)", pi->sequence);
+ } else if(pi->key_val == 23) {
+ /* User pressed the soft key 3 */
+ /* Cancel on cs2k so clear buffer */
+ /* On mcs its config which will clear the buffer too */
+ tmp_unistim_info->key_buffer = g_strdup_printf("\n");
+
+ /* User pressed something, set labels*/
+ comment = g_strdup_printf("Key Input Sent: S3 (%d)", pi->sequence);
+ } else if(pi->key_val == 27) {
+ /* User pressed something */
+ comment = g_strdup_printf("Key Input Sent: Hold (%d)", pi->sequence);
+ } else if(pi->key_val == 29) {
+ /* User pressed something */
+ comment = g_strdup_printf("Key Input Sent: Mute (%d)", pi->sequence);
+ } else if(pi->key_val == 30) {
+ /* User pressed something */
+ comment = g_strdup_printf("Key Input Sent: Headset (%d)", pi->sequence);
+ } else if(pi->key_val == 31) {
+ /* Handsfree button */
+ comment = g_strdup_printf("Key Input Sent: Handsfree (%d)", pi->sequence);
+ } else if(pi->key_val >= 32 && pi->key_val <= 56) {
+ /* Prog. Key X */
+ comment = g_strdup_printf("Key Input Sent: Prog%d (%d)", (pi->key_val & 31), pi->sequence);
+ }
+
+ if(pi->key_val != -1) {
+
+ frame_label = g_strdup_printf("KEY INPUT");
+
+ if (comment == NULL)
+ /* Ouch! What do you do!? */
+ /* User pressed something */
+ comment = g_strdup_printf("Key Input Sent: UNKNOWN - %d (%d)", pi->key_val, pi->sequence);
+
+ /* add to the graph */
+ add_to_graph(tapinfo, pinfo, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+
+ }
+
+ if(pi->hook_state == 1) {
+
+ /* Phone is off hook */
+ frame_label = g_strdup_printf("OFF HOOK");
+ comment = g_strdup_printf("Off Hook (%d)", pi->sequence);
+
+ /* add to the graph */
+ add_to_graph(tapinfo, pinfo, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+ } else if(pi->hook_state == 0) {
+
+ /* Phone is on hook */
+ frame_label = g_strdup_printf("ON HOOK");
+ comment = g_strdup_printf("On Hook (%d)", pi->sequence);
+
+ /* add to the graph */
+ add_to_graph(tapinfo, pinfo, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+ }
+
+ }
+
+ /* Open stream was sent from server */
+ if(pi->stream_connect == 1 && callsinfo != NULL) {
+
+ /* Open stream */
+ /* Signifies the start of the call so set start_sec & start_usec */
+ callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
+
+ /* Local packets too */
+ ++(callsinfo->npackets);
+
+ /* increment the packets counter of all calls */
+ ++(tapinfo->npackets);
+
+ /* ?? means we're not quite sure if this is accurate. Since Unistim isn't a true
+ Call control protocol, we can only guess at the destination by messing with
+ key buffers. */
+ if(tmp_unistim_info->key_buffer != NULL){
+ callsinfo->to_identity = g_strdup_printf("?? %s",tmp_unistim_info->key_buffer);
+ }
+
+ /* change sequence number for ACK detection */
+ tmp_unistim_info->sequence = pi->sequence;
+
+ /* State changes too */
+ callsinfo->call_active_state = VOIP_ACTIVE;
+ callsinfo->call_state = VOIP_IN_CALL;
+
+ /* Add graph data */
+ frame_label = g_strdup_printf("STREAM OPENED");
+ comment = g_strdup_printf("Stream Opened (%d)",pi->sequence);
+
+ /* add to the graph */
+ add_to_graph(tapinfo, pinfo, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+
+ /* Redraw the scree */
+ tapinfo->redraw = TRUE;
+ return 1;
+
+ } else if(pi->stream_connect == 1 && callsinfo == NULL) {
+
+ /* Research indicates some nortel products initiate stream first
+ * without keypresses. therefore creating this solely on a keypress is
+ * ineffective.
+ * Sometimes calls start immediately with open stream.
+ */
+ callsinfo = g_malloc0(sizeof(voip_calls_info_t));
+ callsinfo->call_active_state = VOIP_ACTIVE;
+ callsinfo->call_state = VOIP_CALL_SETUP;
+ callsinfo->from_identity=g_strdup_printf("UNKNOWN");
+ callsinfo->to_identity=g_strdup_printf("UNKNOWN");
+ COPY_ADDRESS(&(callsinfo->initial_speaker),&(pinfo->src));
+ callsinfo->first_frame_num=pinfo->fd->num;
+ callsinfo->selected=FALSE;
+
+ /* Set this on init of struct so in case the call doesn't complete, we'll have a ref. */
+ /* Otherwise if the call is completed we'll have the open/close streams to ref actual call duration */
+ callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
+
+ callsinfo->protocol=VOIP_UNISTIM;
+ callsinfo->prot_info=g_malloc(sizeof(unistim_info_t));
+
+ tmp_unistim_info = callsinfo->prot_info;
+
+ /* Clear tap struct */
+ tmp_unistim_info->rudp_type = 0;
+ tmp_unistim_info->payload_type = 0;
+ tmp_unistim_info->sequence = pi->sequence;
+ tmp_unistim_info->termid = 0;
+ tmp_unistim_info->key_val = -1;
+ tmp_unistim_info->key_state = -1;
+ tmp_unistim_info->hook_state = -1;
+ tmp_unistim_info->stream_connect = -1;
+ tmp_unistim_info->trans_connect = -1;
+ tmp_unistim_info->set_termid = -1;
+ tmp_unistim_info->string_data = NULL;
+ tmp_unistim_info->key_buffer = NULL;
+
+ COPY_ADDRESS(&(tmp_unistim_info->it_ip),&(pi->it_ip));
+ COPY_ADDRESS(&(tmp_unistim_info->ni_ip),&(pi->ni_ip));
+ tmp_unistim_info->it_port = pi->it_port;
+
+ callsinfo->free_prot_info = g_free;
+ callsinfo->npackets = 0;
+ callsinfo->call_num = tapinfo->ncalls++;
+ tapinfo->callsinfo_list = g_list_append(tapinfo->callsinfo_list, callsinfo);
+
+ /* Open stream */
+ /* Signifies the start of the call so set start_sec & start_usec */
+ callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
+
+ /* Local packets too */
+ ++(callsinfo->npackets);
+
+ /* increment the packets counter of all calls */
+ ++(tapinfo->npackets);
+
+ /* ?? means we're not quite sure if this is accurate. Since Unistim isn't a true
+ Call control protocol, we can only guess at the destination by messing with
+ key buffers. */
+ if(tmp_unistim_info->key_buffer != NULL){
+ callsinfo->to_identity = g_strdup_printf("?? %s",tmp_unistim_info->key_buffer);
+ }
+
+ /* change sequence number for ACK detection */
+ tmp_unistim_info->sequence = pi->sequence;
+
+ /* State changes too */
+ callsinfo->call_active_state = VOIP_ACTIVE;
+ callsinfo->call_state = VOIP_IN_CALL;
+
+ /* Add graph data */
+ frame_label = g_strdup_printf("STREAM OPENED");
+ comment = g_strdup_printf("Stream Opened (%d)",pi->sequence);
+
+ /* add to the graph */
+ add_to_graph(tapinfo, pinfo, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+
+ /* Redraw the scree */
+ tapinfo->redraw = TRUE;
+ return 1;
+
+
+ } else if(pi->stream_connect == 0 && callsinfo != NULL) {
+ /* Close Stream */
+
+ /* Set stop seconds + usec */
+ callsinfo->stop_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->last_frame_num=pinfo->fd->num;
+
+ tmp_unistim_info->sequence = pi->sequence;
+
+ if(callsinfo->call_state == VOIP_IN_CALL){
+ callsinfo->call_active_state = VOIP_INACTIVE;
+ callsinfo->call_state = VOIP_COMPLETED;
+ } else {
+ callsinfo->call_state = VOIP_UNKNOWN;
+ callsinfo->call_active_state = VOIP_INACTIVE;
+ }
+
+ frame_label = g_strdup_printf("STREAM CLOSED");
+ comment = g_strdup_printf("Stream Closed (%d)",pi->sequence);
+
+ /* add to the graph */
+ add_to_graph(tapinfo, pinfo, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+
+ }
+
+ } else if(pi->rudp_type == 1 && callsinfo != NULL) {
+ /* ACK */
+ /* Only show acks for processed seq #s */
+ if(tmp_unistim_info->sequence == pi->sequence) {
+
+ frame_label = g_strdup_printf("ACK");
+ comment = g_strdup_printf("ACK for sequence %d",pi->sequence);
+
+ /* add to the graph */
+ add_to_graph(tapinfo, pinfo, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+
+ }
+
+ } else if(pi->rudp_type == 0 && callsinfo != NULL) {
+
+ /* NAK */
+ frame_label = g_strdup_printf("NAK");
+ comment = g_strdup_printf("NAK for sequence %d",pi->sequence);
+
+ /* add to the graph */
+ add_to_graph(tapinfo, pinfo, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+
+ }
+
+ /* free dataz */
+ g_free(frame_label);
+ g_free(comment);
+
+ tapinfo->redraw = TRUE;
+
+ return 1;
+}
+
+/****************************************************************************/
+/* TAP INTERFACE */
+/****************************************************************************/
+static gboolean have_unistim_tap_listener=FALSE;
+/****************************************************************************/
+void
+unistim_calls_init_tap(void){
+
+ GString *error_string;
+
+ if(have_unistim_tap_listener==FALSE) {
+
+ error_string = register_tap_listener("unistim", &(the_tapinfo_struct.unistim_dummy),
+ NULL,
+ voip_calls_dlg_reset,
+ unistim_calls_packet,
+ voip_calls_dlg_draw
+ );
+
+ if (error_string != NULL) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ error_string->str);
+ g_string_free(error_string, TRUE);
+ exit(1);
+ }
+
+ have_unistim_tap_listener=TRUE;
+ }
+}
+
+/****************************************************************************/
+void
+remove_tap_listener_unistim_calls(void)
+{
+ protect_thread_critical_region();
+ remove_tap_listener(&(the_tapinfo_struct.unistim_dummy));
+ unprotect_thread_critical_region();
+
+ have_unistim_tap_listener=FALSE;
+}
+
+/****************************************************************************/
+/* ***************************TAP for OTHER PROTOCOL **********************************/
+/****************************************************************************/
+
+static int
+VoIPcalls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *VoIPinfo _U_)
+{
+ voip_calls_tapinfo_t *tapinfo = &the_tapinfo_struct;
+ voip_calls_info_t *callsinfo = NULL;
+ voip_calls_info_t *tmp_listinfo;
+ GList *list = NULL;
+ const voip_packet_info_t *pi = VoIPinfo;
+
+ if (pi->call_id)
+ list = g_list_first(tapinfo->callsinfo_list);
+ while (list) {
+ tmp_listinfo = list->data;
+ if ( tmp_listinfo->protocol == VOIP_COMMON ) {
+ if (!strcmp(pi->call_id, tmp_listinfo->call_id)) {
+ callsinfo = (voip_calls_info_t*)(list->data);
+ break;
+ }
+ }
+ list = g_list_next(list);
+ }
+
+ if (callsinfo == NULL) {
+ callsinfo = g_malloc0(sizeof(voip_calls_info_t));
+ callsinfo->call_active_state = pi->call_active_state;
+ callsinfo->call_state = pi->call_state;
+ callsinfo->call_id=g_strdup((pi->call_id)?pi->call_id:"");
+ callsinfo->from_identity = g_strdup((pi->from_identity)?pi->from_identity:"");
+ callsinfo->to_identity = g_strdup((pi->to_identity)?pi->to_identity:"");
+ COPY_ADDRESS(&(callsinfo->initial_speaker),&(pinfo->src));
+ callsinfo->selected=FALSE;
+ callsinfo->first_frame_num=pinfo->fd->num;
+ callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs);
+ callsinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->protocol=VOIP_COMMON;
+ callsinfo->protocol_name=g_strdup((pi->protocol_name)?pi->protocol_name:"");
+ callsinfo->call_comment=g_strdup((pi->call_comment)?pi->call_comment:"");
+ callsinfo->prot_info=NULL;
+ callsinfo->free_prot_info = NULL;
+
+ callsinfo->call_num = tapinfo->ncalls++;
+ callsinfo->npackets = 0;
+
+ tapinfo->callsinfo_list = g_list_append(tapinfo->callsinfo_list, callsinfo);
+ }
+
+ if (callsinfo != NULL) {
+ callsinfo->call_active_state = pi->call_active_state;
+ if ((callsinfo->call_state != VOIP_COMPLETED) && (pi->call_state == VOIP_COMPLETED))
+ tapinfo->completed_calls++;
+ if (pi->call_state != VOIP_NO_STATE)
+ callsinfo->call_state = pi->call_state;
+ callsinfo->stop_sec=(gint32)(pinfo->fd->rel_ts.secs);
+ callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
+ callsinfo->last_frame_num=pinfo->fd->num;
+ ++(callsinfo->npackets);
+ ++(tapinfo->npackets);
+ }
+
+ /* add to the graph */
+ add_to_graph(tapinfo, pinfo, (pi->frame_label)?pi->frame_label:"VoIP msg", (pi->frame_comment)?pi->frame_comment:"", callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
+
+ tapinfo->redraw = TRUE;
+
+ return 1;
+}
+/****************************************************************************/
+static gboolean have_voip_tap_listener=FALSE;
+
+void
+VoIPcalls_init_tap(void)
+{
+ GString *error_string;
+
+ if(have_voip_tap_listener==FALSE)
+ {
+ error_string = register_tap_listener("voip", &(the_tapinfo_struct.voip_dummy),
+ NULL,
+ voip_calls_dlg_reset,
+ VoIPcalls_packet,
+ voip_calls_dlg_draw
+ );
+
+ if (error_string != NULL) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ error_string->str);
+ g_string_free(error_string, TRUE);
+ exit(1);
+ }
+ have_voip_tap_listener=TRUE;
+ }
+}
+/****************************************************************************/
+void
+remove_tap_listener_voip_calls(void)
+{
+ protect_thread_critical_region();
+ remove_tap_listener(&(the_tapinfo_struct.voip_dummy));
+ unprotect_thread_critical_region();
+
+ have_voip_tap_listener=FALSE;
+}
+
+
/****************************************************************************/
/* ***************************TAP for OTHER PROTOCOL **********************************/
/****************************************************************************/
prot_calls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prot_info _U_)
{
voip_calls_tapinfo_t *tapinfo = &the_tapinfo_struct;
- if (strinfo!=NULL){
- strinfo->stop_sec=pinfo->fd->rel_secs;
- strinfo->stop_usec=pinfo->fd->rel_usecs;
- strinfo->last_frame_num=pinfo->fd->num;
- ++(strinfo->npackets);
+ if (callsinfo!=NULL){
+ callsinfo->stop_sec=pinfo->fd->rel_secs;
+ callsinfo->stop_usec=pinfo->fd->rel_usecs;
+ callsinfo->last_frame_num=pinfo->fd->num;
+ ++(callsinfo->npackets);
++(tapinfo->npackets);
}