*
* $Id$
*
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
# include "config.h"
#endif
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <glib.h>
#include <epan/packet.h>
-#include <epan/emem.h>
#include <epan/prefs.h>
#include <packet-tcp.h>
/* Preferences */
static guint global_lsc_port = 0;
-static guint lsc_port = 0;
-
/* Initialize the subtree pointers */
static gint ett_lsc = -1;
guint expected_len;
/* Protocol is LSC, packet summary is not yet known */
- if (check_col(pinfo->cinfo, COL_PROTOCOL))
- col_set_str(pinfo->cinfo, COL_PROTOCOL, "LSC");
- if (check_col(pinfo->cinfo, COL_INFO))
- col_clear(pinfo->cinfo, COL_INFO);
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "LSC");
+ col_clear(pinfo->cinfo, COL_INFO);
/* Too little data? */
- if (tvb->length < LSC_MIN_LEN)
+ if (tvb_length(tvb) < LSC_MIN_LEN)
{
- if (check_col(pinfo->cinfo, COL_INFO))
- col_set_str(pinfo->cinfo, COL_INFO, "[Too short]");
+ col_set_str(pinfo->cinfo, COL_INFO, "[Too short]");
return;
}
val_to_str(op_code, op_code_vals, "Unknown op code (0x%x)"),
stream);
- if (tvb->length < expected_len)
+ if (tvb_length(tvb) < expected_len)
col_append_str(pinfo->cinfo, COL_INFO, " [Too short]");
- else if (tvb->length > expected_len)
+ else if (tvb_length(tvb) > expected_len)
col_append_str(pinfo->cinfo, COL_INFO, " [Too long]");
}
if (tree) {
/* Create display subtree for the protocol */
- ti = proto_tree_add_item(tree, proto_lsc, tvb, 0, -1, FALSE);
+ ti = proto_tree_add_item(tree, proto_lsc, tvb, 0, -1, ENC_NA);
lsc_tree = proto_item_add_subtree(ti, ett_lsc);
/* Add already fetched items to the tree */
/* Determine length of LSC message */
static guint
-get_lsc_pdu_len(tvbuff_t *tvb, int offset)
+get_lsc_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
{
guint8 op_code;
guint pdu_len;
dissect_lsc_common);
}
-/* Register the protocol with Ethereal */
+/* Register the protocol with Wireshark */
void
proto_register_lsc(void)
-{
+{
module_t *lsc_module;
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_lsc_version,
{ "Version", "lsc.version",
- FT_UINT8, BASE_DEC, NULL, 0,
+ FT_UINT8, BASE_DEC, NULL, 0,
"Version of the Pegasus LSC protocol", HFILL }
},
{ &hf_lsc_trans_id,
{ "Transaction ID", "lsc.trans_id",
- FT_UINT8, BASE_DEC, NULL, 0,
- "Transaction ID", HFILL }
+ FT_UINT8, BASE_DEC, NULL, 0,
+ NULL, HFILL }
},
{ &hf_lsc_op_code,
{ "Op Code", "lsc.op_code",
- FT_UINT8, BASE_HEX, VALS(op_code_vals), 0,
+ FT_UINT8, BASE_HEX, VALS(op_code_vals), 0,
"Operation Code", HFILL }
},
{ &hf_lsc_status_code,
{ "Status Code", "lsc.status_code",
- FT_UINT8, BASE_HEX, VALS(status_code_vals), 0,
- "Status Code", HFILL }
+ FT_UINT8, BASE_HEX, VALS(status_code_vals), 0,
+ NULL, HFILL }
},
{ &hf_lsc_stream_handle,
{ "Stream Handle", "lsc.stream_handle",
- FT_UINT32, BASE_DEC, NULL, 0,
+ FT_UINT32, BASE_DEC, NULL, 0,
"Stream identification handle", HFILL }
},
{ &hf_lsc_start_npt,
{ "Start NPT", "lsc.start_npt",
- FT_INT32, BASE_DEC, NULL, 0,
+ FT_INT32, BASE_DEC, NULL, 0,
"Start Time (milliseconds)", HFILL }
},
{ &hf_lsc_stop_npt,
{ "Stop NPT", "lsc.stop_npt",
- FT_INT32, BASE_DEC, NULL, 0,
+ FT_INT32, BASE_DEC, NULL, 0,
"Stop Time (milliseconds)", HFILL }
},
{ &hf_lsc_current_npt,
{ "Current NPT", "lsc.current_npt",
- FT_INT32, BASE_DEC, NULL, 0,
+ FT_INT32, BASE_DEC, NULL, 0,
"Current Time (milliseconds)", HFILL }
},
{ &hf_lsc_scale_num,
{ "Scale Numerator", "lsc.scale_num",
- FT_INT16, BASE_DEC, NULL, 0,
- "Scale Numerator", HFILL }
+ FT_INT16, BASE_DEC, NULL, 0,
+ NULL, HFILL }
},
{ &hf_lsc_scale_denom,
{ "Scale Denominator", "lsc.scale_denum",
- FT_UINT16, BASE_DEC, NULL, 0,
- "Scale Denominator", HFILL }
+ FT_UINT16, BASE_DEC, NULL, 0,
+ NULL, HFILL }
},
{ &hf_lsc_mode,
{ "Server Mode", "lsc.mode",
- FT_UINT8, BASE_HEX, VALS(mode_vals), 0,
+ FT_UINT8, BASE_HEX, VALS(mode_vals), 0,
"Current Server Mode", HFILL }
}
};
proto_register_field_array(proto_lsc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
- /* Register preferences module */
+ /* Register preferences module */
lsc_module = prefs_register_protocol(proto_lsc, proto_reg_handoff_lsc);
-
- /* Register preferences */
+
+ /* Register preferences */
prefs_register_uint_preference(lsc_module, "port",
"LSC Port",
"Set the TCP or UDP port for Pegasus LSC messages",
void
proto_reg_handoff_lsc(void)
{
- dissector_handle_t lsc_udp_handle;
- dissector_handle_t lsc_tcp_handle;
-
- lsc_udp_handle = create_dissector_handle(dissect_lsc_udp, proto_lsc);
- lsc_tcp_handle = create_dissector_handle(dissect_lsc_tcp, proto_lsc);
+ static gboolean initialized = FALSE;
+ static dissector_handle_t lsc_udp_handle;
+ static dissector_handle_t lsc_tcp_handle;
+ static guint saved_lsc_port;
+
+ if (!initialized) {
+ lsc_udp_handle = create_dissector_handle(dissect_lsc_udp, proto_lsc);
+ lsc_tcp_handle = create_dissector_handle(dissect_lsc_tcp, proto_lsc);
+ dissector_add_handle("udp.port", lsc_udp_handle); /* for 'decode-as' */
+ dissector_add_handle("tcp.port", lsc_tcp_handle); /* ... */
+ initialized = TRUE;
+ } else {
+ if (saved_lsc_port != 0) {
+ dissector_delete_uint("udp.port", saved_lsc_port, lsc_udp_handle);
+ dissector_delete_uint("tcp.port", saved_lsc_port, lsc_tcp_handle);
+ }
+ }
/* Set the port number */
- lsc_port = global_lsc_port;
-
- dissector_add("udp.port", lsc_port, lsc_udp_handle);
- dissector_add("tcp.port", lsc_port, lsc_tcp_handle);
+ if (global_lsc_port != 0) {
+ dissector_add_uint("udp.port", global_lsc_port, lsc_udp_handle);
+ dissector_add_uint("tcp.port", global_lsc_port, lsc_tcp_handle);
+ }
+ saved_lsc_port = global_lsc_port;
}