diff --git a/AUTHORS b/AUTHORS index c1e902a96c..1fedded8f4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -162,6 +162,10 @@ Uwe Girlich { ONC RPC and NFS support } +Warren Young { + "Print" button support in "Tools:Follow TCP Stream" window +} + Alain Magloire was kind enough to give his permission to use his version of snprintf.c. diff --git a/doc/ethereal.pod.template b/doc/ethereal.pod.template index 9ee9c7cbd4..6ffd658131 100644 --- a/doc/ethereal.pod.template +++ b/doc/ethereal.pod.template @@ -47,11 +47,13 @@ shows a summary line, briefly describing what the packet is. A protocol tree is you to drill down to exact protocol or field that you interested in. Finally, a hex dump shows you exactly what the packet looks like when it goes over the wire. -In addition, B has some features that make it unique. It can assemble all -the packets in a TCP conversation and show you the ASCII data in that conversation. Display -filters in B are very powerful; more fields are filterable in Ethereal than in other -protocol analyzers, and the syntax you can use to create your filters is richer. As Ethereal -progresses, expect more and more protocol fields to be allowed in display filters. +In addition, B has some features that make it unique. It can +assemble all the packets in a TCP conversation and show you the ASCII +(or EBCDIC) data in that conversation. Display filters in B +are very powerful; more fields are filterable in Ethereal than in other +protocol analyzers, and the syntax you can use to create your filters is +richer. As Ethereal progresses, expect more and more protocol fields to +be allowed in display filters. Packet capturing is performed with the pcap library. The capture filter syntax follows the rules of the pcap library. This syntax is different from the display filter syntax. @@ -93,7 +95,8 @@ should match one of the names listed in "B" or "B". =item -k Starts the capture session immediately; this option requires -the B<-i> and B<-w> parameters. +the B<-i> parameter, specifying the interface on which the capture +should be done. =item -m @@ -237,12 +240,18 @@ Expands all branches of the protocol tree. =item Tools:Follow TCP Stream -If you have a TCP packet selected, it will display the contents of the TCP -data stream in a separate window. This has the side-effect of leaving -the list of packets in a filtered state; only those packets that make up -the TCP stream are shown. You can revert to your old view by pressing -ENTER in the display filter text box, thereby invoking your old -display filter (or resetting it back to no display filter). +If you have a TCP packet selected, it will display the contents of the +data stream for the TCP connection to which that packet belongs, as +text, in a separate window, and will leave the list of packets in a +filtered state, with only those packets that are part of that TCP +connection being displayed. You can revert to your old view by pressing +ENTER in the display filter text box, thereby invoking your old display +filter (or resetting it back to no display filter). + +The window in which the data stream is displayed lets you select whether +the data being displayed is to be treated as ASCII or EBCDIC text, and +lets you print the text, using the same print options that are used for +the I menu item. =back @@ -623,6 +632,7 @@ B. Tomislav Vujec Kojak Uwe Girlich + Warren Young Alain Magloire was kind enough to give his permission to use his version of snprintf.c. diff --git a/gtk/main.c b/gtk/main.c index 1bfeea9815..e974e7a3da 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1,6 +1,6 @@ /* main.c * - * $Id: main.c,v 1.29 1999/10/29 01:04:44 guy Exp $ + * $Id: main.c,v 1.30 1999/10/30 06:41:51 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -118,6 +118,7 @@ static gint tree_selected_start=-1, tree_selected_len=-1; static void follow_destroy_cb(GtkWidget *win, gpointer data); static void follow_charset_toggle_cb(GtkWidget *w, gpointer parent_w); static void follow_load_text(GtkWidget *text, char *filename, gboolean show_ascii); +static void follow_print_stream(GtkWidget *w, gpointer parent_w); /* About Ethereal window */ void @@ -157,6 +158,7 @@ about_ethereal( GtkWidget *w, gpointer data ) { "Tomislav Vujec \n" "Kojak \n" "Uwe Girlich \n" + "Warren Young \n" "\nSee http://ethereal.zing.org for more information", VERSION, comp_info_str); @@ -169,7 +171,7 @@ void follow_stream_cb( GtkWidget *w, gpointer data ) { char filename1[128+1]; GtkWidget *streamwindow, *box, *text, *vscrollbar, *table; - GtkWidget *hbox, *close_bt, *button; + GtkWidget *hbox, *close_bt, *print_bt, *button; int tmp_fd; gchar *follow_filter; @@ -282,6 +284,13 @@ follow_stream_cb( GtkWidget *w, gpointer data ) { gtk_box_pack_end( GTK_BOX(hbox), close_bt, FALSE, FALSE, 0); gtk_widget_show( close_bt ); + /* Create Print Button */ + print_bt = gtk_button_new_with_label("Print"); + gtk_signal_connect(GTK_OBJECT(print_bt), "clicked", + GTK_SIGNAL_FUNC(follow_print_stream), + GTK_OBJECT(streamwindow)); + gtk_box_pack_end( GTK_BOX(hbox), print_bt, FALSE, FALSE, 0); + gtk_widget_show( print_bt ); /* create the scrollbar */ vscrollbar = gtk_vscrollbar_new( GTK_TEXT(text)->vadj ); @@ -350,6 +359,65 @@ follow_charset_toggle_cb(GtkWidget *w, gpointer parent_w) follow_load_text(text, filename, show_ascii); } +static void follow_print_stream(GtkWidget *w, gpointer parent_w) +{ + FILE *fh = NULL; + int to_file = -1; + char* print_dest = NULL; + char* filename; + + switch (prefs.pr_dest) { + case PR_DEST_CMD: + print_dest = prefs.pr_cmd; + to_file = FALSE; + break; + + case PR_DEST_FILE: + print_dest = prefs.pr_file; + to_file = TRUE; + break; + } + + if (print_dest != NULL) { + fh = open_print_dest(to_file, print_dest); + } + + if (fh == NULL) { + switch (to_file) { + case -1: + simple_dialog(ESD_TYPE_WARN, NULL, + "Couldn't figure out where to send the print " + "job. Check your preferences."); + break; + + case FALSE: + simple_dialog(ESD_TYPE_WARN, NULL, + "Couldn't run print command %s.", prefs.pr_cmd); + break; + + case TRUE: + simple_dialog(ESD_TYPE_WARN, NULL, + file_write_error_message(errno), + prefs.pr_file); + break; + } + return; + } + + filename = (char*) gtk_object_get_data(GTK_OBJECT(parent_w), + E_FOLLOW_FILENAME_KEY); + + if (filename != NULL) { + print_preamble(fh); + print_file(fh, filename); + print_finale(fh); + close_print_dest(to_file, fh); + } + else { + simple_dialog(ESD_TYPE_WARN, NULL, "Could not find data to print."); + } +} + static void follow_load_text(GtkWidget *text, char *filename, gboolean show_ascii) { diff --git a/print.c b/print.c index fd89b2c267..8d6c40ac87 100644 --- a/print.c +++ b/print.c @@ -1,7 +1,7 @@ /* print.c * Routines for printing packet analysis trees. * - * $Id: print.c,v 1.21 1999/09/29 22:19:13 guy Exp $ + * $Id: print.c,v 1.22 1999/10/30 06:41:36 guy Exp $ * * Gilbert Ramirez * @@ -47,6 +47,8 @@ static void proto_tree_print_node_ps(GNode *node, gpointer data); static void ps_clean_string(unsigned char *out, const unsigned char *in, int outbuf_size); static void print_hex_data_ps(FILE *fh, register const u_char *cp, register u_int length); +static void print_ps_file(FILE* target_fh, FILE* source_fh); +static void print_text_file(FILE* target_fh, FILE* source_fh); extern int proto_data; /* in packet-data.c */ @@ -93,6 +95,20 @@ void print_finale(FILE *fh) print_ps_finale(fh); } +void print_file(FILE* fh, const char* filename) +{ + FILE* fh2 = fopen(filename, "r"); + if (fh2 == NULL) { + fprintf(stderr, "Could not open file %s for reading.\n", filename); + return; + } + + if (prefs.pr_format == PR_FMT_PS) + print_ps_file(fh, fh2); + else + print_text_file(fh, fh2); +} + void proto_tree_print(gboolean print_one_packet, print_args_t *print_args, GNode *protocol_tree, const u_char *pd, frame_data *fd, FILE *fh) { @@ -317,3 +333,25 @@ void print_hex_data_ps(FILE *fh, register const u_char *cp, register u_int lengt return; } + +static +void print_text_file(FILE* target_fh, FILE* source_fh) +{ + gchar buffer[MAX_LINE_LENGTH]; + while (fgets(buffer, sizeof(buffer), source_fh) != NULL) { + fputs(buffer, target_fh); + } +} + +static +void print_ps_file(FILE* target_fh, FILE* source_fh) +{ + gchar buffer[MAX_LINE_LENGTH]; + gchar ps_buffer[MAX_LINE_LENGTH]; + + while (fgets(buffer, sizeof(buffer), source_fh) != NULL) { + ps_clean_string(ps_buffer, buffer, MAX_LINE_LENGTH); + fputs(ps_buffer, target_fh); + } +} + diff --git a/print.h b/print.h index 3be9128641..8e87820ea1 100644 --- a/print.h +++ b/print.h @@ -1,7 +1,7 @@ /* print.h * Definitions for printing packet analysis trees. * - * $Id: print.h,v 1.13 1999/09/29 22:19:13 guy Exp $ + * $Id: print.h,v 1.14 1999/10/30 06:41:36 guy Exp $ * * Gilbert Ramirez * @@ -46,6 +46,7 @@ FILE *open_print_dest(int to_file, const char *dest); void close_print_dest(int to_file, FILE *fh); void print_preamble(FILE *fh); void print_finale(FILE *fh); +void print_file(FILE* fh, const char* filename); void proto_tree_print(gboolean print_one_packet, print_args_t *print_args, GNode *protocol_tree, const u_char *pd, frame_data *fd, FILE *fh); void print_hex_data(FILE *fh, register const u_char *cp,