QList<QVariant> rowData() { return QList<QVariant>() << type_ << timestat_->rtd->num << nstime_to_sec(×tat_->rtd->min) << nstime_to_sec(×tat_->rtd->max) << get_average(×tat_->rtd->tot, timestat_->rtd->num) / 1000.0 << timestat_->rtd->min_num << timestat_->rtd->max_num << timestat_->open_req_num << timestat_->disc_rsp_num << timestat_->req_dup_num << timestat_->rsp_dup_num; }
// XXX We add multiple RTP streams here because that's what the GTK+ UI does. // Should we make these distinct, with their own waveforms? It seems like // that would simplify a lot of things. void RtpAudioStream::addRtpStream(const _rtp_stream_info *rtp_stream) { if (!rtp_stream) return; // RTP_STREAM_DEBUG("added %d:%u packets", g_list_length(rtp_stream->rtp_packet_list), rtp_stream->packet_count); rtp_streams_ << rtp_stream; double stream_srt = nstime_to_sec(&rtp_stream->start_rel_time); if (rtp_streams_.length() < 2 || stream_srt > start_rel_time_) { start_rel_time_ = stop_rel_time_ = stream_srt; start_abs_offset_ = nstime_to_sec(&rtp_stream->start_fd->abs_ts) - start_rel_time_; } }
void draw() { setText(col_messages_, QString::number(timestat_->rtd->num)); setText(col_min_srt_, QString::number(nstime_to_sec(×tat_->rtd->min), 'f', 6)); setText(col_max_srt_, QString::number(nstime_to_sec(×tat_->rtd->max), 'f', 6)); setText(col_avg_srt_, QString::number(get_average(×tat_->rtd->tot, timestat_->rtd->num) / 1000.0, 'f', 6)); setText(col_min_frame_, QString::number(timestat_->rtd->min_num)); setText(col_max_frame_, QString::number(timestat_->rtd->max_num)); setText(col_open_requests, QString::number(timestat_->open_req_num)); setText(col_discarded_responses_, QString::number(timestat_->disc_rsp_num)); setText(col_repeated_requests_, QString::number(timestat_->req_dup_num)); setText(col_repeated_responses_, QString::number(timestat_->rsp_dup_num)); setHidden(timestat_->rtd->num < 1); }
void draw() { setText(SRT_COLUMN_INDEX, QString::number(procedure_->index)); setText(SRT_COLUMN_CALLS, QString::number(procedure_->stats.num)); setText(SRT_COLUMN_MIN, QString::number(nstime_to_sec(&procedure_->stats.min), 'f', 6)); setText(SRT_COLUMN_MAX, QString::number(nstime_to_sec(&procedure_->stats.max), 'f', 6)); setText(SRT_COLUMN_AVG, QString::number(get_average(&procedure_->stats.tot, procedure_->stats.num) / 1000.0, 'f', 6)); setText(SRT_COLUMN_SUM, QString::number(nstime_to_sec(&procedure_->stats.tot), 'f', 6)); for (int col = 0; col < columnCount(); col++) { if (col == SRT_COLUMN_PROCEDURE) continue; setTextAlignment(col, Qt::AlignRight); } setHidden(procedure_->stats.num < 1); }
static gboolean process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps) { epan_dissect_t edt; union wtap_pseudo_header phdr; guint8 pd[WTAP_MAX_PACKET_SIZE]; double cur_time; /* Load the frame from the capture file */ if (!cf_read_frame_r(&cfile, frame, &phdr, pd)) return FALSE; /* failure */ /* Dissect the frame tree not visible */ epan_dissect_init(&edt, TRUE, FALSE); /* Don't fake protocols. We need them for the protocol hierarchy */ epan_dissect_fake_protocols(&edt, FALSE); epan_dissect_run(&edt, &phdr, pd, frame, cinfo); /* Get stats from this protocol tree */ process_tree(edt.tree, ps, frame->pkt_len); /* Update times */ cur_time = nstime_to_sec(&frame->abs_ts); if (cur_time < ps->first_time) { ps->first_time = cur_time; } if (cur_time > ps->last_time) { ps->last_time = cur_time; } /* Free our memory. */ epan_dissect_cleanup(&edt); return TRUE; /* success */ }
WSLUA_METHOD NSTime_tonumber(lua_State* L) { /* Returns a Lua number of the `NSTime` representing seconds from epoch @since 2.4.0 */ NSTime nstime = checkNSTime(L,1); lua_pushnumber(L, (lua_Number)nstime_to_sec(nstime)); WSLUA_RETURN(1); /* The Lua number. */ }
void RtpAudioStream::addRtpPacket(const struct _packet_info *pinfo, const struct _rtp_info *rtp_info) { // gtk/rtp_player.c:decode_rtp_packet if (!rtp_info) return; rtp_packet_t *rtp_packet = g_new0(rtp_packet_t, 1); rtp_packet->info = (struct _rtp_info *) g_memdup(rtp_info, sizeof(struct _rtp_info)); if (rtp_info->info_all_data_present && (rtp_info->info_payload_len != 0)) { rtp_packet->payload_data = (guint8 *) g_memdup(&(rtp_info->info_data[rtp_info->info_payload_offset]), (guint) rtp_info->info_payload_len); } if (rtp_packets_.size() < 1) { // First packet start_abs_offset_ = nstime_to_sec(&pinfo->fd->abs_ts) - start_rel_time_; start_rel_time_ = stop_rel_time_ = nstime_to_sec(&pinfo->rel_ts); } rtp_packet->frame_num = pinfo->fd->num; rtp_packet->arrive_offset = nstime_to_sec(&pinfo->rel_ts) - start_rel_time_; rtp_packets_ << rtp_packet; }
static gpointer pyshark_format_field(gpointer item, gchar *format) { if(strcmp(format, "s") == 0) { return Py_BuildValue(format, item); } else if(strcmp(format, "N") == 0) { return Py_BuildValue(""); // None object } else if(strcmp(format, "T") == 0) { nstime_t *tmp_timestamp = fvalue_get(item); /* Use fn in $wireshark/epan/nstime.c to convert timestamp to a float */ double tmp_double = nstime_to_sec(tmp_timestamp); /* TODO: create a Python-native time or timedelta object instead (?) */ return Py_BuildValue("f", tmp_double); } else if(strcmp(format, "f") == 0) { double tmp_double = fvalue_get_floating(item); return Py_BuildValue(format, tmp_double); } else if(strcmp(format, "K") == 0) { unsigned long long tmp_unsigned_long_long = fvalue_get_integer64(item); return Py_BuildValue(format, tmp_unsigned_long_long); } else if(strcmp(format, "i") == 0) { /* FIXME: does fvalue_get_sinteger() work properly with FT_INT{8,16,24} types? */ unsigned long tmp_long = fvalue_get_sinteger(item); return Py_BuildValue(format, tmp_long); } else if(strcmp(format, "k") == 0) { unsigned long tmp_unsigned_long = fvalue_get_uinteger(item); return Py_BuildValue(format, tmp_unsigned_long); } else if(strcmp(format, "B") == 0) { /* Wireshark implements FT_BOOLEANs as uintegers. See epan/ftype/ftype-integer.c */ unsigned long tmp_unsigned_long = fvalue_get_uinteger(item); return PyBool_FromLong(tmp_unsigned_long); } else return NULL; }
static gboolean process_record(capture_file *cf, frame_data *frame, column_info *cinfo, ph_stats_t* ps) { epan_dissect_t edt; struct wtap_pkthdr phdr; Buffer buf; double cur_time; wtap_phdr_init(&phdr); /* Load the record from the capture file */ ws_buffer_init(&buf, 1500); if (!cf_read_record_r(cf, frame, &phdr, &buf)) return FALSE; /* failure */ /* Dissect the record tree not visible */ epan_dissect_init(&edt, cf->epan, TRUE, FALSE); /* Don't fake protocols. We need them for the protocol hierarchy */ epan_dissect_fake_protocols(&edt, FALSE); epan_dissect_run(&edt, cf->cd_t, &phdr, frame_tvbuff_new_buffer(frame, &buf), frame, cinfo); /* Get stats from this protocol tree */ process_tree(edt.tree, ps, frame->pkt_len); if (frame->flags.has_ts) { /* Update times */ cur_time = nstime_to_sec(&frame->abs_ts); if (cur_time < ps->first_time) ps->first_time = cur_time; if (cur_time > ps->last_time) ps->last_time = cur_time; } /* Free our memory. */ epan_dissect_cleanup(&edt); wtap_phdr_cleanup(&phdr); ws_buffer_free(&buf); return TRUE; /* success */ }
static gboolean process_record(capture_file *cf, frame_data *frame, column_info *cinfo, wtap_rec *rec, Buffer *buf, ph_stats_t* ps) { epan_dissect_t edt; double cur_time; /* Load the record from the capture file */ if (!cf_read_record(cf, frame, rec, buf)) return FALSE; /* failure */ /* Dissect the record tree not visible */ epan_dissect_init(&edt, cf->epan, TRUE, FALSE); /* Don't fake protocols. We need them for the protocol hierarchy */ epan_dissect_fake_protocols(&edt, FALSE); epan_dissect_run(&edt, cf->cd_t, rec, frame_tvbuff_new_buffer(&cf->provider, frame, buf), frame, cinfo); /* Get stats from this protocol tree */ process_tree(edt.tree, ps); if (frame->has_ts) { /* Update times */ cur_time = nstime_to_sec(&frame->abs_ts); if (cur_time < ps->first_time) ps->first_time = cur_time; if (cur_time > ps->last_time) ps->last_time = cur_time; } /* Free our memory. */ epan_dissect_cleanup(&edt); return TRUE; /* success */ }
extern void mate_analyze_frame(packet_info *pinfo, proto_tree* tree) { mate_cfg_pdu* cfg; GPtrArray* protos; field_info* proto; guint i,j; AVPL* criterium_match; mate_pdu* pdu = NULL; mate_pdu* last = NULL; rd->now = (float) nstime_to_sec(&pinfo->fd->rel_ts); if ( proto_tracking_interesting_fields(tree) && rd->highest_analyzed_frame < pinfo->fd->num ) { for ( i = 0; i < mc->pducfglist->len; i++ ) { cfg = g_ptr_array_index(mc->pducfglist,i); dbg_print (dbg_pdu,4,dbg_facility,"mate_analyze_frame: trying to extract: %s",cfg->name); protos = proto_get_finfo_ptr_array(tree, cfg->hfid_proto); if (protos) { pdu = NULL; for (j = 0; j < protos->len; j++) { dbg_print (dbg_pdu,3,dbg_facility,"mate_analyze_frame: found matching proto, extracting: %s",cfg->name); proto = (field_info*) g_ptr_array_index(protos,j); pdu = new_pdu(cfg, pinfo->fd->num, proto, tree); if (cfg->criterium) { criterium_match = new_avpl_from_match(cfg->criterium_match_mode,"",pdu->avpl,cfg->criterium,FALSE); if (criterium_match) { delete_avpl(criterium_match,FALSE); } if ( (criterium_match && cfg->criterium_accept_mode == REJECT_MODE ) || ( ! criterium_match && cfg->criterium_accept_mode == ACCEPT_MODE )) { delete_avpl(pdu->avpl,TRUE); g_slice_free(mate_max_size,(mate_max_size*)pdu); pdu = NULL; continue; } } analyze_pdu(pdu); if ( ! pdu->gop && cfg->drop_unassigned) { delete_avpl(pdu->avpl,TRUE); g_slice_free(mate_max_size,(mate_max_size*)pdu); pdu = NULL; continue; } if ( cfg->discard ) { delete_avpl(pdu->avpl,TRUE); pdu->avpl = NULL; } if (!last) { g_hash_table_insert(rd->frames,GINT_TO_POINTER(pinfo->fd->num),pdu); last = pdu; } else { last->next_in_frame = pdu; last = pdu; } } if ( pdu && cfg->last_extracted ) break; } } rd->highest_analyzed_frame = pinfo->fd->num; } }
static int process_cap_file(wtap *wth, const char *filename) { int status = 0; int err; gchar *err_info; gint64 size; gint64 data_offset; guint32 packet = 0; gint64 bytes = 0; guint32 snaplen_min_inferred = 0xffffffff; guint32 snaplen_max_inferred = 0; const struct wtap_pkthdr *phdr; capture_info cf_info; gboolean have_times = TRUE; double start_time = 0; double stop_time = 0; double cur_time = 0; double prev_time = 0; gboolean know_order = FALSE; order_t order = IN_ORDER; wtapng_section_t *shb_inf; gchar *p; cf_info.encap_counts = g_new0(int,WTAP_NUM_ENCAP_TYPES); /* Tally up data that we need to parse through the file to find */ while (wtap_read(wth, &err, &err_info, &data_offset)) { phdr = wtap_phdr(wth); if (phdr->presence_flags & WTAP_HAS_TS) { prev_time = cur_time; cur_time = nstime_to_sec(&phdr->ts); if (packet == 0) { start_time = cur_time; stop_time = cur_time; prev_time = cur_time; } if (cur_time < prev_time) { order = NOT_IN_ORDER; } if (cur_time < start_time) { start_time = cur_time; } if (cur_time > stop_time) { stop_time = cur_time; } } else { have_times = FALSE; /* at least one packet has no time stamp */ if (order != NOT_IN_ORDER) order = ORDER_UNKNOWN; } if (phdr->rec_type == REC_TYPE_PACKET) { bytes+=phdr->len; packet++; /* If caplen < len for a rcd, then presumably */ /* 'Limit packet capture length' was done for this rcd. */ /* Keep track as to the min/max actual snapshot lengths */ /* seen for this file. */ if (phdr->caplen < phdr->len) { if (phdr->caplen < snaplen_min_inferred) snaplen_min_inferred = phdr->caplen; if (phdr->caplen > snaplen_max_inferred) snaplen_max_inferred = phdr->caplen; } /* Per-packet encapsulation */ if (wtap_file_encap(wth) == WTAP_ENCAP_PER_PACKET) { if ((phdr->pkt_encap > 0) && (phdr->pkt_encap < WTAP_NUM_ENCAP_TYPES)) { cf_info.encap_counts[phdr->pkt_encap] += 1; } else { fprintf(stderr, "capinfos: Unknown per-packet encapsulation: %d [frame number: %d]\n", phdr->pkt_encap, packet); } } } } /* while */ if (err != 0) { fprintf(stderr, "capinfos: An error occurred after reading %u packets from \"%s\": %s.\n", packet, filename, wtap_strerror(err)); switch (err) { case WTAP_ERR_SHORT_READ: status = 1; fprintf(stderr, " (will continue anyway, checksums might be incorrect)\n"); break; case WTAP_ERR_UNSUPPORTED: case WTAP_ERR_UNSUPPORTED_ENCAP: case WTAP_ERR_BAD_FILE: case WTAP_ERR_DECOMPRESS: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); /* fallthrough */ default: g_free(cf_info.encap_counts); return 1; } } /* File size */ size = wtap_file_size(wth, &err); if (size == -1) { fprintf(stderr, "capinfos: Can't get size of \"%s\": %s.\n", filename, g_strerror(err)); g_free(cf_info.encap_counts); return 1; } cf_info.filesize = size; /* File Type */ cf_info.file_type = wtap_file_type_subtype(wth); cf_info.iscompressed = wtap_iscompressed(wth); /* File Encapsulation */ cf_info.file_encap = wtap_file_encap(wth); /* Packet size limit (snaplen) */ cf_info.snaplen = wtap_snapshot_length(wth); if (cf_info.snaplen > 0) cf_info.snap_set = TRUE; else cf_info.snap_set = FALSE; cf_info.snaplen_min_inferred = snaplen_min_inferred; cf_info.snaplen_max_inferred = snaplen_max_inferred; /* # of packets */ cf_info.packet_count = packet; /* File Times */ cf_info.times_known = have_times; cf_info.start_time = start_time; cf_info.stop_time = stop_time; cf_info.duration = stop_time-start_time; cf_info.know_order = know_order; cf_info.order = order; /* Number of packet bytes */ cf_info.packet_bytes = bytes; cf_info.data_rate = 0.0; cf_info.packet_rate = 0.0; cf_info.packet_size = 0.0; if (packet > 0) { if (cf_info.duration > 0.0) { cf_info.data_rate = (double)bytes / (stop_time-start_time); /* Data rate per second */ cf_info.packet_rate = (double)packet / (stop_time-start_time); /* packet rate per second */ } cf_info.packet_size = (double)bytes / packet; /* Avg packet size */ } cf_info.comment = NULL; shb_inf = wtap_file_get_shb_info(wth); if (shb_inf) { /* opt_comment is always 0-terminated by pcapng_read_section_header_block */ cf_info.comment = g_strdup(shb_inf->opt_comment); } g_free(shb_inf); if (cf_info.comment) { /* multi-line comments would conflict with the formatting that capinfos uses we replace linefeeds with spaces */ p = cf_info.comment; while (*p != '\0') { if (*p == '\n') *p = ' '; p++; } } if (long_report) { print_stats(filename, &cf_info); } else { print_stats_table(filename, &cf_info); } g_free(cf_info.encap_counts); g_free(cf_info.comment); return status; }
static void iousers_draw(void *arg) { conv_hash_t *hash = (conv_hash_t*)arg; io_users_t *iu = (io_users_t *)hash->user_data; conv_item_t *iui; guint64 last_frames, max_frames; struct tm * tm_time; guint i; gboolean display_ports = (!strncmp(iu->type, "TCP", 3) || !strncmp(iu->type, "UDP", 3) || !strncmp(iu->type, "SCTP", 4)) ? TRUE : FALSE; printf("================================================================================\n"); printf("%s Conversations\n", iu->type); printf("Filter:%s\n", iu->filter ? iu->filter : "<No Filter>"); switch (timestamp_get_type()) { case TS_ABSOLUTE: case TS_UTC: printf("%s | <- | | -> | | Total | Absolute Time | Duration |\n", display_ports ? " " : ""); printf("%s | Frames Bytes | | Frames Bytes | | Frames Bytes | Start | |\n", display_ports ? " " : ""); break; case TS_ABSOLUTE_WITH_YMD: case TS_ABSOLUTE_WITH_YDOY: case TS_UTC_WITH_YMD: case TS_UTC_WITH_YDOY: printf("%s | <- | | -> | | Total | Absolute Date | Duration |\n", display_ports ? " " : ""); printf("%s | Frames Bytes | | Frames Bytes | | Frames Bytes | Start | |\n", display_ports ? " " : ""); break; case TS_RELATIVE: case TS_NOT_SET: default: printf("%s | <- | | -> | | Total | Relative | Duration |\n", display_ports ? " " : ""); printf("%s | Frames Bytes | | Frames Bytes | | Frames Bytes | Start | |\n", display_ports ? " " : ""); break; } max_frames = UINT_MAX; do { last_frames = 0; for (i=0; (iu->hash.conv_array && i < iu->hash.conv_array->len); i++) { guint64 tot_frames; iui = &g_array_index(iu->hash.conv_array, conv_item_t, i); tot_frames = iui->rx_frames + iui->tx_frames; if ((tot_frames > last_frames) && (tot_frames < max_frames)) { last_frames = tot_frames; } } for (i=0; (iu->hash.conv_array && i < iu->hash.conv_array->len); i++) { guint64 tot_frames; char *src_addr, *dst_addr; iui = &g_array_index(iu->hash.conv_array, conv_item_t, i); tot_frames = iui->rx_frames + iui->tx_frames; if (tot_frames == last_frames) { /* XXX - TODO: make name / port resolution configurable (through gbl_resolv_flags?) */ src_addr = get_conversation_address(NULL, &iui->src_address, TRUE); dst_addr = get_conversation_address(NULL, &iui->dst_address, TRUE); if (display_ports) { char *src, *dst, *src_port, *dst_port; src_port = get_conversation_port(NULL, iui->src_port, iui->ptype, TRUE); dst_port = get_conversation_port(NULL, iui->dst_port, iui->ptype, TRUE); src = wmem_strconcat(NULL, src_addr, ":", src_port, NULL); dst = wmem_strconcat(NULL, dst_addr, ":", dst_port, NULL); printf("%-26s <-> %-26s %6" G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER "u %6" G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER "u %6" G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER "u ", src, dst, iui->rx_frames, iui->rx_bytes, iui->tx_frames, iui->tx_bytes, iui->tx_frames+iui->rx_frames, iui->tx_bytes+iui->rx_bytes ); wmem_free(NULL, src_port); wmem_free(NULL, dst_port); wmem_free(NULL, src); wmem_free(NULL, dst); } else { printf("%-20s <-> %-20s %6" G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER "u %6" G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER "u %6" G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER "u ", src_addr, dst_addr, iui->rx_frames, iui->rx_bytes, iui->tx_frames, iui->tx_bytes, iui->tx_frames+iui->rx_frames, iui->tx_bytes+iui->rx_bytes ); } wmem_free(NULL, src_addr); wmem_free(NULL, dst_addr); switch (timestamp_get_type()) { case TS_ABSOLUTE: tm_time = localtime(&iui->start_abs_time.secs); printf("%02d:%02d:%02d %12.4f\n", tm_time->tm_hour, tm_time->tm_min, tm_time->tm_sec, nstime_to_sec(&iui->stop_time) - nstime_to_sec(&iui->start_time)); break; case TS_ABSOLUTE_WITH_YMD: tm_time = localtime(&iui->start_abs_time.secs); printf("%04d-%02d-%02d %02d:%02d:%02d %12.4f\n", tm_time->tm_year + 1900, tm_time->tm_mon + 1, tm_time->tm_mday, tm_time->tm_hour, tm_time->tm_min, tm_time->tm_sec, nstime_to_sec(&iui->stop_time) - nstime_to_sec(&iui->start_time)); break; case TS_ABSOLUTE_WITH_YDOY: tm_time = localtime(&iui->start_abs_time.secs); printf("%04d/%03d %02d:%02d:%02d %12.4f\n", tm_time->tm_year + 1900, tm_time->tm_yday + 1, tm_time->tm_hour, tm_time->tm_min, tm_time->tm_sec, nstime_to_sec(&iui->stop_time) - nstime_to_sec(&iui->start_time)); break; case TS_UTC: tm_time = gmtime(&iui->start_abs_time.secs); printf("%02d:%02d:%02d %12.4f\n", tm_time->tm_hour, tm_time->tm_min, tm_time->tm_sec, nstime_to_sec(&iui->stop_time) - nstime_to_sec(&iui->start_time)); break; case TS_UTC_WITH_YMD: tm_time = gmtime(&iui->start_abs_time.secs); printf("%04d-%02d-%02d %02d:%02d:%02d %12.4f\n", tm_time->tm_year + 1900, tm_time->tm_mon + 1, tm_time->tm_mday, tm_time->tm_hour, tm_time->tm_min, tm_time->tm_sec, nstime_to_sec(&iui->stop_time) - nstime_to_sec(&iui->start_time)); break; case TS_UTC_WITH_YDOY: tm_time = gmtime(&iui->start_abs_time.secs); printf("%04d/%03d %02d:%02d:%02d %12.4f\n", tm_time->tm_year + 1900, tm_time->tm_yday + 1, tm_time->tm_hour, tm_time->tm_min, tm_time->tm_sec, nstime_to_sec(&iui->stop_time) - nstime_to_sec(&iui->start_time)); break; case TS_RELATIVE: case TS_NOT_SET: default: printf("%14.9f %12.4f\n", nstime_to_sec(&iui->start_time), nstime_to_sec(&iui->stop_time) - nstime_to_sec(&iui->start_time) ); break; } } } max_frames = last_frames; } while (last_frames); printf("================================================================================\n"); }
#include <glib.h> #include <epan/packet_info.h> #include <epan/tap.h> #include <epan/stat_tap_ui.h> #include <epan/dissectors/packet-sv.h> void register_tap_listener_sv(void); static int sv_packet(void *prs _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pri) { int i; const sv_frame_data * sv_data = (const sv_frame_data *)pri; printf("%f %u ", nstime_to_sec(&pinfo->rel_ts), sv_data->smpCnt); for (i = 0; i < sv_data->num_phsMeas; i++) { printf("%d ", sv_data->phsMeas[i].value); } printf("\n"); return 0; } static void svstat_init(const char *opt_arg _U_, void *userdata _U_) { GString *error_string;
void summary_fill_in(capture_file *cf, summary_tally *st) { frame_data *first_frame, *cur_frame; guint32 framenum; wtapng_section_t* shb_inf; st->packet_count_ts = 0; st->start_time = 0; st->stop_time = 0; st->bytes = 0; st->filtered_count = 0; st->filtered_count_ts = 0; st->filtered_start = 0; st->filtered_stop = 0; st->filtered_bytes = 0; st->marked_count = 0; st->marked_count_ts = 0; st->marked_start = 0; st->marked_stop = 0; st->marked_bytes = 0; st->ignored_count = 0; /* initialize the tally */ if (cf->count != 0) { first_frame = frame_data_sequence_find(cf->frames, 1); st->start_time = nstime_to_sec(&first_frame->abs_ts); st->stop_time = nstime_to_sec(&first_frame->abs_ts); for (framenum = 1; framenum <= cf->count; framenum++) { cur_frame = frame_data_sequence_find(cf->frames, framenum); tally_frame_data(cur_frame, st); } } st->filename = cf->filename; st->file_length = cf->f_datalen; st->file_type = cf->cd_t; st->is_tempfile = cf->is_tempfile; st->encap_type = cf->lnk_t; st->has_snap = cf->has_snap; st->snap = cf->snap; st->elapsed_time = nstime_to_sec(&cf->elapsed_time); st->packet_count = cf->count; st->drops_known = cf->drops_known; st->drops = cf->drops; st->dfilter = cf->dfilter; /* Get info from SHB */ shb_inf = wtap_file_get_shb_info(cf->wth); if(shb_inf == NULL){ st->opt_comment = NULL; st->shb_hardware = NULL; st->shb_os = NULL; st->shb_user_appl = NULL; }else{ st->opt_comment = shb_inf->opt_comment; st->shb_hardware = shb_inf->shb_hardware; st->shb_os = shb_inf->shb_os; st->shb_user_appl = shb_inf->shb_user_appl; g_free(shb_inf); } st->ifaces = g_array_new(FALSE, FALSE, sizeof(iface_options)); }
QList<QVariant> rowData() { return QList<QVariant>() << QString(procedure_->procedure) << procedure_->index << procedure_->stats.num << nstime_to_sec(&procedure_->stats.min) << nstime_to_sec(&procedure_->stats.max) << get_average(&procedure_->stats.tot, procedure_->stats.num) / 1000.0 << nstime_to_sec(&procedure_->stats.tot); }
static rtpproxy_info_t * rtpproxy_add_tid(gboolean is_request, tvbuff_t *tvb, packet_info *pinfo, proto_tree *rtpproxy_tree, rtpproxy_conv_info_t *rtpproxy_conv, gchar* cookie) { rtpproxy_info_t *rtpproxy_info; proto_item *pi; if (!PINFO_FD_VISITED(pinfo)) { if (is_request) { rtpproxy_info = wmem_new(wmem_file_scope(), rtpproxy_info_t); rtpproxy_info->req_frame = PINFO_FD_NUM(pinfo); rtpproxy_info->resp_frame = 0; rtpproxy_info->req_time = pinfo->fd->abs_ts; rtpproxy_info->callid = NULL; wmem_tree_insert_string(rtpproxy_conv->trans, cookie, rtpproxy_info, 0); } else { rtpproxy_info = (rtpproxy_info_t *)wmem_tree_lookup_string(rtpproxy_conv->trans, cookie, 0); if (rtpproxy_info) { rtpproxy_info->resp_frame = PINFO_FD_NUM(pinfo); } } } else { rtpproxy_info = (rtpproxy_info_t *)wmem_tree_lookup_string(rtpproxy_conv->trans, cookie, 0); if (rtpproxy_info && (is_request ? rtpproxy_info->resp_frame : rtpproxy_info->req_frame)) { nstime_t ns; pi = proto_tree_add_uint(rtpproxy_tree, is_request ? hf_rtpproxy_response_in : hf_rtpproxy_request_in, tvb, 0, 0, is_request ? rtpproxy_info->resp_frame : rtpproxy_info->req_frame); PROTO_ITEM_SET_GENERATED(pi); /* If reply then calculate response time */ if (!is_request) { nstime_delta(&ns, &pinfo->fd->abs_ts, &rtpproxy_info->req_time); pi = proto_tree_add_time(rtpproxy_tree, hf_rtpproxy_response_time, tvb, 0, 0, &ns); PROTO_ITEM_SET_GENERATED(pi); if (nstime_cmp(&rtpproxy_timeout_ns, &ns) < 0) expert_add_info_format(pinfo, rtpproxy_tree, &ei_rtpproxy_timeout, "Response timeout %.3f seconds", nstime_to_sec(&ns)); } } } /* Could be NULL so we should check it before dereferencing */ return rtpproxy_info; }
static void tally_frame_data(frame_data *cur_frame, summary_tally *sum_tally) { double cur_time; sum_tally->bytes += cur_frame->pkt_len; if (cur_frame->flags.passed_dfilter){ sum_tally->filtered_count++; sum_tally->filtered_bytes += cur_frame->pkt_len; } if (cur_frame->flags.marked){ sum_tally->marked_count++; sum_tally->marked_bytes += cur_frame->pkt_len; } if (cur_frame->flags.ignored){ sum_tally->ignored_count++; } if (cur_frame->flags.has_ts) { /* This packet has a time stamp. */ cur_time = nstime_to_sec(&cur_frame->abs_ts); sum_tally->packet_count_ts++; if (cur_time < sum_tally->start_time) { sum_tally->start_time = cur_time; } if (cur_time > sum_tally->stop_time){ sum_tally->stop_time = cur_time; } if (cur_frame->flags.passed_dfilter){ sum_tally->filtered_count_ts++; /* * If we've seen one filtered packet, this is the first * one. */ if (sum_tally->filtered_count == 1){ sum_tally->filtered_start= cur_time; sum_tally->filtered_stop = cur_time; } else { if (cur_time < sum_tally->filtered_start) { sum_tally->filtered_start = cur_time; } if (cur_time > sum_tally->filtered_stop) { sum_tally->filtered_stop = cur_time; } } } if (cur_frame->flags.marked){ sum_tally->marked_count_ts++; /* * If we've seen one marked packet, this is the first * one. */ if (sum_tally->marked_count == 1){ sum_tally->marked_start= cur_time; sum_tally->marked_stop = cur_time; } else { if (cur_time < sum_tally->marked_start) { sum_tally->marked_start = cur_time; } if (cur_time > sum_tally->marked_stop) { sum_tally->marked_stop = cur_time; } } } } }
void summary_fill_in(capture_file *cf, summary_tally *st) { frame_data *first_frame, *cur_frame; guint32 framenum; wtapng_section_t* shb_inf; iface_options iface; guint i; wtapng_iface_descriptions_t* idb_info; wtapng_if_descr_t wtapng_if_descr; wtapng_if_stats_t *if_stats; st->packet_count_ts = 0; st->start_time = 0; st->stop_time = 0; st->bytes = 0; st->filtered_count = 0; st->filtered_count_ts = 0; st->filtered_start = 0; st->filtered_stop = 0; st->filtered_bytes = 0; st->marked_count = 0; st->marked_count_ts = 0; st->marked_start = 0; st->marked_stop = 0; st->marked_bytes = 0; st->ignored_count = 0; /* initialize the tally */ if (cf->count != 0) { first_frame = frame_data_sequence_find(cf->frames, 1); st->start_time = nstime_to_sec(&first_frame->abs_ts); st->stop_time = nstime_to_sec(&first_frame->abs_ts); for (framenum = 1; framenum <= cf->count; framenum++) { cur_frame = frame_data_sequence_find(cf->frames, framenum); tally_frame_data(cur_frame, st); } } st->filename = cf->filename; st->file_length = cf->f_datalen; st->file_type = cf->cd_t; st->iscompressed = cf->iscompressed; st->is_tempfile = cf->is_tempfile; st->file_encap_type = cf->lnk_t; st->packet_encap_types = cf->linktypes; st->has_snap = cf->has_snap; st->snap = cf->snap; st->elapsed_time = nstime_to_sec(&cf->elapsed_time); st->packet_count = cf->count; st->drops_known = cf->drops_known; st->drops = cf->drops; st->dfilter = cf->dfilter; /* Get info from SHB */ shb_inf = wtap_file_get_shb_info(cf->wth); if(shb_inf == NULL){ st->opt_comment = NULL; st->shb_hardware = NULL; st->shb_os = NULL; st->shb_user_appl = NULL; }else{ st->opt_comment = shb_inf->opt_comment; st->shb_hardware = shb_inf->shb_hardware; st->shb_os = shb_inf->shb_os; st->shb_user_appl = shb_inf->shb_user_appl; g_free(shb_inf); } st->ifaces = g_array_new(FALSE, FALSE, sizeof(iface_options)); idb_info = wtap_file_get_idb_info(cf->wth); for (i = 0; i < idb_info->interface_data->len; i++) { wtapng_if_descr = g_array_index(idb_info->interface_data, wtapng_if_descr_t, i); iface.cfilter = g_strdup(wtapng_if_descr.if_filter_str); iface.name = g_strdup(wtapng_if_descr.if_name); iface.descr = g_strdup(wtapng_if_descr.if_description); iface.drops_known = FALSE; iface.drops = 0; iface.snap = wtapng_if_descr.snap_len; iface.has_snap = (iface.snap != 65535); iface.encap_type = wtapng_if_descr.wtap_encap; if(wtapng_if_descr.num_stat_entries == 1){ /* dumpcap only writes one ISB, only handle that for now */ if_stats = &g_array_index(wtapng_if_descr.interface_statistics, wtapng_if_stats_t, 0); iface.drops_known = TRUE; iface.drops = if_stats->isb_ifdrop; iface.isb_comment = if_stats->opt_comment; } g_array_append_val(st->ifaces, iface); } g_free(idb_info); }
void iax2_packet_analyse(tap_iax2_stat_t *statinfo, packet_info *pinfo, const struct _iax2_info_t *iax2info) { double current_time; double current_jitter; double current_diff; statinfo->flags = 0; /* check payload type */ if (iax2info->ftype == AST_FRAME_VOICE) { if (iax2info->csub != statinfo->pt) statinfo->flags |= STAT_FLAG_PT_CHANGE; statinfo->pt = iax2info->csub; } /* store the current time and calculate the current jitter */ current_time = nstime_to_sec(&pinfo->rel_ts); current_diff = fabs (current_time - statinfo->time - (((double)iax2info->timestamp - (double)statinfo->timestamp)/1000)); current_jitter = statinfo->jitter + ( current_diff - statinfo->jitter)/16; statinfo->delta = current_time - (statinfo->time); statinfo->jitter = current_jitter; statinfo->diff = current_diff; /* calculate the BW in Kbps adding the IP+IAX2 header to the RTP -> 20bytes(IP)+ 4bytes(Mini) = 24bytes */ statinfo->bw_history[statinfo->bw_index].bytes = iax2info->payload_len + 24; statinfo->bw_history[statinfo->bw_index].time = current_time; /* check if there are more than 1sec in the history buffer to calculate BW in bps. If so, remove those for the calculation */ while ((statinfo->bw_history[statinfo->bw_start_index].time+1) < current_time) { statinfo->total_bytes -= statinfo->bw_history[statinfo->bw_start_index].bytes; statinfo->bw_start_index++; if (statinfo->bw_start_index == BUFF_BW) statinfo->bw_start_index = 0; }; statinfo->total_bytes += iax2info->payload_len + 24; statinfo->bandwidth = (double)(statinfo->total_bytes*8)/1000; statinfo->bw_index++; if (statinfo->bw_index == BUFF_BW) statinfo->bw_index = 0; /* is this the first packet we got in this direction? */ if (statinfo->first_packet) { statinfo->start_seq_nr = 0; statinfo->start_time = current_time; statinfo->delta = 0; statinfo->jitter = 0; statinfo->diff = 0; statinfo->flags |= STAT_FLAG_FIRST; statinfo->first_packet = FALSE; } /* is it a regular packet? */ if (!(statinfo->flags & STAT_FLAG_FIRST) && !(statinfo->flags & STAT_FLAG_MARKER) && !(statinfo->flags & STAT_FLAG_PT_CN) && !(statinfo->flags & STAT_FLAG_WRONG_TIMESTAMP) && !(statinfo->flags & STAT_FLAG_FOLLOW_PT_CN)) { /* include it in maximum delta calculation */ if (statinfo->delta > statinfo->max_delta) { statinfo->max_delta = statinfo->delta; statinfo->max_nr = pinfo->num; } /* maximum and mean jitter calculation */ if (statinfo->jitter > statinfo->max_jitter) { statinfo->max_jitter = statinfo->jitter; } statinfo->mean_jitter = (statinfo->mean_jitter*statinfo->total_nr + current_diff) / (statinfo->total_nr+1); } /* regular payload change? (CN ignored) */ if (!(statinfo->flags & STAT_FLAG_FIRST) && !(statinfo->flags & STAT_FLAG_PT_CN)) { if ((statinfo->pt != statinfo->reg_pt) && (statinfo->reg_pt != PT_UNDEFINED)) { statinfo->flags |= STAT_FLAG_REG_PT_CHANGE; } } /* set regular payload*/ if (!(statinfo->flags & STAT_FLAG_PT_CN)) { statinfo->reg_pt = statinfo->pt; } /* TODO: lost packets / duplicated: we should infer this from timestamp... */ statinfo->time = current_time; statinfo->timestamp = iax2info->timestamp; /* millisecs */ statinfo->stop_seq_nr = 0; statinfo->total_nr++; return; }
// Adapted from get_it_value in gtk/io_stat.c. double get_io_graph_item(const io_graph_item_t *items_, io_graph_item_unit_t val_units_, int idx, int hf_index_, const capture_file *cap_file, int interval_, int cur_idx_) { double value = 0; /* FIXME: loss of precision, visible on the graph for small values */ int adv_type; const io_graph_item_t *item; guint32 interval; item = &items_[idx]; // Basic units switch (val_units_) { case IOG_ITEM_UNIT_PACKETS: return item->frames; case IOG_ITEM_UNIT_BYTES: return (double) item->bytes; case IOG_ITEM_UNIT_BITS: return (double) (item->bytes * 8); case IOG_ITEM_UNIT_CALC_FRAMES: return item->frames; case IOG_ITEM_UNIT_CALC_FIELDS: return (double) item->fields; default: /* If it's COUNT_TYPE_ADVANCED but not one of the * generic ones we'll get it when we switch on the * adv_type below. */ break; } if (hf_index_ < 0) { return 0; } // Advanced units adv_type = proto_registrar_get_ftype(hf_index_); switch (adv_type) { case FT_UINT8: case FT_UINT16: case FT_UINT24: case FT_UINT32: case FT_UINT64: case FT_INT8: case FT_INT16: case FT_INT24: case FT_INT32: case FT_INT64: switch (val_units_) { case IOG_ITEM_UNIT_CALC_SUM: value = (double) item->int_tot; break; case IOG_ITEM_UNIT_CALC_MAX: value = (double) item->int_max; break; case IOG_ITEM_UNIT_CALC_MIN: value = (double) item->int_min; break; case IOG_ITEM_UNIT_CALC_AVERAGE: if (item->fields) { value = (double)item->int_tot / item->fields; } else { value = 0; } break; default: break; } break; case FT_FLOAT: switch (val_units_) { case IOG_ITEM_UNIT_CALC_SUM: value = item->float_tot; break; case IOG_ITEM_UNIT_CALC_MAX: value = item->float_max; break; case IOG_ITEM_UNIT_CALC_MIN: value = item->float_min; break; case IOG_ITEM_UNIT_CALC_AVERAGE: if (item->fields) { value = (double)item->float_tot / item->fields; } else { value = 0; } break; default: break; } break; case FT_DOUBLE: switch (val_units_) { case IOG_ITEM_UNIT_CALC_SUM: value = item->double_tot; break; case IOG_ITEM_UNIT_CALC_MAX: value = item->double_max; break; case IOG_ITEM_UNIT_CALC_MIN: value = item->double_min; break; case IOG_ITEM_UNIT_CALC_AVERAGE: if (item->fields) { value = item->double_tot / item->fields; } else { value = 0; } break; default: break; } break; case FT_RELATIVE_TIME: switch (val_units_) { case IOG_ITEM_UNIT_CALC_MAX: value = nstime_to_sec(&item->time_max); break; case IOG_ITEM_UNIT_CALC_MIN: value = nstime_to_sec(&item->time_min); break; case IOG_ITEM_UNIT_CALC_SUM: value = nstime_to_sec(&item->time_tot); break; case IOG_ITEM_UNIT_CALC_AVERAGE: if (item->fields) { value = nstime_to_sec(&item->time_tot) / item->fields; } else { value = 0; } break; case IOG_ITEM_UNIT_CALC_LOAD: // "LOAD graphs plot the QUEUE-depth of the connection over time" // (for response time fields such as smb.time, rpc.time, etc.) // This interval is expressed in milliseconds. if (idx == cur_idx_ && cap_file) { interval = (guint32)(nstime_to_msec(&cap_file->elapsed_time) + 0.5); interval -= (interval_ * idx); } else { interval = interval_; } value = nstime_to_msec(&item->time_tot) / interval; break; default: break; } break; default: break; } return value; }
ph_stats_t* ph_stats_new(void) { ph_stats_t *ps; frame_data *frame; guint tot_packets, tot_bytes; progdlg_t *progbar = NULL; gboolean stop_flag; int count; float progbar_val; GTimeVal start_time; gchar status_str[100]; int progbar_nextstep; int progbar_quantum; /* Initialize the data */ ps = g_new(ph_stats_t, 1); ps->tot_packets = 0; ps->tot_bytes = 0; ps->stats_tree = g_node_new(NULL); ps->first_time = 0.0; ps->last_time = 0.0; /* Update the progress bar when it gets to this value. */ progbar_nextstep = 0; /* When we reach the value that triggers a progress bar update, bump that value by this amount. */ progbar_quantum = cfile.count/N_PROGBAR_UPDATES; /* Count of packets at which we've looked. */ count = 0; /* Progress so far. */ progbar_val = 0.0f; stop_flag = FALSE; g_get_current_time(&start_time); tot_packets = 0; tot_bytes = 0; for (frame = cfile.plist_start; frame != NULL; frame = frame->next) { /* Create the progress bar if necessary. We check on every iteration of the loop, so that it takes no longer than the standard time to create it (otherwise, for a large file, we might take considerably longer than that standard time in order to get to the next progress bar step). */ if (progbar == NULL) progbar = delayed_create_progress_dlg( "Computing", "protocol hierarchy statistics", TRUE, &stop_flag, &start_time, progbar_val); /* Update the progress bar, but do it only N_PROGBAR_UPDATES times; when we update it, we have to run the GTK+ main loop to get it to repaint what's pending, and doing so may involve an "ioctl()" to see if there's any pending input from an X server, and doing that for every packet can be costly, especially on a big file. */ if (count >= progbar_nextstep) { /* let's not divide by zero. I should never be started * with count == 0, so let's assert that */ g_assert(cfile.count > 0); progbar_val = (gfloat) count / cfile.count; if (progbar != NULL) { g_snprintf(status_str, sizeof(status_str), "%4u of %u frames", count, cfile.count); update_progress_dlg(progbar, progbar_val, status_str); } progbar_nextstep += progbar_quantum; } if (stop_flag) { /* Well, the user decided to abort the statistics. computation process Just stop. */ break; } /* Skip frames that are hidden due to the display filter. XXX - should the progress bar count only packets that passed the display filter? If so, it should probably do so for other loops (see "file.c") that look only at those packets. */ if (frame->flags.passed_dfilter) { if (tot_packets == 0) { double cur_time = nstime_to_sec(&frame->abs_ts); ps->first_time = cur_time; ps->last_time = cur_time; } /* we don't care about colinfo */ if (!process_frame(frame, NULL, ps)) { /* * Give up, and set "stop_flag" so we * just abort rather than popping up * the statistics window. */ stop_flag = TRUE; break; } tot_packets++; tot_bytes += frame->pkt_len; } count++; } /* We're done calculating the statistics; destroy the progress bar if it was created. */ if (progbar != NULL) destroy_progress_dlg(progbar); if (stop_flag) { /* * We quit in the middle; throw away the statistics * and return NULL, so our caller doesn't pop up a * window with the incomplete statistics. */ ph_stats_free(ps); return NULL; } ps->tot_packets = tot_packets; ps->tot_bytes = tot_bytes; return ps; }
void RtpAudioStream::addRtpPacket(const struct _packet_info *pinfo, const _rtp_info *rtp_info) { if (!rtp_info) return; // Combination of gtk/rtp_player.c:decode_rtp_stream + decode_rtp_packet // XXX This is more messy than it should be. SAMPLE *decode_buff = NULL; SAMPLE *resample_buff = NULL; spx_uint32_t cur_in_rate, visual_out_rate; char *write_buff; qint64 write_bytes; unsigned channels; unsigned sample_rate; rtp_packet_t rtp_packet; stop_rel_time_ = nstime_to_sec(&pinfo->rel_ts); ws_codec_resampler_get_rate(visual_resampler_, &cur_in_rate, &visual_out_rate); QString payload_name; if (rtp_info->info_payload_type_str) { payload_name = rtp_info->info_payload_type_str; } else { payload_name = try_val_to_str_ext(rtp_info->info_payload_type, &rtp_payload_type_short_vals_ext); } if (!payload_name.isEmpty()) { payload_names_ << payload_name; } // First, decode the payload. rtp_packet.info = (_rtp_info *) g_memdup(rtp_info, sizeof(struct _rtp_info)); rtp_packet.arrive_offset = start_rel_time_; if (rtp_info->info_all_data_present && (rtp_info->info_payload_len != 0)) { rtp_packet.payload_data = (guint8 *)g_malloc(rtp_info->info_payload_len); memcpy(rtp_packet.payload_data, rtp_info->info_data + rtp_info->info_payload_offset, rtp_info->info_payload_len); } else { rtp_packet.payload_data = NULL; } //size_t decoded_bytes = decode_rtp_packet(&rtp_packet, &decode_buff, decoders_hash_, &channels, &sample_rate); write_buff = (char *) decode_buff; write_bytes = rtp_info->info_payload_len * sample_bytes_; if (tempfile_->pos() == 0) { // First packet. Let it determine our sample rate. audio_out_rate_ = sample_rate; last_sequence_ = rtp_info->info_seq_num - 1; // Prepend silence to match our sibling streams. int prepend_samples = (start_rel_time_ - global_start_rel_time_) * audio_out_rate_; if (prepend_samples > 0) { int prepend_bytes = prepend_samples * sample_bytes_; char *prepend_buff = (char *) g_malloc(prepend_bytes); SAMPLE silence = 0; memccpy(prepend_buff, &silence, prepend_samples, sample_bytes_); tempfile_->write(prepend_buff, prepend_bytes); } } else if (audio_out_rate_ != sample_rate) { // Resample the audio to match our previous output rate. if (!audio_resampler_) { audio_resampler_ = ws_codec_resampler_init(1, sample_rate, audio_out_rate_, 10, NULL); ws_codec_resampler_skip_zeros(audio_resampler_); // RTP_STREAM_DEBUG("Started resampling from %u to (out) %u Hz.", sample_rate, audio_out_rate_); } else { spx_uint32_t audio_out_rate; ws_codec_resampler_get_rate(audio_resampler_, &cur_in_rate, &audio_out_rate); // Adjust rates if needed. if (sample_rate != cur_in_rate) { ws_codec_resampler_set_rate(audio_resampler_, sample_rate, audio_out_rate); ws_codec_resampler_set_rate(visual_resampler_, sample_rate, visual_out_rate); // RTP_STREAM_DEBUG("Changed input rate from %u to %u Hz. Out is %u.", cur_in_rate, sample_rate, audio_out_rate_); } } spx_uint32_t in_len = (spx_uint32_t)rtp_info->info_payload_len; spx_uint32_t out_len = (audio_out_rate_ * (spx_uint32_t)rtp_info->info_payload_len / sample_rate) + (audio_out_rate_ % sample_rate != 0); resample_buff = (SAMPLE *) g_malloc(out_len * sample_bytes_); ws_codec_resampler_process_int(audio_resampler_, 0, decode_buff, &in_len, resample_buff, &out_len); write_buff = (char *) decode_buff; write_bytes = out_len * sample_bytes_; } if (rtp_info->info_seq_num != last_sequence_+1) { out_of_seq_timestamps_.append(stop_rel_time_); // XXX Add silence to tempfile_ and visual_samples_ } last_sequence_ = rtp_info->info_seq_num; // Write the decoded, possibly-resampled audio to our temp file. tempfile_->write(write_buff, write_bytes); // Collect our visual samples. spx_uint32_t in_len = (spx_uint32_t)rtp_info->info_payload_len; spx_uint32_t out_len = (visual_out_rate * in_len / sample_rate) + (visual_out_rate % sample_rate != 0); resample_buff = (SAMPLE *) g_realloc(resample_buff, out_len * sizeof(SAMPLE)); ws_codec_resampler_process_int(visual_resampler_, 0, decode_buff, &in_len, resample_buff, &out_len); for (unsigned i = 0; i < out_len; i++) { packet_timestamps_[stop_rel_time_ + (double) i / visual_out_rate] = pinfo->fd->num; if (qAbs(resample_buff[i]) > max_sample_val_) max_sample_val_ = qAbs(resample_buff[i]); visual_samples_.append(resample_buff[i]); } // Finally, write the resampled audio to our temp file and clean up. g_free(rtp_packet.payload_data); g_free(decode_buff); g_free(resample_buff); }
ti->setData(stream_data_col_, Qt::UserRole, QVariant::fromValue(audio_stream)); for (int col = 0; col < ui->streamTreeWidget->columnCount(); col++) { ti->setTextColor(col, audio_stream->color()); } connect(ui->playButton, SIGNAL(clicked(bool)), audio_stream, SLOT(startPlaying())); connect(ui->stopButton, SIGNAL(clicked(bool)), audio_stream, SLOT(stopPlaying())); connect(audio_stream, SIGNAL(startedPlaying()), this, SLOT(updateWidgets())); connect(audio_stream, SIGNAL(finishedPlaying()), this, SLOT(updateWidgets())); connect(audio_stream, SIGNAL(processedSecs(double)), this, SLOT(setPlayPosition(double))); } audio_stream->addRtpStream(rtp_stream); double start_rel_time = nstime_to_sec(&rtp_stream->start_rel_time); if (tli_count < 2) { start_rel_time_ = start_rel_time; } else { start_rel_time_ = qMin(start_rel_time_, start_rel_time); } RTP_STREAM_DEBUG("adding stream %d to layout, %u packets, %u in list, start %u", ui->streamTreeWidget->topLevelItemCount(), rtp_stream->packet_count, g_list_length(rtp_stream->rtp_packet_list), rtp_stream->start_fd->num); } void RtpPlayerDialog::showEvent(QShowEvent *) { QList<int> split_sizes = ui->splitter->sizes();
gpointer cb_row_set(sharktools_callbacks *cb, void *row, void *key, gulong type, GPtrArray *tree_values) { static nstime_t *tmp_timestamp; double tmp_double; // Bomb out; I haven't updated this app... fvalue_t *val_native; const gchar *val_string; g_assert_not_reached(); //printf("%s (%d)\t\t", val_string, (int)type); switch(type) { case FT_NONE: /* used for text labels with no value */ printf("None"); break; //case FT_PROTOCOL: //case FT_BOOLEAN: /* TRUE and FALSE come from <glib.h> */ case FT_UINT8: case FT_UINT16: case FT_UINT24: /* really a UINT32, but displayed as 3 hex-digits if FD_HEX*/ case FT_UINT32: /* FIXME: does fvalue_get_uinteger() work properly with FT_UINT{8,16,24} types? */ printf("%u", fvalue_get_uinteger(val_native)); break; case FT_INT64: /* Wireshark doesn't seem to make a difference between INT64 and UINT64 */ case FT_UINT64: //guint64 tmp = printf("%llu", (long long unsigned int)fvalue_get_integer64(val_native));// tmp); break; case FT_INT8: case FT_INT16: case FT_INT24: /* same as for UINT24 */ case FT_INT32: /* FIXME: does fvalue_get_sinteger() work properly with FT_INT{8,16,24} types? */ printf("%d", fvalue_get_sinteger(val_native)); break; case FT_FLOAT: case FT_DOUBLE: printf("%f", fvalue_get_floating(val_native)); break; case FT_ABSOLUTE_TIME: case FT_RELATIVE_TIME: tmp_timestamp = fvalue_get(val_native); // Use fn in $wireshark/epan/nstime.c to convert timestamp to a float tmp_double = nstime_to_sec(tmp_timestamp); printf("%f", tmp_double); break; //case FT_UINT_STRING: /* for use with proto_tree_add_item() */ //case FT_ETHER: //case FT_BYTES: //case FT_UINT_BYTES: //case FT_IPv4: //case FT_IPv6: //case FT_IPXNET: //case FT_FRAMENUM: /* a UINT32, but if selected lets you go to frame with that numbe */ //case FT_PCRE: /* a compiled Perl-Compatible Regular Expression object */ //case FT_GUID: /* GUID, UUID */ //case FT_OID: /* OBJECT IDENTIFIER */ default: printf("%s", val_string); break; } printf(" (%d)\t\t", (int)type); /* if(type == FT_UINT32) { //printf("%d (%d)\t\t", val_native->value.uinteger, (int)type); printf("%d (%d)\t\t", fvalue_get_uinteger(val_native), (int)type); } */ return NULL; }