Wireshark-dev: [Wireshark-dev] syntax errors are eating my time and brain though my code is alm
From: prashanth sappidi <prashanth.sappidi5@xxxxxxxxx>
Date: Sat, 8 Oct 2011 13:25:35 +0530
Hello there,
Thanks to Grahamb for suggesting me to post the email to you guys. I have got a syntax problem in ftype-integer.c. the error is...
All are same errors. Please help. For mor information please read my question in the ask.wireshark.org
http://ask.wireshark.org/questions/6768/filtering-bitwise-and-is-leading-to-linker-error
ftype-integer.c
ftype-integer.c(258) : error C2037: left of 'trig_vals' specifies undefined stru
ct/union 'trigger_structure'
ftype-integer.c(259) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(263) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(266) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(269) : error C2037: left of 'trigger_temp' specifies undefined s
truct/union 'trigger_structure'
ftype-integer.c(270) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(271) : error C2037: left of 'trigger_temp' specifies undefined s
truct/union 'trigger_structure'
ftype-integer.c(274) : error C2037: left of 'trig_vals' specifies undefined stru
ct/union 'trigger_structure'
ftype-integer.c(274) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(275) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(275) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(282) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(454) : error C2037: left of 'trig_vals' specifies undefined stru
ct/union 'trigger_structure'
ftype-integer.c(455) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(459) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(462) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(465) : error C2037: left of 'trigger_temp' specifies undefined s
truct/union 'trigger_structure'
ftype-integer.c(466) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(467) : error C2037: left of 'trigger_temp' specifies undefined s
truct/union 'trigger_structure'
ftype-integer.c(470) : error C2037: left of 'trig_vals' specifies undefined stru
ct/union 'trigger_structure'
ftype-integer.c(470) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(471) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(471) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(478) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(597) : error C2037: left of 'trig_vals' specifies undefined stru
ct/union 'trigger_structure'
ftype-integer.c(598) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(602) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(605) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(608) : error C2037: left of 'trigger_temp' specifies undefined s
truct/union 'trigger_structure'
ftype-integer.c(609) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(610) : error C2037: left of 'trigger_temp' specifies undefined s
truct/union 'trigger_structure'
ftype-integer.c(613) : error C2037: left of 'trig_vals' specifies undefined stru
ct/union 'trigger_structure'
ftype-integer.c(613) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(614) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(614) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(621) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
Thanks to Grahamb for suggesting me to post the email to you guys. I have got a syntax problem in ftype-integer.c. the error is...
All are same errors. Please help. For mor information please read my question in the ask.wireshark.org
http://ask.wireshark.org/questions/6768/filtering-bitwise-and-is-leading-to-linker-error
ftype-integer.c
ftype-integer.c(258) : error C2037: left of 'trig_vals' specifies undefined stru
ct/union 'trigger_structure'
ftype-integer.c(259) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(263) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(266) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(269) : error C2037: left of 'trigger_temp' specifies undefined s
truct/union 'trigger_structure'
ftype-integer.c(270) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(271) : error C2037: left of 'trigger_temp' specifies undefined s
truct/union 'trigger_structure'
ftype-integer.c(274) : error C2037: left of 'trig_vals' specifies undefined stru
ct/union 'trigger_structure'
ftype-integer.c(274) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(275) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(275) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(282) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(454) : error C2037: left of 'trig_vals' specifies undefined stru
ct/union 'trigger_structure'
ftype-integer.c(455) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(459) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(462) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(465) : error C2037: left of 'trigger_temp' specifies undefined s
truct/union 'trigger_structure'
ftype-integer.c(466) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(467) : error C2037: left of 'trigger_temp' specifies undefined s
truct/union 'trigger_structure'
ftype-integer.c(470) : error C2037: left of 'trig_vals' specifies undefined stru
ct/union 'trigger_structure'
ftype-integer.c(470) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(471) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(471) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(478) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(597) : error C2037: left of 'trig_vals' specifies undefined stru
ct/union 'trigger_structure'
ftype-integer.c(598) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(602) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(605) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(608) : error C2037: left of 'trigger_temp' specifies undefined s
truct/union 'trigger_structure'
ftype-integer.c(609) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
ftype-integer.c(610) : error C2037: left of 'trigger_temp' specifies undefined s
truct/union 'trigger_structure'
ftype-integer.c(613) : error C2037: left of 'trig_vals' specifies undefined stru
ct/union 'trigger_structure'
ftype-integer.c(613) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(614) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(614) : error C2037: left of 'trigger_temp2' specifies undefined
struct/union 'trigger_structure'
ftype-integer.c(621) : error C2037: left of 'restart_trigger' specifies undefine
d struct/union 'trigger_structure'
/* main_filter_toolbar.c * The filter toolbar * * $Id: main_filter_toolbar.c 34486 2010-10-12 07:41:18Z etxrab $ * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@xxxxxxxxxxxxx> * Copyright 1998 Gerald Combs * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * This file implements the "filter" toolbar for Wireshark. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <stdio.h> #include <string.h> #include <gtk/gtk.h> #include "filter_dlg.h" #include "filter_autocomplete.h" #include "epan/prefs.h" #include "keys.h" #include "gtkglobals.h" #include "stock_icons.h" #include "recent.h" #include "main.h" #include "menus.h" #include "main_toolbar.h" #include "main_filter_toolbar.h" GtkWidget *main_display_filter_widget=NULL; /* Run the current display filter on the current packet set, and redisplay. */ static void filter_activate_cb(GtkWidget *w _U_, gpointer data) { const char *s; s = gtk_entry_get_text(GTK_ENTRY(data)); main_filter_packets(&cfile, s, FALSE); } /* Enable both Clear and Apply button when filter is changed */ static void filter_changed_cb(GtkWidget *w _U_, gpointer data) { gtk_widget_set_sensitive (g_object_get_data (G_OBJECT(data), E_DFILTER_APPLY_KEY), TRUE); gtk_widget_set_sensitive (g_object_get_data (G_OBJECT(data), E_DFILTER_CLEAR_KEY), TRUE); } static void filter_reset_cb(GtkWidget *w, gpointer data _U_) { /* my_code BEGIN */ gchar *dfilter ="http"; printf("entered gtk: restart_trigger=%d\n",trig_struct->restart_trigger); if (dfilter) { GtkWidget *filter_te; int i; for(i=0;i<10;i++) trig_struct->trig_vals[i]=0;//epan/ftypes/ftypes.h triggering can be restarted if made 0. filter_te = gtk_bin_get_child(GTK_BIN(g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY))); gtk_entry_set_text(GTK_ENTRY(filter_te), dfilter); /* Run the display filter so it goes in effect. */ main_filter_packets(&cfile, dfilter, FALSE); } printf("leaving gtk: restart_trigger=%d\n",trig_struct->restart_trigger); /* my_code END */ } GtkWidget *filter_toolbar_new(void) { GtkWidget *filter_cm; GtkWidget *filter_te; GtkWidget *filter_tb; GtkTooltips *tooltips; GtkToolItem *filter_bt, *filter_add_expr_bt, *filter_reset; GtkToolItem *filter_apply, *item; /* Display filter construct dialog has an Apply button, and "OK" not only sets our text widget, it activates it (i.e., it causes us to filter the capture). */ static construct_args_t args = { "Wireshark: Display Filter", TRUE, TRUE, FALSE }; tooltips = gtk_tooltips_new(); /* filter toolbar */ filter_tb = gtk_toolbar_new(); gtk_toolbar_set_orientation(GTK_TOOLBAR(filter_tb), GTK_ORIENTATION_HORIZONTAL); g_object_set_data(G_OBJECT(top_level), E_TB_FILTER_KEY, filter_tb); gtk_widget_show(filter_tb); /* Create the "Filter:" button */ filter_bt = gtk_tool_button_new_from_stock (WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY); g_signal_connect(filter_bt, "clicked", G_CALLBACK(display_filter_construct_cb), &args); gtk_widget_show(GTK_WIDGET (filter_bt)); g_object_set_data(G_OBJECT(top_level), E_FILT_BT_PTR_KEY, filter_bt); gtk_toolbar_insert(GTK_TOOLBAR(filter_tb), filter_bt, -1); gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), GTK_WIDGET(filter_bt), "Open the \"Display Filter\" dialog, to edit/apply filters", "Private"); /* Create the filter combobox */ filter_cm = gtk_combo_box_entry_new_text (); filter_te = gtk_bin_get_child(GTK_BIN(filter_cm)); main_display_filter_widget=filter_te; g_object_set_data(G_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_te); g_object_set_data(G_OBJECT(filter_te), E_DFILTER_CM_KEY, filter_cm); g_object_set_data(G_OBJECT(top_level), E_DFILTER_CM_KEY, filter_cm); g_signal_connect(filter_te, "activate", G_CALLBACK(filter_activate_cb), filter_te); g_signal_connect(filter_te, "changed", G_CALLBACK(filter_changed_cb), filter_cm); g_signal_connect(filter_te, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL); g_object_set_data(G_OBJECT(filter_tb), E_FILT_AUTOCOMP_PTR_KEY, NULL); g_object_set_data(G_OBJECT(filter_te), E_FILT_FIELD_USE_STATUSBAR_KEY, ""); g_signal_connect(filter_te, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL); g_signal_connect(filter_tb, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL); gtk_widget_set_size_request(filter_cm, 400, -1); gtk_widget_show(filter_cm); item = gtk_tool_item_new (); gtk_container_add (GTK_CONTAINER (item), filter_cm); gtk_widget_show (GTK_WIDGET (item)); gtk_toolbar_insert(GTK_TOOLBAR(filter_tb), item, -1); /* setting a tooltip for a combobox will do nothing, so add it to the corresponding text entry */ gtk_tooltips_set_tip(tooltips, filter_cm, "Enter a display filter, or choose one of your recently used filters. " "The background color of this field is changed by a continuous syntax check " "(green is valid, red is invalid, yellow may have unexpected results).", NULL); /* Create the "Add Expression..." button, to pop up a dialog for constructing filter comparison expressions. */ filter_add_expr_bt = gtk_tool_button_new_from_stock(WIRESHARK_STOCK_ADD_EXPRESSION); g_object_set_data(G_OBJECT(filter_tb), E_FILT_FILTER_TE_KEY, filter_te); g_signal_connect(filter_add_expr_bt, "clicked", G_CALLBACK(filter_add_expr_bt_cb), filter_tb); gtk_widget_show(GTK_WIDGET(filter_add_expr_bt)); gtk_toolbar_insert(GTK_TOOLBAR(filter_tb), filter_add_expr_bt, -1); gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), GTK_WIDGET(filter_add_expr_bt), "Add an expression to this filter string", "Private"); /* Create the "Clear" button */ filter_reset = gtk_tool_button_new_from_stock(WIRESHARK_STOCK_CLEAR_EXPRESSION); g_object_set_data(G_OBJECT(filter_reset), E_DFILTER_TE_KEY, filter_te); g_object_set_data (G_OBJECT(filter_cm), E_DFILTER_CLEAR_KEY, filter_reset); g_signal_connect(filter_reset, "clicked", G_CALLBACK(filter_reset_cb), NULL); gtk_widget_set_sensitive (GTK_WIDGET(filter_reset), FALSE); gtk_widget_show(GTK_WIDGET(filter_reset)); gtk_toolbar_insert(GTK_TOOLBAR(filter_tb), filter_reset, -1); gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), GTK_WIDGET(filter_reset), "Clear this filter string and update the display", "Private"); /* Create the "Apply" button */ filter_apply = gtk_tool_button_new_from_stock(WIRESHARK_STOCK_APPLY_EXPRESSION); g_object_set_data(G_OBJECT(filter_apply), E_DFILTER_CM_KEY, filter_cm); g_object_set_data (G_OBJECT(filter_cm), E_DFILTER_APPLY_KEY, filter_apply); g_signal_connect(filter_apply, "clicked", G_CALLBACK(filter_activate_cb), filter_te); gtk_widget_set_sensitive (GTK_WIDGET(filter_apply), FALSE); gtk_widget_show(GTK_WIDGET(filter_apply)); gtk_toolbar_insert(GTK_TOOLBAR(filter_tb), filter_apply, -1); gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), GTK_WIDGET(filter_apply), "Apply this filter string to the display", "Private"); /* Sets the text entry widget pointer as the E_DILTER_TE_KEY data * of any widget that ends up calling a callback which needs * that text entry pointer */ #ifdef MAIN_MENU_USE_UIMANAGER set_menu_object_data(MENU_BAR_PATH_FILE_OPEN, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_EDIT_COPY_AS_FLT, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_DISPLAY_FLT, E_FILT_TE_PTR_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_FOLLOW_TCP_STREAM, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_FOLLOW_UDP_STREAM, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_FOLLOW_SSL_STREAM, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_APL_AS_FLT_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_APL_AS_FLT_NOT_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_APL_AS_FLT_AND_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_APL_AS_FLT_OR_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_APL_AS_FLT_AND_NOT_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_APL_AS_FLT_OR_NOT_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_PREP_A_FLT_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_PREP_A_FLT_NOT_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_PREP_A_FLT_AND_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_PREP_A_FLT_OR_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_PREP_A_FLT_AND_NOT_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data(MENU_BAR_PATH_ANALYZE_PREP_A_FLT_OR_NOT_SEL, E_DFILTER_TE_KEY, filter_te); #else set_menu_object_data_old(MENU_BAR_PATH_FILE_OPEN, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_EDIT_COPY_AS_FLT, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_DISPLAY_FLT, E_FILT_TE_PTR_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_FOLLOW_TCP_STREAM, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_FOLLOW_UDP_STREAM, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_FOLLOW_SSL_STREAM, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_APL_AS_FLT_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_APL_AS_FLT_NOT_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_APL_AS_FLT_AND_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_APL_AS_FLT_OR_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_APL_AS_FLT_AND_NOT_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_APL_AS_FLT_OR_NOT_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_PREP_A_FLT_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_PREP_A_FLT_NOT_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_PREP_A_FLT_AND_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_PREP_A_FLT_OR_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_PREP_A_FLT_AND_NOT_SEL, E_DFILTER_TE_KEY, filter_te); set_menu_object_data_old(MENU_BAR_PATH_ANALYZE_PREP_A_FLT_OR_NOT_SEL, E_DFILTER_TE_KEY, filter_te); #endif /* MAIN_MENU_USE_UIMANAGER */ set_toolbar_object_data(E_DFILTER_TE_KEY, filter_te); g_object_set_data(G_OBJECT(popup_menu_object), E_DFILTER_TE_KEY, filter_te); /* make current preferences effective */ toolbar_redraw_all(); return filter_tb; } static gboolean dfilter_entry_match(GtkWidget *filter_cm, char *s, int *index) { GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX(filter_cm)); GtkTreeIter iter; GValue value = { 0, {{0}}}; const char *filter_str; int i; i = -1; if (!gtk_tree_model_get_iter_first (model, &iter)){ *index = i; return FALSE; } do{ i++; gtk_tree_model_get_value (model, &iter, 0, &value); filter_str = g_value_get_string (&value); if(filter_str){ if(strcmp(s, filter_str) == 0){ g_value_unset (&value); *index = i; return TRUE; } } g_value_unset (&value); }while (gtk_tree_model_iter_next (model, &iter)); *index = i; return FALSE; } /* add a display filter to the combo box */ /* Note: a new filter string will not replace an old identical one */ static gboolean dfilter_combo_add(GtkWidget *filter_cm, char *s) { int index; if(!dfilter_entry_match(filter_cm,s, &index)) gtk_combo_box_append_text(GTK_COMBO_BOX(filter_cm), s); g_free(s); return TRUE; } /* write all non empty display filters (until maximum count) * of the combo box GList to the user's recent file */ void dfilter_recent_combo_write_all(FILE *rf) { GtkWidget *filter_cm = g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY); GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX(filter_cm)); GtkTreeIter iter; GValue value = { 0, {{0}}}; const char *filter_str; guint max_count = 0; if (!gtk_tree_model_get_iter_first (model, &iter)) return; do{ gtk_tree_model_get_value (model, &iter, 0, &value); filter_str = g_value_get_string (&value); if(filter_str) fprintf (rf, RECENT_KEY_DISPLAY_FILTER ": %s\n", filter_str); g_value_unset (&value); }while (gtk_tree_model_iter_next (model, &iter)&& (max_count++ < prefs.gui_recent_df_entries_max)); } /* add a display filter coming from the user's recent file to the dfilter combo box */ gboolean dfilter_combo_add_recent(gchar *s) { GtkWidget *filter_cm = g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY); char *dup; dup = g_strdup(s); return dfilter_combo_add(filter_cm, dup); } /* call cf_filter_packets() and add this filter string to the recent filter list */ gboolean main_filter_packets(capture_file *cf, const gchar *dftext, gboolean force) { GtkWidget *filter_cm = g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY); gboolean free_filter = TRUE; char *s; cf_status_t cf_status; s = g_strdup(dftext); cf_status = cf_filter_packets(cf, s, force); if (cf_status == CF_OK) { gtk_widget_set_sensitive (g_object_get_data (G_OBJECT(filter_cm), E_DFILTER_APPLY_KEY), FALSE); if (!s || strlen (s) == 0) { gtk_widget_set_sensitive (g_object_get_data (G_OBJECT(filter_cm), E_DFILTER_CLEAR_KEY), FALSE); } } if (!s) return (cf_status == CF_OK); /* GtkCombos don't let us get at their list contents easily, so we maintain our own filter list, and feed it to gtk_combo_set_popdown_strings when a new filter is added. */ if (cf_status == CF_OK && strlen(s) > 0) { int index; if(!dfilter_entry_match(filter_cm,s, &index)){ gtk_combo_box_prepend_text(GTK_COMBO_BOX(filter_cm), s); index++; } while ((guint)index >= prefs.gui_recent_df_entries_max){ gtk_combo_box_remove_text(GTK_COMBO_BOX(filter_cm), index); index--; } } if (free_filter) g_free(s); return (cf_status == CF_OK); }
/* * $Id: ftype-integer.c 37015 2011-05-08 10:23:53Z alagoutte $ * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@xxxxxxxxxxxxx> * Copyright 2001 Gerald Combs * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <stdio.h> #include <errno.h> #include "ftypes-int.h" #include <epan/addr_resolv.h> static void int_fvalue_new(fvalue_t *fv) { fv->value.uinteger = 0; } static void set_uinteger(fvalue_t *fv, guint32 value) { fv->value.uinteger = value; } static void set_sinteger(fvalue_t *fv, gint32 value) { fv->value.sinteger = value; } static guint32 get_uinteger(fvalue_t *fv) { return fv->value.uinteger; } static gint32 get_sinteger(fvalue_t *fv) { return fv->value.sinteger; } static gboolean uint_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc) { unsigned long value; char *endptr; errno = 0; value = strtoul(s, &endptr, 0); if (errno == EINVAL || endptr == s || *endptr != '\0') { /* This isn't a valid number. */ if (logfunc != NULL) logfunc("\"%s\" is not a valid number.", s); return FALSE; } if (errno == ERANGE) { if (logfunc != NULL) { if (value == ULONG_MAX) { logfunc("\"%s\" causes an integer overflow.", s); } else { /* * XXX - can "strtoul()" set errno to * ERANGE without returning ULONG_MAX? */ logfunc("\"%s\" is not an integer.", s); } } return FALSE; } if (value > G_MAXUINT32) { /* * Fits in an unsigned long, but not in a guint32 * (an unsigned long might be 64 bits). */ if (logfunc != NULL) logfunc("\"%s\" causes an integer overflow.", s); return FALSE; } fv->value.uinteger = (guint32)value; return TRUE; } static gboolean sint_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc) { long value; char *endptr; errno = 0; value = strtol(s, &endptr, 0); if (errno == EINVAL || endptr == s || *endptr != '\0') { /* This isn't a valid number. */ if (logfunc != NULL) logfunc("\"%s\" is not a valid number.", s); return FALSE; } if (errno == ERANGE) { if (logfunc != NULL) { if (value == LONG_MAX) { logfunc("\"%s\" causes an integer overflow.", s); } else { /* * XXX - can "strtol()" set errno to * ERANGE without returning ULONG_MAX? */ logfunc("\"%s\" is not an integer.", s); } } return FALSE; } if (value > G_MAXINT32) { /* * Fits in an long, but not in a gint32 * (a long might be 64 bits). */ if (logfunc != NULL) logfunc("\"%s\" causes an integer overflow.", s); return FALSE; } if (value < G_MININT32) { /* * Fits in a long, but not in a gint32 (a long might be * 64 bits). */ if (logfunc != NULL) logfunc("\"%s\" causes an integer underflow.", s); return FALSE; } fv->value.sinteger = (gint32)value; return TRUE; } static int integer_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_) { return 11; /* enough for 12^31-1, in decimal */ } static void integer_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf) { guint32 val; if (fv->value.sinteger < 0) { *buf++ = '-'; val = -fv->value.sinteger; } else val = fv->value.sinteger; guint32_to_str_buf(val, buf, 11); } static int uinteger_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_) { return 10; /* enough for 2^32-1, in decimal */ } static void uinteger_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf) { guint32_to_str_buf(fv->value.uinteger, buf, 11); } static gboolean ipxnet_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc) { guint32 val; gboolean known; /* * Don't log a message if this fails; we'll try looking it * up as an IPX network name if it does, and if that fails, * we'll log a message. */ if (uint_from_unparsed(fv, s, TRUE, NULL)) { return TRUE; } val = get_ipxnet_addr(s, &known); if (known) { fv->value.uinteger = val; return TRUE; } logfunc("\"%s\" is not a valid IPX network name or address.", s); return FALSE; } static int ipxnet_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_) { return 2+8; /* 0xXXXXXXXX */ } static void ipxnet_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf) { sprintf(buf, "0x%08x", fv->value.uinteger); } static gboolean cmp_eq(fvalue_t *a, fvalue_t *b) { return a->value.uinteger == b->value.uinteger; } static gboolean cmp_ne(fvalue_t *a, fvalue_t *b) { return a->value.uinteger != b->value.uinteger; } /*my_code BEGIN*/ static gboolean cmp_trig(fvalue_t *a, fvalue_t *b) { int i,j,loop; i = a->value.uinteger; j = b->value.uinteger; //printf("%10d\t%10d\t%10d\n",a->value.uinteger,b->value.uinteger,trig_struct.restart_trigger); for(loop=0;loop<10;loop++){ if(trig_struct.trig_vals[loop] == j){ trig_struct.restart_trigger = 1; break; } else trig_struct.restart_trigger = 0; } if(trig_struct.restart_trigger == 0){ if(i == j){ if(trig_struct.trigger_temp != j){ trig_struct.restart_trigger = 1; trig_struct.trigger_temp = j; //additional code array logic trig_struct.trig_vals[trig_struct.trigger_temp2] = j; trig_struct.trigger_temp2 = trig_struct.trigger_temp2+1; } return TRUE; } else{ trig_struct.restart_trigger = 0; return FALSE; } } else{ return TRUE; } } /*my_code END*/ static gboolean u_cmp_gt(fvalue_t *a, fvalue_t *b) { return a->value.uinteger > b->value.uinteger; } static gboolean u_cmp_ge(fvalue_t *a, fvalue_t *b) { return a->value.uinteger >= b->value.uinteger; } static gboolean u_cmp_lt(fvalue_t *a, fvalue_t *b) { return a->value.uinteger < b->value.uinteger; } static gboolean u_cmp_le(fvalue_t *a, fvalue_t *b) { return a->value.uinteger <= b->value.uinteger; } static gboolean s_cmp_gt(fvalue_t *a, fvalue_t *b) { return a->value.sinteger > b->value.sinteger; } static gboolean s_cmp_ge(fvalue_t *a, fvalue_t *b) { return a->value.sinteger >= b->value.sinteger; } static gboolean s_cmp_lt(fvalue_t *a, fvalue_t *b) { return a->value.sinteger < b->value.sinteger; } static gboolean s_cmp_le(fvalue_t *a, fvalue_t *b) { return a->value.sinteger <= b->value.sinteger; } static gboolean cmp_bitwise_and(fvalue_t *a, fvalue_t *b) { return ((a->value.uinteger & b->value.uinteger) != 0); } static void int64_fvalue_new(fvalue_t *fv) { fv->value.integer64 = 0; } static void set_integer64(fvalue_t *fv, guint64 value) { fv->value.integer64 = value; } static guint64 get_integer64(fvalue_t *fv) { return fv->value.integer64; } static gboolean val64_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc) { guint64 value; char *endptr; errno = 0; value = g_ascii_strtoull(s, &endptr, 0); if (errno == EINVAL || endptr == s || *endptr != '\0') { /* This isn't a valid number. */ if (logfunc != NULL) logfunc("\"%s\" is not a valid number.", s); return FALSE; } if (errno == ERANGE) { if (logfunc != NULL) { if (value == ULONG_MAX) { logfunc("\"%s\" causes an integer overflow.", s); } else { /* * XXX - can "strtoul()" set errno to * ERANGE without returning ULONG_MAX? */ logfunc("\"%s\" is not an integer.", s); } } return FALSE; } if (value > G_MAXUINT64) { /* * Fits in an unsigned long, but not in a guint64 * (unlikely, but not impossible). */ if (logfunc != NULL) logfunc("\"%s\" causes an integer overflow.", s); return FALSE; } fv->value.integer64 = value; return TRUE; } static int integer64_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_) { return 20; /* enough for -2^63-1, in decimal */ } static void integer64_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf) { sprintf(buf, "%" G_GINT64_MODIFIER "d", fv->value.integer64); } static int uinteger64_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_) { return 20; /* enough for 2^64-1, in decimal */ } static void uinteger64_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf) { sprintf(buf, "%" G_GINT64_MODIFIER "u", fv->value.integer64); } static gboolean cmp_eq64(fvalue_t *a, fvalue_t *b) { return a->value.integer64 == b->value.integer64; } static gboolean cmp_ne64(fvalue_t *a, fvalue_t *b) { return a->value.integer64 != b->value.integer64; } /*my_code begin*/ static gboolean cmp_trig64(fvalue_t *a, fvalue_t *b) { gint64 i,j,loop; i = a->value.integer64; j = b->value.integer64; for(loop=0;loop<10;loop++){ if(trig_struct.trig_vals[loop] == j){ trig_struct.restart_trigger = 1; break; } else trig_struct.restart_trigger = 0; } if(trig_struct.restart_trigger == 0){ if(i == j){ if(trig_struct.trigger_temp != j){ trig_struct.restart_trigger = 1; trig_struct.trigger_temp = j; //additional code array logic trig_struct.trig_vals[trig_struct.trigger_temp2] = j; trig_struct.trigger_temp2 = trig_struct.trigger_temp2+1; } return TRUE; } else{ trig_struct.restart_trigger = 0; return FALSE; } } else{ return TRUE; } } /* my_code end*/ static gboolean u_cmp_gt64(fvalue_t *a, fvalue_t *b) { return (gint64)a->value.integer64 > (gint64)b->value.integer64; } static gboolean u_cmp_ge64(fvalue_t *a, fvalue_t *b) { return (gint64)a->value.integer64 >= (gint64)b->value.integer64; } static gboolean u_cmp_lt64(fvalue_t *a, fvalue_t *b) { return (gint64)a->value.integer64 < (gint64)b->value.integer64; } static gboolean u_cmp_le64(fvalue_t *a, fvalue_t *b) { return (gint64)a->value.integer64 <= (gint64)b->value.integer64; } static gboolean s_cmp_gt64(fvalue_t *a, fvalue_t *b) { return a->value.integer64 > b->value.integer64; } static gboolean s_cmp_ge64(fvalue_t *a, fvalue_t *b) { return a->value.integer64 >= b->value.integer64; } static gboolean s_cmp_lt64(fvalue_t *a, fvalue_t *b) { return a->value.integer64 < b->value.integer64; } static gboolean s_cmp_le64(fvalue_t *a, fvalue_t *b) { return a->value.integer64 <= b->value.integer64; } static gboolean cmp_bitwise_and64(fvalue_t *a, fvalue_t *b) { return ((a->value.integer64 & b->value.integer64) != 0); } /* BOOLEAN-specific */ static void boolean_fvalue_new(fvalue_t *fv) { fv->value.uinteger = TRUE; } static int boolean_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_) { return 1; } static void boolean_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf) { *buf++ = (fv->value.uinteger) ? '1' : '0'; *buf = '\0'; } /* Checks for equality with zero or non-zero */ static gboolean bool_eq(fvalue_t *a, fvalue_t *b) { if (a->value.uinteger) { if (b->value.uinteger) { return TRUE; } else { return FALSE; } } else { if (b->value.uinteger) { return FALSE; } else { return TRUE; } } } /* Checks for inequality with zero or non-zero */ static gboolean bool_ne(fvalue_t *a, fvalue_t *b) { return (!bool_eq(a,b)); } /*my_code begin*/ static gboolean bool_trig(fvalue_t *a, fvalue_t *b) { int loop; for(loop=0;loop<10;loop++){ if(trig_struct.trig_vals[loop] == b->value.uinteger){ trig_struct.restart_trigger = 1; break; } else trig_struct.restart_trigger = 0; } if(trig_struct.restart_trigger == 0){ if(a->value.uinteger == b->value.uinteger){ if(trig_struct.trigger_temp != b->value.uinteger){ trig_struct.restart_trigger = 1; trig_struct.trigger_temp = b->value.uinteger; //additional code array logic trig_struct.trig_vals[trig_struct.trigger_temp2] = b->value.uinteger; trig_struct.trigger_temp2 = trig_struct.trigger_temp2+1; } return bool_eq(a,b); } else{ trig_struct.restart_trigger = 0; return (!bool_eq(a,b)); } } else{ return bool_eq(a,b); } } /* EUI64-specific */ static gboolean eui64_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc) { /* * Don't log a message if this fails; we'll try looking it * up as an EUI64 Address if it does, and if that fails, * we'll log a message. */ if (val64_from_unparsed(fv, s, TRUE, NULL)) { return TRUE; } logfunc("\"%s\" is not a valid EUI64 Address", s); return FALSE; } static int eui64_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_) { return 8*3-1; /* XX:XX:XX:XX:XX:XX:XX:XX */ } static void eui64_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf) { guint8 *p_eui64 = ep_alloc(8); /* Copy and convert the address to network byte order. */ *(guint64 *)(p_eui64) = pntoh64(&(fv->value.integer64)); sprintf(buf, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", p_eui64[0], p_eui64[1], p_eui64[2], p_eui64[3], p_eui64[4], p_eui64[5], p_eui64[6], p_eui64[7] ); } void ftype_register_integers(void) { static ftype_t uint8_type = { FT_UINT8, /* ftype */ "FT_UINT8", /* name */ "unsigned, 1 byte", /* pretty name */ 1, /* wire_size */ int_fvalue_new, /* new_value */ NULL, /* free_value */ uint_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ uinteger_to_repr, /* val_to_string_repr */ uinteger_repr_len, /* len_string_repr */ NULL, /* set_value */ set_uinteger, /* set_value_uinteger */ NULL, /* set_value_sinteger */ NULL, /* set_value_integer64 */ NULL, /* set_value_floating */ NULL, /* get_value */ get_uinteger, /* get_value_uinteger */ NULL, /* get_value_sinteger */ NULL, /* get_value_integer64 */ NULL, /* get_value_floating */ cmp_eq, cmp_ne, cmp_trig,/*my_code*/ u_cmp_gt, u_cmp_ge, u_cmp_lt, u_cmp_le, cmp_bitwise_and, NULL, /* cmp_contains */ NULL, /* cmp_matches */ NULL, /* len */ NULL, /* slice */ }; static ftype_t uint16_type = { FT_UINT16, /* ftype */ "FT_UINT16", /* name */ "unsigned, 2 bytes", /* pretty_name */ 2, /* wire_size */ int_fvalue_new, /* new_value */ NULL, /* free_value */ uint_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ uinteger_to_repr, /* val_to_string_repr */ uinteger_repr_len, /* len_string_repr */ NULL, /* set_value */ set_uinteger, /* set_value_uinteger */ NULL, /* set_value_sinteger */ NULL, /* set_value_integer64 */ NULL, /* set_value_floating */ NULL, /* get_value */ get_uinteger, /* get_value_integer */ NULL, /* get_value_sinteger */ NULL, /* get_value_integer64 */ NULL, /* get_value_floating */ cmp_eq, cmp_ne, cmp_trig,/*my_code*/ u_cmp_gt, u_cmp_ge, u_cmp_lt, u_cmp_le, cmp_bitwise_and, NULL, /* cmp_contains */ NULL, /* cmp_matches */ NULL, /* len */ NULL, /* slice */ }; static ftype_t uint24_type = { FT_UINT24, /* ftype */ "FT_UINT24", /* name */ "unsigned, 3 bytes", /* pretty_name */ 3, /* wire_size */ int_fvalue_new, /* new_value */ NULL, /* free_value */ uint_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ uinteger_to_repr, /* val_to_string_repr */ uinteger_repr_len, /* len_string_repr */ NULL, /* set_value */ set_uinteger, /* set_value_integer */ NULL, /* set_value_sinteger */ NULL, /* set_value_integer64 */ NULL, /* set_value_floating */ NULL, /* get_value */ get_uinteger, /* get_value_integer */ NULL, /* get_value_sinteger */ NULL, /* get_value_integer64 */ NULL, /* get_value_floating */ cmp_eq, cmp_ne, cmp_trig,/*my_code*/ u_cmp_gt, u_cmp_ge, u_cmp_lt, u_cmp_le, cmp_bitwise_and, NULL, /* cmp_contains */ NULL, /* cmp_matches */ NULL, /* len */ NULL, /* slice */ }; static ftype_t uint32_type = { FT_UINT32, /* ftype */ "FT_UINT32", /* name */ "unsigned, 4 bytes", /* pretty_name */ 4, /* wire_size */ int_fvalue_new, /* new_value */ NULL, /* free_value */ uint_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ uinteger_to_repr, /* val_to_string_repr */ uinteger_repr_len, /* len_string_repr */ NULL, /* set_value */ set_uinteger, /* set_value_uinteger */ NULL, /* set_value_sinteger */ NULL, /* set_value_integer64 */ NULL, /* set_value_floating */ NULL, /* get_value */ get_uinteger, /* get_value_integer */ NULL, /* get_value_sinteger */ NULL, /* get_value_integer64 */ NULL, /* get_value_floating */ cmp_eq, cmp_ne, cmp_trig,/*my_code*/ u_cmp_gt, u_cmp_ge, u_cmp_lt, u_cmp_le, cmp_bitwise_and, NULL, /* cmp_contains */ NULL, /* cmp_matches */ NULL, /* len */ NULL, /* slice */ }; static ftype_t uint64_type = { FT_UINT64, /* ftype */ "FT_UINT64", /* name */ "unsigned, 8 bytes", /* pretty_name */ 8, /* wire_size */ int64_fvalue_new, /* new_value */ NULL, /* free_value */ val64_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ uinteger64_to_repr, /* val_to_string_repr */ uinteger64_repr_len, /* len_string_repr */ NULL, /* set_value */ NULL, /* set_value_uinteger */ NULL, /* set_value_sinteger */ set_integer64, /* set_value_integer64 */ NULL, /* set_value_floating */ NULL, /* get_value */ NULL, /* get_value_uinteger */ NULL, /* get_value_sinteger */ get_integer64, /* get_value_integer64 */ NULL, /* get_value_floating */ cmp_eq64, cmp_ne64, cmp_trig64,/*my_code*/ u_cmp_gt64, u_cmp_ge64, u_cmp_lt64, u_cmp_le64, cmp_bitwise_and64, NULL, /* cmp_contains */ NULL, /* cmp_matches */ NULL, NULL, }; static ftype_t int8_type = { FT_INT8, /* ftype */ "FT_INT8", /* name */ "signed, 1 byte", /* pretty_name */ 1, /* wire_size */ int_fvalue_new, /* new_value */ NULL, /* free_value */ sint_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ integer_to_repr, /* val_to_string_repr */ integer_repr_len, /* len_string_repr */ NULL, /* set_value */ NULL, /* set_value_uinteger */ set_sinteger, /* set_value_sinteger */ NULL, /* set_value_integer64 */ NULL, /* set_value_floating */ NULL, /* get_value */ NULL, /* get_value_uinteger */ get_sinteger, /* get_value_sinteger */ NULL, /* get_value_integer64 */ NULL, /* get_value_floating */ cmp_eq, cmp_ne, cmp_trig,/*my_code*/ s_cmp_gt, s_cmp_ge, s_cmp_lt, s_cmp_le, cmp_bitwise_and, NULL, /* cmp_contains */ NULL, /* cmp_matches */ NULL, /* len */ NULL, /* slice */ }; static ftype_t int16_type = { FT_INT16, /* ftype */ "FT_INT16", /* name */ "signed, 2 bytes", /* pretty_name */ 2, /* wire_size */ int_fvalue_new, /* new_value */ NULL, /* free_value */ sint_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ integer_to_repr, /* val_to_string_repr */ integer_repr_len, /* len_string_repr */ NULL, /* set_value */ NULL, /* set_value_uinteger */ set_sinteger, /* set_value_sinteger */ NULL, /* set_value_integer64 */ NULL, /* set_value_floating */ NULL, /* get_value */ NULL, /* get_value_uinteger */ get_sinteger, /* get_value_sinteger */ NULL, /* get_value_integer64 */ NULL, /* get_value_floating */ cmp_eq, cmp_ne, cmp_trig,/*my_code*/ s_cmp_gt, s_cmp_ge, s_cmp_lt, s_cmp_le, cmp_bitwise_and, NULL, /* cmp_contains */ NULL, /* cmp_matches */ NULL, /* len */ NULL, /* slice */ }; static ftype_t int24_type = { FT_INT24, /* ftype */ "FT_INT24", /* name */ "signed, 3 bytes", /* pretty_name */ 3, /* wire_size */ int_fvalue_new, /* new_value */ NULL, /* free_value */ sint_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ integer_to_repr, /* val_to_string_repr */ integer_repr_len, /* len_string_repr */ NULL, /* set_value */ NULL, /* set_value_uinteger */ set_sinteger, /* set_value_sinteger */ NULL, /* set_value_integer64 */ NULL, /* set_value_floating */ NULL, /* get_value */ NULL, /* get_value_uinteger */ get_sinteger, /* get_value_integer */ NULL, /* get_value_integer64 */ NULL, /* get_value_floating */ cmp_eq, cmp_ne, cmp_trig,/*my_code*/ s_cmp_gt, s_cmp_ge, s_cmp_lt, s_cmp_le, cmp_bitwise_and, NULL, /* cmp_contains */ NULL, /* cmp_matches */ NULL, /* len */ NULL, /* slice */ }; static ftype_t int32_type = { FT_INT32, /* ftype */ "FT_INT32", /* name */ "signed, 4 bytes", /* pretty_name */ 4, /* wire_size */ int_fvalue_new, /* new_value */ NULL, /* free_value */ sint_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ integer_to_repr, /* val_to_string_repr */ integer_repr_len, /* len_string_repr */ NULL, /* set_value */ NULL, /* set_value_uinteger */ set_sinteger, /* set_value_sinteger */ NULL, /* set_value_integer64 */ NULL, /* set_value_floating */ NULL, /* get_value */ NULL, /* get_value_uinteger */ get_sinteger, /* get_value_sinteger */ NULL, /* get_value_integer64 */ NULL, /* get_value_floating */ cmp_eq, cmp_ne, cmp_trig,/*my_code*/ s_cmp_gt, s_cmp_ge, s_cmp_lt, s_cmp_le, cmp_bitwise_and, NULL, /* cmp_contains */ NULL, /* cmp_matches */ NULL, /* len */ NULL, /* slice */ }; static ftype_t int64_type = { FT_INT64, /* ftype */ "FT_INT64", /* name */ "signed, 8 bytes", /* pretty_name */ 8, /* wire_size */ int64_fvalue_new, /* new_value */ NULL, /* free_value */ val64_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ integer64_to_repr, /* val_to_string_repr */ integer64_repr_len, /* len_string_repr */ NULL, /* set_value */ NULL, /* set_value_uinteger */ NULL, /* set_value_sinteger */ set_integer64, /* set_value_integer64 */ NULL, /* set_value_floating */ NULL, /* get_value */ NULL, /* get_value_uinteger */ NULL, /* get_value_sinteger */ get_integer64, /* get_value_integer64 */ NULL, /* get_value_floating */ cmp_eq64, cmp_ne64, cmp_trig64,/*my_code*/ s_cmp_gt64, s_cmp_ge64, s_cmp_lt64, s_cmp_le64, cmp_bitwise_and64, NULL, /* cmp_contains */ NULL, /* cmp_matches */ NULL, NULL, }; static ftype_t boolean_type = { FT_BOOLEAN, /* ftype */ "FT_BOOLEAN", /* name */ "Boolean", /* pretty_name */ 0, /* wire_size */ boolean_fvalue_new, /* new_value */ NULL, /* free_value */ uint_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ boolean_to_repr, /* val_to_string_repr */ boolean_repr_len, /* len_string_repr */ NULL, /* set_value */ set_uinteger, /* set_value_uinteger */ NULL, /* set_value_sinteger */ NULL, /* set_value_integer64 */ NULL, /* set_value_floating */ NULL, /* get_value */ get_uinteger, /* get_value_uinteger */ NULL, /* get_value_sinteger */ NULL, /* get_value_integer64 */ NULL, /* get_value_floating */ bool_eq, /* cmp_eq */ bool_ne, /* cmp_ne */ bool_trig,/*my_code*/ NULL, /* cmp_gt */ NULL, /* cmp_ge */ NULL, /* cmp_lt */ NULL, /* cmp_le */ NULL, /* cmp_bitwise_and */ NULL, /* cmp_contains */ NULL, /* cmp_matches */ NULL, /* len */ NULL, /* slice */ }; static ftype_t ipxnet_type = { FT_IPXNET, /* ftype */ "FT_IPXNET", /* name */ "IPX network number", /* pretty_name */ 4, /* wire_size */ int_fvalue_new, /* new_value */ NULL, /* free_value */ ipxnet_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ ipxnet_to_repr, /* val_to_string_repr */ ipxnet_repr_len, /* len_string_repr */ NULL, /* set_value */ set_uinteger, /* set_value_uinteger */ NULL, /* get_value_sinteger */ NULL, /* set_value_integer64 */ NULL, /* set_value_floating */ NULL, /* get_value */ get_uinteger, /* get_value_uinteger */ NULL, /* get_value_sinteger */ NULL, /* get_value_integer64 */ NULL, /* get_value_floating */ cmp_eq, cmp_ne, cmp_trig,/*my_code*/ u_cmp_gt, u_cmp_ge, u_cmp_lt, u_cmp_le, cmp_bitwise_and, NULL, /* cmp_contains */ NULL, /* cmp_matches */ NULL, /* len */ NULL, /* slice */ }; static ftype_t framenum_type = { FT_FRAMENUM, /* ftype */ "FT_FRAMENUM", /* name */ "frame number", /* pretty_name */ 4, /* wire_size */ int_fvalue_new, /* new_value */ NULL, /* free_value */ uint_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ uinteger_to_repr, /* val_to_string_repr */ uinteger_repr_len, /* len_string_repr */ NULL, /* set_value */ set_uinteger, /* set_value_uinteger */ NULL, /* set_value_sinteger */ NULL, /* set_value_integer64 */ NULL, /* set_value_floating */ NULL, /* get_value */ get_uinteger, /* get_value_uinteger */ NULL, /* get_value_sinteger */ NULL, /* get_value_integer64 */ NULL, /* get_value_floating */ cmp_eq, cmp_ne, cmp_trig,/*my_code*/ u_cmp_gt, u_cmp_ge, u_cmp_lt, u_cmp_le, NULL, /* cmp_bitwise_and */ NULL, /* cmp_contains */ NULL, /* cmp_matches */ NULL, /* len */ NULL, /* slice */ }; static ftype_t eui64_type = { FT_EUI64, /* ftype */ "FT_EUI64", /* name */ "EUI64 address", /* pretty_name */ FT_EUI64_LEN, /* wire_size */ int64_fvalue_new, /* new_value */ NULL, /* free_value */ eui64_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ eui64_to_repr, /* val_to_string_repr */ eui64_repr_len, /* len_string_repr */ NULL, /* set_value */ NULL, /* set_value_uinteger */ NULL, /* set_value_sinteger */ set_integer64, /* set_value_integer64 */ NULL, /* set_value_floating */ NULL, /* get_value */ NULL, /* get_value_uinteger */ NULL, /* get_value_sinteger */ get_integer64, /* get_value_integer64 */ NULL, /* get_value_floating */ cmp_eq64, cmp_ne64, cmp_trig64,/*my_code*/ u_cmp_gt64, u_cmp_ge64, u_cmp_lt64, u_cmp_le64, cmp_bitwise_and64, NULL, /* cmp_contains */ NULL, /* cmp_matches */ NULL, NULL, }; ftype_register(FT_UINT8, &uint8_type); ftype_register(FT_UINT16, &uint16_type); ftype_register(FT_UINT24, &uint24_type); ftype_register(FT_UINT32, &uint32_type); ftype_register(FT_UINT64, &uint64_type); ftype_register(FT_INT8, &int8_type); ftype_register(FT_INT16, &int16_type); ftype_register(FT_INT24, &int24_type); ftype_register(FT_INT32, &int32_type); ftype_register(FT_INT64, &int64_type); ftype_register(FT_BOOLEAN, &boolean_type); ftype_register(FT_IPXNET, &ipxnet_type); ftype_register(FT_FRAMENUM, &framenum_type); ftype_register(FT_EUI64, &eui64_type); }
/* ftypes.h * Definitions for field types * * $Id: ftypes.h 37030 2011-05-09 12:52:55Z darkjames $ * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@xxxxxxxxxxxxx> * Copyright 2001 Gerald Combs * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef FTYPES_H #define FTYPES_H #include <glib.h> #include "../emem.h" /* MY_CODE BEGIN */ typedef struct _trigger_structure { int restart_trigger; gint64 trigger_temp; int trigger_temp2; gint64 trig_vals[10]; }trigger_structure; WS_VAR_IMPORT struct trigger_structure trig_struct; /* MY_CODE END */ /* field types */ enum ftenum { FT_NONE, /* used for text labels with no value */ FT_PROTOCOL, FT_BOOLEAN, /* TRUE and FALSE come from <glib.h> */ FT_UINT8, FT_UINT16, FT_UINT24, /* really a UINT32, but displayed as 3 hex-digits if FD_HEX*/ FT_UINT32, FT_UINT64, FT_INT8, FT_INT16, FT_INT24, /* same as for UINT24 */ FT_INT32, FT_INT64, FT_FLOAT, FT_DOUBLE, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME, FT_STRING, FT_STRINGZ, /* for use with proto_tree_add_item() */ FT_EBCDIC, /* for use with proto_tree_add_item() */ FT_UINT_STRING, /* for use with proto_tree_add_item() */ /*FT_UCS2_LE, */ /* Unicode, 2 byte, Little Endian */ FT_ETHER, FT_BYTES, FT_UINT_BYTES, FT_IPv4, FT_IPv6, FT_IPXNET, FT_FRAMENUM, /* a UINT32, but if selected lets you go to frame with that number */ FT_PCRE, /* a compiled Perl-Compatible Regular Expression object */ FT_GUID, /* GUID, UUID */ FT_OID, /* OBJECT IDENTIFIER */ FT_EUI64, FT_NUM_TYPES /* last item number plus one */ }; #define IS_FT_INT(ft) ((ft)==FT_INT8||(ft)==FT_INT16||(ft)==FT_INT24||(ft)==FT_INT32||(ft)==FT_INT64) #define IS_FT_UINT(ft) ((ft)==FT_UINT8||(ft)==FT_UINT16||(ft)==FT_UINT24||(ft)==FT_UINT32||(ft)==FT_UINT64||(ft)==FT_FRAMENUM) #define IS_FT_TIME(ft) ((ft)==FT_ABSOLUTE_TIME||(ft)==FT_RELATIVE_TIME) #define IS_FT_STRING(ft) ((ft)==FT_STRING||(ft)==FT_STRINGZ) /* field types lengths */ #define FT_ETHER_LEN 6 #define FT_GUID_LEN 16 #define FT_IPv4_LEN 4 #define FT_IPv6_LEN 16 #define FT_IPXNET_LEN 4 #define FT_EUI64_LEN 8 typedef enum ftenum ftenum_t; typedef struct _ftype_t ftype_t; /* String representation types. */ enum ftrepr { FTREPR_DISPLAY, FTREPR_DFILTER }; typedef enum ftrepr ftrepr_t; #ifdef HAVE_LIBPCRE typedef struct _pcre_tuple_t pcre_tuple_t; #endif /* HAVE_LIBPCRE */ /* Initialize the ftypes subsytem. Called once. */ void ftypes_initialize(void); /* ---------------- FTYPE ----------------- */ /* Return a string representing the name of the type */ const char* ftype_name(ftenum_t ftype); /* Return a string presenting a "pretty" representation of the * name of the type. The pretty name means more to the user than * that "FT_*" name. */ const char* ftype_pretty_name(ftenum_t ftype); /* Returns length of field in packet, or 0 if not determinable/defined. */ int ftype_length(ftenum_t ftype); gboolean ftype_can_slice(enum ftenum ftype); gboolean ftype_can_eq(enum ftenum ftype); gboolean ftype_can_ne(enum ftenum ftype); gboolean ftype_can_trig(enum ftenum ftype);/*MY_CODE*/ gboolean ftype_can_gt(enum ftenum ftype); gboolean ftype_can_ge(enum ftenum ftype); gboolean ftype_can_lt(enum ftenum ftype); gboolean ftype_can_le(enum ftenum ftype); gboolean ftype_can_bitwise_and(enum ftenum ftype); gboolean ftype_can_contains(enum ftenum ftype); gboolean ftype_can_matches(enum ftenum ftype); /* ---------------- FVALUE ----------------- */ #include <epan/ipv4.h> #include <epan/guid-utils.h> #include <epan/tvbuff.h> #include <epan/nstime.h> #include <epan/dfilter/drange.h> typedef struct _fvalue_t { ftype_t *ftype; union { /* Put a few basic types in here */ guint32 uinteger; gint32 sinteger; guint64 integer64; gdouble floating; gchar *string; guchar *ustring; GByteArray *bytes; ipv4_addr ipv4; e_guid_t guid; nstime_t time; tvbuff_t *tvb; #ifdef HAVE_LIBPCRE pcre_tuple_t *re; #elif GLIB_CHECK_VERSION(2,14,0) /* Try falling back to GRegex. */ GRegex *re; #endif /* HAVE_LIBPCRE */ } value; /* The following is provided for private use * by the fvalue. */ gboolean fvalue_gboolean1; } fvalue_t; typedef void (*FvalueNewFunc)(fvalue_t*); typedef void (*FvalueFreeFunc)(fvalue_t*); typedef void (*LogFunc)(const char*,...); typedef gboolean (*FvalueFromUnparsed)(fvalue_t*, char*, gboolean, LogFunc); typedef gboolean (*FvalueFromString)(fvalue_t*, char*, LogFunc); typedef void (*FvalueToStringRepr)(fvalue_t*, ftrepr_t, char*); typedef int (*FvalueStringReprLen)(fvalue_t*, ftrepr_t); typedef void (*FvalueSetFunc)(fvalue_t*, gpointer, gboolean); typedef void (*FvalueSetUnsignedIntegerFunc)(fvalue_t*, guint32); typedef void (*FvalueSetSignedIntegerFunc)(fvalue_t*, gint32); typedef void (*FvalueSetInteger64Func)(fvalue_t*, guint64); typedef void (*FvalueSetFloatingFunc)(fvalue_t*, gdouble); typedef gpointer (*FvalueGetFunc)(fvalue_t*); typedef guint32 (*FvalueGetUnsignedIntegerFunc)(fvalue_t*); typedef gint32 (*FvalueGetSignedIntegerFunc)(fvalue_t*); typedef guint64 (*FvalueGetInteger64Func)(fvalue_t*); typedef double (*FvalueGetFloatingFunc)(fvalue_t*); typedef gboolean (*FvalueCmp)(fvalue_t*, fvalue_t*); typedef guint (*FvalueLen)(fvalue_t*); typedef void (*FvalueSlice)(fvalue_t*, GByteArray *, guint offset, guint length); struct _ftype_t { ftenum_t ftype; const char *name; const char *pretty_name; int wire_size; FvalueNewFunc new_value; FvalueFreeFunc free_value; FvalueFromUnparsed val_from_unparsed; FvalueFromString val_from_string; FvalueToStringRepr val_to_string_repr; FvalueStringReprLen len_string_repr; /* could be union */ FvalueSetFunc set_value; FvalueSetUnsignedIntegerFunc set_value_uinteger; FvalueSetSignedIntegerFunc set_value_sinteger; FvalueSetInteger64Func set_value_integer64; FvalueSetFloatingFunc set_value_floating; /* could be union */ FvalueGetFunc get_value; FvalueGetUnsignedIntegerFunc get_value_uinteger; FvalueGetSignedIntegerFunc get_value_sinteger; FvalueGetInteger64Func get_value_integer64; FvalueGetFloatingFunc get_value_floating; FvalueCmp cmp_eq; FvalueCmp cmp_ne; FvalueCmp cmp_trig;/*MY_CODE*/ FvalueCmp cmp_gt; FvalueCmp cmp_ge; FvalueCmp cmp_lt; FvalueCmp cmp_le; FvalueCmp cmp_bitwise_and; FvalueCmp cmp_contains; FvalueCmp cmp_matches; FvalueLen len; FvalueSlice slice; }; fvalue_t* fvalue_new(ftenum_t ftype); void fvalue_init(fvalue_t *fv, ftenum_t ftype); /* Free all memory used by an fvalue_t. With MSVC and a * libwireshark.dll, we need a special declaration. */ WS_VAR_IMPORT struct ws_memory_slab fvalue_t_slab; #define FVALUE_CLEANUP(fv) \ { \ register FvalueFreeFunc free_value; \ free_value = (fv)->ftype->free_value; \ if (free_value) { \ free_value((fv)); \ } \ } #define FVALUE_FREE(fv) \ { \ FVALUE_CLEANUP(fv) \ sl_free(&fvalue_t_slab, fv); \ } fvalue_t* fvalue_from_unparsed(ftenum_t ftype, char *s, gboolean allow_partial_value, LogFunc logfunc); fvalue_t* fvalue_from_string(ftenum_t ftype, char *s, LogFunc logfunc); /* Returns the length of the string required to hold the * string representation of the the field value. * * Returns -1 if the string cannot be represented in the given rtype. * * The length DOES NOT include the terminating NUL. */ int fvalue_string_repr_len(fvalue_t *fv, ftrepr_t rtype); /* Creates the string representation of the field value. * If given non-NULL 'buf', the string is written at the memory * location pointed to by 'buf'. If 'buf' is NULL, new memory * is malloc'ed and the string representation is written there. * The pointer to the beginning of the string representation is * returned. If 'buf' was NULL, this points to the newly-allocated * memory. if 'buf' was non-NULL, then the return value will be * 'buf'. * * Returns NULL if the string cannot be represented in the given rtype.*/ extern char * fvalue_to_string_repr(fvalue_t *fv, ftrepr_t rtype, char *buf); ftype_t* fvalue_ftype(fvalue_t *fv); const char* fvalue_type_name(fvalue_t *fv); void fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied); void fvalue_set_uinteger(fvalue_t *fv, guint32 value); void fvalue_set_sinteger(fvalue_t *fv, gint32 value); void fvalue_set_integer64(fvalue_t *fv, guint64 value); void fvalue_set_floating(fvalue_t *fv, gdouble value); gpointer fvalue_get(fvalue_t *fv); extern guint32 fvalue_get_uinteger(fvalue_t *fv); extern gint32 fvalue_get_sinteger(fvalue_t *fv); guint64 fvalue_get_integer64(fvalue_t *fv); extern double fvalue_get_floating(fvalue_t *fv); gboolean fvalue_eq(fvalue_t *a, fvalue_t *b); gboolean fvalue_ne(fvalue_t *a, fvalue_t *b); gboolean fvalue_trig(fvalue_t *a, fvalue_t *b);/*MY_CODE*/ gboolean fvalue_gt(fvalue_t *a, fvalue_t *b); gboolean fvalue_ge(fvalue_t *a, fvalue_t *b); gboolean fvalue_lt(fvalue_t *a, fvalue_t *b); gboolean fvalue_le(fvalue_t *a, fvalue_t *b); gboolean fvalue_bitwise_and(fvalue_t *a, fvalue_t *b); gboolean fvalue_contains(fvalue_t *a, fvalue_t *b); gboolean fvalue_matches(fvalue_t *a, fvalue_t *b); guint fvalue_length(fvalue_t *fv); fvalue_t* fvalue_slice(fvalue_t *fv, drange *dr); #endif /* ftypes.h */
Attachment:
libwireshark.def
Description: Binary data
- Follow-Ups:
- Prev by Date: [Wireshark-dev] Correct and efficient way of displaying bit fields?
- Next by Date: Re: [Wireshark-dev] Correct and efficient way of displaying bit fields?
- Previous by thread: Re: [Wireshark-dev] Correct and efficient way of displaying bit fields?
- Next by thread: Re: [Wireshark-dev] syntax errors are eating my time and brain though my code is almost correct
- Index(es):