forked from osmocom/wireshark
- epan/uat.h: change the UAT_PROTO_DEF macro to handle both the name of the dissector and the handle
- packet-user_encap.c: use the new UAT_PROTO_DEF - gtk/uat_gui.c: change the order of "containment" of the widgets to have the clist fields sized to the scrolledwindow instead of the whole window svn path=/trunk/; revision=21934daniel/osmux
parent
31e3747eab
commit
c22f70ec1b
|
@ -43,8 +43,11 @@
|
|||
|
||||
typedef struct _user_encap_t {
|
||||
guint encap;
|
||||
char* payload_proto_name;
|
||||
dissector_handle_t payload_proto;
|
||||
char* header_proto_name;
|
||||
dissector_handle_t header_proto;
|
||||
char* trailer_proto_name;
|
||||
dissector_handle_t trailer_proto;
|
||||
guint header_size;
|
||||
guint trailer_size;
|
||||
|
@ -127,11 +130,11 @@ static void user_update_cb(void* r _U_, const char** err _U_) {
|
|||
}
|
||||
|
||||
UAT_VS_DEF(user_encap, encap, user_encap_t, WTAP_ENCAP_USER0, ENCAP0_STR)
|
||||
UAT_PROTO_DEF(user_encap, payload_proto, user_encap_t)
|
||||
UAT_PROTO_DEF(user_encap, payload_proto, payload_proto, payload_proto_name, user_encap_t)
|
||||
UAT_DEC_CB_DEF(user_encap, header_size, user_encap_t)
|
||||
UAT_DEC_CB_DEF(user_encap, trailer_size, user_encap_t)
|
||||
UAT_PROTO_DEF(user_encap, header_proto, user_encap_t)
|
||||
UAT_PROTO_DEF(user_encap, trailer_proto, user_encap_t)
|
||||
UAT_PROTO_DEF(user_encap, header_proto, header_proto, header_proto_name, user_encap_t)
|
||||
UAT_PROTO_DEF(user_encap, trailer_proto, trailer_proto, trailer_proto_name, user_encap_t)
|
||||
|
||||
static dissector_handle_t user_encap_handle;
|
||||
|
||||
|
|
15
epan/uat.h
15
epan/uat.h
|
@ -418,15 +418,18 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
|
|||
* PROTO macros
|
||||
*/
|
||||
|
||||
#define UAT_PROTO_DEF(basename,field_name,rec_t) \
|
||||
#define UAT_PROTO_DEF(basename, field_name, dissector_field, name_field, rec_t) \
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, void* u1 _U_, void* u2 _U_) {\
|
||||
if (len) { \
|
||||
char* name = ep_strndup(buf,len); g_strdown(name); g_strchug(name); \
|
||||
((rec_t*)rec)->field_name = find_dissector(name); \
|
||||
} else { ((rec_t*)rec)->field_name = find_dissector("data"); } } \
|
||||
((rec_t*)rec)->name_field = ep_strndup(buf,len); g_strdown(((rec_t*)rec)->name_field ); g_strchug(((rec_t*)rec)->name_field); \
|
||||
((rec_t*)rec)->dissector_field = find_dissector(((rec_t*)rec)->name_field); \
|
||||
} else { \
|
||||
((rec_t*)rec)->dissector_field = find_dissector("data"); \
|
||||
((rec_t*)rec)->name_field = NULL; \
|
||||
} } \
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, void* u1 _U_, void* u2 _U_) {\
|
||||
if ( ((rec_t*)rec)->field_name ) { \
|
||||
char *name = ep_strdup(dissector_handle_get_short_name(((rec_t*)rec)->field_name)); g_strdown(name); *out_ptr = name; \
|
||||
if ( ((rec_t*)rec)->name_field ) { \
|
||||
*out_ptr = (((rec_t*)rec)->name_field); \
|
||||
*out_len = strlen(*out_ptr); \
|
||||
} else { \
|
||||
*out_ptr = ""; *out_len = 0; } }
|
||||
|
|
|
@ -912,14 +912,15 @@ static GtkWidget* uat_window(void* u) {
|
|||
|
||||
|
||||
rep->scrolledwindow = scrolled_window_new(NULL, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), rep->scrolledwindow, TRUE, TRUE, 0);
|
||||
|
||||
#if GTK_MAJOR_VERSION >= 2
|
||||
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(rep->scrolledwindow), GTK_SHADOW_IN);
|
||||
#endif
|
||||
|
||||
rep->clist = gtk_clist_new(uat->ncols);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(rep->scrolledwindow), rep->clist);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), rep->scrolledwindow, TRUE, TRUE, 0);
|
||||
|
||||
for ( colnum = 0; colnum < uat->ncols; colnum++ ) {
|
||||
gtk_clist_set_column_title(GTK_CLIST(rep->clist), colnum, f[colnum].name);
|
||||
gtk_clist_set_column_auto_resize(GTK_CLIST(rep->clist), colnum, TRUE);
|
||||
|
@ -941,8 +942,6 @@ static GtkWidget* uat_window(void* u) {
|
|||
gtk_tree_selection_set_mode(rep->selection, GTK_SELECTION_SINGLE);
|
||||
#endif
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(rep->scrolledwindow), rep->clist);
|
||||
|
||||
rep->bbox = dlg_button_row_new(GTK_STOCK_HELP, GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_CANCEL, NULL);
|
||||
|
||||
#if (GLIB_MAJOR_VERSION >= 2)
|
||||
|
|
Loading…
Reference in New Issue