Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package sngrep for openSUSE:Factory checked in at 2022-05-09 18:44:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/sngrep (Old) and /work/SRC/openSUSE:Factory/.sngrep.new.1538 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "sngrep" Mon May 9 18:44:21 2022 rev:7 rq:975758 version:1.5.0 Changes: -------- --- /work/SRC/openSUSE:Factory/sngrep/sngrep.changes 2021-12-02 02:27:00.704242848 +0100 +++ /work/SRC/openSUSE:Factory/.sngrep.new.1538/sngrep.changes 2022-05-09 18:45:19.516293457 +0200 @@ -1,0 +2,10 @@ +Sat May 7 09:11:02 UTC 2022 - Martin Hauke <mar...@gmx.de> + +- Update to version 1.5.0 + * capture: add support for IP-IP encapsulation + * capture: add support for IPv6 fragments reassembly + * hep: add support for saving HEP received packets to PCAP + * tls: check client TLS version in gnutls code + * ui: fixed a crash when leaving ncurses screens + +------------------------------------------------------------------- Old: ---- sngrep-1.4.10.tar.gz New: ---- sngrep-1.5.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ sngrep.spec ++++++ --- /var/tmp/diff_new_pack.Y6j890/_old 2022-05-09 18:45:20.180294236 +0200 +++ /var/tmp/diff_new_pack.Y6j890/_new 2022-05-09 18:45:20.200294259 +0200 @@ -1,8 +1,8 @@ # # spec file for package sngrep # -# Copyright (c) 2021 SUSE LLC -# Copyright (c) 2018-2021, Martin Hauke <mar...@gmx.de> +# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2018-2022, Martin Hauke <mar...@gmx.de> # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ Name: sngrep -Version: 1.4.10 +Version: 1.5.0 Release: 0 Summary: Ncurses SIP Messages flow viewer License: GPL-3.0-or-later ++++++ sngrep-1.4.10.tar.gz -> sngrep-1.5.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/.gitignore new/sngrep-1.5.0/.gitignore --- old/sngrep-1.4.10/.gitignore 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/.gitignore 2022-04-26 15:59:33.000000000 +0200 @@ -3,6 +3,7 @@ .settings .vscode .idea +build # Build files src/sngrep diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/ChangeLog new/sngrep-1.5.0/ChangeLog --- old/sngrep-1.4.10/ChangeLog 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/ChangeLog 2022-04-26 15:59:33.000000000 +0200 @@ -1,3 +1,12 @@ +2021-04-26 Ivan Alonso <ka...@irontec.com> + * sngrep 1.5.0 released + + * capture: add support for IP-IP encapsulation + * capture: add support for IPv6 fragments reassembly + * hep: add support for saving HEP received packets to PCAP + * tls: check client TLS version in gnutls code + * ui: fixed a crash when leaving ncurses screens + 2021-11-19 Ivan Alonso <ka...@irontec.com> * sngrep 1.4.10 released diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/configure.ac new/sngrep-1.5.0/configure.ac --- old/sngrep-1.4.10/configure.ac 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/configure.ac 2022-04-26 15:59:33.000000000 +0200 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([sngrep], [1.4.10], [ka...@irontec.com], [sngrep], [http://www.irontec.com/]) +AC_INIT([sngrep], [1.5.0], [ka...@irontec.com], [sngrep], [http://www.irontec.com/]) AM_INIT_AUTOMAKE([1.9]) AC_CONFIG_HEADERS([src/config.h]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/doc/sngrep.8 new/sngrep-1.5.0/doc/sngrep.8 --- old/sngrep-1.4.10/doc/sngrep.8 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/doc/sngrep.8 2022-04-26 15:59:33.000000000 +0200 @@ -3,7 +3,7 @@ .\" Copyright (c) 2013-2021 Ivan Alonso <ka...@irontec.com> .\" Copyright (c) 2013-2021 Irontec S.L. -.TH SNGREP 8 "May 2021" "sngrep 1.4.10" +.TH SNGREP 8 "May 2021" "sngrep 1.5.0" .SH NAME diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/pkg/apk/APKBUILD new/sngrep-1.5.0/pkg/apk/APKBUILD --- old/sngrep-1.4.10/pkg/apk/APKBUILD 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/pkg/apk/APKBUILD 2022-04-26 15:59:33.000000000 +0200 @@ -1,7 +1,7 @@ # Contributor: Francesco Colista <fcoli...@alpinelinux.org> # Maintainer: Francesco Colista <fcoli...@alpinelinux.org> pkgname=sngrep -pkgver=1.4.9 +pkgver=1.5.0 pkgrel=0 pkgdesc="display SIP call message flows from a terminal" url="https://github.com/irontec/sngrep" @@ -38,4 +38,4 @@ make DESTDIR="$pkgdir/" install } -sha512sums="f25e8c5b1a6feddc2210fc8295f6e2c7ce708ae4bc4903f33b334f210e67c5c58d636e0a3bcaecef6d0c2bdfb9cab7c9ee28a5605d4df5ab1251be0856674c42 sngrep-1.4.9.tar.gz" +sha512sums="d3aabe22a31ec5860ec80f94b6556d345d72574e552c4e92dfebdddeaaa5f69caf811fc2fa201ca7af24cabfcbdd530a4f50248ebf0381cef26390a78824d1af sngrep-1.4.10.tar.gz" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/pkg/debian/changelog new/sngrep-1.5.0/pkg/debian/changelog --- old/sngrep-1.4.10/pkg/debian/changelog 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/pkg/debian/changelog 2022-04-26 15:59:33.000000000 +0200 @@ -1,3 +1,9 @@ +sngrep (1.5.0) experimental; urgency=low + + * sngrep 1.5.0 released + + -- Ivan Alonso <ka...@irontec.com> Tue, 26 Apr 2022 15:57:37 +0200 + sngrep (1.4.10) experimental; urgency=low * sngrep 1.4.10 released diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/pkg/rpm/SPECS/sngrep.spec new/sngrep-1.5.0/pkg/rpm/SPECS/sngrep.spec --- old/sngrep-1.4.10/pkg/rpm/SPECS/sngrep.spec 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/pkg/rpm/SPECS/sngrep.spec 2022-04-26 15:59:33.000000000 +0200 @@ -2,7 +2,7 @@ Summary: SIP Messages flow viewer Name: sngrep -Version: 1.4.10 +Version: 1.5.0 Release: 0%{?dist} License: GPLv3 Group: Applications/Engineering @@ -59,6 +59,8 @@ %{__rm} -rf %{buildroot} %changelog +* Tue Apr 26 2022 Ivan Alonso <ka...@irontec.com> - 1.5.0 + - Version 1.5.0 * Fri Nov 19 2021 Ivan Alonso <ka...@irontec.com> - 1.4.10 - Version 1.4.10 * Thu May 20 2021 Ivan Alonso <ka...@irontec.com> - 1.4.9 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/src/capture.c new/sngrep-1.5.0/src/capture.c --- old/sngrep-1.4.10/src/capture.c 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/src/capture.c 2022-04-26 15:59:33.000000000 +0200 @@ -173,7 +173,7 @@ capinfo->ip_reasm = vector_create(0, 10); // Add this capture information as packet source - vector_append(capture_cfg.sources, capinfo); + capture_add_source(capinfo); // If requested store packets in a dump file if (outfile && !capture_cfg.pd) { @@ -238,7 +238,7 @@ capinfo->ip_reasm = vector_create(0, 10); // Add this capture information as packet source - vector_append(capture_cfg.sources, capinfo); + capture_add_source(capinfo); // If requested store packets in a dump file if (outfile && !capture_cfg.pd) { @@ -448,6 +448,9 @@ uint32_t len_data = 0; //! Link + Extra header size uint16_t link_hl = capinfo->link_hl; +#ifdef USE_IPV6 + struct ip6_frag *ip6f; +#endif // Skip VLAN header if present if (capinfo->link == DLT_EN10MB) { @@ -485,56 +488,69 @@ } } - // Get IP header - ip4 = (struct ip *) (packet + link_hl); + while (*size >= sizeof(struct ip)) { + // Get IP header + ip4 = (struct ip *) (packet + link_hl); #ifdef USE_IPV6 - // Get IPv6 header - ip6 = (struct ip6_hdr *) (packet + link_hl); + // Get IPv6 header + ip6 = (struct ip6_hdr *) (packet + link_hl); #endif - // Get IP version - ip_ver = ip4->ip_v; + // Get IP version + ip_ver = ip4->ip_v; - switch (ip_ver) { - case 4: - ip_hl = ip4->ip_hl * 4; - ip_proto = ip4->ip_p; - ip_off = ntohs(ip4->ip_off); - ip_len = ntohs(ip4->ip_len); - - ip_frag = ip_off & (IP_MF | IP_OFFMASK); - ip_frag_off = (ip_frag) ? (ip_off & IP_OFFMASK) * 8 : 0; - ip_id = ntohs(ip4->ip_id); + switch (ip_ver) { + case 4: + ip_hl = ip4->ip_hl * 4; + ip_proto = ip4->ip_p; + ip_off = ntohs(ip4->ip_off); + ip_len = ntohs(ip4->ip_len); + + ip_frag = ip_off & (IP_MF | IP_OFFMASK); + ip_frag_off = (ip_frag) ? (ip_off & IP_OFFMASK) * 8 : 0; + ip_id = ntohs(ip4->ip_id); - inet_ntop(AF_INET, &ip4->ip_src, src.ip, sizeof(src.ip)); - inet_ntop(AF_INET, &ip4->ip_dst, dst.ip, sizeof(dst.ip)); - break; + inet_ntop(AF_INET, &ip4->ip_src, src.ip, sizeof(src.ip)); + inet_ntop(AF_INET, &ip4->ip_dst, dst.ip, sizeof(dst.ip)); + break; #ifdef USE_IPV6 - case 6: - ip_hl = sizeof(struct ip6_hdr); - ip_proto = ip6->ip6_nxt; - ip_len = ntohs(ip6->ip6_ctlun.ip6_un1.ip6_un1_plen) + ip_hl; - - if (ip_proto == IPPROTO_FRAGMENT) { - struct ip6_frag *ip6f = (struct ip6_frag *) (ip6 + ip_hl); - ip_frag_off = ntohs(ip6f->ip6f_offlg & IP6F_OFF_MASK); - ip_id = ntohl(ip6f->ip6f_ident); - } + case 6: + ip_hl = sizeof(struct ip6_hdr); + ip_proto = ip6->ip6_nxt; + ip_len = ntohs(ip6->ip6_ctlun.ip6_un1.ip6_un1_plen) + ip_hl; + + if (ip_proto == IPPROTO_FRAGMENT) { + ip_frag = 1; + ip6f = (struct ip6_frag *) (packet + link_hl + ip_hl); + ip_frag_off = ntohs(ip6f->ip6f_offlg & IP6F_OFF_MASK); + ip_id = ntohl(ip6f->ip6f_ident); + } - inet_ntop(AF_INET6, &ip6->ip6_src, src.ip, sizeof(src.ip)); - inet_ntop(AF_INET6, &ip6->ip6_dst, dst.ip, sizeof(dst.ip)); - break; + inet_ntop(AF_INET6, &ip6->ip6_src, src.ip, sizeof(src.ip)); + inet_ntop(AF_INET6, &ip6->ip6_dst, dst.ip, sizeof(dst.ip)); + break; #endif - default: - return NULL; - } + default: + return NULL; + } - // Fixup VSS trailer in ethernet packets - *caplen = link_hl + ip_len; + // Fixup VSS trailer in ethernet packets + *caplen = link_hl + ip_len; - // Remove IP Header length from payload - *size = *caplen - link_hl - ip_hl; + // Remove IP Header length from payload + *size = *caplen - link_hl - ip_hl; + + if (ip_proto == IPPROTO_IPIP) { + // The payload is an incapsulated IP packet (IP-IP tunnel) + // so we simply skip the "outer" IP header and repeat. + // NOTE: this will break IP reassembly if the "outer" + // packet is fragmented. + link_hl += ip_hl; + } else { + break; + } + } // If no fragmentation if (ip_frag == 0) { @@ -566,14 +582,25 @@ // Add this IP content length to the total captured of the packet pkt->ip_cap_len += ip_len - ip_hl; +#ifdef USE_IPV6 + if (ip_ver == 6 && ip_frag) { + pkt->ip_cap_len -= sizeof(struct ip6_frag); + } +#endif // Calculate how much data we need to complete this packet // The total packet size can only be known using the last fragment of the packet // where 'No more fragments is enabled' and it's calculated based on the // last fragment offset - if ((ip_off & IP_MF) == 0) { + if (ip_ver == 4 && (ip_off & IP_MF) == 0) { pkt->ip_exp_len = ip_frag_off + ip_len - ip_hl; } +#ifdef USE_IPV6 + if (ip_ver == 6 && ip_frag && (ip6f->ip6f_offlg & htons(0x01)) == 0) { + pkt->ip_exp_len = ip_frag_off + ip_len - ip_hl - sizeof(struct ip6_frag); + } +#endif + // If we have the whole packet (captured length is expected length) if (pkt->ip_cap_len == pkt->ip_exp_len) { @@ -581,8 +608,22 @@ // Calculate assembled IP payload data it = vector_iterator(pkt->frames); while ((frame = vector_iterator_next(&it))) { - struct ip *frame_ip = (struct ip *) (frame->data + link_hl); - len_data += ntohs(frame_ip->ip_len) - frame_ip->ip_hl * 4; + switch (ip_ver) { + case 4: { + struct ip *frame_ip = (struct ip *) (frame->data + link_hl); + len_data += ntohs(frame_ip->ip_len) - frame_ip->ip_hl * 4; + break; + } +#ifdef USE_IPV6 + case 6: { + struct ip6_hdr *frame_ip6 = (struct ip6_hdr *) (frame->data + link_hl); + len_data += ntohs(frame_ip6->ip6_ctlun.ip6_un1.ip6_un1_plen); + break; + } +#endif + default: + break; + } } // Check packet content length @@ -594,14 +635,39 @@ it = vector_iterator(pkt->frames); while ((frame = vector_iterator_next(&it))) { - // Get IP header - struct ip *frame_ip = (struct ip *) (frame->data + link_hl); - memcpy(packet + link_hl + ip_hl + (ntohs(frame_ip->ip_off) & IP_OFFMASK) * 8, - frame->data + link_hl + frame_ip->ip_hl * 4, - ntohs(frame_ip->ip_len) - frame_ip->ip_hl * 4); + switch (ip_ver) { + case 4: { + // Get IP header + struct ip *frame_ip = (struct ip *) (frame->data + link_hl); + memcpy(packet + link_hl + ip_hl + (ntohs(frame_ip->ip_off) & IP_OFFMASK) * 8, + frame->data + link_hl + frame_ip->ip_hl * 4, + ntohs(frame_ip->ip_len) - frame_ip->ip_hl * 4); + + } + break; +#ifdef USE_IPV6 + case 6: { + struct ip6_hdr *frame_ip6 = (struct ip6_hdr*)(frame->data + link_hl); + struct ip6_frag *frame_ip6f = (struct ip6_frag *)(frame->data + link_hl + ip_hl); + uint16_t frame_ip_frag_off = ntohs(frame_ip6f->ip6f_offlg & IP6F_OFF_MASK); + memcpy(packet + link_hl + ip_hl + sizeof(struct ip6_frag) + frame_ip_frag_off, + frame->data + link_hl + ip_hl + sizeof (struct ip6_frag), + ntohs(frame_ip6->ip6_ctlun.ip6_un1.ip6_un1_plen)); + pkt->proto = frame_ip6f->ip6f_nxt; + } + break; +#endif + default: + break; + } } *caplen = link_hl + ip_hl + len_data; +#ifdef USE_IPV6 + if (ip_ver == 6) { + *caplen += sizeof(struct ip6_frag); + } +#endif *size = len_data; // Return the assembled IP packet @@ -1074,6 +1140,12 @@ return capture_cfg.tlsserver; } +void +capture_add_source(struct capture_info *capinfo) +{ + vector_append(capture_cfg.sources, capinfo); +} + int capture_sources_count() { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/src/capture.h new/sngrep-1.5.0/src/capture.h --- old/sngrep-1.4.10/src/capture.h 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/src/capture.h 2022-04-26 15:59:33.000000000 +0200 @@ -420,6 +420,12 @@ capture_tls_server(); /** + * @brief Add new source to capture list + */ +void +capture_add_source(struct capture_info *capinfo); + +/** * @brief Return packet catprue sources count * @return capture sources count */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/src/capture_eep.c new/sngrep-1.5.0/src/capture_eep.c --- old/sngrep-1.4.10/src/capture_eep.c 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/src/capture_eep.c 2022-04-26 15:59:33.000000000 +0200 @@ -131,6 +131,32 @@ return 1; } + capture_info_t *capinfo; + + // Create a new structure to handle this capture source + if (!(capinfo = sng_malloc(sizeof(capture_info_t)))) { + fprintf(stderr, "Can't allocate memory for capture data!\n"); + return 1; + } + + // Open capture device + capinfo->handle = pcap_open_dead(DLT_EN10MB, MAXIMUM_SNAPLEN); + + // Get datalink to parse packets correctly + capinfo->link = pcap_datalink(capinfo->handle); + + // Check linktypes sngrep knowns before start parsing packets + if ((capinfo->link_hl = datalink_size(capinfo->link)) == -1) { + fprintf(stderr, "Unable to handle linktype %d\n", capinfo->link); + return 3; + } + + // Create Vectors for IP and TCP reassembly + capinfo->tcp_reasm = vector_create(0, 10); + capinfo->ip_reasm = vector_create(0, 10); + + // Add this capture information as packet source + capture_add_source(capinfo); } // Settings for EEP server @@ -206,6 +232,65 @@ return 1; } +struct pcap_pkthdr +capture_eep_build_frame_data( + const struct pcap_pkthdr header, + const unsigned char *payload, + const uint32_t payload_size, + const address_t src, + const address_t dst, + unsigned char **frame_payload +) { + //! Frame variables + struct pcap_pkthdr frame_pcap_header; + uint32_t frame_size = 0; + + // Build frame ethernet header + struct ether_header ether_hdr = { + .ether_dhost = { 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB }, + .ether_shost = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA }, + .ether_type = htons(ETHERTYPE_IP), + }; + + // Build frame IP header + struct ip ip_hdr = { + .ip_v = 4, + .ip_p = IPPROTO_UDP, + .ip_hl = sizeof(ip_hdr) / 4, + .ip_len = htons(sizeof(ip_hdr) + sizeof(struct udphdr) + payload_size), + .ip_ttl = 128, + }; + inet_pton(AF_INET, src.ip, &ip_hdr.ip_src); + inet_pton(AF_INET, dst.ip, &ip_hdr.ip_dst); + + // Build frame UDP header + struct udphdr udp_hdr = { + .uh_sport = htons(src.port), + .uh_dport = htons(dst.port), + .uh_ulen = htons(sizeof(struct udphdr) + payload_size), + }; + + // Allocate memory for payload contents + *frame_payload = sng_malloc(sizeof(ether_hdr) + sizeof(ip_hdr) + sizeof(udp_hdr) + payload_size); + + // Append all headers to frame contents + memcpy(*frame_payload + frame_size, (void*) ðer_hdr, sizeof(ether_hdr)); + frame_size += sizeof(ether_hdr); + memcpy(*frame_payload + frame_size, (void*) &ip_hdr, sizeof(ip_hdr)); + frame_size += sizeof(ip_hdr); + memcpy(*frame_payload + frame_size, (void*) &udp_hdr, sizeof(udp_hdr)); + frame_size += sizeof(udp_hdr); + memcpy(*frame_payload + frame_size, (void*) payload, payload_size); + frame_size += payload_size; + + // Build a custom frame pcap header + frame_pcap_header.caplen = frame_size; + frame_pcap_header.len = frame_size; + frame_pcap_header.ts = header.ts; + + return frame_pcap_header; +} + int capture_eep_send_v2(packet_t *pkt) { @@ -514,6 +599,9 @@ struct hep_hdr hdr; struct hep_timehdr hep_time; struct hep_iphdr hep_ipheader; + //! Frame contents + struct pcap_pkthdr frame_pcap_header; + unsigned char *frame_payload; #ifdef USE_IPV6 struct hep_ip6hdr hep_ip6header; #endif @@ -576,9 +664,12 @@ payload = sng_malloc(header.caplen + 1); memcpy(payload, (void*) buffer + pos, header.caplen); + // Build a custom frame pcap header + frame_pcap_header = capture_eep_build_frame_data(header, payload,header.caplen, src, dst, &frame_payload); + // Create a new packet pkt = packet_create((family == AF_INET) ? 4 : 6, proto, src, dst, 0); - packet_add_frame(pkt, &header, payload); + packet_add_frame(pkt, &frame_pcap_header, frame_payload); packet_set_transport_data(pkt, src.port, dst.port); packet_set_type(pkt, PACKET_SIP_UDP); packet_set_payload(pkt, payload, header.caplen); @@ -624,6 +715,9 @@ struct pcap_pkthdr header; //! New created packet pointer packet_t *pkt_new; + //! Frame contents + struct pcap_pkthdr frame_pcap_header; + unsigned char *frame_payload; if(!pkt) { /* Receive EEP generic header */ @@ -750,9 +844,12 @@ return NULL; } + // Build a custom frame pcap header + frame_pcap_header = capture_eep_build_frame_data(header, payload,header.caplen, src, dst, &frame_payload); + // Create a new packet pkt_new = packet_create((hg.ip_family.data == AF_INET)?4:6, hg.ip_proto.data, src, dst, 0); - packet_add_frame(pkt_new, &header, payload); + packet_add_frame(pkt_new, &frame_pcap_header, frame_payload); packet_set_type(pkt_new, PACKET_SIP_UDP); packet_set_payload(pkt_new, payload, header.caplen); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/src/capture_gnutls.c new/sngrep-1.5.0/src/capture_gnutls.c --- old/sngrep-1.4.10/src/capture_gnutls.c 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/src/capture_gnutls.c 2022-04-26 15:59:33.000000000 +0200 @@ -477,6 +477,20 @@ // Client Hello SSLv2 struct ClientHelloSSLv2 *clienthello = (struct ClientHelloSSLv2 *) fragment; + // Check we have a TLS handshake + if (clienthello->client_version.major != 0x03) { + tls_connection_destroy(conn); + return 1; + } + + // Only TLS 1.0, 1.1 or 1.2 connections + if (clienthello->client_version.minor != 0x01 + && clienthello->client_version.minor != 0x02 + && clienthello->client_version.minor != 0x03) { + tls_connection_destroy(conn); + return 1; + } + // Store TLS version conn->version = clienthello->client_version.minor; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/src/curses/ui_filter.c new/sngrep-1.5.0/src/curses/ui_filter.c --- old/sngrep-1.4.10/src/curses/ui_filter.c 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/src/curses/ui_filter.c 2022-04-26 15:59:33.000000000 +0200 @@ -55,7 +55,7 @@ const char *method, *payload; // Cerate a new indow for the panel and form - ui_panel_create(ui, 17, 50); + ui_panel_create(ui, 18, 50); // Initialize Filter panel specific data info = sng_malloc(sizeof(filter_info_t)); @@ -74,6 +74,7 @@ info->fields[FLD_FILTER_SUBSCRIBE] = new_field(1, 1, 11, 15, 0, 0); info->fields[FLD_FILTER_NOTIFY] = new_field(1, 1, 12, 15, 0, 0); info->fields[FLD_FILTER_INFO] = new_field(1, 1, 13, 15, 0, 0); + info->fields[FLD_FILTER_KDMQ] = new_field(1, 1, 14, 15, 0, 0); info->fields[FLD_FILTER_OPTIONS] = new_field(1, 1, 9, 37, 0, 0); info->fields[FLD_FILTER_PUBLISH] = new_field(1, 1, 10, 37, 0, 0); info->fields[FLD_FILTER_MESSAGE] = new_field(1, 1, 11, 37, 0, 0); @@ -94,6 +95,7 @@ field_opts_off(info->fields[FLD_FILTER_SUBSCRIBE], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_NOTIFY], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_INFO], O_AUTOSKIP); + field_opts_off(info->fields[FLD_FILTER_KDMQ], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_OPTIONS], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_PUBLISH], O_AUTOSKIP); field_opts_off(info->fields[FLD_FILTER_MESSAGE], O_AUTOSKIP); @@ -129,6 +131,7 @@ mvwprintw(ui->win, 11, 3, "SUBSCRIBE [ ]"); mvwprintw(ui->win, 12, 3, "NOTIFY [ ]"); mvwprintw(ui->win, 13, 3, "INFO [ ]"); + mvwprintw(ui->win, 14, 3, "KDMQ [ ]"); mvwprintw(ui->win, 9, 25, "OPTIONS [ ]"); mvwprintw(ui->win, 10, 25, "PUBLISH [ ]"); mvwprintw(ui->win, 11, 25, "MESSAGE [ ]"); @@ -159,6 +162,8 @@ strcasestr(method, sip_method_str(SIP_METHOD_NOTIFY)) ? "*" : ""); set_field_buffer(info->fields[FLD_FILTER_INFO], 0, strcasestr(method, sip_method_str(SIP_METHOD_INFO)) ? "*" : ""); + set_field_buffer(info->fields[FLD_FILTER_KDMQ], 0, + strcasestr(method, sip_method_str(SIP_METHOD_KDMQ)) ? "*" : ""); set_field_buffer(info->fields[FLD_FILTER_OPTIONS], 0, strcasestr(method, sip_method_str(SIP_METHOD_OPTIONS)) ? "*" : ""); set_field_buffer(info->fields[FLD_FILTER_PUBLISH], 0, @@ -274,6 +279,7 @@ case FLD_FILTER_SUBSCRIBE: case FLD_FILTER_NOTIFY: case FLD_FILTER_INFO: + case FLD_FILTER_KDMQ: case FLD_FILTER_OPTIONS: case FLD_FILTER_PUBLISH: case FLD_FILTER_MESSAGE: @@ -378,6 +384,7 @@ case FLD_FILTER_INFO: case FLD_FILTER_REFER: case FLD_FILTER_UPDATE: + case FLD_FILTER_KDMQ: if (!strcmp(field_value, "*")) { if (strlen(method_expr)) { sprintf(method_expr + strlen(method_expr), ",%s", filter_field_method(field_id)); @@ -436,6 +443,9 @@ case FLD_FILTER_UPDATE: method = SIP_METHOD_UPDATE; break; + case FLD_FILTER_KDMQ: + method = SIP_METHOD_KDMQ; + break; } return sip_method_str(method); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/src/curses/ui_filter.h new/sngrep-1.5.0/src/curses/ui_filter.h --- old/sngrep-1.4.10/src/curses/ui_filter.h 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/src/curses/ui_filter.h 2022-04-26 15:59:33.000000000 +0200 @@ -54,6 +54,7 @@ FLD_FILTER_SUBSCRIBE, FLD_FILTER_NOTIFY, FLD_FILTER_INFO, + FLD_FILTER_KDMQ, FLD_FILTER_OPTIONS, FLD_FILTER_PUBLISH, FLD_FILTER_MESSAGE, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/src/curses/ui_panel.c new/sngrep-1.5.0/src/curses/ui_panel.c --- old/sngrep-1.4.10/src/curses/ui_panel.c 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/src/curses/ui_panel.c 2022-04-26 15:59:33.000000000 +0200 @@ -172,10 +172,10 @@ void ui_panel_destroy(ui_t *ui) { - // Deallocate panel window - delwin(ui->win); // Deallocate panel pointer del_panel(ui->panel); + // Deallocate panel window + delwin(ui->win); } void diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/src/main.c new/sngrep-1.5.0/src/main.c --- old/sngrep-1.4.10/src/main.c 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/src/main.c 2022-04-26 15:59:33.000000000 +0200 @@ -356,7 +356,8 @@ #endif // If no device or files has been specified in command line, use default - if (vector_count(indevices) == 0 && vector_count(infiles) == 0) { + if (capture_sources_count() == 0 && + vector_count(indevices) == 0 && vector_count(infiles) == 0) { token = strdup(device); token = strtok(token, ","); while (token) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/src/option.c new/sngrep-1.5.0/src/option.c --- old/sngrep-1.4.10/src/option.c 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/src/option.c 2022-04-26 15:59:33.000000000 +0200 @@ -109,7 +109,7 @@ read_options(const char *fname) { FILE *fh; - char line[1024], type[20], option[50], value[50]; + char line[1024], type[20], option[50], value[500]; int id; if (!(fh = fopen(fname, "rt"))) @@ -121,7 +121,7 @@ continue; // Get configuration option from setting line - if (sscanf(line, "%19s %49s %49[^\t\n]", type, option, value) == 3) { + if (sscanf(line, "%19s %49s %499[^\t\n]", type, option, value) == 3) { if (!strcasecmp(type, "set")) { if ((id = setting_id(option)) >= 0) { setting_set_value(id, value); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/src/packet.h new/sngrep-1.5.0/src/packet.h --- old/sngrep-1.4.10/src/packet.h 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/src/packet.h 2022-04-26 15:59:33.000000000 +0200 @@ -77,7 +77,11 @@ //! Destination address_t dst; //! Packet IP id +#ifdef USE_IPV6 + uint32_t ip_id; +#else uint16_t ip_id; +#endif //! Packet IP fragmentation captured data uint32_t ip_cap_len; //! Packet IP fragmentation expected data diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/tests/Makefile.am new/sngrep-1.5.0/tests/Makefile.am --- old/sngrep-1.4.10/tests/Makefile.am 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/tests/Makefile.am 2022-04-26 15:59:33.000000000 +0200 @@ -2,6 +2,7 @@ check_PROGRAMS=test-001 test-002 test-003 test-004 test-005 check_PROGRAMS+=test-006 test-007 test-008 test-009 test-010 +check_PROGRAMS+=test-011 test_001_SOURCES=test_001.c test_002_SOURCES=test_002.c @@ -13,5 +14,6 @@ test_008_SOURCES=test_008.c test_009_SOURCES=test_009.c test_010_SOURCES=test_010.c ../src/hash.c +test_011_SOURCES=test_011.c TESTS = $(check_PROGRAMS) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/tests/README new/sngrep-1.5.0/tests/README --- old/sngrep-1.4.10/tests/README 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/tests/README 2022-04-26 15:59:33.000000000 +0200 @@ -1,6 +1,6 @@ Basic testing programs for sngrep. -This set of test will do some basic inputs to check sngrep screen navigation +This set of test will do some basic inputs to check sngrep screen navigation doesn't crash. This checks are ultra-super-basic. - test_001 : UI testing @@ -10,6 +10,7 @@ - test_005 : Column selection testing - test_006 : Message diff testing - test_007: Test vector container structures +- test_011: Test mix of normal packets with IPIP tunneled packets Sample capture files has been taken from wireshark Wiki: - https://wiki.wireshark.org/SampleCaptures Binary files old/sngrep-1.4.10/tests/ipip.pcap and new/sngrep-1.5.0/tests/ipip.pcap differ Binary files old/sngrep-1.4.10/tests/ipv6frag.pcap and new/sngrep-1.5.0/tests/ipv6frag.pcap differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/tests/test_008.c new/sngrep-1.5.0/tests/test_008.c --- old/sngrep-1.4.10/tests/test_008.c 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/tests/test_008.c 2022-04-26 15:59:33.000000000 +0200 @@ -20,7 +20,7 @@ ** ****************************************************************************/ /** - * @file test_001.c + * @file test_008.c * @author Ivan Alonso [aka Kaian] <ka...@irontec.com> * * Test for sorting columns based on standard attributes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/tests/test_009.c new/sngrep-1.5.0/tests/test_009.c --- old/sngrep-1.4.10/tests/test_009.c 2021-11-22 11:50:47.000000000 +0100 +++ new/sngrep-1.5.0/tests/test_009.c 2022-04-26 15:59:33.000000000 +0200 @@ -20,7 +20,7 @@ ** ****************************************************************************/ /** - * @file test_001.c + * @file test_009.c * @author Ivan Alonso [aka Kaian] <ka...@irontec.com> * * Test for adding a new attribute column and sorting using it. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sngrep-1.4.10/tests/test_011.c new/sngrep-1.5.0/tests/test_011.c --- old/sngrep-1.4.10/tests/test_011.c 1970-01-01 01:00:00.000000000 +0100 +++ new/sngrep-1.5.0/tests/test_011.c 2022-04-26 15:59:33.000000000 +0200 @@ -0,0 +1,43 @@ +/************************************************************************** + ** + ** sngrep - SIP Messages flow viewer + ** + ** Copyright (C) 2013-2018 Ivan Alonso (Kaian) + ** Copyright (C) 2013-2018 Irontec SL. All rights reserved. + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see <http://www.gnu.org/licenses/>. + ** + ****************************************************************************/ +/** + * @file test_011.c + * @author Evgeny Khramtsov <evgeny.khramt...@nordigy.ru> + * + * IP-IP tunnel test from ipip.pcap + */ + +const char keys[] = + { + /* Enter Call Flow */ + 10, + /* Leave Call Flow */ + 27, + /* Exit */ + 27, + 10, + 0 + }; + +#define TEST_PCAP_INPUT "ipip.pcap" + +#include "test_input.c"