Fix for handling dumpcap errmsgs when wireshark does 'dumpcap -D -M', etc

svn path=/trunk/; revision=24507
This commit is contained in:
Bill Meier 2008-02-29 18:48:29 +00:00
parent 26b8bf31d7
commit 2c07da3195
2 changed files with 55 additions and 15 deletions

View File

@ -856,10 +856,22 @@ sync_interface_list_open(gchar **msg) {
argv = sync_pipe_add_arg(argv, &argc, "-D");
argv = sync_pipe_add_arg(argv, &argc, "-M");
/* dumpcap should be running in capture child mode (hidden feature) */
#if 0
/* dumpcap should be running in capture child mode (hidden feature) */
/* XXX: Actually: don't run dumpcap in capture_child_mode. */
/* Instead run dumpcap in 'normal' mode so that dumpcap err msgs are sent to */
/* stderr in normal format and are then sent to whereever our stderr goes. */
/* Note: Using 'dumpcap -D -M -Z' (capture_child mode) changes only the format of */
/* dumpcap err msgs. That is: dumpcap in capture_child mode outputs err */
/* msgs to stderr in a special type/len/string format which would then */
/* currently be sent as is to stderr resulting in garbled output. */
/* ToDo: Revise this code to be similar to sync_pipe_start so that 'dumpcap -Z' */
/* special format error messages to stderr are captured and returned to caller */
/* (eg: so can be processed and displayed in a pop-up box). */
#ifndef DEBUG_CHILD
argv = sync_pipe_add_arg(argv, &argc, "-Z");
argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE);
#endif
#endif
return sync_pipe_run_command(argv, msg);
@ -896,12 +908,23 @@ sync_linktype_list_open(const gchar *ifname, gchar **msg) {
argv = sync_pipe_add_arg(argv, &argc, "-L");
argv = sync_pipe_add_arg(argv, &argc, "-M");
/* dumpcap should be running in capture child mode (hidden feature) */
#if 0
/* dumpcap should be running in capture child mode (hidden feature) */
/* XXX: Actually: don't run dumpcap in capture_child_mode. */
/* Instead run dumpcap in 'normal' mode so that dumpcap err msgs are sent to */
/* stderr in normal format and are then sent to whereever our stderr goes. */
/* Note: Using 'dumpcap -L -M -Z' (capture_child mode) changes only the format of */
/* dumpcap err msgs. That is: dumpcap in capture_child mode outputs err */
/* msgs to stderr in a special type/len/string format which would then */
/* currently be sent as is to stderr resulting in garbled output. */
/* ToDo: Revise this code to be similar to sync_pipe_start so that 'dumpcap -Z' */
/* special format error messages to stderr are captured and returned to caller */
/* (eg: so can be processed and displayed in a pop-up box). */
#ifndef DEBUG_CHILD
argv = sync_pipe_add_arg(argv, &argc, "-Z");
argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE);
#endif
#endif
return sync_pipe_run_command(argv, msg);
}
@ -921,7 +944,7 @@ sync_interface_stats_open(int *read_fd, int *fork_child, gchar **msg) {
return -1;
}
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_linktype_list_open");
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_interface_stats_open");
argv = init_pipe_args(&argc);
@ -930,16 +953,27 @@ sync_interface_stats_open(int *read_fd, int *fork_child, gchar **msg) {
return CANT_RUN_DUMPCAP;
}
/* Ask for the linktype list */
/* Ask for the interface statistics */
argv = sync_pipe_add_arg(argv, &argc, "-S");
argv = sync_pipe_add_arg(argv, &argc, "-M");
/* dumpcap should be running in capture child mode (hidden feature) */
#if 0
/* dumpcap should be running in capture child mode (hidden feature) */
/* XXX: Actually: don't run dumpcap in capture_child_mode. */
/* Instead run dumpcap in 'normal' mode so that dumpcap err msgs are sent to */
/* stderr in normal format and are then sent to whereever our stderr goes. */
/* Note: Using 'dumpcap -S -M -Z' (capture_child mode) changes only the format of */
/* dumpcap err msgs. That is: dumpcap in capture_child mode outputs err */
/* msgs to stderr in a special type/len/string format which would then */
/* currently be sent as is to stderr resulting in garbled output. */
/* ToDo: Revise this code to be similar to sync_pipe_start so that 'dumpcap -Z' */
/* special format error messages to stderr are captured and returned to caller */
/* (eg: so can be processed and displayed in a pop-up box). */
#ifndef DEBUG_CHILD
argv = sync_pipe_add_arg(argv, &argc, "-Z");
argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE);
#endif
#endif
return sync_pipe_open_command(argv, read_fd, fork_child, msg);
}

View File

@ -2233,14 +2233,20 @@ main(int argc, char *argv[])
}
#endif
/* Determine if dumpcap is running as a child process by going thru */
/* the command line args to see if a -Z option (which is the */
/* hidden option which indicates that dumpcap has been invoked */
/* from a parent process using a pipe). */
/* "Child" status needs to be determined immediately upon startup so */
/* that any messages generated by dumpcap (eg: during initialization)*/
/* will be formatted properly if being sent back to a parent via */
/* a pipe. */
/* Determine if dumpcap is being requested to run in a special */
/* capture_child mode by going thru the command line args to see if */
/* a -Z is present. (-Z is a hidden option). */
/* The primary result of running in capture_child mode is that */
/* all messages sent out on stderr are in a special type/len/string */
/* format to allow message processing by type. */
/* These messages include various 'status' messages which are sent */
/* when an actual capture is in progress. Capture_child mode */
/* would normally be requested by a parent process which invokes */
/* dumpcap and obtains dumpcap stderr output via a pipe to which */
/* dumpcap stderr has been redirected. */
/* Capture_child mode needs to be determined immediately upon */
/* startup so that any messages generated by dumpcap in this mode */
/* (eg: during initialization) will be formatted properly. */
for (i=1; i<argc; i++) {
if (strcmp("-Z", argv[i]) == 0) {