From fa8146f053967b306aa431fe9d7708236b5d8bf3 Mon Sep 17 00:00:00 2001 From: Dylan Mikus Date: Tue, 22 Mar 2016 15:23:07 +0000 Subject: [PATCH] Fixes for recording packet counter - The packet counter was accidentally a pointer, resulting in it incrementing by 8 instead of 1. That is fixed. - Use proper formatting macro for uint64_t printing. - Start PCAP packet indexing at 1 since that is what Wireshark does. --- daemon/media_socket.c | 4 +--- daemon/recording.c | 9 +++++---- daemon/recording.h | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/daemon/media_socket.c b/daemon/media_socket.c index a2da1349b..4a00fd1d9 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -21,8 +21,6 @@ #include "recording.h" - - #ifndef PORT_RANDOM_MIN #define PORT_RANDOM_MIN 6 #define PORT_RANDOM_MAX 20 @@ -1202,7 +1200,7 @@ loop_ok: // If recording pcap dumper is set, then we record the call. if (recording_pdumper != NULL && call->record_call) { stream_pcap_dump(recording_pdumper, stream, s); - call->recording->packet_num += 1; + call->recording->packet_num++; } if (handler_ret >= 0) { diff --git a/daemon/recording.c b/daemon/recording.c index 10c7db5ce..4779b61ab 100644 --- a/daemon/recording.c +++ b/daemon/recording.c @@ -6,10 +6,10 @@ #include #include #include -#include "call.h" #include #include - +#include +#include "call.h" int maybe_create_spool_dir(char *dirpath); @@ -136,7 +136,8 @@ int set_record_call(struct call *call, str recordcall) { call->recording = g_slice_alloc0(sizeof(struct recording)); call->recording->recording_pd = NULL; call->recording->recording_pdumper = NULL; - call->recording->packet_num = 0; + // Wireshark starts at packet index 1, so we start there, too + call->recording->packet_num = 1; meta_setup_file(call->recording, call->callid); } } else if (!str_cmp(&recordcall, "no")) { @@ -219,7 +220,7 @@ ssize_t meta_write_sdp(FILE *meta_fp, struct iovec *sdp_iov, int iovcnt, } else { fprintf(meta_fp, "other"); } - fprintf(meta_fp, "\nSDP before RTP packet: %llu\n\n", packet_num); + fprintf(meta_fp, "\nSDP before RTP packet: %" PRIu64 "\n\n", packet_num); fflush(meta_fp); return writev(meta_fd, sdp_iov, iovcnt); } diff --git a/daemon/recording.h b/daemon/recording.h index 2f83b979e..0a0cd2784 100644 --- a/daemon/recording.h +++ b/daemon/recording.h @@ -20,7 +20,7 @@ struct recording { str *metadata; pcap_t *recording_pd; pcap_dumper_t *recording_pdumper; - uint64_t *packet_num; + uint64_t packet_num; str *recording_path; };