VoIP Calls Dialog: List of calls is not cleared/refilled on retaps
!1257 solved issue with duplication of information, but removed all calls from VoIP Calls dialog. This patch solves the issue. It was tested with many samples and provides same output as 3.4 branch.
This commit is contained in:
parent
45df54d319
commit
41bf14a39d
|
@ -184,7 +184,23 @@ bool VoipCallsInfoModel::timeOfDay() const
|
|||
void VoipCallsInfoModel::updateCalls(GQueue *callsinfos)
|
||||
{
|
||||
if (callsinfos) {
|
||||
GList *cur_call = g_queue_peek_nth_link(callsinfos, rowCount());
|
||||
int calls = callinfos_.count();
|
||||
int cnt = 0;
|
||||
GList *cur_call;
|
||||
|
||||
// Iterate new callsinfos and replace data in mode if required
|
||||
cur_call = g_queue_peek_nth_link(callsinfos, 0);
|
||||
while (cur_call && (cnt < calls)) {
|
||||
if (callinfos_.at(cnt) != cur_call->data) {
|
||||
// Data changed, use it
|
||||
callinfos_.replace(cnt, cur_call->data);
|
||||
}
|
||||
cur_call = gxx_list_next(cur_call);
|
||||
cnt++;
|
||||
}
|
||||
|
||||
// Add new rows
|
||||
cur_call = g_queue_peek_nth_link(callsinfos, rowCount());
|
||||
guint extra = g_list_length(cur_call);
|
||||
if (extra > 0) {
|
||||
beginInsertRows(QModelIndex(), rowCount(), rowCount() + extra - 1);
|
||||
|
@ -198,13 +214,6 @@ void VoipCallsInfoModel::updateCalls(GQueue *callsinfos)
|
|||
}
|
||||
}
|
||||
|
||||
void VoipCallsInfoModel::removeAllCalls()
|
||||
{
|
||||
beginRemoveRows(QModelIndex(), 0, rowCount() - 1);
|
||||
callinfos_.clear();
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
|
||||
// Proxy model that allows columns to be sorted.
|
||||
VoipCallsInfoSortedModel::VoipCallsInfoSortedModel(QObject *parent) :
|
||||
|
|
|
@ -33,7 +33,6 @@ public:
|
|||
void setTimeOfDay(bool timeOfDay);
|
||||
bool timeOfDay() const;
|
||||
void updateCalls(GQueue *callsinfos);
|
||||
void removeAllCalls();
|
||||
|
||||
static voip_calls_info_t *indexToCallInfo(const QModelIndex &index);
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ VoipCallsDialog::VoipCallsDialog(QWidget &parent, CaptureFile &cf, bool all_flow
|
|||
tapinfo_.graph_analysis = sequence_analysis_info_new();
|
||||
tapinfo_.graph_analysis->name = "voip";
|
||||
sequence_info_ = new SequenceInfo(tapinfo_.graph_analysis);
|
||||
shown_callsinfos_ = g_queue_new();
|
||||
|
||||
voip_calls_init_all_taps(&tapinfo_);
|
||||
|
||||
|
@ -113,6 +114,10 @@ VoipCallsDialog::~VoipCallsDialog()
|
|||
}
|
||||
sequence_info_->unref();
|
||||
g_queue_free(tapinfo_.callsinfos);
|
||||
// We don't need to clear shown_callsinfos_ data, it was shared
|
||||
// with tapinfo_.callsinfos and was cleared
|
||||
// during voip_calls_reset_all_taps
|
||||
g_queue_free(shown_callsinfos_);
|
||||
}
|
||||
|
||||
void VoipCallsDialog::removeTapListeners()
|
||||
|
@ -182,7 +187,10 @@ void VoipCallsDialog::tapReset(void *tapinfo_ptr)
|
|||
{
|
||||
voip_calls_tapinfo_t *tapinfo = static_cast<voip_calls_tapinfo_t *>(tapinfo_ptr);
|
||||
VoipCallsDialog *voip_calls_dialog = static_cast<VoipCallsDialog *>(tapinfo->tap_data);
|
||||
voip_calls_dialog->call_infos_model_->removeAllCalls();
|
||||
|
||||
// Create new callsinfos queue in tapinfo. Current callsinfos are
|
||||
// in shown_callsinfos_.
|
||||
voip_calls_dialog->tapinfo_.callsinfos = g_queue_new();
|
||||
voip_calls_reset_all_taps(tapinfo);
|
||||
|
||||
// Leave old graph_analysis as is and allocate new one
|
||||
|
@ -229,12 +237,51 @@ void VoipCallsDialog::tapDraw(void *tapinfo_ptr)
|
|||
}
|
||||
}
|
||||
|
||||
gint VoipCallsDialog::compareCallid(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
voip_calls_info_t *call_a = (voip_calls_info_t *)a;
|
||||
voip_calls_info_t *call_b = (voip_calls_info_t *)b;
|
||||
|
||||
if (call_a->call_id && call_b->call_id) {
|
||||
return strcmp(call_a->call_id, call_b->call_id);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void VoipCallsDialog::updateCalls()
|
||||
{
|
||||
voip_calls_info_t *new_callsinfo;
|
||||
voip_calls_info_t *old_callsinfo;
|
||||
GList *found;
|
||||
|
||||
ui->callTreeView->setSortingEnabled(false);
|
||||
|
||||
// Add any missing items
|
||||
call_infos_model_->updateCalls(tapinfo_.callsinfos);
|
||||
// Merge new callsinfos with old ones
|
||||
// It keeps list of calls visible including selected items
|
||||
GList *list = g_queue_peek_nth_link(tapinfo_.callsinfos, 0);
|
||||
while (list) {
|
||||
// Find new callsinfo
|
||||
new_callsinfo = gxx_list_data(voip_calls_info_t*, list);
|
||||
found = g_queue_find_custom(shown_callsinfos_, new_callsinfo, VoipCallsDialog::compareCallid);
|
||||
if (!found) {
|
||||
// New call, add it to list for show
|
||||
g_queue_push_tail(shown_callsinfos_, new_callsinfo);
|
||||
} else {
|
||||
// Existing call
|
||||
old_callsinfo = (voip_calls_info_t *)found->data;
|
||||
if (new_callsinfo != old_callsinfo) {
|
||||
// Replace it
|
||||
voip_calls_free_callsinfo(old_callsinfo);
|
||||
found->data = new_callsinfo;
|
||||
}
|
||||
}
|
||||
|
||||
list = gxx_list_next(list);
|
||||
}
|
||||
|
||||
// Update model
|
||||
call_infos_model_->updateCalls(shown_callsinfos_);
|
||||
|
||||
// Resize columns
|
||||
for (int i = 0; i < call_infos_model_->columnCount(); i++) {
|
||||
|
|
|
@ -70,11 +70,13 @@ private:
|
|||
QPushButton *player_button_;
|
||||
QPushButton *copy_button_;
|
||||
bool voip_calls_tap_listeners_removed_;
|
||||
GQueue* shown_callsinfos_; /* queue with all shown calls (voip_calls_info_t) */
|
||||
|
||||
// Tap callbacks
|
||||
static void tapReset(void *tapinfo_ptr);
|
||||
static tap_packet_status tapPacket(void *tapinfo_ptr, packet_info *pinfo, epan_dissect_t *, const void *data);
|
||||
static void tapDraw(void *tapinfo_ptr);
|
||||
static gint compareCallid(gconstpointer a, gconstpointer b);
|
||||
|
||||
void updateCalls();
|
||||
void prepareFilter();
|
||||
|
|
|
@ -270,17 +270,7 @@ voip_calls_reset_all_taps(voip_calls_tapinfo_t *tapinfo)
|
|||
while (list)
|
||||
{
|
||||
callsinfo = (voip_calls_info_t *)list->data;
|
||||
g_free(callsinfo->call_id);
|
||||
g_free(callsinfo->from_identity);
|
||||
g_free(callsinfo->to_identity);
|
||||
free_address(&callsinfo->initial_speaker);
|
||||
g_free(callsinfo->protocol_name);
|
||||
g_free(callsinfo->call_comment);
|
||||
|
||||
if (callsinfo->free_prot_info && callsinfo->prot_info)
|
||||
callsinfo->free_prot_info(callsinfo->prot_info);
|
||||
|
||||
g_free(list->data);
|
||||
voip_calls_free_callsinfo(callsinfo);
|
||||
list = g_list_next(list);
|
||||
}
|
||||
g_queue_clear(tapinfo->callsinfos);
|
||||
|
@ -314,6 +304,24 @@ voip_calls_reset_all_taps(voip_calls_tapinfo_t *tapinfo)
|
|||
return;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* free one callsinfo */
|
||||
void
|
||||
voip_calls_free_callsinfo(voip_calls_info_t *callsinfo)
|
||||
{
|
||||
g_free(callsinfo->call_id);
|
||||
g_free(callsinfo->from_identity);
|
||||
g_free(callsinfo->to_identity);
|
||||
free_address(&callsinfo->initial_speaker);
|
||||
g_free(callsinfo->protocol_name);
|
||||
g_free(callsinfo->call_comment);
|
||||
|
||||
if (callsinfo->free_prot_info && callsinfo->prot_info)
|
||||
callsinfo->free_prot_info(callsinfo->prot_info);
|
||||
|
||||
g_free(callsinfo);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* Add a new item into the graph */
|
||||
static void
|
||||
|
@ -1693,7 +1701,7 @@ q931_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt,
|
|||
/* remove this LRQ/LCF call entry because we have found the Setup that match them */
|
||||
g_free(tmp_listinfo->from_identity);
|
||||
g_free(tmp_listinfo->to_identity);
|
||||
DUMP_PTR2(tmp2_h323info->guid);
|
||||
/* DUMP_PTR2(tmp2_h323info->guid); */
|
||||
g_free(tmp2_h323info->guid);
|
||||
|
||||
list2 = g_list_first(tmp2_h323info->h245_list);
|
||||
|
@ -1924,7 +1932,7 @@ static void
|
|||
free_h225_info(gpointer p) {
|
||||
h323_calls_info_t *tmp_h323info = (h323_calls_info_t *)p;
|
||||
|
||||
DUMP_PTR2(tmp_h323info->guid);
|
||||
/* DUMP_PTR2(tmp_h323info->guid); */
|
||||
g_free(tmp_h323info->guid);
|
||||
|
||||
if (tmp_h323info->h245_list) {
|
||||
|
@ -2008,6 +2016,8 @@ h225_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt,
|
|||
|
||||
/* not in the list? then create a new entry */
|
||||
if (callsinfo==NULL) {
|
||||
char *guid_str;
|
||||
|
||||
callsinfo = g_new0(voip_calls_info_t, 1);
|
||||
callsinfo->call_active_state = VOIP_ACTIVE;
|
||||
callsinfo->call_state = VOIP_UNKNOWN;
|
||||
|
@ -2023,7 +2033,10 @@ h225_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt,
|
|||
tmp_h323info = (h323_calls_info_t *)callsinfo->prot_info;
|
||||
g_assert(tmp_h323info != NULL);
|
||||
tmp_h323info->guid = (e_guid_t *)g_memdup(&pi->guid, sizeof pi->guid);
|
||||
DUMP_PTR1(tmp_h323info->guid);
|
||||
/* DUMP_PTR1(tmp_h323info->guid); */
|
||||
guid_str = guid_to_str(NULL, tmp_h323info->guid);
|
||||
callsinfo->call_id = g_strdup(guid_str);
|
||||
wmem_free(NULL, guid_str);
|
||||
|
||||
clear_address(&tmp_h323info->h225SetupAddr);
|
||||
tmp_h323info->h245_list = NULL;
|
||||
|
@ -2672,6 +2685,7 @@ mgcp_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt,
|
|||
tmp_mgcpinfo->fromEndpoint = fromEndpoint;
|
||||
callsinfo->npackets = 0;
|
||||
callsinfo->call_num = tapinfo->ncalls++;
|
||||
callsinfo->call_id=g_strdup_printf("%s --- %s --- %d", callsinfo->from_identity, callsinfo->to_identity, callsinfo->call_num);
|
||||
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
|
||||
}
|
||||
|
||||
|
@ -2881,6 +2895,7 @@ actrace_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *e
|
|||
tmp_actrace_cas_info->trunk=tapinfo->actrace_trunk;
|
||||
callsinfo->npackets = 0;
|
||||
callsinfo->call_num = tapinfo->ncalls++;
|
||||
callsinfo->call_id=g_strdup_printf("%s --- %s --- %d", callsinfo->from_identity, callsinfo->to_identity, callsinfo->call_num);
|
||||
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
|
||||
}
|
||||
|
||||
|
@ -3012,6 +3027,7 @@ h248_calls_packet_common(voip_calls_tapinfo_t *tapinfo, packet_info *pinfo, epan
|
|||
|
||||
callsinfo->protocol = TEL_H248;
|
||||
callsinfo->call_num = tapinfo->ncalls++;
|
||||
callsinfo->call_id=g_strdup_printf("%s --- %s --- %d", callsinfo->from_identity, callsinfo->to_identity, callsinfo->call_num);
|
||||
callsinfo->start_fd = pinfo->fd;
|
||||
callsinfo->start_rel_ts = pinfo->rel_ts;
|
||||
callsinfo->stop_fd = pinfo->fd;
|
||||
|
@ -3192,6 +3208,7 @@ sccp_calls(voip_calls_tapinfo_t *tapinfo, packet_info *pinfo, epan_dissect_t *ed
|
|||
callsinfo->stop_rel_ts = pinfo->rel_ts;
|
||||
|
||||
callsinfo->call_num = tapinfo->ncalls++;
|
||||
callsinfo->call_id=g_strdup_printf("%s --- %s --- %d", callsinfo->from_identity, callsinfo->to_identity, callsinfo->call_num);
|
||||
|
||||
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
|
||||
} else {
|
||||
|
@ -3444,6 +3461,7 @@ unistim_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *e
|
|||
callsinfo->free_prot_info = g_free;
|
||||
callsinfo->npackets = 0;
|
||||
callsinfo->call_num = tapinfo->ncalls++;
|
||||
callsinfo->call_id=g_strdup_printf("%s --- %s --- %d", callsinfo->from_identity, callsinfo->to_identity, callsinfo->call_num);
|
||||
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
|
||||
|
||||
} else {
|
||||
|
@ -3699,6 +3717,7 @@ unistim_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *e
|
|||
callsinfo->free_prot_info = g_free;
|
||||
callsinfo->npackets = 0;
|
||||
callsinfo->call_num = tapinfo->ncalls++;
|
||||
callsinfo->call_id=g_strdup_printf("%s --- %s --- %d", callsinfo->from_identity, callsinfo->to_identity, callsinfo->call_num);
|
||||
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
|
||||
|
||||
/* Open stream */
|
||||
|
@ -3910,6 +3929,7 @@ skinny_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *ed
|
|||
|
||||
callsinfo->protocol = VOIP_SKINNY;
|
||||
callsinfo->call_num = tapinfo->ncalls++;
|
||||
callsinfo->call_id=g_strdup_printf("%s --- %s --- %d", callsinfo->from_identity, callsinfo->to_identity, callsinfo->call_num);
|
||||
callsinfo->start_fd = pinfo->fd;
|
||||
callsinfo->start_rel_ts = pinfo->rel_ts;
|
||||
callsinfo->stop_fd = pinfo->fd;
|
||||
|
@ -4069,6 +4089,7 @@ iax2_calls_packet( void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt
|
|||
|
||||
callsinfo->protocol = VOIP_IAX2;
|
||||
callsinfo->call_num = tapinfo->ncalls++;
|
||||
callsinfo->call_id=g_strdup_printf("%s --- %s --- %d", callsinfo->from_identity, callsinfo->to_identity, callsinfo->call_num);
|
||||
callsinfo->start_fd=pinfo->fd;
|
||||
callsinfo->start_rel_ts=pinfo->rel_ts;
|
||||
callsinfo->stop_fd = pinfo->fd;
|
||||
|
@ -4190,6 +4211,7 @@ voip_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt,
|
|||
callsinfo->free_prot_info = NULL;
|
||||
|
||||
callsinfo->call_num = tapinfo->ncalls++;
|
||||
callsinfo->call_id=g_strdup_printf("%s --- %s --- %d", callsinfo->from_identity, callsinfo->to_identity, callsinfo->call_num);
|
||||
callsinfo->npackets = 0;
|
||||
|
||||
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
|
||||
|
|
|
@ -251,6 +251,12 @@ void voip_calls_remove_all_tap_listeners(voip_calls_tapinfo_t *tap_id_base);
|
|||
*/
|
||||
void voip_calls_reset_all_taps(voip_calls_tapinfo_t *tapinfo);
|
||||
|
||||
/**
|
||||
* Frees one callsinfo
|
||||
*/
|
||||
void
|
||||
voip_calls_free_callsinfo(voip_calls_info_t *callsinfo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
Loading…
Reference in New Issue