diff options
author | Guy Harris <guy@alum.mit.edu> | 2007-09-29 01:36:03 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2007-09-29 01:36:03 +0000 |
commit | 322d44d416c84ac2ae12dae16b7b5cbf6d33c216 (patch) | |
tree | 0308b7980991dfb622660383d785b9bb954999dd /dumpcap.c | |
parent | 6d065e2eb2792e6b4add180d7ac6190ecff3f925 (diff) |
Make the "-Z" argument to dumpcap take an argument that's the file
descriptor to use as the sync pipe. For now, always pass 1, so the sync
pipe is the standard output of dumpcap.
svn path=/trunk/; revision=23025
Diffstat (limited to 'dumpcap.c')
-rw-r--r-- | dumpcap.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -85,6 +85,8 @@ void exit_main(int err) __attribute__ ((noreturn)); void exit_main(int err); #endif +/* Sync pipe file descriptor. */ +static int sync_pipe_fd; static void print_usage(gboolean print_ver) { @@ -253,7 +255,7 @@ main(int argc, char *argv[]) gboolean print_statistics = FALSE; int status, run_once_args = 0; -#define OPTSTRING_INIT "a:b:c:Df:hi:LMpSs:vw:y:Z" +#define OPTSTRING_INIT "a:b:c:Df:hi:LMpSs:vw:y:Z:" #ifdef _WIN32 #define OPTSTRING_WIN32 "B:" @@ -362,9 +364,10 @@ main(int argc, char *argv[]) /*** hidden option: Wireshark child mode (using binary output messages) ***/ case 'Z': capture_child = TRUE; + sync_pipe_fd = get_positive_int(optarg, "sync pipe file descriptor"); #ifdef _WIN32 /* set output pipe to binary mode, to avoid ugly text conversions */ - _setmode(1, O_BINARY); + _setmode(sync_pipe_fd, O_BINARY); #endif break; @@ -554,7 +557,7 @@ report_packet_count(int packet_count) if(capture_child) { g_snprintf(tmp, sizeof(tmp), "%d", packet_count); g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Packets: %s", tmp); - pipe_write_block(1, SP_PACKET_COUNT, tmp); + pipe_write_block(sync_pipe_fd, SP_PACKET_COUNT, tmp); } else { count += packet_count; fprintf(stderr, "\rPackets: %u ", count); @@ -568,7 +571,7 @@ report_new_capture_file(const char *filename) { if(capture_child) { g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "File: %s", filename); - pipe_write_block(1, SP_FILE, filename); + pipe_write_block(sync_pipe_fd, SP_FILE, filename); } else { fprintf(stderr, "File: %s\n", filename); /* stderr could be line buffered */ @@ -581,7 +584,7 @@ report_cfilter_error(const char *cfilter, const char *errmsg) { if (capture_child) { g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Capture filter error: %s", errmsg); - pipe_write_block(1, SP_BAD_FILTER, errmsg); + pipe_write_block(sync_pipe_fd, SP_BAD_FILTER, errmsg); } else { fprintf(stderr, "Invalid capture filter: \"%s\"!\n" @@ -600,7 +603,7 @@ report_capture_error(const char *error_msg, const char *secondary_error_msg) "Primary Error: %s", error_msg); g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Secondary Error: %s", secondary_error_msg); - sync_pipe_errmsg_to_parent(1, error_msg, secondary_error_msg); + sync_pipe_errmsg_to_parent(sync_pipe_fd, error_msg, secondary_error_msg); } else { fprintf(stderr, "%s\n%s\n", error_msg, secondary_error_msg); } @@ -615,7 +618,7 @@ report_packet_drops(int drops) if(capture_child) { g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Packets dropped: %s", tmp); - pipe_write_block(1, SP_DROPS, tmp); + pipe_write_block(sync_pipe_fd, SP_DROPS, tmp); } else { fprintf(stderr, "Packets dropped: %s\n", tmp); /* stderr could be line buffered */ |