2
* packETH - ethernet packet generator
3
* By Miha Jemec <jemcek@gmail.com>
4
* Copyright 2003 Miha Jemec, Iskratel
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
* callback.c - all callback routines
25
#define MAXNUMLOADPACKETS 1000
33
#include "callbacks.h"
34
#include "interface.h"
36
#include "loadpacket.h"
37
#include "savepacket.h"
40
#include <sys/ioctl.h>
41
#include <sys/socket.h>
46
static GtkWidget *file_menu = NULL;
47
static GtkWidget *save_file_menu = NULL;
48
static GtkWidget *database_file_menu = NULL;
49
static GtkWidget *interface_dialog_menu = NULL;
50
static GtkWidget *error_dialog_menu = NULL;
51
static GtkWidget *about_dialog_menu = NULL;
52
static GtkWidget *tos_dialog_menu = NULL;
53
static GtkWidget *fragment_dialog_menu = NULL;
54
static GtkWidget *selection1_dialog = NULL;
55
static GtkWidget *udp_payload_dialog = NULL;
56
extern unsigned char packet[1522];
59
gint row_number;/* this is because i cant get the selected row number*/
61
gchar address_filename[100] = "addresslist";
62
static GtkWidget *entry_field;
63
static GtkWidget *entry_field_ip;
64
static GtkWidget *entry_field_udp;
65
static GtkWidget *entry_field_tos;
66
static GtkWidget *entry_field_fragment;
67
static GtkButton *btx;
68
static gboolean IP_yes = FALSE;
69
static gboolean MAC_yes = FALSE;
70
static int load_select_nr = 0;
71
int show_error_dialog = 1;
75
IP_packet_toggled (GtkToggleButton *togglebutton,
80
GtkWidget *rb1, *rb2, *rb3, *rb4, *rb5;
81
GtkWidget *option_menu, *opt_value;
82
GtkWidget *option_menu2, *opt_value2;
85
cbt = lookup_widget(GTK_WIDGET(togglebutton), "auto_get_mac_cbt");
86
gtk_widget_set_sensitive (cbt, TRUE);
89
option_menu = lookup_widget(GTK_WIDGET(togglebutton), "L_optmenu1_bt");
90
opt_value = lookup_widget(GTK_WIDGET(togglebutton), "L_ethtype");
91
gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), 0);
92
gtk_entry_set_text(GTK_ENTRY(opt_value), "0800");
95
option_menu2 = lookup_widget(GTK_WIDGET(togglebutton), "optionmenu6");
96
opt_value2 = lookup_widget(GTK_WIDGET(togglebutton), "L_pid");
97
gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu2), 0);
98
gtk_entry_set_text(GTK_ENTRY(opt_value2), "0800");
101
nt2 = lookup_widget(GTK_WIDGET(togglebutton), "notebook2");
102
gtk_notebook_set_page(GTK_NOTEBOOK(nt2), 0);
104
/* what is next page */
105
rb1 = lookup_widget(GTK_WIDGET(togglebutton), "tcp_bt");
106
rb2 = lookup_widget(GTK_WIDGET(togglebutton), "udp_bt");
107
rb3 = lookup_widget(GTK_WIDGET(togglebutton), "icmp_bt");
108
rb4 = lookup_widget(GTK_WIDGET(togglebutton), "ip_user_data_bt");
109
rb5 = lookup_widget(GTK_WIDGET(togglebutton), "igmp_bt");
110
nt4 = lookup_widget(GTK_WIDGET(togglebutton), "notebook4");
112
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
113
gtk_editable_set_editable(GTK_EDITABLE(opt_value2), FALSE);
115
if (GTK_TOGGLE_BUTTON(rb1)->active)
116
gtk_notebook_set_page(GTK_NOTEBOOK(nt4), 1);
117
else if (GTK_TOGGLE_BUTTON(rb2)->active)
118
gtk_notebook_set_page(GTK_NOTEBOOK(nt4), 0);
119
else if (GTK_TOGGLE_BUTTON(rb3)->active)
120
gtk_notebook_set_page(GTK_NOTEBOOK(nt4), 2);
121
else if (GTK_TOGGLE_BUTTON(rb5)->active)
122
gtk_notebook_set_page(GTK_NOTEBOOK(nt4), 4);
124
gtk_notebook_set_page(GTK_NOTEBOOK(nt4), 3);
130
on_arppkt_radiobt_toggled (GtkToggleButton *togglebutton,
133
GtkWidget *nt2, *nt4;
134
GtkWidget *option_menu, *opt_value;
135
GtkWidget *option_menu2, *opt_value2;
138
cbt = lookup_widget(GTK_WIDGET(togglebutton), "auto_get_mac_cbt");
139
gtk_widget_set_sensitive (cbt, TRUE);
142
option_menu = lookup_widget(GTK_WIDGET(togglebutton), "L_optmenu1_bt");
143
opt_value = lookup_widget(GTK_WIDGET(togglebutton), "L_ethtype");
144
gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), 2);
145
gtk_entry_set_text(GTK_ENTRY(opt_value), "0806");
148
option_menu2 = lookup_widget(GTK_WIDGET(togglebutton), "optionmenu6");
149
opt_value2 = lookup_widget(GTK_WIDGET(togglebutton), "L_pid");
150
gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu2), 2);
151
gtk_entry_set_text(GTK_ENTRY(opt_value2), "0806");
153
/* open arp notebook page and empty notebook page for 4 layer */
154
nt2 = lookup_widget(GTK_WIDGET(togglebutton), "notebook2");
155
gtk_notebook_set_page(GTK_NOTEBOOK(nt2), 2);
156
nt4 = lookup_widget(GTK_WIDGET(togglebutton), "notebook4");
157
gtk_notebook_set_page(GTK_NOTEBOOK(nt4), 5);
159
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
160
gtk_editable_set_editable(GTK_EDITABLE(opt_value2), FALSE);
165
on_usedef2_radibt_toggled (GtkToggleButton *togglebutton,
168
GtkWidget *nt2, *nt4;
169
GtkWidget *option_menu, *opt_value;
172
//cbt = lookup_widget(GTK_WIDGET(togglebutton), "auto_get_mac_cbt");
173
//if (GTK_TOGGLE_BUTTON(cbt)->active) {
174
// on_auto_get_mac_cbt_toggled(togglebutton, user_data);
175
// gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbt), FALSE);
176
// gtk_widget_set_sensitive (cbt, FALSE);
179
// gtk_widget_set_sensitive (cbt, FALSE);
182
option_menu = lookup_widget(GTK_WIDGET(togglebutton), "L_optmenu1_bt");
183
gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), 3);
184
opt_value = lookup_widget(GTK_WIDGET(togglebutton), "L_ethtype");
185
gtk_editable_set_editable(GTK_EDITABLE(opt_value), TRUE);
186
gtk_entry_set_text(GTK_ENTRY(opt_value), "");
189
option_menu = lookup_widget(GTK_WIDGET(togglebutton), "optionmenu6");
190
gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), 3);
191
opt_value = lookup_widget(GTK_WIDGET(togglebutton), "L_pid");
192
gtk_editable_set_editable(GTK_EDITABLE(opt_value), TRUE);
193
gtk_entry_set_text(GTK_ENTRY(opt_value), "");
195
/* set the correct notebooks */
196
nt2 = lookup_widget(GTK_WIDGET(togglebutton), "notebook2");
197
gtk_notebook_set_page(GTK_NOTEBOOK(nt2), 3);
198
nt4 = lookup_widget(GTK_WIDGET(togglebutton), "notebook4");
199
gtk_notebook_set_page(GTK_NOTEBOOK(nt4), 5);
205
on_ver_II_bt_toggled (GtkToggleButton *togglebutton,
210
nt1 = lookup_widget(GTK_WIDGET(togglebutton), "notebook_ethtype");
211
gtk_notebook_set_page(GTK_NOTEBOOK(nt1), 0);
212
fr7 = lookup_widget(GTK_WIDGET(togglebutton), "frame7");
213
gtk_widget_set_sensitive(fr7, FALSE);
219
on_802_3_bt_toggled (GtkToggleButton *togglebutton,
224
nt1 = lookup_widget(GTK_WIDGET(togglebutton), "notebook_ethtype");
225
gtk_notebook_set_page(GTK_NOTEBOOK(nt1), 1);
226
fr7 = lookup_widget(GTK_WIDGET(togglebutton), "frame7");
227
gtk_widget_set_sensitive(fr7, TRUE);
233
on_802_1q_bt_clicked (GtkButton *button,
237
fr6 = lookup_widget(GTK_WIDGET(button), "frame6");
238
if (GTK_TOGGLE_BUTTON(button)->active)
239
gtk_widget_set_sensitive(fr6, TRUE);
241
gtk_widget_set_sensitive(fr6, FALSE);
246
on_L_8023_llc_tbt_toggled (GtkToggleButton *togglebutton,
249
GtkWidget *l_oui, *l_pid, *lbl_oui, *lbl_pid, *opt;
250
l_oui = lookup_widget(GTK_WIDGET(togglebutton), "L_oui");
251
l_pid = lookup_widget(GTK_WIDGET(togglebutton), "L_pid");
252
lbl_oui = lookup_widget(GTK_WIDGET(togglebutton), "label_oui");
253
lbl_pid = lookup_widget(GTK_WIDGET(togglebutton), "label_pid");
254
lbl_pid = lookup_widget(GTK_WIDGET(togglebutton), "label_pid");
255
opt = lookup_widget(GTK_WIDGET(togglebutton), "optionmenu6");
256
gtk_entry_set_text(GTK_ENTRY(l_oui), "");
257
gtk_entry_set_text(GTK_ENTRY(l_pid), "");
258
gtk_widget_set_sensitive(l_oui, FALSE);
259
gtk_widget_set_sensitive(l_pid, FALSE);
260
gtk_widget_set_sensitive(lbl_oui, FALSE);
261
gtk_widget_set_sensitive(lbl_pid, FALSE);
262
gtk_widget_set_sensitive(opt, FALSE);
268
on_L_8023_llcsnap_tbt_toggled (GtkToggleButton *togglebutton,
271
GtkWidget *l_oui, *l_pid, *lbl_oui, *lbl_pid, *opt, *menu, *menu_item;
274
l_oui = lookup_widget(GTK_WIDGET(togglebutton), "L_oui");
275
l_pid = lookup_widget(GTK_WIDGET(togglebutton), "L_pid");
276
lbl_oui = lookup_widget(GTK_WIDGET(togglebutton), "label_oui");
277
lbl_pid = lookup_widget(GTK_WIDGET(togglebutton), "label_pid");
278
opt = lookup_widget(GTK_WIDGET(togglebutton), "optionmenu6");
280
gtk_widget_set_sensitive(l_oui, TRUE);
281
gtk_widget_set_sensitive(l_pid, TRUE);
282
gtk_widget_set_sensitive(lbl_oui, TRUE);
283
gtk_widget_set_sensitive(lbl_pid, TRUE);
284
gtk_entry_set_text(GTK_ENTRY(l_oui), "000000");
285
menu = GTK_OPTION_MENU(opt)->menu;
286
menu_item = gtk_menu_get_active (GTK_MENU (menu));
287
index = g_list_index (GTK_MENU_SHELL (menu)->children, menu_item);
290
gtk_entry_set_text(GTK_ENTRY(l_pid), "86DD");
294
gtk_entry_set_text(GTK_ENTRY(l_pid), "0806");
298
gtk_entry_set_text(GTK_ENTRY(l_pid), "");
302
gtk_entry_set_text(GTK_ENTRY(l_pid), "0800");
305
gtk_widget_set_sensitive(opt, TRUE);
311
on_exit1_activate (GtkMenuItem *menuitem,
320
on_about1_activate (GtkMenuItem *menuitem,
323
if (about_dialog_menu != NULL) {
324
gdk_window_show(about_dialog_menu->window);
325
gdk_window_raise(about_dialog_menu->window);
329
about_dialog_menu = create_about_dialog();
330
gtk_widget_show(about_dialog_menu);
335
on_window1_destroy (GtkObject *object,
343
on_fileselection1_destroy (GtkObject *object,
350
/* button1 is the load button, so what this function will do depends on who called it:
351
it can be one of the 4 basic windows: builder, gen-b, gen-s or gen-k.
352
And there can be a call for this window from each of these windows too.
355
on_ok_button1_clicked (GtkButton *button,
361
gchar *fname /* , *fname2 */;
364
fname = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(lookup_widget(gtk_widget_get_toplevel(GTK_WIDGET(button)),"fileselection1"))));
365
//fname2 = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_FILE_SELECTION (user_data)->selection_entry)));
367
if((file_p = fopen(fname, "r")) == NULL) {
368
//printf("can not open file for reading\n");
369
error("Error: can't open file for reading!");
373
/* now who called this function */
374
switch (load_select_nr) {
375
case 1: { /* this is the toolbar load button, we need to know which notebook is open */
376
notbk = lookup_widget(GTK_WIDGET(btx), "notebook1");
377
page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notbk));
379
if (page == 0) { /* so we have the build notebook open */
381
if (load_data(btx, file_p, 1, 1) == -1) {
382
/* calling previous function with last argument =1 means loading for builder */
388
else if (page == 1) { /* it is the send build generator */
390
if (load_gen_b_data(btx, file_p) == -1) {
391
error("Error: wrong file format!");
398
/* page with sequence generator is open */
399
else if (page == 2) { /* it is the send build generator */
401
if (load_gen_s_data(btx, file_p) == -1) {
402
error("Error: wrong file format!");
408
else if (page == 3) { /* it is the send pcap file generator */
410
if (load_data(btx, file_p, 2, MAXNUMLOADPACKETS) == -1) {
411
error("Error: wrong file format!");
418
/* next are the select buttons on the gen-s window */
428
//if (check_if_file_is_packet(file_p) == -1) {
429
if (load_data(btx, file_p, 1, 1) == -1) {
430
error("Error: wrong file format!");
434
gtk_entry_set_text(GTK_ENTRY(entry_field), fname);
442
snprintf(buff, 100, " Parameters loaded from file %s", fname);
443
statusbar_text(btx, buff);
445
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
446
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
452
on_cancel_button1_clicked (GtkButton *button,
455
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
456
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
461
on_Load_button_clicked (GtkButton *button,
464
statusbar_text(button, "");
466
if (file_menu != NULL) {
467
gdk_window_show(file_menu->window);
468
gdk_window_raise(file_menu->window);
472
file_menu = create_fileselection1();
473
gtk_widget_show(file_menu);
481
on_Save_button_clicked (GtkButton *button,
484
statusbar_text(button, "");
486
if (save_file_menu != NULL) {
487
gdk_window_show(save_file_menu->window);
488
gdk_window_raise(save_file_menu->window);
492
save_file_menu = create_fileselection2();
493
gtk_widget_show(save_file_menu);
500
/* pressing the ok button in the save dialog causes us to be here */
502
on_ok_button2_clicked (GtkButton *button,
511
/* hm, first we should decide, what are we going to save: a packet, send_built parameters,
512
* send_sequence parameters or send kernel parameters. I last three cases we only save
513
* the values and not also the packets themself (only the names of the packet)
514
* so let's check which notebook is open */
516
notbk = lookup_widget(GTK_WIDGET(btx), "notebook1");
517
page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notbk));
519
fname = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(lookup_widget(gtk_widget_get_toplevel(GTK_WIDGET(button)),"fileselection2"))));
521
/* lets check if the file exists and we don't allow to overwrite it
522
* is there any way to do this in a more elegant manner? */
523
//if((file_p = fopen(fname, "r")) != NULL) { /* could be also some other failure??? */
524
// error("Error: wrong file name, file already exists!");
528
if((file_p = fopen(fname, "w")) == NULL) {
529
error("Error: can not open file for saving");
534
if (page == 0) { /* so we have the build notebook open, it means we save the packet */
535
/* YYY ok, this is not yet implemented */
536
/* you could also add possibility to save even with this button on??? */
537
//bt1 = lookup_widget(GTK_WIDGET(btx), "auto_get_mac_cbt");
538
//if (GTK_TOGGLE_BUTTON(bt1)->active) {
539
//printf("Error: you can't save in a packet if auto get link layer is on!\n");
540
// error("Error: you can't save in a packet if auto get link layer is on!");
544
if (save_packet(btx, user_data, file_p) == -1) {
550
else if (page == 1) { /* it is the send_built page */
552
if (save_gen_b(btx, file_p) == -1) {
558
else if (page == 2) {
560
if (save_gen_s(btx, file_p) == -1) {
566
else if (page == 3) {
568
if (save_gen_pcap(btx, file_p) == -1) {
579
snprintf(buff4, 100, " Parameters saved in file %s", fname);
580
statusbar_text(btx, buff4);
582
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
583
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
589
on_cancel_button2_clicked (GtkButton *button,
592
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
593
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
599
on_fileselection2_destroy (GtkObject *object,
602
save_file_menu = NULL;
608
on_clist1_select_row ( GtkWidget *clist, gint row, gint column, GdkEventButton *event, gpointer data)
610
GtkWidget *en_ip, *en_mac, *en_name;
611
gchar *text_ip, *text_mac, *text_name;
612
//gchar *textip, *textmac;
614
//textip = (gchar *)malloc(16*sizeof(gchar));
615
//textmac = (gchar *)malloc(18*sizeof(gchar));
618
en_ip = lookup_widget(GTK_WIDGET(clist), "sel1_IP_entry");
619
en_mac = lookup_widget(GTK_WIDGET(clist), "sel1_mac_entry");
620
en_name = lookup_widget(GTK_WIDGET(clist), "entry153");
621
gtk_clist_get_text(GTK_CLIST(clist), row, 0, &text_ip);
622
gtk_clist_get_text(GTK_CLIST(clist), row, 1, &text_mac);
623
gtk_clist_get_text(GTK_CLIST(clist), row, 2, &text_name);
625
//strncpy(textip, text_ip, strlen(text_ip+1));
626
//strncpy(textmac, text_mac, strlen(text_mac+1));
628
gtk_entry_set_text(GTK_ENTRY(en_ip), text_ip);
629
gtk_entry_set_text(GTK_ENTRY(en_mac), text_mac);
630
gtk_entry_set_text(GTK_ENTRY(en_name), text_name);
640
on_sel1_add_bt_clicked (GtkButton *button,
643
GtkWidget *clist, *en_ip, *en_mac, *en_name;
644
gchar *en_ip_t, *en_mac_t, *en_name_t;
645
gchar *text_ip, *text_mac, *text_name;
648
GtkTreeModel *treestore;
649
GtkTreeIter toplevel;
651
clist = lookup_widget(GTK_WIDGET (selection1_dialog), "clist1");
652
treestore = gtk_tree_view_get_model(GTK_TREE_VIEW(clist));
653
en_ip = lookup_widget(GTK_WIDGET(clist), "sel1_IP_entry");
654
en_mac = lookup_widget(GTK_WIDGET(clist), "sel1_mac_entry");
656
en_ip = lookup_widget(GTK_WIDGET(clist), "sel1_IP_entry");
657
en_mac = lookup_widget(GTK_WIDGET(clist), "sel1_mac_entry");
658
en_name = lookup_widget(GTK_WIDGET(clist), "entry153");
660
/* is there any other elegant way to get the row number but with global variable? */
661
en_ip_t = (char *)gtk_entry_get_text(GTK_ENTRY(en_ip));
662
en_mac_t = (char *)gtk_entry_get_text(GTK_ENTRY(en_mac));
663
en_name_t = (char *)gtk_entry_get_text(GTK_ENTRY(en_name));
665
/* we still have the value of the row number, so we can check wheather this is
666
* the same as in the entry fields. so in case the user selects an entry and then
667
* presses add button we won't get duplicated entries */
668
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(clist));
670
gtk_tree_selection_get_selected(selection,&treestore,&iter);
671
gtk_tree_model_get(treestore,&iter,0,&text_ip,1,&text_mac,2,&text_name,-1);
673
if ( (strlen(en_ip_t) == 0) && (strlen(en_mac_t) == 0) )
676
if ( (strcmp(en_ip_t, text_ip) == 0) && (strcmp(en_mac_t, text_mac) == 0) &&
677
(strcmp(en_name_t, text_name) == 0)) {
678
//printf("values are the same, we don't insert them!\n");
679
error("Error: values are the same, we don't insert them!");
682
/* now we have to check if the values are ok */
684
if ( (strlen(en_ip_t) != 0) && (check_ip_address(en_ip_t) == -1) ) {
685
//printf("wrong ip entry in address list\n");
686
error("Error: wrong ip entry in address list");
690
if ( (strlen(en_mac_t) != 0) && (check_mac_address(en_mac_t) == -1) ) {
691
//printf("wrong mac entry in address list\n");
692
error("Error: wrong mac entry in address list");
696
tmp[0]= (gchar *)malloc(16*sizeof(gchar));
697
tmp[1]= (gchar *)malloc(18*sizeof(gchar));
698
tmp[2]= (gchar *)malloc(50*sizeof(gchar));
700
strcpy(tmp[0], en_ip_t);
701
strcpy(tmp[1], en_mac_t);
702
strcpy(tmp[2], en_name_t);
704
gtk_tree_store_append(GTK_TREE_STORE(treestore),&toplevel,NULL);
705
gtk_tree_store_set(GTK_TREE_STORE(treestore),&toplevel,0,tmp[0],1,tmp[1],2,tmp[2],-1);
714
on_sel1_delete_bt_clicked (GtkButton *button,
719
GtkTreeModel *treestore;
720
//GtkTreeIter toplevel;
722
clist = lookup_widget(GTK_WIDGET (selection1_dialog), "clist1");
723
treestore = gtk_tree_view_get_model(GTK_TREE_VIEW(clist));
725
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(clist));
727
gtk_tree_selection_get_selected(selection,&treestore,&iter);
728
gtk_tree_store_remove(GTK_TREE_STORE(treestore),&iter);
730
gtk_tree_model_get_iter_first(treestore,&iter);
732
gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(lookup_widget(GTK_WIDGET (selection1_dialog), "clist1"))),&iter);
739
on_sel1_ok_bt_clicked (GtkButton *button,
742
GtkWidget *clist; // *en_ip, *en_mac;
743
gchar *en_ip_t, *en_mac_t;
744
gchar *text_ip, *text_mac, *text_name;
749
/* so we want to insert the choosen values into the entry mac field.
750
* we have to check again, that the values are correct
751
* if they are not a warning should pop up and the window should stay open
752
* if they are ok, then the value is inserted and we try to write in the file */
753
GtkTreeModel *treestore;
754
//GtkTreeIter toplevel;
756
clist = lookup_widget(GTK_WIDGET (selection1_dialog), "clist1");
757
treestore = gtk_tree_view_get_model(GTK_TREE_VIEW(clist));
759
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(clist));
761
gtk_tree_selection_get_selected(selection,&treestore,&iter);
762
gtk_tree_model_get(treestore,&iter,0,&en_ip_t,1,&en_mac_t,-1);
764
/* we need to access the L_dst_mac or L_src_mac entry in the main window!
765
* that is why we putted it static global before */
766
if (MAC_yes == TRUE) {
767
if (check_mac_address(en_mac_t) == -1) {
768
//printf("wrong mac entry in address list\n");
769
error("Error: wrong mac entry in address list");
773
gtk_entry_set_text(GTK_ENTRY(entry_field), en_mac_t);
776
/* in case we need to insert the IP value as well
777
* this is in case of an arp packet or ip packet, so we check the IP_yes value */
778
if (IP_yes == TRUE) {
779
if (check_ip_address(en_ip_t) == -1) { // ---
780
//printf("wrong ip entry in address list\n");
781
error("Error: wrong ip entry in address list");
785
gtk_entry_set_text(GTK_ENTRY(entry_field_ip), en_ip_t);
788
/* we need to reopen the file with datebase and overwrite it with
789
* the values in the clist field */
790
if((fp = fopen(address_filename, "w")) == NULL) { /* could be also some other failure??? */
791
//printf("file %s with database can't be opened!\n", address_filename);
792
snprintf(temp, 100, "file %s with database can't be opened", address_filename);
794
/* YYY we could call a function where we could select the database file */
798
gtk_tree_model_get_iter_first(treestore,&iter);
800
gtk_tree_model_get(treestore,&iter,0,&text_ip,1,&text_mac,2,&text_name,-1);
805
fputs(text_name, fp);
807
if (gtk_tree_model_iter_next(treestore,&iter) == FALSE)
813
gtk_grab_remove(GTK_WIDGET(selection1_dialog));
814
gtk_widget_destroy(GTK_WIDGET(selection1_dialog));
820
on_sel1_cancel_bt_clicked (GtkButton *button,
823
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
824
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
830
on_sel1_dialog_destroy (GtkObject *object,
833
selection1_dialog = NULL;
838
on_L_dst_select_bt_clicked (GtkButton *button,
841
entry_field = lookup_widget(GTK_WIDGET(button), "L_dst_mac");
844
selection_dialog_show(button, user_data);
849
on_L_src_select_bt_clicked (GtkButton *button,
852
entry_field = lookup_widget(GTK_WIDGET(button), "L_src_mac");
855
selection_dialog_show(button, user_data);
860
/* this one shows the addresslist dialog. it tries to open a file with addresses. It should return an error in case of file error or if the contents of the file does not hold the specified structure */
862
selection_dialog_show (GtkButton *button,
867
gchar *row[3], tmp[84] /*, temp[100]*/;
868
int i=0, ch, first = 0, second = 0;
869
GtkTreeStore *treestore;
870
GtkTreeIter toplevel;
872
treestore = gtk_tree_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);
874
/* if there is a dialog already open, reopen it */
875
if (selection1_dialog != NULL){
876
gdk_window_show(selection1_dialog->window);
877
gdk_window_raise(selection1_dialog->window);
880
/* if we can't open file then we raise an error dialog. user has to change the
881
* address_filename variable using the File-> Select database option */
882
if((fp = fopen(address_filename, "r")) == NULL) {
883
//printf("file %s with database can't be opened!\n", address_filename);
884
//snprintf(temp,100,"File %s with database can't be opened!\nClick on File->Select database",
885
// address_filename);
887
error("Error: Can't open selected address database!\n\n"
888
"Click on File -> Select database\n"
889
"to choose another one or create a new one\n\n"
890
"File format: <IP address>,<MAC address>,<Name>");
894
/* create this dialog */
895
selection1_dialog = create_sel1_dialog();
897
/* resrve place for ip address, mac address and name */
898
row[0]= (gchar *)malloc(16*sizeof(gchar));
899
row[1]= (gchar *)malloc(18*sizeof(gchar));
900
row[2]= (gchar *)malloc(50*sizeof(gchar));
902
/* now we have to append the saved values: */
903
/* we make following presumption: all entries must be in following format:
904
* xxx.xxx.xxx.xxx,xx:xx:xx:xx:xx:xx,name
905
* that means first there is IP in dot format and then mac address with : and name in the end
906
* there can be an entry only with either ip or mac address and without name.
907
* new lines and comments starting with # are allowed */
910
/* we read the whole line and remember where the comma is
911
* first is the place of the comma between ip and mac address
912
* second is the variable holding the position between mac address and name
913
* the line can have max 83 characters: 15 for ip , 18 for mac and 50 for name
914
* commas are obligatoty */
915
for (i=1, first = 0, second = 0; (ch=getc(fp)) != '\n' && i<84 && ch != EOF ;i++ ) {
919
else if (second == 0)
926
/* if first and second are == 0 and ch== '\n' - new line, ok, skip this */
927
if ( (first==0) && (second==0) && (ch == '\n') && (i==1) )
930
/* we also allow comments lines starting with # */
931
if ( (i>1) && (tmp[0] == '#') )
934
/* first > 16 - ip address can not be longer then 15 char including points
935
* second - first (mac address) exactly 18 char including : or 1 if without it
936
* second - i > 50 - name can only have max 50 chars
937
* if first and second are == 0 and i>0 there was no commas -> error
938
* if first is 1 and seconf is 2, then there were no ip nor mac address -> error */
939
if ( (first>16) || (((second-first) > 18) && ((second-first) != 1)) || ((i-second) > 50) ||
940
((first==0) && (second==0) && (i>1)) || ((first==1) && (second==2) && (i>1)) ) {
941
error("Error: Selected address database has wrong format!\n\n"
942
"Click on File -> Select database\n"
943
"to choose another one or create a new one\n\n"
944
"File format: <IP address>,<MAC address>,<Name>");
949
selection1_dialog = NULL;
957
tmp[second-1] = '\0';
959
strncpy(row[0], tmp, first );
960
strncpy(row[1], &tmp[first], (second-first));
961
strncpy(row[2], &tmp[second], (i-second));
963
if ( (check_ip_address(row[0]) == -1) && (strlen(row[0]) !=0) ) {
964
//printf("wrong ip entry in address list\n");
965
error("Error: Wrong IP entry in address list!\n\n"
966
"Click on File -> Select database\n"
967
"to choose another one or create a new one\n\n"
968
"File format: <IP address>,<MAC address>,<Name>");
973
selection1_dialog = NULL;
977
if ( (check_mac_address(row[1]) == -1) && (strlen(row[1]) !=0) ) {
978
//printf("wrong mac entry in address list\n");
979
error("Error: Wrong MAC entry in address list\n\n"
980
"Click on File -> Select database\n"
981
"to choose another one or create a new one\n\n"
982
"File format: <IP address>,<MAC address>,<Name>");
987
selection1_dialog = NULL;
990
gtk_tree_store_append(treestore,&toplevel,NULL);
991
gtk_tree_store_set(treestore,&toplevel,0,row[0],1,row[1],2,row[2],-1);
999
gtk_widget_show(selection1_dialog);
1003
GtkTreeViewColumn *stolpec;
1004
GtkCellRenderer *renderer;
1006
stolpec = gtk_tree_view_column_new();
1007
gtk_tree_view_column_set_title(stolpec,"IP address");
1008
gtk_tree_view_append_column(GTK_TREE_VIEW(lookup_widget(GTK_WIDGET (selection1_dialog), "clist1")),stolpec);
1009
renderer = gtk_cell_renderer_text_new();
1010
gtk_tree_view_column_pack_start(stolpec,renderer,TRUE);
1011
gtk_tree_view_column_add_attribute(stolpec,renderer,"text",0);
1013
stolpec = gtk_tree_view_column_new();
1014
gtk_tree_view_column_set_title(stolpec,"MAC value");
1015
gtk_tree_view_append_column(GTK_TREE_VIEW(lookup_widget(GTK_WIDGET (selection1_dialog), "clist1")),stolpec);
1016
renderer = gtk_cell_renderer_text_new();
1017
gtk_tree_view_column_pack_start(stolpec,renderer,TRUE);
1018
gtk_tree_view_column_add_attribute(stolpec,renderer,"text",1);
1020
stolpec = gtk_tree_view_column_new();
1021
gtk_tree_view_column_set_title(stolpec,"Name");
1022
gtk_tree_view_append_column(GTK_TREE_VIEW(lookup_widget(GTK_WIDGET (selection1_dialog), "clist1")),stolpec);
1023
renderer = gtk_cell_renderer_text_new();
1024
gtk_tree_view_column_pack_start(stolpec,renderer,TRUE);
1025
gtk_tree_view_column_add_attribute(stolpec,renderer,"text",2);
1027
GtkTreeModel *model = GTK_TREE_MODEL(treestore);
1028
gtk_tree_view_set_model(GTK_TREE_VIEW(lookup_widget(GTK_WIDGET (selection1_dialog), "clist1")),model);
1030
gtk_tree_model_get_iter_first(model,&iter);
1031
g_object_unref(model);
1032
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(lookup_widget(GTK_WIDGET (selection1_dialog), "clist1"))),GTK_SELECTION_SINGLE);
1033
gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(lookup_widget(GTK_WIDGET (selection1_dialog), "clist1"))),&iter);
1042
on_auto_get_mac_cbt_toggled (GtkToggleButton *togglebutton,
1045
GtkWidget *hb5, *option_menu, *opt_value, *menu, *active_item;
1048
hb5 = lookup_widget(GTK_WIDGET(togglebutton), "hbox4");
1049
option_menu = lookup_widget(GTK_WIDGET(togglebutton), "L_optmenu1_bt");
1050
opt_value = lookup_widget(GTK_WIDGET(togglebutton), "L_ethtype");
1051
if (GTK_TOGGLE_BUTTON(togglebutton)->active) {
1052
gtk_widget_set_sensitive(hb5, FALSE);
1055
gtk_widget_set_sensitive(hb5, TRUE);
1056
menu = GTK_OPTION_MENU (option_menu)->menu;
1057
active_item = gtk_menu_get_active (GTK_MENU (menu));
1058
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
1059
if (active_index == 0) {
1060
gtk_entry_set_text(GTK_ENTRY(opt_value), "0800");
1061
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1063
else if (active_index == 1) {
1064
gtk_entry_set_text(GTK_ENTRY(opt_value), "86DD");
1065
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1067
else if (active_index == 2) {
1068
gtk_entry_set_text(GTK_ENTRY(opt_value), "0806");
1069
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1071
else if (active_index == 3) {
1072
gtk_entry_set_text(GTK_ENTRY(opt_value), "");
1073
gtk_editable_set_editable(GTK_EDITABLE(opt_value), TRUE);
1080
on_tcp_bt_toggled (GtkToggleButton *togglebutton,
1083
GtkWidget *nt4, *en1, *opt1;
1085
nt4 = lookup_widget(GTK_WIDGET(togglebutton), "notebook4");
1086
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry34");
1087
opt1 = lookup_widget(GTK_WIDGET(togglebutton), "optionmenu3");
1089
gtk_option_menu_set_history (GTK_OPTION_MENU (opt1), 3);
1090
gtk_notebook_set_page(GTK_NOTEBOOK(nt4), 1);
1091
gtk_entry_set_text(GTK_ENTRY(en1), "6");
1092
gtk_editable_set_editable(GTK_EDITABLE(en1), FALSE);
1098
on_udp_bt_toggled (GtkToggleButton *togglebutton,
1101
GtkWidget *nt4, *en1, *opt1;
1102
nt4 = lookup_widget(GTK_WIDGET(togglebutton), "notebook4");
1103
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry34");
1104
opt1 = lookup_widget(GTK_WIDGET(togglebutton), "optionmenu3");
1106
gtk_notebook_set_page(GTK_NOTEBOOK(nt4), 0);
1107
gtk_option_menu_set_history (GTK_OPTION_MENU (opt1), 4);
1108
gtk_entry_set_text(GTK_ENTRY(en1), "17");
1109
gtk_editable_set_editable(GTK_EDITABLE(en1), FALSE);
1115
on_icmp_bt_toggled (GtkToggleButton *togglebutton,
1118
GtkWidget *nt4, *en1, *opt1;
1120
nt4 = lookup_widget(GTK_WIDGET(togglebutton), "notebook4");
1121
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry34");
1122
opt1 = lookup_widget(GTK_WIDGET(togglebutton), "optionmenu3");
1124
gtk_option_menu_set_history (GTK_OPTION_MENU (opt1), 1);
1125
gtk_notebook_set_page(GTK_NOTEBOOK(nt4), 2);
1126
gtk_entry_set_text(GTK_ENTRY(en1), "1");
1127
gtk_editable_set_editable(GTK_EDITABLE(en1), FALSE);
1133
on_igmp_bt_toggled (GtkToggleButton *togglebutton,
1137
GtkWidget *nt4, *en1, *opt1;
1139
nt4 = lookup_widget(GTK_WIDGET(togglebutton), "notebook4");
1140
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry34");
1141
opt1 = lookup_widget(GTK_WIDGET(togglebutton), "optionmenu3");
1143
gtk_option_menu_set_history (GTK_OPTION_MENU (opt1), 2);
1144
gtk_notebook_set_page(GTK_NOTEBOOK(nt4), 4);
1145
gtk_entry_set_text(GTK_ENTRY(en1), "2");
1146
gtk_editable_set_editable(GTK_EDITABLE(en1), FALSE);
1151
on_ip_user_data_bt_toggled (GtkToggleButton *togglebutton,
1154
GtkWidget *nt4, *en1, *opt1;
1156
nt4 = lookup_widget(GTK_WIDGET(togglebutton), "notebook4");
1157
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry34");
1158
opt1 = lookup_widget(GTK_WIDGET(togglebutton), "optionmenu3");
1160
gtk_option_menu_set_history (GTK_OPTION_MENU (opt1), 5);
1161
gtk_notebook_set_page(GTK_NOTEBOOK(nt4), 3);
1162
gtk_entry_set_text(GTK_ENTRY(en1), "");
1163
gtk_editable_set_editable(GTK_EDITABLE(en1), TRUE);
1169
on_L_optmenu1_bt_clicked (GtkButton *button,
1172
GtkWidget *option_menu, *menu, *active_item, *opt_value;
1175
option_menu = lookup_widget (GTK_WIDGET (button), "L_optmenu1_bt");
1176
opt_value = lookup_widget (GTK_WIDGET (button), "L_ethtype");
1177
menu = GTK_OPTION_MENU (option_menu)->menu;
1178
active_item = gtk_menu_get_active (GTK_MENU (menu));
1179
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
1182
if (active_index == 0) {
1183
gtk_entry_set_text(GTK_ENTRY(opt_value), "0800");
1184
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1186
else if (active_index == 1) {
1187
gtk_entry_set_text(GTK_ENTRY(opt_value), "86DD");
1188
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1190
else if (active_index == 2) {
1191
gtk_entry_set_text(GTK_ENTRY(opt_value), "0806");
1192
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1194
else if (active_index == 3) {
1195
gtk_entry_set_text(GTK_ENTRY(opt_value), "");
1196
gtk_editable_set_editable(GTK_EDITABLE(opt_value), TRUE);
1202
on_optionmenu6_clicked (GtkButton *button,
1205
GtkWidget *option_menu, *menu, *active_item, *opt_value;
1208
option_menu = lookup_widget (GTK_WIDGET (button), "optionmenu6");
1209
opt_value = lookup_widget (GTK_WIDGET (button), "L_pid");
1210
menu = GTK_OPTION_MENU (option_menu)->menu;
1211
active_item = gtk_menu_get_active (GTK_MENU (menu));
1212
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
1215
if (active_index == 0) {
1216
gtk_entry_set_text(GTK_ENTRY(opt_value), "0800");
1217
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1219
else if (active_index == 1) {
1220
gtk_entry_set_text(GTK_ENTRY(opt_value), "86DD");
1221
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1223
else if (active_index == 2) {
1224
gtk_entry_set_text(GTK_ENTRY(opt_value), "0806");
1225
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1227
else if (active_index == 3) {
1228
gtk_entry_set_text(GTK_ENTRY(opt_value), "");
1229
gtk_editable_set_editable(GTK_EDITABLE(opt_value), TRUE);
1235
on_optionmenu7_clicked (GtkButton *button,
1238
GtkWidget *option_menu, *menu, *active_item, *opt_value;
1241
option_menu = lookup_widget (GTK_WIDGET (button), "optionmenu7");
1242
opt_value = lookup_widget (GTK_WIDGET (button), "entry102");
1243
menu = GTK_OPTION_MENU (option_menu)->menu;
1244
active_item = gtk_menu_get_active (GTK_MENU (menu));
1245
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
1248
if (active_index == 0) {
1249
gtk_entry_set_text(GTK_ENTRY(opt_value), "8");
1250
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1252
else if (active_index == 1) {
1253
gtk_entry_set_text(GTK_ENTRY(opt_value), "0");
1254
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1256
else if (active_index == 2) {
1257
gtk_entry_set_text(GTK_ENTRY(opt_value), "4");
1258
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1260
else if (active_index == 3) {
1261
gtk_entry_set_text(GTK_ENTRY(opt_value), "18");
1262
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1264
else if (active_index == 4) {
1265
gtk_entry_set_text(GTK_ENTRY(opt_value), "");
1266
gtk_editable_set_editable(GTK_EDITABLE(opt_value), TRUE);
1272
on_IPv6_rdbt_toggled (GtkToggleButton *togglebutton,
1277
GtkWidget *option_menu, *opt_value;
1280
cbt = lookup_widget(GTK_WIDGET(togglebutton), "auto_get_mac_cbt");
1281
gtk_widget_set_sensitive (cbt, TRUE);
1282
option_menu = lookup_widget(GTK_WIDGET(togglebutton), "L_optmenu1_bt");
1283
opt_value = lookup_widget(GTK_WIDGET(togglebutton), "L_ethtype");
1284
nt2 = lookup_widget(GTK_WIDGET(togglebutton), "notebook2");
1285
gtk_notebook_set_page(GTK_NOTEBOOK(nt2), 1);
1286
nt4 = lookup_widget(GTK_WIDGET(togglebutton), "notebook4");
1287
gtk_notebook_set_page(GTK_NOTEBOOK(nt4), 4);
1288
gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), 1);
1289
gtk_entry_set_text(GTK_ENTRY(opt_value), "86DD");
1290
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1297
on_Build_button_clicked (GtkButton *button,
1302
nt1 = lookup_widget(GTK_WIDGET(button), "notebook1");
1303
gtk_notebook_set_page(GTK_NOTEBOOK(nt1), 0);
1305
nt1 = lookup_widget(GTK_WIDGET(button), "Load_button");
1306
gtk_widget_set_sensitive(nt1, TRUE);
1307
nt1 = lookup_widget(GTK_WIDGET(button), "Save_button");
1308
gtk_widget_set_sensitive(nt1, TRUE);
1309
nt1 = lookup_widget(GTK_WIDGET(button), "Reset_button");
1310
gtk_widget_set_sensitive(nt1, TRUE);
1311
nt1 = lookup_widget(GTK_WIDGET(button), "button62");
1312
gtk_widget_set_sensitive(nt1, TRUE);
1313
nt1 = lookup_widget(GTK_WIDGET(button), "Interface_button");
1314
gtk_widget_set_sensitive(nt1, TRUE);
1315
nt1 = lookup_widget(GTK_WIDGET(button), "Send_button");
1316
gtk_widget_set_sensitive(nt1, TRUE);
1317
nt1 = lookup_widget(GTK_WIDGET(button), "Stop_button");
1318
gtk_widget_set_sensitive(nt1, TRUE);
1320
statusbar_text(button, " Builder window opened");
1325
on_Gen_button_clicked (GtkButton *button,
1328
GtkWidget *ntbk2, *ntbk4, *ntbk7;
1331
GtkWidget *crc_value;
1333
unsigned long crc32;
1336
guint i, j, m, page1, page2;
1338
ntbk2 = lookup_widget (GTK_WIDGET (button), "notebook2");
1339
ntbk4 = lookup_widget (GTK_WIDGET (button), "notebook4");
1340
ntbk7 = lookup_widget (GTK_WIDGET (button), "notebook7");
1341
nt1 = lookup_widget(GTK_WIDGET(button), "notebook1");
1342
crc_value = lookup_widget(GTK_WIDGET (button), "entry164");
1343
gtk_notebook_set_page(GTK_NOTEBOOK(nt1), 1);
1345
nt1 = lookup_widget(GTK_WIDGET(button), "Load_button");
1346
gtk_widget_set_sensitive(nt1, FALSE);
1347
nt1 = lookup_widget(GTK_WIDGET(button), "Save_button");
1348
gtk_widget_set_sensitive(nt1, FALSE);
1349
nt1 = lookup_widget(GTK_WIDGET(button), "Reset_button");
1350
gtk_widget_set_sensitive(nt1, FALSE);
1351
nt1 = lookup_widget(GTK_WIDGET(button), "button62");
1352
gtk_widget_set_sensitive(nt1, FALSE);
1353
nt1 = lookup_widget(GTK_WIDGET(button), "Interface_button");
1354
gtk_widget_set_sensitive(nt1, TRUE);
1355
nt1 = lookup_widget(GTK_WIDGET(button), "Send_button");
1356
gtk_widget_set_sensitive(nt1, TRUE);
1357
nt1 = lookup_widget(GTK_WIDGET(button), "Stop_button");
1358
gtk_widget_set_sensitive(nt1, TRUE);
1360
statusbar_text(button, " Gen-b window opened.");
1362
/* get access to the buffer of text field */
1363
text_e = lookup_widget(GTK_WIDGET (button), "text5");
1364
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_e));
1366
show_error_dialog = 0;
1368
if (make_packet(button, user_data) == -1) {
1369
//error("Packet contents is not ok!\n");
1370
snprintf(&tmp[0], 200, "\n\n\n\n Packet constructed in Builder is not ok!");
1371
gtk_entry_set_text(GTK_ENTRY(crc_value), "");
1374
/* copy data to tmp field */
1375
for (i=0, j=0, m=1; j < number; m++, j++) {
1376
snprintf(&tmp[i], 4600, "%02x", packet[j]);
1378
/* we allow only 16 bytes in each row - looks nicer */
1379
if ((m % 16) == 0 && (m > 1)) {
1389
crc32 = get_crc32(packet, number);
1390
snprintf(str_crc32, 9, "%08lX", crc32);
1391
gtk_entry_set_text(GTK_ENTRY(crc_value), str_crc32);
1394
/* insert the text in the text field */
1395
gtk_text_buffer_set_text(buffer,tmp,-1);
1397
/* we want to set correct options in send built change while sending option menu */
1398
page1 = gtk_notebook_get_current_page(GTK_NOTEBOOK(ntbk2));
1400
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk7), 0);
1401
else if (page1 == 2)
1402
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk7), 2);
1404
page2 = gtk_notebook_get_current_page(GTK_NOTEBOOK(ntbk4));
1406
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk7), 4);
1407
else if (page2 == 1)
1408
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk7), 3);
1410
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk7), 1);
1414
show_error_dialog = 1;
1419
on_Gen_s_bt_clicked (GtkButton *button,
1424
nt1 = lookup_widget(GTK_WIDGET(button), "notebook1");
1425
gtk_notebook_set_page(GTK_NOTEBOOK(nt1), 2);
1427
nt1 = lookup_widget(GTK_WIDGET(button), "Load_button");
1428
gtk_widget_set_sensitive(nt1, FALSE);
1429
nt1 = lookup_widget(GTK_WIDGET(button), "Save_button");
1430
gtk_widget_set_sensitive(nt1, FALSE);
1431
nt1 = lookup_widget(GTK_WIDGET(button), "Reset_button");
1432
gtk_widget_set_sensitive(nt1, FALSE);
1433
nt1 = lookup_widget(GTK_WIDGET(button), "button62");
1434
gtk_widget_set_sensitive(nt1, FALSE);
1435
nt1 = lookup_widget(GTK_WIDGET(button), "Interface_button");
1436
gtk_widget_set_sensitive(nt1, TRUE);
1437
nt1 = lookup_widget(GTK_WIDGET(button), "Send_button");
1438
gtk_widget_set_sensitive(nt1, TRUE);
1439
nt1 = lookup_widget(GTK_WIDGET(button), "Stop_button");
1440
gtk_widget_set_sensitive(nt1, TRUE);
1441
statusbar_text(button, " Gen-s window opened");
1446
on_Gen_k_bt_clicked (GtkButton *button,
1451
nt1 = lookup_widget(GTK_WIDGET(button), "notebook1");
1452
gtk_notebook_set_page(GTK_NOTEBOOK(nt1), 3);
1456
on_Send_button_clicked (GtkButton *button,
1460
if (send_packet(button, user_data) == -1) {
1461
//printf("problems sending packet; send_packet() returned -1\n");
1468
on_optionmenu3_clicked (GtkButton *button,
1471
GtkWidget *option_menu, *menu, *active_item, *opt_value;
1474
option_menu = lookup_widget (GTK_WIDGET (button), "optionmenu3");
1475
opt_value = lookup_widget (GTK_WIDGET (button), "entry34");
1476
menu = GTK_OPTION_MENU (option_menu)->menu;
1477
active_item = gtk_menu_get_active (GTK_MENU (menu));
1478
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
1480
if (active_index == 0) {
1481
gtk_entry_set_text(GTK_ENTRY(opt_value), "0");
1482
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1484
else if (active_index == 1) {
1485
gtk_entry_set_text(GTK_ENTRY(opt_value), "1");
1486
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1488
else if (active_index == 2) {
1489
gtk_entry_set_text(GTK_ENTRY(opt_value), "2");
1490
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1492
else if (active_index == 3) {
1493
gtk_entry_set_text(GTK_ENTRY(opt_value), "6");
1494
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1496
else if (active_index == 4) {
1497
gtk_entry_set_text(GTK_ENTRY(opt_value), "17");
1498
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1500
else if (active_index == 5) {
1501
gtk_entry_set_text(GTK_ENTRY(opt_value), "");
1502
gtk_editable_set_editable(GTK_EDITABLE(opt_value), TRUE);
1509
on_ip_header_cks_cbt_toggled (GtkToggleButton *togglebutton,
1513
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry35");
1514
if (GTK_TOGGLE_BUTTON(togglebutton)->active) {
1515
gtk_widget_set_sensitive(en1, FALSE);
1516
gtk_entry_set_text(GTK_ENTRY(en1), "");
1519
gtk_widget_set_sensitive(en1, TRUE);
1525
on_button24_clicked (GtkButton *button,
1528
entry_field_ip = lookup_widget(GTK_WIDGET(button), "entry38");
1531
selection_dialog_show(button, user_data);
1537
on_button25_clicked (GtkButton *button,
1540
entry_field_ip = lookup_widget(GTK_WIDGET(button), "entry37");
1543
selection_dialog_show(button, user_data);
1549
on_checkbutton13_toggled (GtkToggleButton *togglebutton,
1553
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry52");
1554
if (GTK_TOGGLE_BUTTON(togglebutton)->active) {
1555
gtk_widget_set_sensitive(en1, FALSE);
1556
gtk_entry_set_text(GTK_ENTRY(en1), "");
1559
gtk_widget_set_sensitive(en1, TRUE);
1565
on_checkbutton4_toggled (GtkToggleButton *togglebutton,
1569
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry43");
1570
if (GTK_TOGGLE_BUTTON(togglebutton)->active) {
1571
gtk_widget_set_sensitive(en1, FALSE);
1572
gtk_entry_set_text(GTK_ENTRY(en1), "");
1575
gtk_widget_set_sensitive(en1, TRUE);
1581
on_optionmenu4_clicked (GtkButton *button,
1584
GtkWidget *option_menu, *menu, *active_item, *opt_value, *ntbk5;
1587
option_menu = lookup_widget (GTK_WIDGET (button), "optionmenu4");
1588
opt_value = lookup_widget (GTK_WIDGET (button), "entry57");
1589
ntbk5 = lookup_widget (GTK_WIDGET (button), "notebook5");
1590
menu = GTK_OPTION_MENU (option_menu)->menu;
1591
active_item = gtk_menu_get_active (GTK_MENU (menu));
1592
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
1594
if (active_index == 0) {
1595
gtk_entry_set_text(GTK_ENTRY(opt_value), "00");
1596
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1597
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk5), 0);
1599
else if (active_index == 1) {
1600
gtk_entry_set_text(GTK_ENTRY(opt_value), "03");
1601
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1602
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk5), 2);
1604
else if (active_index == 2) {
1605
gtk_entry_set_text(GTK_ENTRY(opt_value), "08");
1606
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1607
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk5), 5);
1610
gtk_entry_set_text(GTK_ENTRY(opt_value), "");
1611
gtk_editable_set_editable(GTK_EDITABLE(opt_value), TRUE);
1612
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk5), 1);
1619
on_checkbutton16_toggled (GtkToggleButton *togglebutton,
1623
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry63");
1624
if (GTK_TOGGLE_BUTTON(togglebutton)->active) {
1625
gtk_widget_set_sensitive(en1, FALSE);
1626
gtk_entry_set_text(GTK_ENTRY(en1), "");
1629
gtk_widget_set_sensitive(en1, TRUE);
1635
on_optionmenu5_clicked (GtkButton *button,
1638
GtkWidget *option_menu, *menu, *active_item, *opt_value;
1641
option_menu = lookup_widget (GTK_WIDGET (button), "optionmenu5");
1642
opt_value = lookup_widget (GTK_WIDGET (button), "entry58");
1643
menu = GTK_OPTION_MENU (option_menu)->menu;
1644
active_item = gtk_menu_get_active (GTK_MENU (menu));
1645
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
1647
if (active_index == 0) {
1648
gtk_entry_set_text(GTK_ENTRY(opt_value), "00");
1649
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1651
else if (active_index == 1) {
1652
gtk_entry_set_text(GTK_ENTRY(opt_value), "01");
1653
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1655
else if (active_index == 2) {
1656
gtk_entry_set_text(GTK_ENTRY(opt_value), "02");
1657
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1659
else if (active_index == 3) {
1660
gtk_entry_set_text(GTK_ENTRY(opt_value), "03");
1661
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1663
else if (active_index == 4) {
1664
gtk_entry_set_text(GTK_ENTRY(opt_value), "04");
1665
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1667
else if (active_index == 5) {
1668
gtk_entry_set_text(GTK_ENTRY(opt_value), "05");
1669
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1671
else if (active_index == 6) {
1672
gtk_entry_set_text(GTK_ENTRY(opt_value), "06");
1673
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1675
else if (active_index == 7) {
1676
gtk_entry_set_text(GTK_ENTRY(opt_value), "07");
1677
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1679
else if (active_index == 8) {
1680
gtk_entry_set_text(GTK_ENTRY(opt_value), "08");
1681
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1683
else if (active_index == 9) {
1684
gtk_entry_set_text(GTK_ENTRY(opt_value), "09");
1685
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1687
else if (active_index == 10) {
1688
gtk_entry_set_text(GTK_ENTRY(opt_value), "0a");
1689
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1691
else if (active_index == 11) {
1692
gtk_entry_set_text(GTK_ENTRY(opt_value), "0b");
1693
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1695
else if (active_index == 12) {
1696
gtk_entry_set_text(GTK_ENTRY(opt_value), "0c");
1697
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1699
else if (active_index == 13) {
1700
gtk_entry_set_text(GTK_ENTRY(opt_value), "0d");
1701
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1703
else if (active_index == 14) {
1704
gtk_entry_set_text(GTK_ENTRY(opt_value), "0e");
1705
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1707
else if (active_index == 15) {
1708
gtk_entry_set_text(GTK_ENTRY(opt_value), "0f");
1709
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
1711
else if (active_index == 16) {
1712
gtk_entry_set_text(GTK_ENTRY(opt_value), "");
1713
gtk_editable_set_editable(GTK_EDITABLE(opt_value), TRUE);
1720
on_checkbutton15_toggled (GtkToggleButton *togglebutton,
1724
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry59");
1725
if (GTK_TOGGLE_BUTTON(togglebutton)->active) {
1726
gtk_widget_set_sensitive(en1, FALSE);
1727
gtk_entry_set_text(GTK_ENTRY(en1), "");
1730
gtk_widget_set_sensitive(en1, TRUE);
1736
on_checkbutton20_toggled (GtkToggleButton *togglebutton,
1740
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry77");
1741
if (GTK_TOGGLE_BUTTON(togglebutton)->active) {
1742
gtk_widget_set_sensitive(en1, FALSE);
1743
gtk_entry_set_text(GTK_ENTRY(en1), "");
1746
gtk_widget_set_sensitive(en1, TRUE);
1752
on_checkbutton2_toggled (GtkToggleButton *togglebutton,
1756
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry5");
1757
if (GTK_TOGGLE_BUTTON(togglebutton)->active) {
1758
gtk_widget_set_sensitive(en1, FALSE);
1759
gtk_entry_set_text(GTK_ENTRY(en1), "");
1762
gtk_widget_set_sensitive(en1, TRUE);
1767
on_N_apply_pattern_clicked (GtkButton *button,
1770
GtkWidget *en1, *en2, *text_e;
1772
char *en1_t, *en2_t;
1773
char tmp[4600], ch1, ch2;
1776
en1 = lookup_widget(GTK_WIDGET(button), "entry79");
1777
en2 = lookup_widget(GTK_WIDGET(button), "entry80");
1778
text_e = lookup_widget(GTK_WIDGET (button), "text1");
1779
en1_t = (char *)gtk_entry_get_text(GTK_ENTRY(en1));
1780
en2_t = (char *)gtk_entry_get_text(GTK_ENTRY(en2));
1782
length = strtol(en2_t, (char **)NULL, 10);
1783
if ( (length > 1500) || (length <= 0) ) {
1784
//printf("Error: network pattern length error\n");
1785
error("Error: network pattern length error");
1789
/* we chech the pattern */
1790
if (char2x(en1_t) == -1) {
1791
//printf("Error: nok network pattern field\n");
1792
error("Error: nok network pattern field");
1796
/* get access to the buffer of the text field */
1797
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_e));
1799
/* apply the new pattern */
1804
/* copy data to tmp field */
1805
for (i=0, j=1; (i < (length*3) ); i++, j++) {
1808
/* we allow only 16 bytes in each row - looks nicer */
1809
if ((j % 16) == 0 && (j > 1)) {
1818
/* insert the text in the text field */
1819
gtk_text_buffer_set_text(buffer,tmp,-1);
1824
on_N_select_payload_clicked (GtkButton *button,
1832
on_button33_clicked (GtkButton *button,
1835
entry_field = lookup_widget(GTK_WIDGET(button), "A_sendermac");
1836
entry_field_ip = lookup_widget(GTK_WIDGET(button), "A_senderip");
1839
selection_dialog_show(button, user_data);
1845
on_button34_clicked (GtkButton *button,
1848
GtkWidget *s_mac, *s_ip;
1850
s_mac = lookup_widget(GTK_WIDGET(button), "A_sendermac");
1851
s_ip = lookup_widget(GTK_WIDGET(button), "A_senderip");
1853
gtk_entry_set_text(GTK_ENTRY(s_mac), "00:E0:00:98:60:13");
1854
gtk_entry_set_text(GTK_ENTRY(s_ip), "10.1.4.107");
1860
on_button35_clicked (GtkButton *button,
1863
entry_field = lookup_widget(GTK_WIDGET(button), "A_targetmac");
1864
entry_field_ip = lookup_widget(GTK_WIDGET(button), "A_targetip");
1867
selection_dialog_show(button, user_data);
1873
on_button36_clicked (GtkButton *button,
1876
GtkWidget *t_mac, *t_ip;
1878
t_mac = lookup_widget(GTK_WIDGET(button), "A_targetmac");
1879
t_ip = lookup_widget(GTK_WIDGET(button), "A_targetip");
1881
gtk_entry_set_text(GTK_ENTRY(t_mac), "FF:FF:FF:FF:FF:FF");
1882
gtk_entry_set_text(GTK_ENTRY(t_ip), "0.0.0.0");
1889
on_button37_clicked (GtkButton *button,
1892
entry_field_tos = lookup_widget(GTK_WIDGET(button), "entry28");
1894
if (tos_dialog_menu != NULL) {
1895
gdk_window_show(tos_dialog_menu->window);
1896
gdk_window_raise(tos_dialog_menu->window);
1899
tos_dialog_menu = create_tos_dialod();
1900
gtk_widget_show(tos_dialog_menu);
1905
on_button39_clicked (GtkButton *button,
1908
GtkWidget *en1, *en2, *text_e;
1910
char *en1_t, *en2_t;
1911
char tmp[4600], ch1, ch2;
1914
en1 = lookup_widget(GTK_WIDGET(button), "entry82");
1915
en2 = lookup_widget(GTK_WIDGET(button), "entry83");
1916
text_e = lookup_widget(GTK_WIDGET (button), "text2");
1917
en1_t = (char *)gtk_entry_get_text(GTK_ENTRY(en1));
1918
en2_t = (char *)gtk_entry_get_text(GTK_ENTRY(en2));
1920
/* we chech the pattern */
1921
if (char2x(en1_t) == -1) {
1922
//printf("Error: transport layer user defined pattern field\n");
1923
error("Error: transport layer user defined pattern field");
1927
length = strtol(en2_t, (char **)NULL, 10);
1928
/* YYY this length 1480 is not accurate in case of non ethernet ver II */
1929
if ( (length > 1480) || (length <= 0) ) {
1930
//printf("Error: transport layer user defined length field\n");
1931
error("Error: transport layer user defined length field");
1935
/* get access to the buffer of the text field */
1936
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_e));
1938
/* apply the new pattern */
1943
/* copy data to tmp field */
1944
for (i=0, j=1; (i < (length*3) ); i++, j++) {
1947
/* we allow only 16 bytes in each row - looks nicer */
1948
if ((j % 16) == 0 && (j > 1)) {
1957
/* insert the text in the text field */
1958
gtk_text_buffer_set_text(buffer,tmp,-1);
1964
on_button38_clicked (GtkButton *button,
1972
on_checkbutton21_toggled (GtkToggleButton *togglebutton,
1976
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry29");
1977
if (GTK_TOGGLE_BUTTON(togglebutton)->active) {
1978
gtk_widget_set_sensitive(en1, FALSE);
1979
gtk_entry_set_text(GTK_ENTRY(en1), "");
1982
gtk_widget_set_sensitive(en1, TRUE);
1987
on_checkbutton3_toggled (GtkToggleButton *togglebutton,
1992
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry42");
1993
if (GTK_TOGGLE_BUTTON(togglebutton)->active) {
1994
gtk_widget_set_sensitive(en1, FALSE);
1995
gtk_entry_set_text(GTK_ENTRY(en1), "");
1998
gtk_widget_set_sensitive(en1, TRUE);
2004
on_Interface_button_clicked (GtkButton *button,
2011
struct ifreq IfcBuf[512];
2018
statusbar_text(button, "");
2020
if (interface_dialog_menu != NULL) {
2021
gdk_window_show(interface_dialog_menu->window);
2022
gdk_window_raise(interface_dialog_menu->window);
2025
interface_dialog_menu = create_interface_dialog();
2027
combo = lookup_widget(GTK_WIDGET (interface_dialog_menu), "combo1");
2029
Ifc.ifc_len = sizeof(IfcBuf);
2030
Ifc.ifc_buf = (char *) IfcBuf;
2032
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
2033
//printf("socket error\n");
2034
error("Error: socket error");
2038
if ( ioctl(fd, SIOCGIFCONF, &Ifc) < 0) {
2039
//printf("ioctl SIOCGIFCONF error\n");
2040
error("Error: ioctl SIOCGIFCONF error");
2044
num_ifreq = Ifc.ifc_len / sizeof(struct ifreq);
2048
for ( pIfr = Ifc.ifc_req, i = 0, length = 0 ; i < num_ifreq; pIfr++, i++ ) {
2049
if ( (length + strlen(pIfr->ifr_name) + 1) < 100) {
2050
snprintf(ptr, 100, "%s", pIfr->ifr_name);
2051
glist = g_list_append(glist, ptr);
2052
ptr = ptr + strlen(pIfr->ifr_name) + 1;
2053
length = length + strlen(pIfr->ifr_name) + 1;
2059
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist) ;
2061
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), iftext);
2063
gtk_widget_show(interface_dialog_menu);
2069
on_button50_clicked (GtkButton *button,
2074
combo = lookup_widget(GTK_WIDGET (interface_dialog_menu), "combo1");
2076
snprintf(iftext, 19, gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)));
2078
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2079
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2084
on_button51_clicked (GtkButton *button,
2087
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2088
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2094
on_interface_dialog_destroy (GtkObject *object,
2097
interface_dialog_menu = NULL;
2102
on_button52_clicked (GtkButton *button,
2105
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2106
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2111
on_error_dialog_destroy (GtkObject *object,
2114
error_dialog_menu = NULL;
2117
void error(gchar *error_type)
2121
if ( show_error_dialog == 0)
2124
if (error_dialog_menu != NULL) {
2125
label = lookup_widget(GTK_WIDGET(error_dialog_menu), "label165");
2126
gtk_label_set_text(GTK_LABEL(label), error_type);
2127
gdk_window_show(error_dialog_menu->window);
2128
gdk_window_raise(error_dialog_menu->window);
2132
error_dialog_menu = create_error_dialog();
2133
label = lookup_widget(GTK_WIDGET(error_dialog_menu), "label165");
2134
gtk_label_set_text(GTK_LABEL(label), error_type);
2135
gtk_widget_show(error_dialog_menu);
2142
on_udp_apply_pattern_button_clicked (GtkButton *button,
2145
GtkWidget *en1, *en2, *text_e;
2147
gchar *en1_t, *en2_t;
2148
char tmp[4600], ch1, ch2;
2151
en1 = lookup_widget(GTK_WIDGET(button), "entry89");
2152
en2 = lookup_widget(GTK_WIDGET(button), "entry90");
2153
text_e = lookup_widget(GTK_WIDGET (button), "text3");
2154
en1_t = (char *)gtk_entry_get_text(GTK_ENTRY(en1));
2155
en2_t = (char *)gtk_entry_get_text(GTK_ENTRY(en2));
2157
/* we chech the pattern */
2158
if (char2x(en1_t) == -1) {
2159
//printf("Error: udp payload pattern field\n");
2160
error("Error: udp payload pattern field");
2164
length = strtol(en2_t, (char **)NULL, 10);
2165
if ( (length > 1472) || (length <= 0) ) {
2166
//printf("Error: udp payload pattern length\n");
2167
error("Error: udp payload pattern length");
2171
/* get access to buffer of the text field */
2172
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_e));
2174
/* apply the new pattern */
2179
/* copy data to tmp field */
2180
for (i=0, j=1; (i < (length*3) ); i++, j++) {
2183
/* we allow only 16 bytes in each row - looks nicer */
2184
if ((j % 16) == 0 && (j > 1)) {
2193
/* insert the text in the text field */
2194
gtk_text_buffer_set_text(buffer,tmp,-1);
2200
on_udp_select_payload_button_clicked (GtkButton *button,
2203
if (udp_payload_dialog != NULL) {
2204
gdk_window_show(udp_payload_dialog->window);
2205
gdk_window_raise(udp_payload_dialog->window);
2209
entry_field_udp = lookup_widget(GTK_WIDGET(button), "text3");
2211
udp_payload_dialog = create_udp_payload_dialog();
2212
gtk_widget_show(udp_payload_dialog);
2217
on_rtp_apply_button_clicked (GtkButton *button,
2220
GtkWidget *freq_entry, *alaw_bt, *ulaw_bt, *length_entry, *apply_bt, *payload_entry;
2221
GtkWidget *menu, *menu_item, *amp;
2223
gchar *freq_entry_t, *length_entry_t;
2224
int length, frequency;
2226
freq_entry = lookup_widget(GTK_WIDGET(button), "entry104");
2227
length_entry = lookup_widget(GTK_WIDGET(button), "entry106");
2228
payload_entry = lookup_widget(GTK_WIDGET(button), "entry103");
2229
alaw_bt= lookup_widget(GTK_WIDGET(button), "radiobutton33");
2230
ulaw_bt = lookup_widget(GTK_WIDGET(button), "radiobutton32");
2231
apply_bt = lookup_widget(GTK_WIDGET(button), "rtp_apply_button");
2232
amp = lookup_widget(GTK_WIDGET(button), "optionmenu12");
2234
freq_entry_t = (char *)gtk_entry_get_text(GTK_ENTRY(freq_entry));
2235
length_entry_t = (char *)gtk_entry_get_text(GTK_ENTRY(length_entry));
2238
/* next we need the amplitude */
2239
menu = GTK_OPTION_MENU(amp)->menu;
2240
menu_item = gtk_menu_get_active (GTK_MENU (menu));
2241
amp_index = g_list_index (GTK_MENU_SHELL (menu)->children, menu_item);
2243
/* frequency; there can be rubbish in this field */
2244
if (check_digit(freq_entry_t, strlen(freq_entry_t),
2245
"Error: apply frequency field values") == -1)
2248
frequency = strtol(freq_entry_t, (char **)NULL, 10);
2249
if ( (frequency >= 4000 ) || (frequency < 0) ) {
2250
//printf("Error: RTP frequency range\n");
2251
error("Error: RTP frequency range ( 0 <= f < 3999 )");
2256
if (check_digit(length_entry_t, strlen(length_entry_t),
2257
"Error: apply length field values") == -1)
2261
length = strtol(length_entry_t, (char **)NULL, 10);
2262
if ( (length >= 1460 ) || (length <= 0) ) {
2263
//printf("Error: RTP length range\n");
2264
error("Error: RTP length range ( 0 < length < 1460 )");
2268
/* call the function */
2269
if (GTK_TOGGLE_BUTTON(alaw_bt)->active) {
2270
if (insert_frequency(1, frequency, length, payload_entry, amp_index) == 0) {
2271
//printf("Error: Problem inserting RTP alaw payload frequency\n");
2272
error("Error: Problem inserting RTP alaw payload frequency");
2277
if (insert_frequency(0, frequency, length, payload_entry, amp_index) == 0) {
2278
//printf("Error: Problem inserting RTP ulaw payload frequency\n");
2279
error("Error: Problem inserting RTP ulaw payload frequency");
2288
on_udp_payload_dialog_destroy (GtkObject *object,
2291
udp_payload_dialog = NULL;
2296
on_cancel_rtp_bt_clicked (GtkButton *button,
2299
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2300
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2305
on_rtp_ok_bt_clicked (GtkButton *button,
2308
char tmp[3000], tmp2[4600];
2310
GtkWidget *version, *csrc_nr, *payload_type, *seq_nr, *timestamp, *ssrc, *csrc, *extension;
2311
GtkWidget *padding_true, *padding_false, *extension_true, *extension_false;
2312
GtkWidget *marker_true, *marker_false, *menu1, *rtp_payload;
2313
gchar *vers_t, *csrc_nr_t, *payload_type_t, *seq_nr_t, *timestamp_t, *ssrc_t;
2314
gchar *csrc_t, *extension_t, *rtp_payload_t;
2315
int sum, intversion, intpadding, intmarker, intextension, intcsrc, inttype;
2317
guint32 inttimestamp, intssrc;
2319
version = lookup_widget(GTK_WIDGET(button), "entry91");
2320
csrc_nr = lookup_widget(GTK_WIDGET(button), "entry92");
2321
payload_type = lookup_widget(GTK_WIDGET(button), "entry102");
2322
seq_nr = lookup_widget(GTK_WIDGET(button), "entry101");
2323
timestamp = lookup_widget(GTK_WIDGET(button), "entry97");
2324
ssrc = lookup_widget(GTK_WIDGET(button), "entry96");
2325
csrc = lookup_widget(GTK_WIDGET(button), "entry98");
2326
extension = lookup_widget(GTK_WIDGET(button), "entry99");
2327
padding_true = lookup_widget(GTK_WIDGET(button), "radiobutton23");
2328
padding_false = lookup_widget(GTK_WIDGET(button), "radiobutton24");
2329
extension_true = lookup_widget(GTK_WIDGET(button), "radiobutton25");
2330
extension_false = lookup_widget(GTK_WIDGET(button), "radiobutton26");
2331
marker_true = lookup_widget(GTK_WIDGET(button), "radiobutton27");
2332
marker_false = lookup_widget(GTK_WIDGET(button), "radiobutton28");
2333
menu1 = lookup_widget(GTK_WIDGET(button), "optionmenu7");
2334
rtp_payload = lookup_widget(GTK_WIDGET(button), "entry103");
2336
vers_t = (char *)gtk_entry_get_text(GTK_ENTRY(version));
2337
csrc_nr_t = (char *)gtk_entry_get_text(GTK_ENTRY(csrc_nr));
2338
payload_type_t = (char *)gtk_entry_get_text(GTK_ENTRY(payload_type));
2339
seq_nr_t = (char *)gtk_entry_get_text(GTK_ENTRY(seq_nr));
2340
timestamp_t = (char *)gtk_entry_get_text(GTK_ENTRY(timestamp));
2341
ssrc_t = (char *)gtk_entry_get_text(GTK_ENTRY(ssrc));
2342
csrc_t = (char *)gtk_entry_get_text(GTK_ENTRY(csrc));
2343
extension_t = (char *)gtk_entry_get_text(GTK_ENTRY(extension));
2344
rtp_payload_t = (char *)gtk_entry_get_text(GTK_ENTRY(rtp_payload));
2346
/* what numbers should we allow? only 2? */
2347
intversion = strtol(vers_t, (char **)NULL, 10);
2348
if ( (intversion > 3) || (intversion < 0) ) {
2349
//printf("Error: RTP version type\n");
2350
error("Error: RTP version type");
2354
/* there can be rubbish in this field */
2355
if (check_digit(vers_t, strlen(vers_t), "Error: RTP version value") == -1)
2358
/* should we add paddind automaticaly or not? no we do not do it */
2359
if (GTK_TOGGLE_BUTTON(padding_true)->active)
2364
if (GTK_TOGGLE_BUTTON(extension_true)->active)
2369
/* what numbers should we allow? between 0 and 15? */
2370
intcsrc = strtol(csrc_nr_t, (char **)NULL, 10);
2371
if ( (intcsrc > 15) || (intcsrc < 0) ) {
2372
//printf("Error: RTP csrc count field\n");
2373
error("Error: RTP csrc count field");
2377
/* there can be rubbish in this field */
2378
if (check_digit(csrc_nr_t, strlen(csrc_nr_t), "Error: rtp csrc value") == -1)
2381
/* first byte is version + padding + extension + csrc */
2382
tmp[ij] = c4((intversion*4 + intpadding*2 + intextension)); ij++;
2383
tmp[ij] = c4(intcsrc); ij++;
2386
if (GTK_TOGGLE_BUTTON(marker_true)->active)
2391
inttype = strtol(payload_type_t, (char **)NULL, 10);
2392
if ( (inttype > 127) || (inttype < 0) ) {
2393
//printf("Error: RTP payload type number\n");
2394
error("Error: RTP payload type number");
2398
/* there can be rubbish in this field */
2399
if (check_digit(payload_type_t, strlen(payload_type_t),
2400
"Error: rtp payload type value") == -1)
2403
snprintf(&(tmp[ij]), 3, "%02x", (intmarker*128) + inttype);
2406
/* next 2 bytes sequence number */
2407
intseq = strtoul(seq_nr_t, (char **)NULL, 10);
2409
/* there can be rubbish in this field */
2410
if (check_digit(seq_nr_t, strlen(seq_nr_t), "Error: rtp sequence number value") == -1)
2413
if ( atol(seq_nr_t) > 65535) {
2414
//printf("Error: rtp sequence number value\n");
2415
error("Error: rtp sequence number value");
2419
snprintf(&(tmp[ij]), 5, "%04x", intseq);
2422
/* next 4 bytes timestamp */
2423
inttimestamp = strtoul(timestamp_t, (char **)NULL, 10);
2425
/* there can be rubbish in this field */
2426
if (check_digit(timestamp_t, strlen(timestamp_t), "Error: rtp timestamp value") == -1)
2429
if ( atoll(timestamp_t) > 0xFFFFFFFF) {
2430
//printf("Error: rtp timestamp value\n");
2431
error("Error: rtp timestamp value");
2435
snprintf(&(tmp[ij]), 9, "%08x", inttimestamp);
2438
/* next 4 bytes ssrc */
2439
intssrc = strtoul(ssrc_t, (char **)NULL, 10);
2441
/* there can be rubbish in this field */
2442
if (check_digit(ssrc_t, strlen(ssrc_t), "Error: rtp ssrc value") == -1)
2445
if ( atoll(timestamp_t) > 0xFFFFFFFF) {
2446
//printf("Error: rtp ssrc value\n");
2447
error("Error: rtp ssrc value");
2451
snprintf(&(tmp[ij]), 9, "%08x", intssrc);
2454
/* csrc identifiers */
2455
if ( (strlen(csrc_t)%8) != 0) {
2456
//printf("Error: rtp csrc identifiers field (length mod 8 should equal 0)\n");
2457
error("Error: rtp csrc identifiers field \n(length mod 8 should equal 0)");
2461
/* there can be rubbish in this field */
2462
if ( (strlen(csrc_t) == 0))
2464
else if (check_hex(csrc_t, strlen(csrc_t), "Error: rtp crsc identifiers field") == -1)
2467
strncpy(&tmp[ij], csrc_t, strlen(csrc_t));
2468
ij = ij + strlen(csrc_t);
2470
/* extension field */
2471
if ( (strlen(extension_t)%8) != 0) {
2472
//printf("Error: RTP extension field (length mod 8 should equal 0)\n");
2473
error("Error: rtp extension value \n(length mod 8 should equal 0)");
2477
/* there can be rubbish in this field */
2478
if ( (strlen(extension_t) == 0) )
2480
else if (check_hex(extension_t, strlen(extension_t), "Error: rtp extension value") == -1)
2483
strncpy(&tmp[ij], extension_t, strlen(extension_t));
2484
ij = ij + strlen(extension_t);
2486
if ( (strlen(rtp_payload_t)> 1460) || (strlen(rtp_payload_t)%2 != 0) ) {
2487
//printf("Error: RTP payload length\n");
2488
error("Error: RTP payload length");
2491
strncpy(&tmp[ij], rtp_payload_t, strlen(rtp_payload_t));
2492
ij = ij + strlen(rtp_payload_t);
2494
/* copy data to tmp2 field */
2495
for (i=0, j=1, sum = 0; (sum < ij ); sum++, i++, j++) {
2496
tmp2[i] = tmp[sum]; i++; sum++;
2497
tmp2[i] = tmp[sum]; i++;
2498
if ((j % 16) == 0 && (j > 1)) {
2507
/* get access to buffer of the text field */
2508
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry_field_udp));
2510
/* insert the text in the text field */
2511
gtk_text_buffer_set_text(buffer,tmp2,-1);
2513
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2514
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2520
on_apply_tcp_pattern_bt_clicked (GtkButton *button,
2523
GtkWidget *en1, *en2, *text_e;
2525
gchar *en1_t, *en2_t;
2526
char tmp[4600], ch1, ch2;
2529
en1 = lookup_widget(GTK_WIDGET(button), "entry107");
2530
en2 = lookup_widget(GTK_WIDGET(button), "entry108");
2531
text_e = lookup_widget(GTK_WIDGET (button), "text4");
2532
en1_t = (char *)gtk_entry_get_text(GTK_ENTRY(en1));
2533
en2_t = (char *)gtk_entry_get_text(GTK_ENTRY(en2));
2535
length = strtol(en2_t, (char **)NULL, 10);
2536
if ( (length > 1460) || (length <= 0) ) {
2537
//printf("Error: tcp pattern length error\n");
2538
error("Error: tcp pattern length error");
2542
/* we chech the pattern */
2543
if (char2x(en1_t) == -1) {
2544
//printf("Error: tcp pattern field\n");
2545
error("Error: tcp pattern field");
2549
/* get access to buffer of the text field */
2550
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_e));
2552
/* apply the new pattern */
2557
/* copy data to tmp field */
2558
for (i=0, j=1; (i < (length*3) ); i++, j++) {
2561
/* we allow only 16 bytes in each row - looks nicer */
2562
if ((j % 16) == 0 && (j > 1)) {
2571
/* insert the text in the text field */
2572
gtk_text_buffer_set_text(buffer,tmp,-1);
2578
on_select_tpc_payload_bt_clicked (GtkButton *button,
2585
on_button61_clicked (GtkButton *button,
2588
//GtkWidget *toolbar, *stopbt/*, *notebk*/;
2590
//toolbar = lookup_widget(GTK_WIDGET (button), "toolbar1");
2591
//stopbt = lookup_widget(GTK_WIDGET (button), "button61");
2593
//gtk_widget_set_sensitive (toolbar, TRUE);
2594
//gtk_widget_set_sensitive (stopbt, FALSE);
2606
on_checkbutton35_toggled (GtkToggleButton *togglebutton,
2610
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry109");
2611
if (GTK_TOGGLE_BUTTON(togglebutton)->active) {
2612
gtk_widget_set_sensitive(en1, FALSE);
2615
gtk_widget_set_sensitive(en1, TRUE);
2620
on_checkbutton36_toggled (GtkToggleButton *togglebutton,
2624
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry151");
2625
if (GTK_TOGGLE_BUTTON(togglebutton)->active) {
2626
gtk_widget_set_sensitive(en1, FALSE);
2629
gtk_widget_set_sensitive(en1, TRUE);
2635
on_button65_clicked (GtkButton *button,
2638
entry_field = lookup_widget(GTK_WIDGET(button), "entry111");
2640
if (file_menu != NULL) {
2641
gdk_window_show(file_menu->window);
2642
gdk_window_raise(file_menu->window);
2646
file_menu = create_fileselection1();
2647
gtk_widget_show(file_menu);
2655
on_button66_clicked (GtkButton *button,
2658
entry_field = lookup_widget(GTK_WIDGET(button), "entry112");
2660
if (file_menu != NULL) {
2661
gdk_window_show(file_menu->window);
2662
gdk_window_raise(file_menu->window);
2665
file_menu = create_fileselection1();
2666
gtk_widget_show(file_menu);
2674
on_button67_clicked (GtkButton *button,
2677
entry_field = lookup_widget(GTK_WIDGET(button), "entry113");
2679
if (file_menu != NULL) {
2680
gdk_window_show(file_menu->window);
2681
gdk_window_raise(file_menu->window);
2684
file_menu = create_fileselection1();
2685
gtk_widget_show(file_menu);
2693
on_button68_clicked (GtkButton *button,
2696
entry_field = lookup_widget(GTK_WIDGET(button), "entry114");
2698
if (file_menu != NULL) {
2699
gdk_window_show(file_menu->window);
2700
gdk_window_raise(file_menu->window);
2703
file_menu = create_fileselection1();
2704
gtk_widget_show(file_menu);
2712
on_button69_clicked (GtkButton *button,
2715
entry_field = lookup_widget(GTK_WIDGET(button), "entry115");
2717
if (file_menu != NULL) {
2718
gdk_window_show(file_menu->window);
2719
gdk_window_raise(file_menu->window);
2722
file_menu = create_fileselection1();
2723
gtk_widget_show(file_menu);
2731
on_button70_clicked (GtkButton *button,
2734
entry_field = lookup_widget(GTK_WIDGET(button), "entry116");
2736
if (file_menu != NULL) {
2737
gdk_window_show(file_menu->window);
2738
gdk_window_raise(file_menu->window);
2741
file_menu = create_fileselection1();
2742
gtk_widget_show(file_menu);
2750
on_button71_clicked (GtkButton *button,
2753
entry_field = lookup_widget(GTK_WIDGET(button), "entry117");
2755
if (file_menu != NULL) {
2756
gdk_window_show(file_menu->window);
2757
gdk_window_raise(file_menu->window);
2760
file_menu = create_fileselection1();
2761
gtk_widget_show(file_menu);
2768
on_button72_clicked (GtkButton *button,
2771
entry_field = lookup_widget(GTK_WIDGET(button), "entry118");
2773
if (file_menu != NULL) {
2774
gdk_window_show(file_menu->window);
2775
gdk_window_raise(file_menu->window);
2778
file_menu = create_fileselection1();
2779
gtk_widget_show(file_menu);
2787
on_button73_clicked (GtkButton *button,
2790
entry_field = lookup_widget(GTK_WIDGET(button), "entry119");
2792
if (file_menu != NULL) {
2793
gdk_window_show(file_menu->window);
2794
gdk_window_raise(file_menu->window);
2797
file_menu = create_fileselection1();
2798
gtk_widget_show(file_menu);
2801
load_select_nr = 10;
2806
on_button74_clicked (GtkButton *button,
2809
entry_field = lookup_widget(GTK_WIDGET(button), "entry120");
2811
if (file_menu != NULL) {
2812
gdk_window_show(file_menu->window);
2813
gdk_window_raise(file_menu->window);
2816
file_menu = create_fileselection1();
2817
gtk_widget_show(file_menu);
2820
load_select_nr = 11;
2825
on_checkbutton37_toggled (GtkToggleButton *togglebutton,
2829
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry110");
2830
if (GTK_TOGGLE_BUTTON(togglebutton)->active) {
2831
gtk_widget_set_sensitive(en1, FALSE);
2834
gtk_widget_set_sensitive(en1, TRUE);
2840
on_select_database1_activate (GtkMenuItem *menuitem,
2843
if (database_file_menu != NULL) {
2844
gdk_window_show(database_file_menu->window);
2845
gdk_window_raise(database_file_menu->window);
2849
if (selection1_dialog != NULL){
2850
gdk_window_show(selection1_dialog->window);
2851
gdk_window_raise(selection1_dialog->window);
2855
database_file_menu = create_fileselection3();
2856
gtk_widget_show(database_file_menu);
2861
on_ok_button3_clicked (GtkButton *button,
2867
fname = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(lookup_widget(gtk_widget_get_toplevel(GTK_WIDGET(button)),"fileselection3"))));
2869
if (strlen(fname) == 0)
2872
if (strlen(fname) > 99) {
2873
error("Error: database file name too long (>100 chars)");
2877
strncpy(address_filename, fname, strlen(fname));
2879
if((file_p = fopen(fname, "a")) == NULL) {
2880
//printf("can not open or create database file\n");
2881
error("Error: can't open or create database file");
2886
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2887
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2892
on_cancel_button3_clicked (GtkButton *button,
2895
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2896
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2901
on_fileselection3_destroy (GtkObject *object,
2904
database_file_menu = NULL;
2911
on_about_dialog_destroy (GtkObject *object,
2914
about_dialog_menu = NULL;
2918
/* ok butoon for about dialog */
2920
on_button75_clicked (GtkButton *button,
2923
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2924
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
2929
on_tos_dialod_destroy (GtkObject *object,
2932
tos_dialog_menu = NULL;
2936
/* inside tos dialog */
2938
on_radiobutton38_toggled (GtkToggleButton *togglebutton,
2941
GtkWidget *fr1, *fr2;
2943
fr1 = lookup_widget(GTK_WIDGET(togglebutton), "frame42");
2944
fr2 = lookup_widget(GTK_WIDGET(togglebutton), "frame43");
2945
gtk_widget_set_sensitive(fr1, TRUE);
2946
gtk_widget_set_sensitive(fr2, FALSE);
2950
/* inside tos dialog */
2952
on_radiobutton39_toggled (GtkToggleButton *togglebutton,
2955
GtkWidget *fr1, *fr2;
2957
fr1 = lookup_widget(GTK_WIDGET(togglebutton), "frame42");
2958
fr2 = lookup_widget(GTK_WIDGET(togglebutton), "frame43");
2959
gtk_widget_set_sensitive(fr1, FALSE);
2960
gtk_widget_set_sensitive(fr2, TRUE);
2964
/* ok button for tos dialog */
2966
on_button76_clicked (GtkButton *button,
2969
GtkWidget *tbt1, *w1, *w2, *w3, *w4, *w5, *en1, *menu, *menu_item;
2974
tbt1 = lookup_widget(GTK_WIDGET(button), "radiobutton38");
2976
if (GTK_TOGGLE_BUTTON(tbt1)->active) {
2977
w1 = lookup_widget(GTK_WIDGET(button), "optionmenu13");
2978
w2 = lookup_widget(GTK_WIDGET(button), "radiobutton48");
2979
w3 = lookup_widget(GTK_WIDGET(button), "radiobutton50");
2980
w4 = lookup_widget(GTK_WIDGET(button), "radiobutton52");
2981
w5 = lookup_widget(GTK_WIDGET(button), "radiobutton54");
2983
menu = GTK_OPTION_MENU(w1)->menu;
2984
menu_item = gtk_menu_get_active (GTK_MENU (menu));
2985
tos_value = g_list_index (GTK_MENU_SHELL (menu)->children, menu_item);
2986
tos_value = tos_value << 5;
2988
if (GTK_TOGGLE_BUTTON(w2)->active)
2989
tos_value = tos_value + 16;
2990
if (GTK_TOGGLE_BUTTON(w3)->active)
2991
tos_value = tos_value + 8;
2992
if (GTK_TOGGLE_BUTTON(w4)->active)
2993
tos_value = tos_value + 4;
2994
if (GTK_TOGGLE_BUTTON(w5)->active)
2995
tos_value = tos_value + 2;
2998
en1 = lookup_widget(GTK_WIDGET(button), "entry154");
2999
en_t = (char *)gtk_entry_get_text(GTK_ENTRY(en1));
3000
tos_value = (guchar)strtol(en_t, (char **)NULL, 10);
3001
if ((tos_value<0) || (tos_value>63)) {
3002
//printf("wrong DSCP value\n");
3003
error("Error: wrong DSCP value");
3007
tos_value = tos_value << 2;
3012
gtk_entry_set_text(GTK_ENTRY(entry_field_tos), tmp);
3014
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
3015
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
3019
/* cancel button for tos dialog */
3021
on_button77_clicked (GtkButton *button,
3024
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
3025
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
3030
on_entry160_changed (GtkEditable *editable,
3033
GtkWidget *en5, *en6, *text_e;
3034
gchar *en5_t, *en6_t;
3035
int length, i, j, m, value, yvalue;
3038
en5 = lookup_widget(GTK_WIDGET (editable), "entry160");
3039
en5_t = (char *)gtk_entry_get_text(GTK_ENTRY(en5));
3040
length = strlen(en5_t);
3042
for(i=0; i<length; i++) {
3043
if (isdigit(*(en5_t+i)) == 0) {
3044
error("Error: Wrong byte x entry!");
3048
value = strtol(en5_t, (char **)NULL, 10);
3050
if (number < value) {
3051
error("Error: Wrong byte x offset!");
3055
text_e = lookup_widget(GTK_WIDGET (editable), "text5");
3057
en6 = lookup_widget(GTK_WIDGET (editable), "entry162");
3058
en6_t = (char *)gtk_entry_get_text(GTK_ENTRY(en6));
3059
yvalue = strtol(en6_t, (char **)NULL, 10);
3061
/* copy data to tmp field */
3062
for (i=0, j=0, m=1; j < number; m++, j++) {
3063
snprintf(&tmp[i], 4600, "%02x", packet[j]);
3065
/* we allow only 16 bytes in each row - looks nicer */
3066
if ((m % 16) == 0 && (m > 1)) {
3076
/* Insert tmp into text field */
3077
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_e));
3078
gtk_text_buffer_set_text(buffer,tmp,-1);
3083
gtk_text_buffer_set_text(buffer,"??",2);
3086
if ( (number < yvalue) || (yvalue == 0) )
3089
gtk_text_buffer_set_text(buffer,"??",2);
3096
on_entry162_changed (GtkEditable *editable,
3099
GtkWidget *en5, *en6, *text_e;
3100
gchar *en5_t, *en6_t;
3101
int length, i, j, m, value, xvalue;
3104
en5 = lookup_widget(GTK_WIDGET (editable), "entry162");
3105
en5_t = (char *)gtk_entry_get_text(GTK_ENTRY(en5));
3106
length = strlen(en5_t);
3108
for(i=0; i<length; i++) {
3109
if (isdigit(*(en5_t+i)) == 0) {
3110
error("Error: Wrong byte y entry!");
3114
value = strtol(en5_t, (char **)NULL, 10);
3116
if (number < value) {
3117
error("Error: Wrong byte y offset!");
3121
text_e = lookup_widget(GTK_WIDGET (editable), "text5");
3123
en6 = lookup_widget(GTK_WIDGET (editable), "entry160");
3124
en6_t = (char *)gtk_entry_get_text(GTK_ENTRY(en6));
3125
xvalue = strtol(en6_t, (char **)NULL, 10);
3127
/* copy data to tmp field */
3128
for (i=0, j=0, m=1; j < number; m++, j++) {
3129
snprintf(&tmp[i], 4600, "%02x", packet[j]);
3131
/* we allow only 16 bytes in each row - looks nicer */
3132
if ((m % 16) == 0 && (m > 1)) {
3142
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_e));
3143
gtk_text_buffer_set_text(buffer,tmp,-1);
3148
gtk_text_buffer_set_text(buffer,"??",2);
3151
if ( (number < xvalue) || (xvalue == 0) )
3154
gtk_text_buffer_set_text(buffer,"??",2);
3159
/* commented out; this makes the byte x and byte y (un)sensitive. Because of problems (difficult
3160
* specify with a lot of options, know everything is on */
3162
on_optionmenu9_clicked (GtkButton *button,
3166
GtkWidget *option_menu, *menu, *active_item;
3168
GtkWidget *hbox1, *hbox2;
3170
option_menu = lookup_widget (GTK_WIDGET (button), "optionmenu9");
3171
hbox1 = lookup_widget (GTK_WIDGET (button), "hbox117");
3172
hbox2 = lookup_widget (GTK_WIDGET (button), "hbox118");
3174
menu = GTK_OPTION_MENU (option_menu)->menu;
3175
active_item = gtk_menu_get_active (GTK_MENU (menu));
3176
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
3178
if (active_index == 2) {
3179
gtk_widget_set_sensitive (hbox1, TRUE);
3180
gtk_widget_set_sensitive (hbox2, FALSE);
3182
else if (active_index == 3) {
3183
gtk_widget_set_sensitive (hbox2, TRUE);
3184
gtk_widget_set_sensitive (hbox1, TRUE);
3187
gtk_widget_set_sensitive (hbox1, FALSE);
3188
gtk_widget_set_sensitive (hbox2, FALSE);
3195
on_optionmenu16_clicked (GtkButton *button,
3198
/* GtkWidget *option_menu, *menu, *active_item;
3200
GtkWidget *hbox1, *hbox2;
3202
option_menu = lookup_widget (GTK_WIDGET (button), "optionmenu16");
3203
hbox1 = lookup_widget (GTK_WIDGET (button), "hbox117");
3204
hbox2 = lookup_widget (GTK_WIDGET (button), "hbox118");
3206
menu = GTK_OPTION_MENU (option_menu)->menu;
3207
active_item = gtk_menu_get_active (GTK_MENU (menu));
3208
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
3210
if (active_index == 4) {
3211
gtk_widget_set_sensitive (hbox1, TRUE);
3212
gtk_widget_set_sensitive (hbox2, FALSE);
3214
else if (active_index == 5) {
3215
gtk_widget_set_sensitive (hbox2, TRUE);
3216
gtk_widget_set_sensitive (hbox1, TRUE);
3219
gtk_widget_set_sensitive (hbox1, FALSE);
3220
gtk_widget_set_sensitive (hbox2, FALSE);
3227
on_optionmenu17_clicked (GtkButton *button,
3230
/* GtkWidget *option_menu, *menu, *active_item;
3232
GtkWidget *hbox1, *hbox2;
3234
option_menu = lookup_widget (GTK_WIDGET (button), "optionmenu17");
3235
hbox1 = lookup_widget (GTK_WIDGET (button), "hbox117");
3236
hbox2 = lookup_widget (GTK_WIDGET (button), "hbox118");
3238
menu = GTK_OPTION_MENU (option_menu)->menu;
3239
active_item = gtk_menu_get_active (GTK_MENU (menu));
3240
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
3242
if (active_index == 3) {
3243
gtk_widget_set_sensitive (hbox1, TRUE);
3244
gtk_widget_set_sensitive (hbox2, FALSE);
3246
else if (active_index == 4) {
3247
gtk_widget_set_sensitive (hbox2, TRUE);
3248
gtk_widget_set_sensitive (hbox1, TRUE);
3251
gtk_widget_set_sensitive (hbox1, FALSE);
3252
gtk_widget_set_sensitive (hbox2, FALSE);
3259
on_optionmenu18_clicked (GtkButton *button,
3262
/* GtkWidget *option_menu, *menu, *active_item;
3264
GtkWidget *hbox1, *hbox2;
3266
option_menu = lookup_widget (GTK_WIDGET (button), "optionmenu18");
3267
hbox1 = lookup_widget (GTK_WIDGET (button), "hbox117");
3268
hbox2 = lookup_widget (GTK_WIDGET (button), "hbox118");
3270
menu = GTK_OPTION_MENU (option_menu)->menu;
3271
active_item = gtk_menu_get_active (GTK_MENU (menu));
3272
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
3274
if (active_index == 5) {
3275
gtk_widget_set_sensitive (hbox1, TRUE);
3276
gtk_widget_set_sensitive (hbox2, FALSE);
3278
else if (active_index == 6) {
3279
gtk_widget_set_sensitive (hbox2, TRUE);
3280
gtk_widget_set_sensitive (hbox1, TRUE);
3283
gtk_widget_set_sensitive (hbox1, FALSE);
3284
gtk_widget_set_sensitive (hbox2, FALSE);
3291
on_optionmenu19_clicked (GtkButton *button,
3294
/* GtkWidget *option_menu, *menu, *active_item;
3296
GtkWidget *hbox1, *hbox2;
3298
option_menu = lookup_widget (GTK_WIDGET (button), "optionmenu19");
3299
hbox1 = lookup_widget (GTK_WIDGET (button), "hbox117");
3300
hbox2 = lookup_widget (GTK_WIDGET (button), "hbox118");
3302
menu = GTK_OPTION_MENU (option_menu)->menu;
3303
active_item = gtk_menu_get_active (GTK_MENU (menu));
3304
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
3306
if (active_index == 8) {
3307
gtk_widget_set_sensitive (hbox1, TRUE);
3308
gtk_widget_set_sensitive (hbox2, FALSE);
3310
else if (active_index == 9) {
3311
gtk_widget_set_sensitive (hbox2, TRUE);
3312
gtk_widget_set_sensitive (hbox1, TRUE);
3315
gtk_widget_set_sensitive (hbox1, FALSE);
3316
gtk_widget_set_sensitive (hbox2, FALSE);
3323
on_optionmenu14_clicked (GtkButton *button,
3326
GtkWidget *option_menu, *menu, *active_item;
3330
option_menu = lookup_widget (GTK_WIDGET (button), "optionmenu14");
3331
en = lookup_widget (GTK_WIDGET (button), "entry161");
3333
menu = GTK_OPTION_MENU (option_menu)->menu;
3334
active_item = gtk_menu_get_active (GTK_MENU (menu));
3335
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
3337
if ((active_index == 0) || (active_index == 3) || (active_index == 4) || (active_index == 5))
3338
gtk_widget_set_sensitive (en, FALSE);
3340
gtk_widget_set_sensitive (en, TRUE);
3346
on_optionmenu15_clicked (GtkButton *button,
3349
GtkWidget *option_menu, *menu, *active_item;
3353
option_menu = lookup_widget (GTK_WIDGET (button), "optionmenu15");
3354
en = lookup_widget (GTK_WIDGET (button), "entry163");
3356
menu = GTK_OPTION_MENU (option_menu)->menu;
3357
active_item = gtk_menu_get_active (GTK_MENU (menu));
3358
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
3360
if ((active_index == 0) || (active_index == 3) || (active_index == 4) || (active_index == 5))
3361
gtk_widget_set_sensitive (en, FALSE);
3363
gtk_widget_set_sensitive (en, TRUE);
3370
on_button78_clicked (GtkButton *button,
3373
entry_field_fragment = lookup_widget(GTK_WIDGET(button), "entry31");
3375
if (fragment_dialog_menu != NULL) {
3376
gdk_window_show(fragment_dialog_menu->window);
3377
gdk_window_raise(fragment_dialog_menu->window);
3380
fragment_dialog_menu = create_fragmentation_dialog();
3381
gtk_widget_show(fragment_dialog_menu);
3386
on_button79_clicked (GtkButton *button,
3393
w1 = lookup_widget(GTK_WIDGET(button), "radiobutton55");
3394
w2 = lookup_widget(GTK_WIDGET(button), "radiobutton57");
3396
if ( (GTK_TOGGLE_BUTTON(w1)->active) && (GTK_TOGGLE_BUTTON(w2)->active) )
3398
else if ( (GTK_TOGGLE_BUTTON(w1)->active) && !(GTK_TOGGLE_BUTTON(w2)->active) )
3400
else if ( !(GTK_TOGGLE_BUTTON(w1)->active) && (GTK_TOGGLE_BUTTON(w2)->active) )
3405
gtk_entry_set_max_length(GTK_ENTRY(entry_field_fragment),1);
3406
gtk_entry_set_text(GTK_ENTRY(entry_field_fragment),tmp);
3408
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
3409
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
3415
on_button80_clicked (GtkButton *button,
3418
gtk_grab_remove(gtk_widget_get_toplevel(GTK_WIDGET(button)));
3419
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
3425
on_fragmentation_dialog_destroy (GtkObject *object,
3428
fragment_dialog_menu = NULL;
3432
/* this one loads parameters from file .default... */
3434
on_Reset_button_clicked (GtkButton *button,
3441
statusbar_text(button, "");
3443
notbk = lookup_widget(GTK_WIDGET(button), "notebook1");
3444
page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notbk));
3447
if (page == 0) { /* so we have the build notebook open */
3448
if((file_p = fopen(".defaultBuilder", "r")) == NULL) {
3449
error("Can't open file with default parameters: \".defaultBuilder\"");
3453
if (load_data(button, file_p, 1, 1) == -1)
3454
;//error("Data in file \".defaultBuilder\" has wrong format");
3458
else if (page == 1) { /* so we have the Gen-b notebook open */
3459
if((file_p = fopen(".defaultGen-b", "r")) == NULL) {
3460
error("Can't open file with default parameters: \".defaultGen-b\"");
3464
if (load_gen_b_data(button, file_p) == -1)
3465
;//error("Data in file \".defaultGen-b\" has wrong format");
3469
else if (page == 2) { /* so we have the Gen-s notebook open */
3470
if((file_p = fopen(".defaultGen-s", "r")) == NULL) {
3471
error("Can't open file with default parameters: \".defaultGen-s\"");
3475
if (load_gen_s_data(button, file_p) == -1)
3476
//error("Data in file \".defaultGen-s\" has wrong format");
3479
//YYY : the above line causes a crash, I don't know why...
3482
statusbar_text(button, " Loaded default parameters");
3488
/* this sets the default parameters */
3490
on_button62_clicked (GtkButton *button,
3497
statusbar_text(button, "");
3499
notbk = lookup_widget(GTK_WIDGET(button), "notebook1");
3500
page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notbk));
3502
if (page == 0) { /* we have the build notebook open */
3503
if((file_p = fopen(".defaultBuilder", "w")) == NULL) {
3504
error("Can't save parameters in file: \".defaultBuilder\"");
3508
if (save_packet(button, user_data, file_p) == -1) {
3514
else if (page == 1) { /* we have the Gen-b notebook open */
3515
if((file_p = fopen(".defaultGen-b", "w")) == NULL) {
3516
error("Can't save parameters in file: \".defaultGen-b\"");
3520
if (save_gen_b(button, file_p) == -1) {
3526
else if (page == 2) { /* we have the Gen-s notebook open */
3527
if((file_p = fopen(".defaultGen-s", "w")) == NULL) {
3528
error("Can't save parameters in file: \".defaultGen-s\"");
3532
if (save_gen_s(button, file_p) == -1) {
3543
statusbar_text(button, " Parameters set as default parameters");
3551
on_checkbutton40_toggled (GtkToggleButton *togglebutton,
3555
txt6 = lookup_widget(GTK_WIDGET(togglebutton), "entry165");
3556
if (GTK_TOGGLE_BUTTON(togglebutton)->active)
3557
gtk_widget_set_sensitive(txt6, TRUE);
3559
gtk_widget_set_sensitive(txt6, FALSE);
3564
on_igmpmessage_type_clicked (GtkButton *button,
3567
GtkWidget *option_menu, *menu, *active_item, *opt_value, *ntbk5;
3570
option_menu = lookup_widget (GTK_WIDGET (button), "optionmenu20");
3571
opt_value = lookup_widget (GTK_WIDGET (button), "entry166");
3572
ntbk5 = lookup_widget (GTK_WIDGET (button), "notebook8");
3573
menu = GTK_OPTION_MENU (option_menu)->menu;
3574
active_item = gtk_menu_get_active (GTK_MENU (menu));
3575
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
3577
if (active_index == 0) {
3578
gtk_entry_set_text(GTK_ENTRY(opt_value), "11");
3579
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
3580
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk5), 0);
3582
else if (active_index == 1) {
3583
gtk_entry_set_text(GTK_ENTRY(opt_value), "11");
3584
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
3585
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk5), 1);
3587
else if (active_index == 2) {
3588
gtk_entry_set_text(GTK_ENTRY(opt_value), "12");
3589
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
3590
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk5), 0);
3592
else if (active_index == 3) {
3593
gtk_entry_set_text(GTK_ENTRY(opt_value), "16");
3594
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
3595
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk5), 0);
3597
else if (active_index == 4) {
3598
gtk_entry_set_text(GTK_ENTRY(opt_value), "22");
3599
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
3600
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk5), 2);
3602
else if (active_index == 5) {
3603
gtk_entry_set_text(GTK_ENTRY(opt_value), "17");
3604
gtk_editable_set_editable(GTK_EDITABLE(opt_value), FALSE);
3605
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk5), 0);
3608
gtk_entry_set_text(GTK_ENTRY(opt_value), "");
3609
gtk_editable_set_editable(GTK_EDITABLE(opt_value), TRUE);
3610
gtk_notebook_set_page(GTK_NOTEBOOK(ntbk5), 0);
3617
on_igmp_checksum_bt_toggled (GtkToggleButton *togglebutton,
3621
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry168");
3622
if (GTK_TOGGLE_BUTTON(togglebutton)->active) {
3623
gtk_widget_set_sensitive(en1, FALSE);
3624
gtk_entry_set_text(GTK_ENTRY(en1), "");
3627
gtk_widget_set_sensitive(en1, TRUE);
3632
/* this is the apply button inside IGMP header field */
3634
on_button81_clicked (GtkButton *button,
3640
char tmpmac[20], tmp[5];
3642
en1 = lookup_widget(GTK_WIDGET(button), "entry39");
3643
gtk_entry_set_text(GTK_ENTRY(en1), "94040000");
3645
en1 = lookup_widget(GTK_WIDGET(button), "entry44");
3646
gtk_entry_set_text(GTK_ENTRY(en1), "1");
3648
en1 = lookup_widget(GTK_WIDGET(button), "entry27");
3649
gtk_entry_set_text(GTK_ENTRY(en1), "6");
3651
en1 = lookup_widget(GTK_WIDGET(button), "entry37");
3652
dst_ip_t = (char *)gtk_entry_get_text(GTK_ENTRY(en1));
3654
/* check destination ip address */
3655
if (check_ip_address(dst_ip_t) == -1) {
3656
//printf("Error: Wrong destination ipv4 address format\n");
3657
error("Error: Wrong destination ipv4 address format");
3661
memset(tmpmac, 0, 20);
3662
strcat(tmpmac, "01:00:5E:");
3664
for (i=0; i<4; i++) {
3665
for(j=0; j<4 && (*dst_ip_t != '\0'); j++) {
3666
if ( ((int)*dst_ip_t == '.') && (i<3) && (j>0) ) {
3681
strcat(tmpmac, tmp);
3682
strcat(tmpmac, ":");
3687
strcat(tmpmac, tmp);
3688
strcat(tmpmac, ":");
3693
strcat(tmpmac, tmp);
3697
en1 = lookup_widget(GTK_WIDGET(button), "L_dst_mac");
3698
gtk_entry_set_text(GTK_ENTRY(en1), tmpmac);
3705
on_0x1_activate (GtkMenuItem *menuitem,
3713
on_0x2_activate (GtkMenuItem *menuitem,
3721
on_0x3_activate (GtkMenuItem *menuitem,
3729
on_0x4_activate (GtkMenuItem *menuitem,
3737
on_Gen_p_clicked (GtkButton *button,
3742
nt1 = lookup_widget(GTK_WIDGET(button), "notebook1");
3743
gtk_notebook_set_page(GTK_NOTEBOOK(nt1), 3);
3745
nt1 = lookup_widget(GTK_WIDGET(button), "Load_button");
3746
gtk_widget_set_sensitive(nt1, TRUE);
3747
nt1 = lookup_widget(GTK_WIDGET(button), "Save_button");
3748
gtk_widget_set_sensitive(nt1, FALSE);
3749
nt1 = lookup_widget(GTK_WIDGET(button), "Reset_button");
3750
gtk_widget_set_sensitive(nt1, FALSE);
3751
nt1 = lookup_widget(GTK_WIDGET(button), "button62");
3752
gtk_widget_set_sensitive(nt1, FALSE);
3753
nt1 = lookup_widget(GTK_WIDGET(button), "Interface_button");
3754
gtk_widget_set_sensitive(nt1, FALSE);
3755
nt1 = lookup_widget(GTK_WIDGET(button), "Send_button");
3756
gtk_widget_set_sensitive(nt1, FALSE);
3757
nt1 = lookup_widget(GTK_WIDGET(button), "Stop_button");
3758
gtk_widget_set_sensitive(nt1, FALSE);
3760
statusbar_text(button, " Open a Pcap file. Selected packet will be shown in Builder!");
3766
on_clist2_select_row (GtkCList *clist,
3776
/* set \0 inside the tmp field, get the length, remove the ! if present
3777
* and convert to int, and pass to load_packet_disector() */
3779
gtk_clist_get_text(GTK_CLIST(clist), row, 3, &text);
3780
memccpy(tmp, text, 32, 4);
3781
length = strtol(tmp, (char **)NULL, 10);
3783
/* Just prints some information about the selected row */
3784
//g_print("You selected row %d column %d, \ntext is %s\n", row, 7, text);
3786
gtk_clist_get_text(GTK_CLIST(clist), row, 7, &text);
3787
load_packet_disector(btx, text, 1, NULL, length);
3794
on_button84_clicked (GtkButton *button,
3800
/* calculate button clicked on Gen-s page */
3802
on_button87_clicked (GtkButton *button,
3810
long pkts[10], pktnr[10];
3812
long totalpkt=0, usdelta, minpkts=1500000, pktlen;
3815
/* dodat moraš če je slučajno prazen, al pa disablan */
3816
for(i=0; i<10; i++) {
3817
bw[i]= -1; pkts[i]= -1; pktnr[i]= -1;
3818
sprintf(ime, "entry%d", i+185);
3819
en1 = lookup_widget(GTK_WIDGET(button), ime);
3820
mbps_t = (char *)gtk_entry_get_text(GTK_ENTRY(en1));
3822
/* if there is nothing inside Mbit/s field, just skip */
3823
if(strlen(mbps_t)==0)
3826
/* if the entry is wrong, skip */
3827
//if (check_digit(mbps_t, strlen(mbps_t),
3828
// "Error: Mbit/s values\nAllowed format: 10,22") == -1) return;
3831
bw[i] = strtod((mbps_t), NULL);
3833
sprintf(ime, "entry%d", i+111);
3834
en1 = lookup_widget(GTK_WIDGET(button), ime);
3835
mbps_t = (char *)gtk_entry_get_text(GTK_ENTRY(en1));
3837
/* if the file is not ready for opening, return error */
3838
if((file_p = fopen(mbps_t, "r")) == NULL) {
3839
error("Error: can't open file for reading!");
3842
fseek(file_p, 0 , SEEK_END);
3843
pktlen = ftell(file_p)-40; /* 40 bytes is the pcap header, not nice I know, but... */
3846
/* number of packets per second */
3847
pkts[i]=bw[i]*1000000/(pktlen*8);
3849
/* remember the min value of packets per second */
3850
if (pkts[i] < minpkts )
3853
totalpkt = totalpkt + pkts[i];
3857
usdelta = 1000000/totalpkt;
3859
for(i=0; i<10; i++) {
3861
pktnr[i] = pkts[i] / minpkts;
3863
sprintf(ime, "entry%d", i+121);
3864
en1 = lookup_widget(GTK_WIDGET(button), ime);
3865
snprintf(ime, 9, "%ld", pktnr[i]);
3866
gtk_entry_set_text(GTK_ENTRY(en1), ime);
3868
sprintf(ime, "entry%d", i+131);
3869
en1 = lookup_widget(GTK_WIDGET(button), ime);
3870
snprintf(ime, 9, "%ld", usdelta);
3871
gtk_entry_set_text(GTK_ENTRY(en1), ime);
3873
sprintf(ime, "entry%d", i+141);
3874
en1 = lookup_widget(GTK_WIDGET(button), ime);
3875
snprintf(ime, 9, "%ld", usdelta);
3876
gtk_entry_set_text(GTK_ENTRY(en1), ime);
3880
//en1 = lookup_widget(GTK_WIDGET(button), "entry152");
3881
//snprintf(ime, 9, "%ld", usdelta);
3882
//gtk_entry_set_text(GTK_ENTRY(en1), ime);
3888
on_radiobutton61_toggled (GtkToggleButton *togglebutton,
3895
for(i=0; i<10; i++) {
3896
sprintf(ime, "entry%d", i+185);
3897
en1 = lookup_widget(GTK_WIDGET(togglebutton), ime);
3898
gtk_widget_set_sensitive(en1, TRUE);
3900
sprintf(ime, "entry%d", i+121);
3901
en1 = lookup_widget(GTK_WIDGET(togglebutton), ime);
3902
gtk_widget_set_sensitive(en1, FALSE);
3904
sprintf(ime, "entry%d", i+131);
3905
en1 = lookup_widget(GTK_WIDGET(togglebutton), ime);
3906
gtk_widget_set_sensitive(en1, FALSE);
3908
sprintf(ime, "entry%d", i+141);
3909
en1 = lookup_widget(GTK_WIDGET(togglebutton), ime);
3910
gtk_widget_set_sensitive(en1, FALSE);
3912
en1 = lookup_widget(GTK_WIDGET(togglebutton), "button87");
3913
gtk_widget_set_sensitive(en1, TRUE);
3915
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry152");
3916
gtk_widget_set_sensitive(en1, FALSE);
3923
on_radiobutton62_toggled (GtkToggleButton *togglebutton,
3930
for(i=0; i<10; i++) {
3931
sprintf(ime, "entry%d", i+185);
3932
en1 = lookup_widget(GTK_WIDGET(togglebutton), ime);
3933
gtk_widget_set_sensitive(en1, FALSE);
3935
sprintf(ime, "entry%d", i+121);
3936
en1 = lookup_widget(GTK_WIDGET(togglebutton), ime);
3937
gtk_widget_set_sensitive(en1, TRUE);
3939
sprintf(ime, "entry%d", i+131);
3940
en1 = lookup_widget(GTK_WIDGET(togglebutton), ime);
3941
gtk_widget_set_sensitive(en1, TRUE);
3943
sprintf(ime, "entry%d", i+141);
3944
en1 = lookup_widget(GTK_WIDGET(togglebutton), ime);
3945
gtk_widget_set_sensitive(en1, TRUE);
3947
en1 = lookup_widget(GTK_WIDGET(togglebutton), "button87");
3948
gtk_widget_set_sensitive(en1, FALSE);
3950
en1 = lookup_widget(GTK_WIDGET(togglebutton), "entry152");
3951
gtk_widget_set_sensitive(en1, TRUE);