packet-mausb.c: proto-reg-handoff() fixes

- proto_reg_handoff...():
    Fix handling of tcp port pref change;
    Rename 'gPORT_PREF' to 'mausb_tcp_port_pref';
    Do 'dissector_add_uint("llc.mausb_pid",..)' only once;

Change-Id: Ic4498560f61d0ce95f8109c3a1bb3c407221269b
Reviewed-on: https://code.wireshark.org/review/3854
Reviewed-by: Bill Meier <wmeier@newsguy.com>
This commit is contained in:
Bill Meier 2014-08-25 22:39:59 -04:00
parent cac381b3de
commit f4b135c147
1 changed files with 8 additions and 6 deletions

View File

@ -630,7 +630,7 @@ static guint mausb_get_pkt_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset
}
/* Global Port Preference */
static unsigned int gPORT_PREF = 0;
static unsigned int mausb_tcp_port_pref = 0;
/* Initialize the subtree pointers */
static gint ett_mausb = -1;
@ -1870,7 +1870,7 @@ proto_register_mausb(void)
/* Register TCP port preference */
prefs_register_uint_preference(mausb_module, "tcp.port", "MAUSB TCP Port",
"Set the port for Media Agnostic Packets",
10, &gPORT_PREF);
10, &mausb_tcp_port_pref);
}
@ -1879,9 +1879,10 @@ proto_reg_handoff_mausb(void)
{
static gboolean initialized = FALSE;
static dissector_handle_t mausb_tcp_handle;
static dissector_handle_t mausb_snap_handle;
static guint saved_mausb_tcp_port_pref;
if (!initialized) {
dissector_handle_t mausb_snap_handle;
/* only initialize once */
mausb_tcp_handle = new_create_dissector_handle(dissect_mausb,
proto_mausb);
@ -1889,15 +1890,16 @@ proto_reg_handoff_mausb(void)
mausb_snap_handle = new_create_dissector_handle(dissect_mausb_pkt,
proto_mausb);
dissector_add_uint("llc.mausb_pid", PID_MAUSB, mausb_snap_handle);
initialized = TRUE;
} else {
/* if we have already been initialized */
dissector_delete_uint("tcp.port", gPORT_PREF, mausb_tcp_handle);
dissector_delete_uint("tcp.port", saved_mausb_tcp_port_pref, mausb_tcp_handle);
}
dissector_add_uint("llc.mausb_pid", PID_MAUSB, mausb_snap_handle);
dissector_add_uint("tcp.port", gPORT_PREF, mausb_tcp_handle);
saved_mausb_tcp_port_pref = mausb_tcp_port_pref;
dissector_add_uint("tcp.port", mausb_tcp_port_pref, mausb_tcp_handle);
}
void