1 /* gtk_callbacks.c
2 * GTK Callbacks
3 *
4 * Yersinia
5 * By David Barroso <tomac@yersinia.net> and Alfredo Andres <aandreswork@hotmail.com>
6 * Copyright 2005-2017 Alfredo Andres and David Barroso
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <time.h>
28
29 #ifdef TIME_WITH_SYS_TIME
30 #include <sys/time.h>
31 #endif
32
33 #include <gtk/gtk.h>
34
35 #include "gtk-callbacks.h"
36
37 #define GLADE_HOOKUP_OBJECT(component,widget,name) \
38 g_object_set_data_full (G_OBJECT (component), name, \
39 gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
40
41 #define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
42 g_object_set_data (G_OBJECT (component), name, widget)
43
44 void
gtk_c_on_file_open_activate(GtkMenuItem * menuitem,gpointer user_data)45 gtk_c_on_file_open_activate(GtkMenuItem *menuitem, gpointer user_data)
46 {
47 GtkWidget *dialog;
48 struct gtk_s_helper *helper;
49
50 helper = (struct gtk_s_helper *)user_data;
51 dialog = gtk_i_create_opendialog(helper);
52 gtk_widget_show(dialog);
53 }
54
55
56 void
gtk_c_on_file_save_activate(GtkMenuItem * menuitem,gpointer user_data)57 gtk_c_on_file_save_activate(GtkMenuItem *menuitem, gpointer user_data)
58 {
59 GtkWidget *dialog;
60 struct gtk_s_helper *helper;
61
62 helper = (struct gtk_s_helper *)user_data;
63 dialog = gtk_i_create_savedialog(helper);
64 gtk_widget_show(dialog);
65 }
66
67
68 void
gtk_c_opendialog_open(GtkWidget * button,gpointer userdata)69 gtk_c_opendialog_open(GtkWidget *button, gpointer userdata)
70 {
71 GtkWidget *dialog;
72 struct gtk_s_helper *helper;
73 char *filename;
74 u_int8_t i;
75
76 helper = (struct gtk_s_helper *)userdata;
77 dialog = lookup_widget(GTK_WIDGET(button), "opendialog");
78 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
79
80 if (strlen(filename)) {
81 strncpy(tty_tmp->config_file, filename, FILENAME_MAX);
82
83 if (parser_read_config_file(tty_tmp, helper->node) < 0) {
84 gtk_i_create_warningdialog("%s", "Error reading config file");
85 }
86
87 /* When parsing the configuration file, everything is updated in protocol[i].default_values, so
88 * now we need to copy it to the current node */
89 for (i = 0; i < MAX_PROTOCOLS; i++)
90 if (protocols[i].visible)
91 memcpy((void *)helper->node->protocol[i].tmp_data, (void *)protocols[i].default_values, protocols[i].size);
92
93 g_free(filename);
94 }
95
96 gtk_statusbar_push(GTK_STATUSBAR(helper->statusbar), 0, "Configuration file read");
97
98 gtk_widget_destroy(GTK_WIDGET(dialog));
99 }
100
101
102 void
gtk_c_savedialog_save(GtkWidget * button,gpointer userdata)103 gtk_c_savedialog_save(GtkWidget *button, gpointer userdata)
104 {
105 GtkWidget *dialog;
106 struct gtk_s_helper *helper;
107 char *filename;
108 u_int8_t i;
109
110 helper = (struct gtk_s_helper *)userdata;
111 dialog = lookup_widget(GTK_WIDGET(button), "savedialog");
112 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
113
114 if (strlen(filename)) {
115 strncpy(tty_tmp->config_file, filename, FILENAME_MAX);
116
117 for (i = 0; i < MAX_PROTOCOLS; i++)
118 if (protocols[i].visible)
119 memcpy((void *)protocols[i].default_values, (void *)helper->node->protocol[i].tmp_data, protocols[i].size);
120
121 strncpy(tty_tmp->config_file, filename, FILENAME_MAX);
122
123 if (parser_write_config_file(tty_tmp) < 0) {
124 gtk_i_create_warningdialog("%s", "Error writing config file");
125 }
126
127 g_free(filename);
128 }
129
130 gtk_statusbar_push(GTK_STATUSBAR(helper->statusbar), 0, "Configuration file written");
131
132 gtk_widget_destroy(GTK_WIDGET(dialog));
133 }
134
135
gtk_c_on_file_quit_activate(GtkMenuItem * menuitem,gpointer user_data)136 void gtk_c_on_file_quit_activate(GtkMenuItem *menuitem, gpointer user_data)
137 {
138 struct gtk_s_helper *helper = (struct gtk_s_helper *)user_data;
139
140 if ( helper->statusbar != NULL )
141 gtk_statusbar_push( GTK_STATUSBAR( helper->statusbar ), 0, "Exiting... be patient" );
142
143 gtk_main_quit();
144 }
145
146
gtk_c_statusbar_destroy(GtkWidget * widget,gpointer user_data)147 void gtk_c_statusbar_destroy( GtkWidget *widget, gpointer user_data )
148 {
149 struct gtk_s_helper *helper = (struct gtk_s_helper *)user_data;
150
151 helper->statusbar = NULL ;
152 }
153
154
155 void
on_protocols_proto1_activate(GtkMenuItem * menuitem,gpointer user_data)156 on_protocols_proto1_activate (GtkMenuItem *menuitem,
157 gpointer user_data)
158 {
159 }
160
161 /* Currently disabled...
162 void
163 gtk_c_on_protocols_toggle(GtkMenuItem *menuitem, gpointer user_data)
164 {
165 GtkWidget *n_label, *notebook, *main_statusbar;
166 u_int8_t *n_mode;
167
168 n_mode = (u_int8_t *) user_data;
169 notebook = lookup_widget(GTK_WIDGET(menuitem), "main_vhv2_notebook");
170 n_label = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), *n_mode);
171 main_statusbar = lookup_widget(GTK_WIDGET(notebook), "statusbar");
172
173 if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem))) {
174 gtk_statusbar_push(GTK_STATUSBAR(main_statusbar), 0, "Closing protocol");
175 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menuitem), FALSE);
176 gtk_widget_hide(n_label);
177 } else {
178 gtk_statusbar_push(GTK_STATUSBAR(main_statusbar), 0, "Opening protocol");
179 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
180 gtk_widget_show(n_label);
181 }
182 }
183 */
184
185 void
gtk_c_on_actions_execute_activate(GtkMenuItem * menuitem,gpointer user_data)186 gtk_c_on_actions_execute_activate(GtkMenuItem *menuitem, gpointer user_data)
187 {
188 GtkWidget *window, *notebook;
189 struct gtk_s_helper *helper;
190 u_int8_t mode;
191
192 helper = (struct gtk_s_helper *)user_data;
193 notebook = lookup_widget(GTK_WIDGET(menuitem), "main_vhv2_notebook");
194 mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
195
196 window = gtk_i_create_attacksdialog(notebook, helper, mode);
197 gtk_widget_show(window);
198 }
199
200
201 void
gtk_c_on_actions_interfaces_activate(GtkMenuItem * menuitem,gpointer user_data)202 gtk_c_on_actions_interfaces_activate (GtkMenuItem *menuitem, gpointer user_data)
203 {
204 GtkWidget *window;
205 struct gtk_s_helper *helper;
206
207 helper = (struct gtk_s_helper *)user_data;
208 window = create_interfacesdialog(helper->node);
209 gtk_widget_show(window);
210 }
211
212
gtk_c_on_menu_actions_load_default_activate(GtkMenuItem * menuitem,gpointer user_data)213 void gtk_c_on_menu_actions_load_default_activate( GtkMenuItem *menuitem, gpointer user_data )
214 {
215 struct gtk_s_helper *helper = (struct gtk_s_helper *) user_data ;
216
217 if ( helper->mode < MAX_PROTOCOLS )
218 {
219 if ( protocols[ helper->mode ].init_attribs )
220 (*protocols[ helper->mode ].init_attribs)( helper->node );
221 else
222 write_log(0, "Warning: no init_attribs for mode %d\n", helper->mode );
223
224 gtk_statusbar_push( GTK_STATUSBAR( helper->statusbar ), 0, "Loaded protocol default values");
225 }
226 }
227
228
229 void
gtk_c_on_menu_actions_list_attacks_activate(GtkMenuItem * menuitem,gpointer user_data)230 gtk_c_on_menu_actions_list_attacks_activate (GtkMenuItem *menuitem, gpointer user_data)
231 {
232 GtkWidget *window;
233 struct gtk_s_helper *helper = (struct gtk_s_helper *)user_data;
234
235 window = gtk_i_create_listattacksdialog(helper->node);
236
237 gtk_widget_show(window);
238 }
239
240
gtk_c_on_actions_clear_activate(GtkMenuItem * menuitem,gpointer user_data)241 void gtk_c_on_actions_clear_activate( GtkMenuItem *menuitem, gpointer user_data )
242 {
243 u_int8_t i;
244 char buffer[64];
245 struct gtk_s_helper *helper = (struct gtk_s_helper *)user_data;
246
247 if ( strcmp( "ALL", gtk_widget_get_name( GTK_WIDGET( menuitem ) ) ) == 0 )
248 helper->extra = PROTO_ALL;
249 else
250 {
251 for( i = 0; i < MAX_PROTOCOLS; i++ )
252 {
253 if ( strcmp( protocols[i].namep, gtk_widget_get_name( GTK_WIDGET( menuitem ) ) ) == 0 )
254 {
255 helper->extra = i;
256 break;
257 }
258 }
259 }
260
261 interfaces_clear_stats( helper->extra );
262
263 snprintf(buffer, 64, "Cleared stats for mode %s", gtk_widget_get_name( GTK_WIDGET( menuitem ) ) );
264
265 gtk_statusbar_push( GTK_STATUSBAR( helper->statusbar ), 0, buffer );
266 }
267
268
gtk_c_on_capture_activate(GtkMenuItem * menuitem,gpointer user_data)269 void gtk_c_on_capture_activate( GtkMenuItem *menuitem, gpointer user_data )
270 {
271 u_int8_t i;
272 GtkWidget *dialog;
273 struct gtk_s_helper *helper = (struct gtk_s_helper *)user_data;
274
275 if ( strcmp( "ALL", gtk_widget_get_name( GTK_WIDGET( menuitem ) ) ) == 0 )
276 helper->extra = PROTO_ALL;
277 else
278 {
279 for( i = 0; i < MAX_PROTOCOLS; i++ )
280 {
281 if ( strcmp( protocols[i].namep, gtk_widget_get_name( GTK_WIDGET( menuitem ) ) ) == 0 )
282 {
283 helper->extra = i;
284 break;
285 }
286 }
287 }
288
289 dialog = gtk_i_create_capturedialog( helper );
290
291 gtk_widget_show( dialog );
292 }
293
294
295 void
gtk_c_capturedialog_save(GtkWidget * button,gpointer userdata)296 gtk_c_capturedialog_save(GtkWidget *button, gpointer userdata)
297 {
298 GtkWidget *dialog;
299 struct gtk_s_helper *helper;
300 char *filename;
301 pcap_dumper_t *pdumper;
302 dlist_t *p;
303 struct interface_data *iface_data;
304
305 helper = (struct gtk_s_helper *)userdata;
306 dialog = lookup_widget(GTK_WIDGET(button), "savedialog");
307 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
308
309 if (helper->extra == PROTO_ALL) {
310 pdumper = helper->node->pcap_file.pdumper;
311 } else {
312 pdumper = helper->node->protocol[helper->extra].pcap_file.pdumper;
313 }
314
315 if (pdumper) {
316 gtk_i_create_warningdialog("%s", "Error: pcap_file is in use");
317 return;
318 }
319
320 /* Take the first active interface for saving data */
321 p = interfaces->list;
322 while(p) {
323 iface_data = (struct interface_data *) dlist_data(p);
324 if (iface_data->up) {
325 if (filename[0] && interfaces_pcap_file_open(helper->node, helper->extra, filename, iface_data->ifname) < 0)
326 {
327 write_log(0, "Error opening file %s to save pcap data\n", filename);
328 gtk_gui_th_exit(helper->node);
329 }
330 break;
331 }
332 else
333 p = dlist_next(interfaces->list, p);
334 }
335
336 /* No interface found*/
337 if (p == NULL)
338 gtk_i_create_warningdialog("%s", "Error: there is no active interface");
339
340 g_free(filename);
341
342 gtk_widget_destroy(GTK_WIDGET(dialog));
343 }
344
345
346 void
gtk_c_attacks_synchro(GtkNotebook * attacks_notebook,GtkNotebookPage * page,guint npage,gpointer userdata)347 gtk_c_attacks_synchro(GtkNotebook *attacks_notebook, GtkNotebookPage *page, guint npage, gpointer userdata)
348 {
349 GtkNotebook *notebook;
350
351 notebook = (GtkNotebook *)userdata;
352
353 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), npage);
354 }
355
356
gtk_c_attacks_radio_changed(GtkWidget * radio,gpointer userdata)357 void gtk_c_attacks_radio_changed( GtkWidget *radio, gpointer userdata )
358 {
359 u_int8_t i;
360 struct gtk_s_helper *helper = (struct gtk_s_helper *) userdata;;
361
362 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) )
363 {
364 if ( helper->mode < MAX_PROTOCOLS )
365 {
366 i = 0;
367
368 while( protocols[ helper->mode ].attack_def_list[i].desc )
369 {
370 if ( strcmp( gtk_button_get_label( GTK_BUTTON( radio ) ), protocols[ helper->mode ].attack_def_list[i].desc ) == 0 )
371 {
372 helper->attack_def = &protocols[ helper->mode ].attack_def_list[i];
373 helper->row = i;
374 break;
375 }
376 i++;
377 }
378 }
379 }
380 }
381
382
gtk_c_attacks_launch(GtkWidget * button,gpointer userdata)383 void gtk_c_attacks_launch( GtkWidget *button, gpointer userdata )
384 {
385 struct gtk_s_helper *helper;
386 GtkWidget *attacksdialog;
387 GtkWidget *attackparamsdialog;
388 GTK_ATTACK_PARAMS_CONTEXT *params_ctx ;
389
390 helper = (struct gtk_s_helper *)userdata;
391 attacksdialog = lookup_widget(GTK_WIDGET(button), "attacksdialog");
392
393 if ( helper->attack_def && helper->attack_def->nparams )
394 {
395 params_ctx = (GTK_ATTACK_PARAMS_CONTEXT *)malloc( sizeof( GTK_ATTACK_PARAMS_CONTEXT ) );
396
397 params_ctx->attack_status = -1 ;
398
399 params_ctx->helper = helper ;
400
401 params_ctx->nparams = helper->attack_def->nparams ;
402
403 params_ctx->vh_entry = (GtkWidget **)calloc( params_ctx->nparams, sizeof( GtkWidget * ) );
404
405 params_ctx->params_list = (struct attack_param *)calloc( 1, ( sizeof( struct attack_param ) * params_ctx->nparams ) );
406
407 memcpy( params_ctx->params_list, (void *)(helper->attack_def->param), sizeof( struct attack_param ) * params_ctx->nparams );
408
409 if ( attack_init_params( helper->node, params_ctx->params_list, params_ctx->nparams ) < 0 )
410 {
411 free( params_ctx->params_list );
412 free( params_ctx->vh_entry );
413 free( params_ctx );
414 return;
415 }
416
417 attackparamsdialog = gtk_i_create_attackparamsdialog( params_ctx );
418
419 gtk_widget_show( attackparamsdialog );
420 }
421 else
422 {
423 if ( attack_launch( helper->node, helper->mode, helper->row, NULL, 0) < 0 )
424 write_log(0, "Error launching attack %d", helper->row);
425 }
426
427 gtk_widget_destroy( attacksdialog );
428 }
429
430
gtk_c_attackparams_free(gpointer userdata)431 void gtk_c_attackparams_free( gpointer userdata )
432 {
433 GTK_ATTACK_PARAMS_CONTEXT *params_ctx = (GTK_ATTACK_PARAMS_CONTEXT *)userdata ;
434
435 gtk_widget_destroy( GTK_WIDGET( params_ctx->dialog ) );
436
437 if ( params_ctx->attack_status == -1 ) /* Attack error */
438 {
439 attack_free_params( params_ctx->params_list, params_ctx->nparams );
440
441 free( params_ctx->params_list );
442 }
443
444 free( params_ctx->vh_entry );
445
446 free( params_ctx );
447 }
448
449
gtk_c_attackparams_cancel_click(GtkWidget * button,gpointer userdata)450 void gtk_c_attackparams_cancel_click( GtkWidget *button, gpointer userdata )
451 {
452 gtk_c_attackparams_free( userdata );
453 }
454
455
gtk_c_attackparams_delete_event(GtkWidget * widget,GdkEvent * event,gpointer userdata)456 gboolean gtk_c_attackparams_delete_event( GtkWidget *widget, GdkEvent *event, gpointer userdata )
457 {
458 gtk_c_attackparams_free( userdata );
459
460 return FALSE ;
461 }
462
463
gtk_c_attackparams_ok_click(GtkWidget * button,gpointer userdata)464 void gtk_c_attackparams_ok_click( GtkWidget *button, gpointer userdata )
465 {
466 GTK_ATTACK_PARAMS_CONTEXT *params_ctx = (GTK_ATTACK_PARAMS_CONTEXT *)userdata ;
467 char *text;
468 u_int8_t i, field;
469
470 for ( i=0; i < params_ctx->nparams; i++ )
471 {
472 text = (char *)gtk_entry_get_text( GTK_ENTRY( params_ctx->vh_entry[i] ) );
473
474 strncpy( params_ctx->params_list[i].print, text, params_ctx->helper->attack_def->param[i].size_print );
475 }
476
477 if ( attack_filter_all_params( params_ctx->params_list, params_ctx->nparams, &field ) < 0 )
478 {
479 if ( params_ctx->helper->attack_def->param[field].type == FIELD_ENABLED_IFACE )
480 gtk_i_modaldialog( GTK_MESSAGE_ERROR, "Attack parameters", "Nonexistant or disabled network interface on field '%s'!!\n\nHave you enabled that interface?",
481 params_ctx->helper->attack_def->param[field].desc );
482 else
483 gtk_i_modaldialog( GTK_MESSAGE_ERROR, "Attack parameters", "Bad data on field '%s'!!", params_ctx->helper->attack_def->param[field].desc );
484 }
485 else
486 {
487 params_ctx->attack_status = attack_launch( params_ctx->helper->node, params_ctx->helper->mode, params_ctx->helper->row,
488 params_ctx->params_list, params_ctx->nparams );
489
490 if ( params_ctx->attack_status < 0 )
491 write_log(0, "Error launching attack %d", params_ctx->helper->row);
492
493 gtk_c_attackparams_free( userdata );
494 }
495 }
496
497
gtk_c_listattacks_free(gpointer userdata)498 void gtk_c_listattacks_free( gpointer userdata )
499 {
500 GTK_DIALOG_ATTACK_CONTEXT *dialog_ctx = (GTK_DIALOG_ATTACK_CONTEXT *)userdata ;
501
502 gtk_widget_destroy( GTK_WIDGET( dialog_ctx->dialog ) );
503
504 free( dialog_ctx->enabled_attacks_list );
505
506 free( dialog_ctx );
507 }
508
509
gtk_c_listattacks_stopall_click(GtkWidget * button,gpointer userdata)510 void gtk_c_listattacks_stopall_click( GtkWidget *button, gpointer userdata )
511 {
512 GTK_DIALOG_ATTACK_CONTEXT *dialog_ctx = (GTK_DIALOG_ATTACK_CONTEXT *)userdata ;
513
514 attack_kill_th( dialog_ctx->node, ALL_ATTACK_THREADS );
515
516 gtk_c_listattacks_free( userdata );
517 }
518
519
gtk_c_listattacks_stop_click(GtkWidget * button,gpointer userdata)520 void gtk_c_listattacks_stop_click( GtkWidget *button, gpointer userdata )
521 {
522 GTK_ATTACK_CONTEXT *gtk_attack_ctx = (GTK_ATTACK_CONTEXT *)userdata ;
523
524 attack_kill_index( gtk_attack_ctx->node, gtk_attack_ctx->protocol, gtk_attack_ctx->attack );
525
526 gtk_button_set_label( GTK_BUTTON( button ), "Stopped" );
527
528 gtk_widget_set_sensitive( gtk_attack_ctx->h_box, FALSE );
529 }
530
531
gtk_c_listattacks_delete_event(GtkWidget * widget,GdkEvent * event,gpointer userdata)532 gboolean gtk_c_listattacks_delete_event( GtkWidget *widget, GdkEvent *event, gpointer userdata )
533 {
534 gtk_c_listattacks_free( userdata );
535
536 return FALSE ;
537 }
538
539
gtk_c_listattacks_quit_click(GtkWidget * button,gpointer userdata)540 void gtk_c_listattacks_quit_click( GtkWidget *button, gpointer userdata )
541 {
542 gtk_c_listattacks_free( userdata );
543 }
544
545
546 void
gtk_c_update_hexview(GtkTreeSelection * selection,gpointer userdata)547 gtk_c_update_hexview(GtkTreeSelection *selection, gpointer userdata)
548 {
549 GtkWidget *textview;
550 GtkTextBuffer *buffer;
551 GtkTreeIter iter;
552 GtkTextIter iter2, start, end;
553 GtkTreeModel *model;
554 struct gtk_s_helper *helper;
555 u_int8_t row, mode, *packet;
556 u_int16_t length, oset;
557 int32_t j;
558 register u_int i;
559 register int s1, s2;
560 register int nshorts;
561 char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp;
562 char asciistuff[ASCII_LINELENGTH+1], *asp;
563 char tmp_str[70];
564 u_int32_t maxlength = HEXDUMP_SHORTS_PER_LINE;
565 gchar *out;
566
567 j = 0;
568 oset = 0;
569 length = 0;
570 packet = NULL;
571
572 helper = (struct gtk_s_helper *) userdata;
573 textview = lookup_widget(GTK_WIDGET(helper->notebook), "main_vhv2_texthex");
574 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
575
576 /* First delete the buffer */
577 gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (buffer), &start, 0);
578 gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (buffer), &end,
579 gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (buffer)));
580
581 gtk_text_buffer_delete (GTK_TEXT_BUFFER (buffer), &start, &end);
582
583 /* We need to get the pointer to the packet selected in the other window */
584 if (gtk_tree_selection_get_selected (selection, &model, &iter))
585 {
586 gtk_tree_model_get(model, &iter, 0, &row, -1);
587 } else {/* TODO: do a proper select */
588 row = 0;
589 }
590
591 gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (buffer), &iter2, 0);
592 mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(helper->notebook));
593
594 packet = protocols[mode].stats[row].packet;
595 length = (protocols[mode].stats[row].header->len < SNAPLEN) ? protocols[mode].stats[row].header->len : SNAPLEN;
596
597 nshorts = length / sizeof(u_int16_t);
598 i = 0;
599 hsp = hexstuff; asp = asciistuff;
600 while (--nshorts >= 0) {
601 s1 = *packet++;
602 s2 = *packet++;
603
604 (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
605 " %02x%02x", s1, s2);
606 hsp += HEXDUMP_HEXSTUFF_PER_SHORT;
607 *(asp++) = (isgraph(s1) ? s1 : '.');
608 *(asp++) = (isgraph(s2) ? s2 : '.');
609 i++;
610
611 if (i >= maxlength) {
612 *hsp = *asp = '\0';
613 snprintf(tmp_str, 70, "0x%04x: %-*s %s\n",
614 oset, HEXDUMP_HEXSTUFF_PER_LINE,
615 hexstuff, asciistuff);
616 /* We need to convert to valid UTF-8; if not, it is not displayed :( */
617 out = g_convert(tmp_str, -1,"UTF-8","ISO8859-1",NULL,NULL,NULL);
618
619 if (out == NULL) {
620 return; /* handle error */
621 }
622 gtk_text_buffer_insert(buffer, &iter2, out, -1);
623 g_free(out);
624 i = 0; hsp = hexstuff; asp = asciistuff;
625 oset += HEXDUMP_BYTES_PER_LINE;
626 j++;
627 }
628 }
629
630 if (length & 1) {
631 s1 = *packet++;
632 (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
633 " %02x", s1);
634 hsp += 3;
635 *(asp++) = (isgraph(s1) ? s1 : '.');
636 ++i;
637 }
638 if (i > 0) {
639 *hsp = *asp = '\0';
640 snprintf(tmp_str, 70, "0x%04x: %-*s %s\n",
641 oset, HEXDUMP_HEXSTUFF_PER_LINE,
642 hexstuff, asciistuff);
643 /* We need to convert to valid UTF-8; if not, it is not displayed :( */
644 out = g_convert(tmp_str, -1,"UTF-8","ISO8859-1",NULL,NULL,NULL);
645
646 if (out == NULL) {
647 return; /* handle error */
648 }
649 gtk_text_buffer_insert(buffer, &iter2, out, -1);
650 g_free(out);
651 }
652 }
653
on_menu_actions_clear_activate(GtkMenuItem * menuitem,GtkWidget * notebook)654 void on_menu_actions_clear_activate( GtkMenuItem *menuitem, GtkWidget *notebook )
655 {
656 GtkWidget *main_statusbar;
657 u_int8_t mode;
658
659 mode = gtk_notebook_get_current_page( GTK_NOTEBOOK( notebook ) );
660
661 if ( mode < MAX_PROTOCOLS )
662 {
663 main_statusbar = lookup_widget(GTK_WIDGET(notebook), "statusbar");
664 interfaces_clear_stats( mode );
665 gtk_statusbar_push( GTK_STATUSBAR( main_statusbar ), 0, "Mode stats cleared" );
666 }
667 }
668
gtk_c_on_menu_options_edit_toggle(GtkWidget * menu,gpointer userdata)669 void gtk_c_on_menu_options_edit_toggle (GtkWidget *menu, gpointer userdata)
670 {
671 GtkWidget *notebook, *widget, *warning;
672 struct gtk_s_helper *helper;
673 u_int8_t i, j;
674 struct commands_param *param;
675 char tmp_name[5], *text;
676
677 helper = (struct gtk_s_helper *)userdata;
678
679 if ( helper->mode < MAX_PROTOCOLS )
680 {
681 notebook = lookup_widget(GTK_WIDGET(menu), "main_vhv2_notebook");
682 if (helper->edit_mode)
683 {
684 for(i = 0; i < MAX_PROTOCOLS; i++)
685 {
686 if (protocols[i].visible)
687 {
688 param = (struct commands_param *)protocols[i].parameters;
689 for (j = 0; j < protocols[i].nparams; j++)
690 {
691 if ((param[j].type != FIELD_DEFAULT) && (param[j].type != FIELD_IFACE) && (param[j].type != FIELD_EXTRA)) {
692 snprintf(tmp_name, 5, "%02d%02d", i, j);
693 widget = lookup_widget(GTK_WIDGET(notebook), tmp_name);
694 text = (char *) gtk_entry_get_text(GTK_ENTRY(widget));
695 if (parser_filter_param(param[j].type, helper->node->protocol[i].commands_param[j],
696 text, param[j].size_print, param[j].size) < 0) {
697 warning = gtk_i_create_warningdialog("Bad Parameter %s with wrong value %s in protocol %s!",
698 param[j].ldesc, text, protocols[i].namep);
699 gtk_widget_show(warning);
700 //break;
701 }
702 gtk_entry_set_editable(GTK_ENTRY(widget), FALSE);
703 }
704 }
705 }
706 }
707 helper->edit_mode = 0;
708 gtk_statusbar_push(GTK_STATUSBAR(helper->statusbar), 0, "Edit mode disabled");
709 }
710 else
711 {
712 helper->edit_mode = 1;
713 for (i = 0; i < MAX_PROTOCOLS; i++) {
714 if (protocols[i].visible) {
715 param = (struct commands_param *)protocols[i].parameters;
716 for (j = 0; j < protocols[i].nparams; j++) {
717 if ((param[j].type != FIELD_DEFAULT) && (param[j].type != FIELD_IFACE) && (param[j].type != FIELD_EXTRA)) {
718 snprintf(tmp_name, 5, "%02d%02d", i, j);
719 widget = lookup_widget(GTK_WIDGET(notebook), tmp_name);
720 gtk_entry_set_editable(GTK_ENTRY(widget), TRUE);
721 }
722 }
723 }
724 }
725 gtk_statusbar_push(GTK_STATUSBAR(helper->statusbar), 0, "Edit mode enabled");
726 }
727 }
728 }
729
730
on_menu_options_macspoofing_toggle(GtkCheckMenuItem * menu_item,gpointer user_data)731 void on_menu_options_macspoofing_toggle( GtkCheckMenuItem *menu_item, gpointer user_data )
732 {
733 struct gtk_s_helper *helper = (struct gtk_s_helper *)user_data ;
734
735 if ( helper->node->mac_spoofing )
736 {
737 helper->node->mac_spoofing = 0;
738 gtk_statusbar_push( GTK_STATUSBAR( helper->statusbar ), 0, "MAC Spoofing set to OFF" );
739 }
740 else
741 {
742 helper->node->mac_spoofing = 1;
743 gtk_statusbar_push( GTK_STATUSBAR( helper->statusbar ), 0, "MAC Spoofing set to ON" );
744 }
745 }
746
747
748 void
gtk_c_clock_update(GtkWidget * clock)749 gtk_c_clock_update(GtkWidget *clock)
750 {
751 struct tm *aux;
752 time_t this_time;
753 char clock_str[10];
754
755 this_time = time(NULL);
756
757 aux = localtime(&this_time);
758
759 if (aux != NULL)
760 snprintf(clock_str, 10, "%02d:%02d:%02d", aux->tm_hour, aux->tm_min,
761 aux->tm_sec);
762
763 gtk_label_set_text((GtkLabel *)clock, clock_str);
764 }
765
766
767 void
gtk_c_tree_update(GtkWidget * tree_model)768 gtk_c_tree_update( GtkWidget *tree_model )
769 {
770 u_int8_t i, j;
771 GtkTreeIter iter;
772 GtkTreePath *path;
773 char tmp[3];
774
775 j = 0;
776 for( i=0; i < MAX_PROTOCOLS; i++ )
777 {
778 if (protocols[i].visible)
779 {
780 snprintf( tmp, 3, "%d", j );
781 /* Modify a particular row */
782 path = gtk_tree_path_new_from_string( tmp );
783 if ( path )
784 {
785 gtk_tree_model_get_iter( GTK_TREE_MODEL( tree_model ), &iter, path );
786 gtk_list_store_set( GTK_LIST_STORE( tree_model ), &iter, 1, protocols[i].packets, -1 );
787 gtk_tree_path_free( path );
788 }
789 j++;
790 }
791 }
792
793 snprintf( tmp, 3, "%d", j );
794 path = gtk_tree_path_new_from_string( tmp );
795 if ( path )
796 {
797 gtk_tree_model_get_iter( GTK_TREE_MODEL( tree_model ), &iter, path );
798 gtk_list_store_set( GTK_LIST_STORE( tree_model ), &iter, 1, packet_stats.global_counter.total_packets, -1 );
799 gtk_tree_path_free( path );
800 }
801 }
802
803
804 void
gtk_c_refresh_mwindow_notebook(GtkNotebook * notebook,GtkNotebookPage * page,guint npage,gpointer userdata)805 gtk_c_refresh_mwindow_notebook(GtkNotebook *notebook, GtkNotebookPage *page, guint npage, gpointer userdata)
806 {
807 struct gtk_s_helper *helper;
808
809 helper = (struct gtk_s_helper *)userdata;
810 helper->mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
811
812 /* Avoid Yersinia window log */
813 if (helper->mode != MAX_PROTOCOLS) {
814 gtk_c_tree_selection_changed_cb (helper->select, helper);
815 gtk_c_update_hexview(helper->select, helper);
816 }
817 gtk_c_refresh_mwindow(helper);
818 }
819
820
821 gboolean
gtk_c_refresh_mwindow(gpointer userdata)822 gtk_c_refresh_mwindow(gpointer userdata)
823 {
824 u_int8_t i, j, k, val, tlv;
825 char *ptrtlv;
826 char timebuf[19], meaningbuf[64], **values;
827 struct commands_param *params;
828 struct commands_param_extra *extra_params;
829 GtkTreeIter iter;
830 GtkListStore *tree_model;
831 GtkWidget *entry[20];
832 GtkNotebook *notebook;
833 struct gtk_s_helper *helper;
834 char tmp_name[5], msg[1024];
835 gboolean valid;
836
837 helper = (struct gtk_s_helper *)userdata;
838 notebook = GTK_NOTEBOOK(helper->notebook);
839 tlv = 0;
840 values = NULL;
841
842 /* Check if it is Yersinia log */
843 if ( ! helper->mode || ( helper->mode >= MAX_PROTOCOLS ) )
844 return TRUE;
845
846 params = protocols[helper->mode].parameters;
847 extra_params = protocols[helper->mode].extra_parameters;
848
849 if ((tree_model = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(protocols_tree[helper->mode])))) == NULL)
850 write_log(0, "Error in gtk_tree_view_get_model\n");
851
852 valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(tree_model), &iter);
853
854 for (i = 0; i < MAX_PACKET_STATS; i++)
855 {
856 if (protocols[helper->mode].stats[i].header->ts.tv_sec > 0)
857 {
858 /* If there isn't a row, append it */
859 if (!valid) {
860 gtk_list_store_append (GTK_LIST_STORE (tree_model), &iter);
861 }
862
863 if (protocols[helper->mode].get_printable_packet)
864 {
865 if ((values = (*protocols[helper->mode].get_printable_packet)(&protocols[helper->mode].stats[i])) == NULL)
866 {
867 write_log(0, "Error in get_printable_packet (mode %d)\n", helper->mode);
868 return FALSE;
869 }
870 }
871 else
872 {
873 write_log(0, "Warning: there is no get_printable_packet for protocol %d\n", helper->mode);
874 return FALSE;
875 }
876
877 j = 0; k = 0;
878 val = 0;
879 gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, i, -1);
880 val++;
881
882 /* Normal parameters (-2 for the interface and defaults) */
883 while (j < protocols[helper->mode].nparams)
884 {
885 if (params[j].mwindow)
886 {
887 if (params[j].meaning)
888 {
889 snprintf(meaningbuf, 64, "%s %s", values[k], parser_get_meaning(values[k], params[j].meaning));
890 gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, meaningbuf, -1);
891 } else
892 gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, values[k], -1);
893
894 val++;
895 }
896 if ((params[j].type != FIELD_IFACE) && (params[j].type != FIELD_DEFAULT) && (params[j].type != FIELD_EXTRA))
897 k++;
898
899 j++;
900 }
901 if ( protocols[helper->mode].extra_nparams > 0 )
902 {
903 tlv = k;
904 j = 0;
905 while(j < protocols[helper->mode].extra_nparams)
906 {
907 if (extra_params[j].mwindow)
908 {
909 ptrtlv = values[tlv];
910 while ((ptrtlv) && (strncmp((char *)ptrtlv, extra_params[j].ldesc, strlen(extra_params[j].ldesc)) != 0))
911 {
912 ptrtlv += strlen((char *)ptrtlv) + 1;
913 }
914
915 if (ptrtlv)
916 {
917 ptrtlv += strlen((char *)ptrtlv) + 1;
918 if (extra_params[j].meaning)
919 {
920 snprintf(meaningbuf, 64, "%s %s", ptrtlv, parser_get_meaning(ptrtlv, extra_params[j].meaning));
921 gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, meaningbuf, -1);
922 } else
923 gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, ptrtlv, -1);
924 val++;
925 } else
926 {
927 gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, "???", -1);
928 val++;
929 }
930 }
931 j++;
932 }
933 }
934
935 gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, protocols[helper->mode].stats[i].iface, -1);
936 val++;
937 gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, protocols[helper->mode].stats[i].total, -1);
938 val++;
939 strftime(timebuf, 19, "%d %b %H:%M:%S", localtime((time_t *)&protocols[helper->mode].stats[i].header->ts));
940 gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, timebuf, -1);
941
942 k = 0;
943 /* Reset values */
944 //memset((void *)values, 0, sizeof(values));
945
946 if (values)
947 {
948 while(values[k])
949 {
950 free(values[k]);
951 k++;
952 }
953 free(values);
954 }
955
956 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(tree_model), &iter);
957 } /* if (protocols->tv_sec) */
958 } /* for i < MAX_PACKET_STATS */
959
960 /* Ok, now refresh the bwindow */
961 if (!helper->edit_mode) {
962 for (i = 0; i < protocols[helper->mode].nparams; i++)
963 {
964 if ((params[i].type != FIELD_DEFAULT) && (params[i].type != FIELD_IFACE) && (params[i].type != FIELD_EXTRA))
965 {
966 snprintf(tmp_name, 5, "%02d%02d", helper->mode, i);
967 entry[i] = lookup_widget(GTK_WIDGET(notebook), tmp_name);
968 parser_binary2printable( helper->mode, i, helper->node->protocol[helper->mode].commands_param[i], msg );
969 gtk_entry_set_text(GTK_ENTRY(entry[i]), msg);
970 }
971 }
972 }
973
974 return TRUE;
975 }
976
977
gtk_c_tree_selection_changed_cb(GtkTreeSelection * selection,gpointer userdata)978 void gtk_c_tree_selection_changed_cb( GtkTreeSelection *selection, gpointer userdata )
979 {
980 GtkTreeIter iter;
981 GtkTreeModel *model;
982 GtkWidget *tree;
983 GtkListStore *tree_model;
984 u_int8_t row = 0;
985 u_int8_t j, k, mode;
986 char **values = NULL, *ptrtlv;
987 struct commands_param *params;
988 struct gtk_s_helper *helper = (struct gtk_s_helper *) userdata;
989
990 if ( gtk_tree_selection_get_selected( selection, &model, &iter ) )
991 gtk_tree_model_get(model, &iter, 0, &row, -1);
992
993 mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(helper->notebook));
994 params = (struct commands_param *)protocols[mode].parameters;
995
996 if ( protocols[mode].stats[row].header->ts.tv_sec <= 0)
997 {
998 /* write_log(0, "Ohhh no hay paquetes del modo %d, fila %d :(\n", mode, row); */
999 return;
1000 }
1001
1002 tree = lookup_widget(GTK_WIDGET(helper->notebook), "main_vhvvs_tree");
1003
1004 if ((tree_model = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))) == NULL)
1005 {
1006 write_log(0, "Error in gtk_tree_view_get_model\n");
1007 return;
1008 }
1009
1010 gtk_list_store_clear(tree_model);
1011
1012 if (protocols[mode].get_printable_packet)
1013 {
1014 values = (*protocols[mode].get_printable_packet)(&protocols[mode].stats[row]);
1015
1016 if ( ! values )
1017 {
1018 write_log(0, "Error in get_printable_packet (mode %d)\n", mode);
1019 return ;
1020 }
1021 }
1022 else
1023 {
1024 write_log(0, "Warning: there is no get_printable_packet for protocol %d\n", mode);
1025 return ;
1026 }
1027
1028 j = 0;
1029 k = 0;
1030
1031 /* Normal parameters (-2 for the interface and defaults) */
1032 while (j < protocols[mode].nparams)
1033 {
1034 if ((params[j].type != FIELD_IFACE) && (params[j].type != FIELD_DEFAULT) && (params[j].type != FIELD_EXTRA))
1035 {
1036 gtk_list_store_append(GTK_LIST_STORE(tree_model), &iter);
1037 gtk_list_store_set(GTK_LIST_STORE(tree_model), &iter, 0, params[j].ldesc, -1);
1038 gtk_list_store_set(GTK_LIST_STORE(tree_model), &iter, 1, values[k], -1);
1039 if (params[j].meaning)
1040 gtk_list_store_set( GTK_LIST_STORE( tree_model ), &iter, 2, parser_get_meaning( values[k], params[j].meaning ), -1 );
1041 k++;
1042 }
1043 j++;
1044 }
1045
1046 ptrtlv = values[k];
1047 if (protocols[mode].extra_nparams > 0)
1048 {
1049 while( ptrtlv && strlen( ptrtlv ) )
1050 {
1051 gtk_list_store_append(GTK_LIST_STORE(tree_model), &iter);
1052 gtk_list_store_set(GTK_LIST_STORE(tree_model), &iter, 0, ptrtlv, -1);
1053 ptrtlv += strlen( ptrtlv ) + 1;
1054 if (ptrtlv)
1055 {
1056 gtk_list_store_set(GTK_LIST_STORE(tree_model), &iter, 1, ptrtlv, -1);
1057 ptrtlv += strlen( ptrtlv ) + 1;
1058 }
1059 }
1060 }
1061
1062 gtk_list_store_append (GTK_LIST_STORE (tree_model), &iter);
1063 gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, 0, "Interface", -1);
1064 gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, 1, protocols[mode].stats[row].iface, -1);
1065
1066 k = 0;
1067
1068 while( values[k] )
1069 {
1070 free((void *)values[k]);
1071 k++;
1072 }
1073
1074 free(values);
1075 }
1076
1077
1078 void
gtk_c_toggle_interface(GtkWidget * toggle,struct term_node * node)1079 gtk_c_toggle_interface(GtkWidget *toggle, struct term_node *node)
1080 {
1081 gboolean state;
1082 const gchar *label;
1083 dlist_t *found;
1084 struct interface_data *iface_data, *iface_new;
1085
1086 label = gtk_button_get_label(GTK_BUTTON(toggle));
1087
1088 state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle));
1089 if (!state)
1090 {
1091 found = dlist_search(node->used_ints->list, node->used_ints->cmp, (void *)label);
1092 iface_data = (struct interface_data *) dlist_data(found);
1093 interfaces_disable(iface_data->ifname);
1094 node->used_ints->list = dlist_remove(node->used_ints->list, (void *)iface_data);
1095 }
1096 else
1097 {
1098 /* First we need to get the interface index */
1099 found = dlist_search(interfaces->list, interfaces->cmp, (void *)label);
1100
1101 if ( !found )
1102 return;
1103
1104 iface_data = (struct interface_data *) dlist_data(found);
1105
1106 interfaces_enable(iface_data->ifname);
1107 iface_new = (struct interface_data *)malloc( sizeof(struct interface_data) );
1108 if ( iface_new )
1109 {
1110 memcpy((void *)iface_new, (void *)iface_data, sizeof(struct interface_data));
1111 node->used_ints->list = dlist_append(node->used_ints->list, (void *)iface_new);
1112 }
1113 }
1114 }
1115
1116
1117 void
gtk_c_view_popup_menu(GtkWidget * menuitem,gpointer userdata)1118 gtk_c_view_popup_menu(GtkWidget *menuitem, gpointer userdata)
1119 {
1120 struct gtk_s_helper *helper = (struct gtk_s_helper *)userdata;
1121
1122 if ( protocols[ helper->mode ].load_values )
1123 {
1124 if ( ( helper->row >= 0 ) && ( helper->row < MAX_PACKET_STATS ) && ( protocols[ helper->mode ].stats[ helper->row ].packet ) )
1125 (*protocols[ helper->mode ].load_values)( (struct pcap_data *)&protocols[ helper->mode ].stats[ helper->row ],
1126 helper->node->protocol[ helper->mode ].tmp_data );
1127 else
1128 write_log(0, "WARNING: gtk_c_view_popup_menu: Mode[%d] Invalid row [%d] or NULL packet pointer!!\n", helper->mode, helper->row );
1129 }
1130 else
1131 write_log(0, "WARNING: gtk_c_view_popup_menu: No load_values callback for protocol %d\n", helper->mode);
1132 }
1133
1134
1135 gboolean
gtk_c_view_onButtonPressed(GtkWidget * treeview,GdkEventButton * event,gpointer userdata)1136 gtk_c_view_onButtonPressed (GtkWidget *treeview, GdkEventButton *event, gpointer userdata)
1137 {
1138 GtkWidget *notebook, *wmain;
1139 GtkTreeSelection *selection;
1140 GtkTreePath *path;
1141 struct gtk_s_helper *helper;
1142 gint *index;
1143 u_int8_t mode;
1144
1145 index = NULL;
1146 notebook = lookup_widget(GTK_WIDGET(treeview), "main_vhv2_notebook");
1147 wmain = lookup_widget(GTK_WIDGET(treeview), "Main");
1148 mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
1149
1150 helper = (struct gtk_s_helper *) userdata;
1151 /* single click with the right mouse button? */
1152 if (event->type == GDK_BUTTON_PRESS && event->button == 3)
1153 {
1154 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
1155
1156 if (gtk_tree_selection_count_selected_rows(selection) <= 1)
1157 {
1158 /* Get tree path for row that was clicked */
1159 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview),
1160 (gint) event->x,
1161 (gint) event->y,
1162 &path, NULL, NULL, NULL))
1163 {
1164 index = gtk_tree_path_get_indices(path);
1165 gtk_tree_selection_unselect_all(selection);
1166 gtk_tree_selection_select_path(selection, path);
1167 gtk_tree_path_free(path);
1168 }
1169 }
1170
1171 helper->mode = mode;
1172
1173 if ( index != NULL )
1174 helper->row = *index;
1175
1176 gtk_i_view_menu(treeview, wmain, event, helper);
1177
1178 return TRUE; /* we handled this */
1179 }
1180
1181 return FALSE; /* we did not handle this */
1182 }
1183
1184
1185 void
gtk_c_on_extra_button_clicked(GtkButton * button,gpointer userdata)1186 gtk_c_on_extra_button_clicked(GtkButton *button, gpointer userdata)
1187 {
1188 struct gtk_s_helper *helper;
1189 GtkWidget *extrawindow;
1190
1191 helper = (struct gtk_s_helper *)userdata;
1192
1193 extrawindow = gtk_i_create_extradialog(helper);
1194
1195 gtk_widget_show(extrawindow);
1196 }
1197
1198
1199 void
gtk_c_extra_button_add_clicked(GtkButton * button,gpointer userdata)1200 gtk_c_extra_button_add_clicked(GtkButton *button, gpointer userdata)
1201 {
1202 struct gtk_s_helper *helper;
1203 GtkWidget *window;
1204 u_int8_t proto;
1205
1206 helper = (struct gtk_s_helper *)userdata;
1207
1208 proto = gtk_notebook_get_current_page(GTK_NOTEBOOK(helper->notebook));
1209 window = gtk_i_create_add_extradialog(helper, proto);
1210 gtk_widget_show(window);
1211 }
1212
1213
1214 void
gtk_c_add_extra_button_add_ok_clicked(GtkButton * button,gpointer userdata)1215 gtk_c_add_extra_button_add_ok_clicked(GtkButton *button, gpointer userdata)
1216 {
1217 /* Do nothing */
1218 }
1219 /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=120: */
1220