Wireshark-dev: [Wireshark-dev] Fwd: Patches
From: Richard van der Hoff <richardv@xxxxxxxxxxxxx>
Date: Mon, 31 Jul 2006 10:29:14 +0100
Hi,I submitted these patches last week, but I think they might have been overlooked. Could they be applied, please?
Thanks, Richard
--- Begin Message ---From: Richard van der Hoff <richardv@xxxxxxxxxxxxx>Date: Wed, 26 Jul 2006 14:22:57 +0100Richard van der Hoff wrote:[tshark from a fifo] Ulf - I notice you made the relevant change here (r16787) - is there any reason why tshark shouldn't use capture_loop_dispatch to do its processing, rather than attempting to use cap_pipe_dispatch or pcap_dispatch directly?well, there didn't seem to be, so I've made a patch which does exactly this, and which fixes the problem.I've even gone so far as to add a unit test for it :). Please could this be applied? -- Richard van der Hoff <richardv@xxxxxxxxxxxxx> Telephony Gateways Project Manager Tel: +44 (0) 845 666 7778 http://www.mxtelecom.comIndex: capture_loop.c =================================================================== --- capture_loop.c (revision 9793) +++ capture_loop.c (working copy) @@ -323,7 +323,7 @@ /* We read one record from the pipe, take care of byte order in the record * header, write the record to the capture file, and update capture statistics. */ -int +static int cap_pipe_dispatch(loop_data *ld, guchar *data, char *errmsg, int errmsgl) { struct pcap_pkthdr phdr; @@ -800,7 +800,7 @@ } /* dispatch incoming packets (pcap or capture pipe) */ -static int +int capture_loop_dispatch(capture_options *capture_opts _U_, loop_data *ld, char *errmsg, int errmsg_len) { int inpkts; @@ -1465,10 +1465,10 @@ void capture_loop_stop(void) { #ifdef HAVE_PCAP_BREAKLOOP - pcap_breakloop(ld.pcap_h); -#else + if(ld.pcap_h != NULL) + pcap_breakloop(ld.pcap_h); +#endif ld.go = FALSE; -#endif } Index: capture_loop.h =================================================================== --- capture_loop.h (revision 9793) +++ capture_loop.h (working copy) @@ -159,12 +159,12 @@ extern initfilter_status_t capture_loop_init_filter(pcap_t *pcap_h, gboolean from_cap_pipe, const gchar * iface, gchar * cfilter); -#ifdef HAVE_LIBPCAP -#ifndef _WIN32 -extern int -cap_pipe_dispatch(loop_data *, guchar *, char *, int); -#endif /* _WIN32 */ -#endif +/** read a single record from the capture input, and dispatch it + returns the number of packets processed. +*/ +extern int +capture_loop_dispatch(capture_options *capture_opts, loop_data *ld, + char *errmsg, int errmsg_len); extern gboolean capture_loop_open_input(capture_options *capture_opts, loop_data *ld, Index: tshark.c =================================================================== --- tshark.c (revision 9793) +++ tshark.c (working copy) @@ -1700,12 +1700,7 @@ each packet. */ pcap_cnt = 1; } -#ifndef _WIN32 - if (ld.from_cap_pipe) { - inpkts = cap_pipe_dispatch(&ld, pcap_data, errmsg, sizeof errmsg); - } else -#endif - inpkts = pcap_dispatch(ld.pcap_h, pcap_cnt, ld.packet_cb, (u_char *) &ld); + inpkts=capture_loop_dispatch(pcap_data, &ld, errmsg, sizeof errmsg); if (inpkts < 0) { /* Error from "pcap_dispatch()", or error or "no more packets" from "cap_pipe_dispatch(). */ Index: test/suite-capture.sh =================================================================== --- test/suite-capture.sh (revision 9793) +++ test/suite-capture.sh (working copy) @@ -93,6 +93,38 @@ fi } +# capture packets via a fifo +capture_step_fifo() { + mkfifo 'fifo' + (cat $CAPFILE; sleep 1; tail -c +25 $CAPFILE) > fifo & + $DUT -i fifo -w ./testout.pcap -a duration:$TRAFFIC_CAPTURE_DURATION > ./testout.txt 2>&1 + RETURNVALUE=$? + rm 'fifo' + if [ ! $RETURNVALUE -eq $EXIT_OK ]; then + test_step_failed "exit status of $DUT: $RETURNVALUE" + return + fi + + # we should have an output file now + if [ ! -f "./testout.pcap" ]; then + test_step_failed "No output file!" + return + fi + + # ok, we got a capture file, does it contain exactly 8 packets? + $CAPINFOS ./testout.pcap > ./testout.txt + grep -i 'Number of packets: 8' ./testout.txt > /dev/null + if [ $? -eq 0 ]; then + test_step_ok + else + echo + cat ./testout.txt + test_step_failed "No or not enough traffic captured." + fi +} + + + # capture exactly 2 times 10 packets (multiple files) capture_step_2multi_10packets() { $DUT -i $TRAFFIC_CAPTURE_IFACE -w ./testout.pcap -c 10 -a duration:$TRAFFIC_CAPTURE_DURATION > ./testout.txt 2>&1 @@ -202,6 +234,7 @@ test_step_add "Capture 10 packets using stdout: -w -" capture_step_10packets_stdout test_step_add "Capture read filter (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_read_filter test_step_add "Capture snapshot length 68 bytes (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_snapshot + test_step_add "Capture via fifo" capture_step_fifo } dumpcap_capture_suite() {_______________________________________________ Wireshark-dev mailing list Wireshark-dev@xxxxxxxxxxxxx http://www.wireshark.org/mailman/listinfo/wireshark-dev
--- End Message ---
--- Begin Message ---From: Richard van der Hoff <richardv@xxxxxxxxxxxxx>Date: Wed, 26 Jul 2006 14:28:37 +0100This patch fixes a couple of comments in capture_sync.c. -- Richard van der Hoff <richardv@xxxxxxxxxxxxx> Telephony Gateways Project Manager Tel: +44 (0) 845 666 7778 http://www.mxtelecom.comIndex: capture_sync.c =================================================================== --- capture_sync.c (revision 9793) +++ capture_sync.c (working copy) @@ -432,7 +432,7 @@ /* associate the operating system filehandle to a C run-time file handle */ capture_opts->signal_pipe_write_fd = _open_osfhandle( (long) signal_pipe_write, _O_BINARY); - /* child own's the read side now, close our handle */ + /* child owns the read side now, close our handle */ CloseHandle(signal_pipe_read); #else /* _WIN32 */ if (pipe(sync_pipe) < 0) { @@ -445,9 +445,8 @@ if ((capture_opts->fork_child = fork()) == 0) { /* - * Child process - run Wireshark with the right arguments to make - * it just pop up the live capture dialog box and capture with - * the specified capture parameters, writing to the specified file. + * Child process - run dumpcap with the right arguments to make + * it just capture with the specified capture parameters */ eth_close(1); dup(sync_pipe[PIPE_WRITE]);_______________________________________________ Wireshark-dev mailing list Wireshark-dev@xxxxxxxxxxxxx http://www.wireshark.org/mailman/listinfo/wireshark-dev
--- End Message ---
--- Begin Message ---An error message has been changed, such that the commandline options test doesn't work any more.From: Richard van der Hoff <richardv@xxxxxxxxxxxxx>Date: Wed, 26 Jul 2006 14:33:22 +0100This patch fixes the test accordingly. -- Richard van der Hoff <richardv@xxxxxxxxxxxxx> Telephony Gateways Project Manager Tel: +44 (0) 845 666 7778 http://www.mxtelecom.comIndex: test/suite-clopts.sh =================================================================== --- test/suite-clopts.sh (revision 9793) +++ test/suite-clopts.sh (working copy) @@ -117,7 +117,7 @@ if [ ! $RETURNVALUE -eq $EXIT_OK ]; then test_step_failed "exit status: $RETURNVALUE" else - grep -i 'The capture session could not be initiated!' ./testout.txt > /dev/null + grep -i 'The capture session could not be initiated' ./testout.txt > /dev/null if [ $? -eq 0 ]; then test_step_ok else_______________________________________________ Wireshark-dev mailing list Wireshark-dev@xxxxxxxxxxxxx http://www.wireshark.org/mailman/listinfo/wireshark-dev
--- End Message ---
- Prev by Date: Re: [Wireshark-dev] Small [Patch] to H.323 VoIP calls
- Next by Date: [Wireshark-dev] Patch to conversation.c
- Previous by thread: [Wireshark-dev] [bug] bugzilla reply address bounces
- Next by thread: [Wireshark-dev] Patch to conversation.c
- Index(es):