diff --git a/CMakeLists.txt b/CMakeLists.txt index 93cdd58..09c68f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(sngrep LANGUAGES C) set(PROJECT_NAME sngrep) -set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD 11) #add_compile_options(-Werror -g) add_compile_options(-Werror -g -Wall -pedantic -Wextra) diff --git a/src/capture/capture_hep.c b/src/capture/capture_hep.c index 413631c..4a92e41 100644 --- a/src/capture/capture_hep.c +++ b/src/capture/capture_hep.c @@ -224,7 +224,7 @@ capture_input_hep_receive_v2(CaptureInput *input) /* IPv4 */ if (family == AF_INET) { - memcpy(&hep_ipheader, (void*) buffer + pos, sizeof(struct _CaptureHepIpHdr)); + memcpy(&hep_ipheader, (gchar *) buffer + pos, sizeof(struct _CaptureHepIpHdr)); inet_ntop(AF_INET, &hep_ipheader.hp_src, src.ip, sizeof(src.ip)); inet_ntop(AF_INET, &hep_ipheader.hp_dst, dst.ip, sizeof(dst.ip)); pos += sizeof(struct _CaptureHepIpHdr); @@ -232,7 +232,7 @@ capture_input_hep_receive_v2(CaptureInput *input) #ifdef USE_IPV6 /* IPv6 */ else if(family == AF_INET6) { - memcpy(&hep_ip6header, (void*) buffer + pos, sizeof(struct _CaptureHepIp6Hdr)); + memcpy(&hep_ip6header, (gchar *) buffer + pos, sizeof(struct _CaptureHepIp6Hdr)); inet_ntop(AF_INET6, &hep_ip6header.hp6_src, src.ip, sizeof(src.ip)); inet_ntop(AF_INET6, &hep_ip6header.hp6_dst, dst.ip, sizeof(dst.ip)); pos += sizeof(struct _CaptureHepIp6Hdr); @@ -244,7 +244,7 @@ capture_input_hep_receive_v2(CaptureInput *input) dst.port = ntohs(hdr.hp_dport); /* TIMESTAMP*/ - memcpy(&hep_time, (void*) buffer + pos, sizeof(struct _CaptureHepTimeHdr)); + memcpy(&hep_time, (gchar *) buffer + pos, sizeof(struct _CaptureHepTimeHdr)); pos += sizeof(struct _CaptureHepTimeHdr); // Create Packet frame data @@ -329,12 +329,12 @@ capture_input_hep_receive_v3(CaptureInput *input) /* IPv4 */ if (family == AF_INET) { /* SRC IP */ - memcpy(&src_ip4, (void*) buffer + pos, sizeof(struct _CaptureHepChunkIp4)); + memcpy(&src_ip4, (gchar *) buffer + pos, sizeof(struct _CaptureHepChunkIp4)); inet_ntop(AF_INET, &src_ip4.data, src.ip, sizeof(src.ip)); pos += sizeof(struct _CaptureHepChunkIp4); /* DST IP */ - memcpy(&dst_ip4, (void*) buffer + pos, sizeof(struct _CaptureHepChunkIp4)); + memcpy(&dst_ip4, (gchar *) buffer + pos, sizeof(struct _CaptureHepChunkIp4)); inet_ntop(AF_INET, &dst_ip4.data, dst.ip, sizeof(src.ip)); pos += sizeof(struct _CaptureHepChunkIp4); } @@ -342,12 +342,12 @@ capture_input_hep_receive_v3(CaptureInput *input) /* IPv6 */ else if(family == AF_INET6) { /* SRC IPv6 */ - memcpy(&src_ip6, (void*) buffer + pos, sizeof(struct _CaptureHepChunkIp6)); + memcpy(&src_ip6, (gchar *) buffer + pos, sizeof(struct _CaptureHepChunkIp6)); inet_ntop(AF_INET6, &src_ip6.data, src.ip, sizeof(src.ip)); pos += sizeof(struct _CaptureHepChunkIp6); /* DST IP */ - memcpy(&src_ip6, (void*) buffer + pos, sizeof(struct _CaptureHepChunkIp6)); + memcpy(&src_ip6, (gchar *) buffer + pos, sizeof(struct _CaptureHepChunkIp6)); inet_ntop(AF_INET6, &dst_ip6.data, dst.ip, sizeof(dst.ip)); pos += sizeof(struct _CaptureHepChunkIp6); } @@ -367,11 +367,11 @@ capture_input_hep_receive_v3(CaptureInput *input) /* auth key */ if (hep->password != NULL) { - memcpy(&authkey_chunk, (void*) buffer + pos, sizeof(authkey_chunk)); + memcpy(&authkey_chunk, (gchar *) buffer + pos, sizeof(authkey_chunk)); pos += sizeof(authkey_chunk); password_len = ntohs(authkey_chunk.length) - sizeof(authkey_chunk); - memcpy(password, (void*) buffer + pos, password_len); + memcpy(password, (gchar *) buffer + pos, password_len); pos += password_len; // Validate the password @@ -380,7 +380,7 @@ capture_input_hep_receive_v3(CaptureInput *input) } if (setting_enabled(SETTING_HEP_LISTEN_UUID)) { - memcpy(&uuid_chunk, (void*) buffer + pos, sizeof(uuid_chunk)); + memcpy(&uuid_chunk, (gchar *) buffer + pos, sizeof(uuid_chunk)); pos += sizeof(uuid_chunk); uuid_len = ntohs(uuid_chunk.length) - sizeof(uuid_chunk); @@ -388,7 +388,7 @@ capture_input_hep_receive_v3(CaptureInput *input) } /* Payload */ - memcpy(&payload_chunk, (void*) buffer + pos, sizeof(payload_chunk)); + memcpy(&payload_chunk, (gchar *) buffer + pos, sizeof(payload_chunk)); pos += sizeof(payload_chunk); // Calculate payload size @@ -465,6 +465,8 @@ capture_input_hep_port(CaptureManager *manager) return hep->url.port; } } + + return ""; } CaptureOutput * @@ -617,27 +619,27 @@ capture_output_hep_write_v2(CaptureOutput *output, Packet *packet) // Copy basic headers buflen = 0; - memcpy(buffer + buflen, &hdr, sizeof(struct _CaptureHepHdr)); + memcpy((gchar *) buffer + buflen, &hdr, sizeof(struct _CaptureHepHdr)); buflen += sizeof(struct _CaptureHepHdr); // Copy IP header if (ip->version == 4) { - memcpy(buffer + buflen, &hep_ipheader, sizeof(struct _CaptureHepIpHdr)); + memcpy((gchar *) buffer + buflen, &hep_ipheader, sizeof(struct _CaptureHepIpHdr)); buflen += sizeof(struct _CaptureHepIpHdr); } #ifdef USE_IPV6 else if(ip->version == 6) { - memcpy(buffer + buflen, &hep_ip6header, sizeof(struct _CaptureHepIp6Hdr)); + memcpy((gchar *) buffer + buflen, &hep_ip6header, sizeof(struct _CaptureHepIp6Hdr)); buflen += sizeof(struct _CaptureHepIp6Hdr); } #endif // Copy TImestamp header - memcpy(buffer + buflen, &hep_time, sizeof(struct _CaptureHepTimeHdr)); + memcpy((gchar *) buffer + buflen, &hep_time, sizeof(struct _CaptureHepTimeHdr)); buflen += sizeof(struct _CaptureHepTimeHdr); // Now copy payload itself - memcpy(buffer + buflen, sip->payload, strlen(sip->payload)); + memcpy((gchar *) buffer + buflen, sip->payload, strlen(sip->payload)); buflen += strlen(sip->payload); if (send(hep->socket, buffer, buflen, 0) == -1) { @@ -788,16 +790,16 @@ capture_output_hep_write_v3(CaptureOutput *output, Packet *packet) hg->header.length = htons(tlen); buffer = g_malloc0(tlen); - memcpy(buffer, hg, sizeof(struct CaptureHepGeneric)); + memcpy((gchar *) buffer, hg, sizeof(struct CaptureHepGeneric)); buflen = sizeof(struct CaptureHepGeneric); /* IPv4 */ if (ip->version == 4) { /* SRC IP */ - memcpy(buffer + buflen, &src_ip4, sizeof(struct _CaptureHepChunkIp4)); + memcpy((gchar *) buffer + buflen, &src_ip4, sizeof(struct _CaptureHepChunkIp4)); buflen += sizeof(struct _CaptureHepChunkIp4); - memcpy(buffer + buflen, &dst_ip4, sizeof(struct _CaptureHepChunkIp4)); + memcpy((gchar *) buffer + buflen, &dst_ip4, sizeof(struct _CaptureHepChunkIp4)); buflen += sizeof(struct _CaptureHepChunkIp4); } @@ -805,10 +807,10 @@ capture_output_hep_write_v3(CaptureOutput *output, Packet *packet) /* IPv6 */ else if(ip->version == 6) { /* SRC IPv6 */ - memcpy(buffer + buflen, &src_ip4, sizeof(struct _CaptureHepChunkIp6)); + memcpy((gchar *) buffer + buflen, &src_ip4, sizeof(struct _CaptureHepChunkIp6)); buflen += sizeof(struct _CaptureHepChunkIp6); - memcpy(buffer + buflen, &dst_ip6, sizeof(struct _CaptureHepChunkIp6)); + memcpy((gchar *) buffer + buflen, &dst_ip6, sizeof(struct _CaptureHepChunkIp6)); buflen += sizeof(struct _CaptureHepChunkIp6); } #endif @@ -816,20 +818,20 @@ capture_output_hep_write_v3(CaptureOutput *output, Packet *packet) /* AUTH KEY CHUNK */ if (hep->password != NULL) { - memcpy(buffer + buflen, &authkey_chunk, sizeof(struct _CaptureHepChunk)); + memcpy((gchar *) buffer + buflen, &authkey_chunk, sizeof(struct _CaptureHepChunk)); buflen += sizeof(struct _CaptureHepChunk); /* Now copying payload self */ - memcpy(buffer + buflen, hep->password, strlen(hep->password)); + memcpy((gchar *) buffer + buflen, hep->password, strlen(hep->password)); buflen += strlen(hep->password); } /* PAYLOAD CHUNK */ - memcpy(buffer + buflen, &payload_chunk, sizeof(struct _CaptureHepChunk)); + memcpy((gchar *) buffer + buflen, &payload_chunk, sizeof(struct _CaptureHepChunk)); buflen += sizeof(struct _CaptureHepChunk); /* Now copying payload itself */ - memcpy(buffer + buflen, sip->payload, strlen(sip->payload)); + memcpy((gchar *) buffer + buflen, sip->payload, strlen(sip->payload)); buflen += strlen(sip->payload); if (send(hep->socket, buffer, buflen, 0) == -1) { @@ -872,4 +874,6 @@ capture_output_hep_port(CaptureManager *manager) return hep->url.port; } } + + return ""; } diff --git a/src/curses/keybinding.c b/src/curses/keybinding.c index 74dd696..fb3baf9 100644 --- a/src/curses/keybinding.c +++ b/src/curses/keybinding.c @@ -37,7 +37,7 @@ //! sngrep keybindings key_binding_t bindings[ACTION_SENTINEL] = { - { ACTION_PRINTABLE, "", { }, 0 }, + { ACTION_PRINTABLE, "", { 0 }, 0 }, { ACTION_UP, "up", { KEY_UP, 'k' }, 2 }, { ACTION_DOWN, "down", { KEY_DOWN, 'j' }, 2 }, { ACTION_LEFT, "left", { KEY_LEFT, 'h' }, 2 }, diff --git a/src/curses/screens/ui_call_flow.c b/src/curses/screens/ui_call_flow.c index 4600886..04aa68f 100644 --- a/src/curses/screens/ui_call_flow.c +++ b/src/curses/screens/ui_call_flow.c @@ -885,7 +885,7 @@ call_flow_arrow_create(ui_t *ui, void *item, int type) } int -call_flow_arrow_height(ui_t *ui, const call_flow_arrow_t *arrow) +call_flow_arrow_height(G_GNUC_UNUSED ui_t *ui, const call_flow_arrow_t *arrow) { if (arrow->type == CF_ARROW_SIP) { if (setting_enabled(SETTING_CF_ONLYMEDIA)) @@ -957,7 +957,6 @@ call_flow_draw_raw(ui_t *ui, SipMsg *msg) { call_flow_info_t *info; WINDOW *raw_win; - call_flow_arrow_t *arrow; int raw_width, raw_height; int min_raw_width, fixed_raw_width; @@ -1017,7 +1016,7 @@ call_flow_draw_raw(ui_t *ui, SipMsg *msg) int -call_flow_draw_raw_rtcp(ui_t *ui, RtpStream *stream) +call_flow_draw_raw_rtcp(ui_t *ui, G_GNUC_UNUSED RtpStream *stream) { /** * TODO This is too experimental to even display it @@ -1105,13 +1104,13 @@ call_flow_handle_key(ui_t *ui, int key) break; case ACTION_HNPAGE: rnpag_steps = rnpag_steps / 2; - /* no break */ + __attribute__((fallthrough)); case ACTION_NPAGE: call_flow_move(ui, info->cur_arrow + rnpag_steps); break; case ACTION_HPPAGE: rnpag_steps = rnpag_steps / 2; - /* no break */ + __attribute__((fallthrough)); case ACTION_PPAGE: // Prev page => N key up strokes call_flow_move(ui, info->cur_arrow - rnpag_steps); @@ -1241,7 +1240,7 @@ call_flow_handle_key(ui_t *ui, int key) } int -call_flow_help(ui_t *ui) +call_flow_help(G_GNUC_UNUSED ui_t *ui) { WINDOW *help_win; int height, width; diff --git a/src/curses/screens/ui_call_list.c b/src/curses/screens/ui_call_list.c index 6768316..15d3d2b 100644 --- a/src/curses/screens/ui_call_list.c +++ b/src/curses/screens/ui_call_list.c @@ -197,7 +197,7 @@ call_list_draw_header(ui_t *ui) int colpos, collen, i; char sortind; const char *countlb; - const char *device, *filterexpr, *filterbpf; + const char *device, *filterbpf; // Get panel info call_list_info_t *info = call_list_info(ui); @@ -283,7 +283,7 @@ call_list_draw_header(ui_t *ui) coldesc = sip_attr_get_title(info->columns[i].id); // Check if the column will fit in the remaining space of the screen - if (colpos + strlen(coldesc) >= ui->width) + if (colpos + strlen(coldesc) >= (guint) ui->width) break; // Print sort column indicator @@ -538,7 +538,7 @@ call_list_line_text(ui_t *ui, SipCall *call, char *text) collen = info->columns[i].width; // Check if next column fits on window width - if (strlen(text) + collen >= ui->width) + if ((gint)(strlen(text) + collen) >= ui->width) collen = ui->width - strlen(text); // If no space left on the screen stop processing columns @@ -594,14 +594,14 @@ call_list_handle_key(ui_t *ui, int key) break; case ACTION_HNPAGE: rnpag_steps = rnpag_steps / 2; - /* no break */ + __attribute__((fallthrough)); case ACTION_NPAGE: // Next page => N key down strokes call_list_move(ui, info->cur_call + rnpag_steps); break; case ACTION_HPPAGE: rnpag_steps = rnpag_steps / 2; - /* no break */ + __attribute__((fallthrough)); case ACTION_PPAGE: // Prev page => N key up strokes call_list_move(ui, info->cur_call - rnpag_steps); @@ -870,7 +870,7 @@ call_list_handle_menu_key(ui_t *ui, int key) sort.by = id; } storage_set_sort_options(sort); - /* no break */ + __attribute__((fallthrough)); case ACTION_PREV_SCREEN: // Desactive sorting menu info->menu_active = 0; @@ -905,7 +905,7 @@ call_list_handle_menu_key(ui_t *ui, int key) } int -call_list_help(ui_t *ui) +call_list_help(G_GNUC_UNUSED ui_t *ui) { WINDOW *help_win; int height, width; diff --git a/src/curses/screens/ui_call_raw.c b/src/curses/screens/ui_call_raw.c index 7997f98..91bc24e 100644 --- a/src/curses/screens/ui_call_raw.c +++ b/src/curses/screens/ui_call_raw.c @@ -127,7 +127,7 @@ int call_raw_print_msg(ui_t *ui, SipMsg *msg) { call_raw_info_t *info; - int payload_lines, i, column, height, width; + int payload_lines, column, height, width; // Message ngrep style Header char header[256]; char payload[MAX_SIP_PAYLOAD]; @@ -149,7 +149,7 @@ call_raw_print_msg(ui_t *ui, SipMsg *msg) // Check how many lines we well need to draw this message payload_lines = 0; column = 0; - for (i = 0; i < strlen(payload); i++) { + for (guint i = 0; i < strlen(payload); i++) { if (column == width || payload[i] == '\n') { payload_lines++; column = 0; @@ -229,14 +229,14 @@ call_raw_handle_key(ui_t *ui, int key) break; case ACTION_HNPAGE: rnpag_steps = rnpag_steps / 2; - /* no break */ + __attribute__((fallthrough)); case ACTION_NPAGE: // Next page => N key down strokes info->scroll += rnpag_steps; break; case ACTION_HPPAGE: rnpag_steps = rnpag_steps / 2; - /* no break */ + __attribute__((fallthrough)); case ACTION_PPAGE: // Prev page => N key up strokes info->scroll -= rnpag_steps; diff --git a/src/curses/screens/ui_column_select.c b/src/curses/screens/ui_column_select.c index 8446452..8709c09 100644 --- a/src/curses/screens/ui_column_select.c +++ b/src/curses/screens/ui_column_select.c @@ -432,7 +432,7 @@ column_select_save_columns(ui_t *ui) column_select_info_t *info = column_select_info(ui); // Add all selected columns - for (guint i = 0; i < item_count(info->menu); i++) { + for (gint i = 0; i < item_count(info->menu); i++) { // If column is active if (!strncmp(item_name(info->items[i]), "[ ]", 3)) continue; diff --git a/src/curses/screens/ui_msg_diff.c b/src/curses/screens/ui_msg_diff.c index 99a9deb..c0cb150 100644 --- a/src/curses/screens/ui_msg_diff.c +++ b/src/curses/screens/ui_msg_diff.c @@ -114,13 +114,13 @@ int msg_diff_line_highlight(const char* payload1, const char* payload2, char *highlight) { char search[MAX_SIP_PAYLOAD]; - int len, i; + int len; // Initialize search terms memset(search, 0, sizeof(search)); len = 0; - for (i = 0; i < strlen(payload1); i++) { + for (guint i = 0; i < strlen(payload1); i++) { // Store this char in the search term search[len++] = payload1[i]; // If we have a full line in search array @@ -176,7 +176,7 @@ msg_diff_draw(ui_t *ui) int msg_diff_draw_message(WINDOW *win, SipMsg *msg, char *highlight) { - int height, width, line, column, i; + int height, width, line, column; char header[MAX_SIP_PAYLOAD]; const char * payload = msg_get_payload(msg); @@ -193,7 +193,7 @@ msg_diff_draw_message(WINDOW *win, SipMsg *msg, char *highlight) // Print msg payload line = 2; column = 0; - for (i = 0; i < strlen(payload); i++) { + for (guint i = 0; i < strlen(payload); i++) { if (payload[i] == '\r') continue; diff --git a/src/curses/screens/ui_save.c b/src/curses/screens/ui_save.c index a2dad3a..23c818f 100644 --- a/src/curses/screens/ui_save.c +++ b/src/curses/screens/ui_save.c @@ -420,7 +420,7 @@ save_to_file(ui_t *ui) int cur = 0, total = 0; WINDOW *progress; GSequence *groupcalls; - GSequenceIter *calls, *msgs, *rtps, *packets; + GSequenceIter *calls, *rtps, *packets; GSequence *sorted; GError *error = NULL; diff --git a/src/curses/screens/ui_stats.c b/src/curses/screens/ui_stats.c index dd57511..b4d033d 100644 --- a/src/curses/screens/ui_stats.c +++ b/src/curses/screens/ui_stats.c @@ -76,7 +76,6 @@ void stats_create(ui_t *ui) { GSequenceIter *calls; - GSequenceIter *msgs; SipCall *call; SipMsg *msg; @@ -170,37 +169,37 @@ stats_create(ui_t *ui) // Print parses data mvwprintw(ui->win, 3, 3, "Dialogs: %d", stats.dtotal); - mvwprintw(ui->win, 4, 3, "Calls: %d (%.1f\%)", stats.dcalls, (float) stats.dcalls * 100 / stats.dtotal); + mvwprintw(ui->win, 4, 3, "Calls: %d (%.1f\\%)", stats.dcalls, (float) stats.dcalls * 100 / stats.dtotal); mvwprintw(ui->win, 5, 3, "Messages: %d", stats.mtotal); // Print status of calls if any if (stats.dcalls) { - mvwprintw(ui->win, 3, 33, "COMPLETED: %d (%.1f\%)", stats.completed, (float) stats.completed * 100 / stats.dcalls); - mvwprintw(ui->win, 4, 33, "CANCELLED: %d (%.1f\%)", stats.cancelled, (float) stats.cancelled * 100 / stats.dcalls); - mvwprintw(ui->win, 5, 33, "IN CALL: %d (%.1f\%)", stats.incall, (float) stats.incall * 100 / stats.dcalls); - mvwprintw(ui->win, 6, 33, "REJECTED: %d (%.1f\%)", stats.rejected, (float) stats.rejected * 100 / stats.dcalls); - mvwprintw(ui->win, 7, 33, "BUSY: %d (%.1f\%)", stats.busy, (float) stats.busy * 100 / stats.dcalls); - mvwprintw(ui->win, 8, 33, "DIVERTED: %d (%.1f\%)", stats.diverted, (float) stats.diverted * 100 / stats.dcalls); - mvwprintw(ui->win, 9, 33, "CALL SETUP: %d (%.1f\%)", stats.setup, (float) stats.setup * 100 / stats.dcalls); + mvwprintw(ui->win, 3, 33, "COMPLETED: %d (%.1f\\%)", stats.completed, (float) stats.completed * 100 / stats.dcalls); + mvwprintw(ui->win, 4, 33, "CANCELLED: %d (%.1f\\%)", stats.cancelled, (float) stats.cancelled * 100 / stats.dcalls); + mvwprintw(ui->win, 5, 33, "IN CALL: %d (%.1f\\%)", stats.incall, (float) stats.incall * 100 / stats.dcalls); + mvwprintw(ui->win, 6, 33, "REJECTED: %d (%.1f\\%)", stats.rejected, (float) stats.rejected * 100 / stats.dcalls); + mvwprintw(ui->win, 7, 33, "BUSY: %d (%.1f\\%)", stats.busy, (float) stats.busy * 100 / stats.dcalls); + mvwprintw(ui->win, 8, 33, "DIVERTED: %d (%.1f\\%)", stats.diverted, (float) stats.diverted * 100 / stats.dcalls); + mvwprintw(ui->win, 9, 33, "CALL SETUP: %d (%.1f\\%)", stats.setup, (float) stats.setup * 100 / stats.dcalls); } - mvwprintw(ui->win, 11, 3, "INVITE: %d (%.1f\%)", stats.invite, (float) stats.invite * 100 / stats.mtotal); - mvwprintw(ui->win, 12, 3, "REGISTER: %d (%.1f\%)", stats.regist, (float) stats.regist * 100 / stats.mtotal); - mvwprintw(ui->win, 13, 3, "SUBSCRIBE: %d (%.1f\%)", stats.subscribe, (float) stats.subscribe * 100 / stats.mtotal); - mvwprintw(ui->win, 14, 3, "UPDATE: %d (%.1f\%)", stats.update, (float) stats.update * 100 / stats.mtotal); - mvwprintw(ui->win, 15, 3, "NOTIFY: %d (%.1f\%)", stats.notify, (float) stats.notify * 100 / stats.mtotal); - mvwprintw(ui->win, 16, 3, "OPTIONS: %d (%.1f\%)", stats.options, (float) stats.options * 100 / stats.mtotal); - mvwprintw(ui->win, 17, 3, "PUBLISH: %d (%.1f\%)", stats.publish, (float) stats.publish * 100 / stats.mtotal); - mvwprintw(ui->win, 18, 3, "MESSAGE: %d (%.1f\%)", stats.message, (float) stats.message * 100 / stats.mtotal); - mvwprintw(ui->win, 19, 3, "INFO: %d (%.1f\%)", stats.info, (float) stats.info * 100 / stats.mtotal); - mvwprintw(ui->win, 20, 3, "BYE: %d (%.1f\%)", stats.bye, (float) stats.bye * 100 / stats.mtotal); - mvwprintw(ui->win, 21, 3, "CANCEL: %d (%.1f\%)", stats.cancel, (float) stats.cancel * 100 / stats.mtotal); + mvwprintw(ui->win, 11, 3, "INVITE: %d (%.1f\\%)", stats.invite, (float) stats.invite * 100 / stats.mtotal); + mvwprintw(ui->win, 12, 3, "REGISTER: %d (%.1f\\%)", stats.regist, (float) stats.regist * 100 / stats.mtotal); + mvwprintw(ui->win, 13, 3, "SUBSCRIBE: %d (%.1f\\%)", stats.subscribe, (float) stats.subscribe * 100 / stats.mtotal); + mvwprintw(ui->win, 14, 3, "UPDATE: %d (%.1f\\%)", stats.update, (float) stats.update * 100 / stats.mtotal); + mvwprintw(ui->win, 15, 3, "NOTIFY: %d (%.1f\\%)", stats.notify, (float) stats.notify * 100 / stats.mtotal); + mvwprintw(ui->win, 16, 3, "OPTIONS: %d (%.1f\\%)", stats.options, (float) stats.options * 100 / stats.mtotal); + mvwprintw(ui->win, 17, 3, "PUBLISH: %d (%.1f\\%)", stats.publish, (float) stats.publish * 100 / stats.mtotal); + mvwprintw(ui->win, 18, 3, "MESSAGE: %d (%.1f\\%)", stats.message, (float) stats.message * 100 / stats.mtotal); + mvwprintw(ui->win, 19, 3, "INFO: %d (%.1f\\%)", stats.info, (float) stats.info * 100 / stats.mtotal); + mvwprintw(ui->win, 20, 3, "BYE: %d (%.1f\\%)", stats.bye, (float) stats.bye * 100 / stats.mtotal); + mvwprintw(ui->win, 21, 3, "CANCEL: %d (%.1f\\%)", stats.cancel, (float) stats.cancel * 100 / stats.mtotal); - mvwprintw(ui->win, 11, 33, "1XX: %d (%.1f\%)", stats.r100, (float) stats.r100 * 100 / stats.mtotal); - mvwprintw(ui->win, 12, 33, "2XX: %d (%.1f\%)", stats.r200, (float) stats.r200 * 100 / stats.mtotal); - mvwprintw(ui->win, 13, 33, "3XX: %d (%.1f\%)", stats.r300, (float) stats.r300 * 100 / stats.mtotal); - mvwprintw(ui->win, 14, 33, "4XX: %d (%.1f\%)", stats.r400, (float) stats.r400 * 100 / stats.mtotal); - mvwprintw(ui->win, 15, 33, "5XX: %d (%.1f\%)", stats.r500, (float) stats.r500 * 100 / stats.mtotal); - mvwprintw(ui->win, 16, 33, "6XX: %d (%.1f\%)", stats.r600, (float) stats.r600 * 100 / stats.mtotal); - mvwprintw(ui->win, 17, 33, "7XX: %d (%.1f\%)", stats.r700, (float) stats.r700 * 100 / stats.mtotal); - mvwprintw(ui->win, 18, 33, "8XX: %d (%.1f\%)", stats.r800, (float) stats.r800 * 100 / stats.mtotal); + mvwprintw(ui->win, 11, 33, "1XX: %d (%.1f\\%)", stats.r100, (float) stats.r100 * 100 / stats.mtotal); + mvwprintw(ui->win, 12, 33, "2XX: %d (%.1f\\%)", stats.r200, (float) stats.r200 * 100 / stats.mtotal); + mvwprintw(ui->win, 13, 33, "3XX: %d (%.1f\\%)", stats.r300, (float) stats.r300 * 100 / stats.mtotal); + mvwprintw(ui->win, 14, 33, "4XX: %d (%.1f\\%)", stats.r400, (float) stats.r400 * 100 / stats.mtotal); + mvwprintw(ui->win, 15, 33, "5XX: %d (%.1f\\%)", stats.r500, (float) stats.r500 * 100 / stats.mtotal); + mvwprintw(ui->win, 16, 33, "6XX: %d (%.1f\\%)", stats.r600, (float) stats.r600 * 100 / stats.mtotal); + mvwprintw(ui->win, 17, 33, "7XX: %d (%.1f\\%)", stats.r700, (float) stats.r700 * 100 / stats.mtotal); + mvwprintw(ui->win, 18, 33, "8XX: %d (%.1f\\%)", stats.r800, (float) stats.r800 * 100 / stats.mtotal); } diff --git a/src/curses/ui_manager.c b/src/curses/ui_manager.c index 97d64ec..e6059c1 100644 --- a/src/curses/ui_manager.c +++ b/src/curses/ui_manager.c @@ -347,7 +347,7 @@ draw_message(WINDOW *win, SipMsg *msg) int draw_message_pos(WINDOW *win, SipMsg *msg, int starting) { - int height, width, line, column, i; + int height, width, line, column; const char *cur_line, *payload, *method = NULL; int syntax = setting_enabled(SETTING_SYNTAX); const char *nonascii = setting_get_value(SETTING_CR_NON_ASCII); @@ -371,7 +371,7 @@ draw_message_pos(WINDOW *win, SipMsg *msg, int starting) // Print msg payload line = starting; column = 0; - for (i = 0; i < strlen(payload); i++) { + for (guint i = 0; i < strlen(payload); i++) { // If syntax highlighting is enabled if (syntax) { // First line highlight @@ -506,7 +506,7 @@ dialog_run(const char *fmt, ...) // Write the message into the screen for (word = strtok(textva, " "); word; word = strtok(NULL, " ")) { - if (col + strlen(word) > width - 2) { + if ((gint)(col + strlen(word)) > width - 2) { line++; col = 2; } @@ -563,7 +563,7 @@ dialog_progress_run(const char *fmt, ...) // Write the message into the screen for (word = strtok(textva, " "); word; word = strtok(NULL, " ")) { - if (col + strlen(word) > width - 2) { + if ((gint)(col + strlen(word)) > width - 2) { line++; col = 2; } @@ -632,9 +632,9 @@ dialog_confirm(const char *title, const char *text, const char *options) // Calculate proper width taking into acount longest data width = strlen(options) + 6 * optioncnt; - if (strlen(title) + 4 > width) + if ((gint)strlen(title) + 4 > width) width = strlen(title) + 4; - if (strlen(text) > width && strlen(text) < 50) + if ((gint)strlen(text) > width && strlen(text) < 50) width = strlen(text); // Check we don't want a too big or small window @@ -691,7 +691,7 @@ dialog_confirm(const char *title, const char *text, const char *options) newl = 1; } - if (col + strlen(word) > width - 2) { + if ((gint)(col + strlen(word)) > width - 2) { line++; col = 2; } diff --git a/src/filter.c b/src/filter.c index 36b4e17..21b7727 100644 --- a/src/filter.c +++ b/src/filter.c @@ -36,7 +36,7 @@ #include "filter.h" //! Storage of filter information -filter_t filters[FILTER_COUNT] = { }; +filter_t filters[FILTER_COUNT] = { 0 }; int filter_set(int type, const char *expr) @@ -72,13 +72,12 @@ filter_get(int type) } gboolean -filter_check_call(gconstpointer item, gconstpointer user_data) +filter_check_call(gconstpointer item, G_GNUC_UNUSED gconstpointer user_data) { int i; char data[MAX_SIP_PAYLOAD]; SipCall *call = (SipCall*) item; SipMsg *msg; - GSequenceIter *it; // Dont filter calls without messages if (call_msg_count(call) == 0) diff --git a/src/group.c b/src/group.c index 5d44ba7..31fa697 100644 --- a/src/group.c +++ b/src/group.c @@ -48,17 +48,6 @@ call_group_free(SipCallGroup *group) g_free(group); } -/** - * @brief Sort messages in a group by message time - * @param vector sorted vector - * @param item item to add to the vector - */ -static gint -call_group_msg_sorter(gconstpointer a, gconstpointer b) -{ - return timeval_is_older(msg_get_time(a), msg_get_time(b)); -} - gboolean call_group_changed(SipCallGroup *group) { @@ -262,7 +251,6 @@ call_group_get_next_stream(SipCallGroup *group, RtpStream *stream) RtpStream *next = NULL; RtpStream *cand; SipCall *call; - GSequenceIter *streams; for (guint i = 0; i < g_list_length(group->calls); i++) { call = g_list_nth_data(group->calls, i); diff --git a/src/main.c b/src/main.c index f0938f8..764c17e 100644 --- a/src/main.c +++ b/src/main.c @@ -71,8 +71,10 @@ main(int argc, char* argv[]) GError *error = NULL; gchar **input_files = NULL; gchar **input_devices = NULL; +#ifdef USE_HEP gchar *hep_listen = NULL; gchar *hep_send = NULL; +#endif gboolean no_interface = FALSE; gboolean quiet = FALSE; gboolean version = FALSE; @@ -80,10 +82,12 @@ main(int argc, char* argv[]) gboolean no_config = FALSE; gchar *output_file = NULL; gchar *config_file = NULL; +#ifdef WITH_SSL gchar *keyfile = NULL; - StorageSortOpts storage_sopts = {}; - StorageMatchOpts storage_mopts = {}; - StorageCaptureOpts storage_copts = {}; +#endif + StorageSortOpts storage_sopts = { 0 }; + StorageMatchOpts storage_mopts = { 0 }; + StorageCaptureOpts storage_copts = { 0 }; CaptureManager *manager; CaptureInput *input; CaptureOutput *output; diff --git a/src/packet/dissectors/packet_sip.c b/src/packet/dissectors/packet_sip.c index db1f0cf..271deca 100644 --- a/src/packet/dissectors/packet_sip.c +++ b/src/packet/dissectors/packet_sip.c @@ -191,7 +191,7 @@ packet_sip_method_str(const Packet *packet) } } -const guint +guint packet_sip_method(const Packet *packet) { return packet_sip_data(packet)->reqresp; diff --git a/src/packet/dissectors/packet_sip.h b/src/packet/dissectors/packet_sip.h index 08deff2..4fb2524 100644 --- a/src/packet/dissectors/packet_sip.h +++ b/src/packet/dissectors/packet_sip.h @@ -130,7 +130,7 @@ packet_sip_header(const Packet *packet, enum sip_headers header); const gchar * packet_sip_method_str(const Packet *packet); -const guint +guint packet_sip_method(const Packet *packet); PacketSipData * diff --git a/src/packet/dissectors/packet_tls.c b/src/packet/dissectors/packet_tls.c index 0a23e6e..4976c39 100644 --- a/src/packet/dissectors/packet_tls.c +++ b/src/packet/dissectors/packet_tls.c @@ -133,7 +133,7 @@ tls_connection_load_cipher(struct SSLConnection *conn) } int -tls_privkey_decrypt_data(gnutls_x509_privkey_t key, unsigned int flags, +tls_privkey_decrypt_data(gnutls_x509_privkey_t key, G_GNUC_UNUSED unsigned int flags, const gnutls_datum_t * ciphertext, gnutls_datum_t * plaintext) { size_t decr_len = 0, i = 0; @@ -229,7 +229,7 @@ P_hash(const char *digest, unsigned char *dest, int dlen, unsigned char *secret, memcpy(hmac, gcry_md_read(md, algo), algolen); hlen = algolen; - hlen = (hlen > pending) ? pending : hlen; + hlen = ((gint) hlen > pending) ? pending : (gint) hlen; memcpy(out, hmac, hlen); out += hlen; pending -= hlen; @@ -522,7 +522,7 @@ tls_connection_find(PacketParser *parser, struct in_addr src, uint16_t sport, st int -tls_record_handshake_is_ssl2(struct SSLConnection *conn, const uint8_t *payload, +tls_record_handshake_is_ssl2(G_GNUC_UNUSED struct SSLConnection *conn, const uint8_t *payload, const int len) { // This magic belongs to wireshark people <3 @@ -537,7 +537,7 @@ tls_record_handshake_is_ssl2(struct SSLConnection *conn, const uint8_t *payload, int tls_process_record_ssl2(struct SSLConnection *conn, const uint8_t *payload, - const int len, uint8_t **out, uint32_t *outl) + const int len, G_GNUC_UNUSED uint8_t **out, G_GNUC_UNUSED uint32_t *outl) { int record_len_len; uint32_t record_len; @@ -569,7 +569,7 @@ tls_process_record_ssl2(struct SSLConnection *conn, const uint8_t *payload, } // We only handle Client Hello handshake SSLv2 records - if (record_type == 0x01 && flen > sizeof(struct ClientHelloSSLv2)) { + if (record_type == 0x01 && (guint) flen > sizeof(struct ClientHelloSSLv2)) { // Client Hello SSLv2 struct ClientHelloSSLv2 *clienthello = (struct ClientHelloSSLv2 *) fragment; diff --git a/src/packet/parser.h b/src/packet/parser.h index bc24a6f..e885e9e 100644 --- a/src/packet/parser.h +++ b/src/packet/parser.h @@ -34,9 +34,13 @@ //! Shorter declaration of packet parser structure typedef struct _PacketParser PacketParser; + //! Forward declaration of Capture input structure +struct _CaptureInput; typedef struct _CaptureInput CaptureInput; + //! Forward declaration of packet parser structure +struct _PacketDissector; typedef struct _PacketDissector PacketDissector; /** diff --git a/src/setting.c b/src/setting.c index 721de56..b6a0b2d 100644 --- a/src/setting.c +++ b/src/setting.c @@ -99,7 +99,7 @@ setting_by_id(int id) { int i; for (i = 0; i < SETTING_COUNT; i++) { - if (id == settings[i].id) + if ((guint) id == settings[i].id) return &settings[i]; } return NULL; @@ -120,7 +120,7 @@ int setting_id(const char *name) { const setting_t *sett = setting_by_name(name); - return (sett) ? sett->id : -1; + return (sett) ? (int) sett->id : -1; } const char * @@ -134,7 +134,7 @@ int setting_format(int id) { const setting_t *sett = setting_by_id(id); - return (sett) ? sett->fmt : -1; + return (sett) ? (int) sett->fmt : -1; } const char ** diff --git a/src/sip_attr.c b/src/sip_attr.c index a53e899..4e91b21 100644 --- a/src/sip_attr.c +++ b/src/sip_attr.c @@ -37,25 +37,25 @@ #include "curses/ui_manager.h" static sip_attr_hdr_t attrs[SIP_ATTR_COUNT] = { - { SIP_ATTR_CALLINDEX, "index", "Idx", "Call Index", 4 }, - { SIP_ATTR_SIPFROM, "sipfrom", NULL, "SIP From", 25 }, - { SIP_ATTR_SIPFROMUSER, "sipfromuser", NULL, "SIP From User", 20 }, - { SIP_ATTR_SIPTO, "sipto", NULL, "SIP To", 25 }, - { SIP_ATTR_SIPTOUSER, "siptouser", NULL, "SIP To User", 20 }, - { SIP_ATTR_SRC, "src", NULL, "Source", 22 }, - { SIP_ATTR_DST, "dst", NULL, "Destination", 22 }, - { SIP_ATTR_CALLID, "callid", NULL, "Call-ID", 50 }, - { SIP_ATTR_XCALLID, "xcallid", NULL, "X-Call-ID", 50 }, - { SIP_ATTR_DATE, "date", NULL, "Date", 10 }, - { SIP_ATTR_TIME, "time", NULL, "Time", 8 }, + { SIP_ATTR_CALLINDEX, "index", "Idx", "Call Index", 4 , NULL }, + { SIP_ATTR_SIPFROM, "sipfrom", NULL, "SIP From", 25, NULL }, + { SIP_ATTR_SIPFROMUSER, "sipfromuser", NULL, "SIP From User", 20, NULL }, + { SIP_ATTR_SIPTO, "sipto", NULL, "SIP To", 25, NULL }, + { SIP_ATTR_SIPTOUSER, "siptouser", NULL, "SIP To User", 20, NULL }, + { SIP_ATTR_SRC, "src", NULL, "Source", 22, NULL }, + { SIP_ATTR_DST, "dst", NULL, "Destination", 22, NULL }, + { SIP_ATTR_CALLID, "callid", NULL, "Call-ID", 50, NULL }, + { SIP_ATTR_XCALLID, "xcallid", NULL, "X-Call-ID", 50, NULL }, + { SIP_ATTR_DATE, "date", NULL, "Date", 10, NULL }, + { SIP_ATTR_TIME, "time", NULL, "Time", 8, NULL }, { SIP_ATTR_METHOD, "method", NULL, "Method", 10, sip_attr_color_method }, - { SIP_ATTR_TRANSPORT, "transport", "Trans", "Transport", 3 }, - { SIP_ATTR_MSGCNT, "msgcnt", "Msgs", "Message Count", 5 }, + { SIP_ATTR_TRANSPORT, "transport", "Trans", "Transport", 3, NULL }, + { SIP_ATTR_MSGCNT, "msgcnt", "Msgs", "Message Count", 5, NULL }, { SIP_ATTR_CALLSTATE, "state", NULL, "Call State", 10, sip_attr_color_state }, - { SIP_ATTR_CONVDUR, "convdur", "ConvDur", "Conversation Duration", 7 }, - { SIP_ATTR_TOTALDUR, "totaldur", "TotalDur", "Total Duration", 8 }, - { SIP_ATTR_REASON_TXT, "reason", "Reason Text", "Reason Text", 25 }, - { SIP_ATTR_WARNING, "warning", "Warning", "Warning code", 4 } + { SIP_ATTR_CONVDUR, "convdur", "ConvDur", "Conversation Duration", 7, NULL }, + { SIP_ATTR_TOTALDUR, "totaldur", "TotalDur", "Total Duration", 8, NULL }, + { SIP_ATTR_REASON_TXT, "reason", "Reason Text", "Reason Text", 25, NULL }, + { SIP_ATTR_WARNING, "warning", "Warning", "Warning code", 4, NULL } }; sip_attr_hdr_t * diff --git a/src/sip_call.c b/src/sip_call.c index b0b739f..2ce9ab1 100644 --- a/src/sip_call.c +++ b/src/sip_call.c @@ -319,7 +319,7 @@ call_attr_compare(const SipCall *one, const SipCall *two, enum sip_attr_id id) if (oneintvalue == twointvalue) return 0; if (oneintvalue > twointvalue) return 1; if (oneintvalue < twointvalue) return -1; - /* no break */ + __attribute__((fallthrough)); default: return 0; } @@ -341,7 +341,6 @@ RtpStream * call_find_stream(SipCall *call, Address src, Address dst) { RtpStream *stream; - GSequenceIter *it; // Look for an incomplete stream with this destination for (guint i = 0; i < g_ptr_array_len(call->streams); i++) { diff --git a/src/sip_msg.c b/src/sip_msg.c index 6f9d2fe..38d026a 100644 --- a/src/sip_msg.c +++ b/src/sip_msg.c @@ -90,7 +90,7 @@ msg_get_payload(SipMsg *msg) GTimeVal msg_get_time(const SipMsg *msg) { - GTimeVal t = { }; + GTimeVal t = { 0 }; PacketFrame *frame; if (msg && (frame = g_list_nth_data(msg->packet->frames, 0))) diff --git a/src/storage.c b/src/storage.c index 83ec28e..2039fbd 100644 --- a/src/storage.c +++ b/src/storage.c @@ -59,7 +59,7 @@ /** * @brief Global Structure with all storage information */ -Storage storage = {}; +Storage storage = { 0 }; void storage_add_packet(Packet *packet) @@ -83,7 +83,7 @@ storage_calls_changed() return changed; } -int +guint storage_calls_count() { return g_sequence_get_length(storage.list); @@ -116,7 +116,7 @@ storage_active_calls_vector() sip_stats_t storage_calls_stats() { - sip_stats_t stats = {}; + sip_stats_t stats = { 0 }; GSequenceIter *it = g_sequence_get_begin_iter(storage.list); // Total number of calls without filtering @@ -194,7 +194,7 @@ storage_check_match_expr(const char *payload) } -const StorageMatchOpts +StorageMatchOpts storage_match_options() { return storage.match; @@ -207,7 +207,7 @@ storage_set_sort_options(StorageSortOpts sort) g_sequence_sort(storage.list, storage_sorter, NULL); } -const StorageSortOpts +StorageSortOpts storage_sort_options() { return storage.sort; @@ -310,15 +310,6 @@ storage_check_rtp_packet(Packet *packet) Address src, dst; RtpStream *stream; RtpStream *reverse; - u_char format = 0; - const gchar *payload; - size_t size, bsize; - uint16_t len; - struct rtcp_hdr_generic hdr; - struct rtcp_hdr_sr hdr_sr; - struct rtcp_hdr_xr hdr_xr; - struct rtcp_blk_xr blk_xr; - struct rtcp_blk_xr_voip blk_xr_voip; // Get Addresses from packet src = packet_src_address(packet); @@ -411,7 +402,7 @@ void storage_register_streams(SipMsg *msg) { Packet *packet = msg->packet; - Address emptyaddr = {}; + Address emptyaddr = { 0 }; PacketSdpData *sdp = g_ptr_array_index(packet->proto, PACKET_SDP); if (sdp == NULL) { diff --git a/src/storage.h b/src/storage.h index 6586096..3c34904 100644 --- a/src/storage.h +++ b/src/storage.h @@ -172,7 +172,7 @@ storage_calls_changed(); * * @return how many calls are linked in the list */ -int +guint storage_calls_count(); /** @@ -236,7 +236,7 @@ storage_register_streams(SipMsg *msg); * * @return Struct containing matching options */ -const StorageMatchOpts +StorageMatchOpts storage_match_options(); /** @@ -244,7 +244,7 @@ storage_match_options(); * * @return Struct containing sorting options */ -const StorageSortOpts +StorageSortOpts storage_sort_options(); diff --git a/src/stream.c b/src/stream.c index cb1d992..4e49bcf 100644 --- a/src/stream.c +++ b/src/stream.c @@ -35,7 +35,7 @@ #include "storage.h" RtpStream * -stream_create(Packet *packet, PacketSdpMedia *media) +stream_create(G_GNUC_UNUSED Packet *packet, PacketSdpMedia *media) { RtpStream *stream = g_malloc0(sizeof(RtpStream)); @@ -77,8 +77,6 @@ const char * stream_get_format(RtpStream *stream) { - const char *fmt; - // Get format for media payload if (!stream || !stream->media) return NULL; @@ -109,8 +107,6 @@ stream_find_by_format(Address src, Address dst, uint32_t format) SipCall *call; // Iterator for active calls GSequenceIter *calls; - // Iterator for call streams - GSequenceIter *streams; // Candiate stream RtpStream *candidate = NULL;