2 * Routines for H.501 packet dissection
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <epan/packet.h>
32 #include <epan/prefs.h>
33 #include <epan/conversation.h>
34 #include <epan/oids.h>
35 #include <epan/asn1.h>
40 #include "packet-tpkt.h"
41 #include "packet-per.h"
42 #include "packet-h225.h"
43 #include "packet-h235.h"
45 #define PNAME "H.501 Mobility"
46 #define PSNAME "H.501"
49 /* Initialize the protocol and registered fields */
51 #include "packet-h501-hf.c"
53 /* Initialize the subtree pointers */
54 static int ett_h501 = -1;
55 #include "packet-h501-ett.c"
58 static dissector_handle_t h501_pdu_handle = NULL;
59 static dissector_handle_t h501_udp_handle = NULL;
60 static dissector_handle_t h501_tcp_handle = NULL;
63 static guint h501_udp_port = 2099;
64 static guint h501_tcp_port = 2099;
65 static gboolean h501_desegment_tcp = TRUE;
67 /* Gloabl variables */
68 static guint saved_h501_udp_port;
69 static guint saved_h501_tcp_port;
71 void proto_reg_handoff_h501(void);
73 #include "packet-h501-fn.c"
76 dissect_h501_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
78 proto_item *ti = NULL;
79 proto_tree *h501_tree = NULL;
81 if (check_col(pinfo->cinfo, COL_PROTOCOL))
82 col_set_str(pinfo->cinfo, COL_PROTOCOL, PSNAME);
84 ti = proto_tree_add_item(tree, proto_h501, tvb, 0, -1, FALSE);
85 h501_tree = proto_item_add_subtree(ti, ett_h501);
87 return dissect_Message_PDU(tvb, pinfo, h501_tree);
91 dissect_h501_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
93 dissect_tpkt_encap(tvb, pinfo, tree, FALSE, h501_pdu_handle);
94 return tvb_length(tvb);
98 dissect_h501_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
100 dissect_tpkt_encap(tvb, pinfo, tree, h501_desegment_tcp, h501_pdu_handle);
101 return tvb_length(tvb);
104 /*--- proto_register_h501 ----------------------------------------------*/
105 void proto_register_h501(void) {
106 module_t *h501_module;
109 static hf_register_info hf[] = {
110 #include "packet-h501-hfarr.c"
113 /* List of subtrees */
114 static gint *ett[] = {
116 #include "packet-h501-ettarr.c"
119 /* Register protocol */
120 proto_h501 = proto_register_protocol(PNAME, PSNAME, PFNAME);
122 /* Register fields and subtrees */
123 proto_register_field_array(proto_h501, hf, array_length(hf));
124 proto_register_subtree_array(ett, array_length(ett));
126 new_register_dissector(PFNAME, dissect_h501_pdu, proto_h501);
127 h501_pdu_handle = find_dissector(PFNAME);
129 h501_udp_handle = new_create_dissector_handle(dissect_h501_udp, proto_h501);
130 h501_tcp_handle = new_create_dissector_handle(dissect_h501_tcp, proto_h501);
132 h501_module = prefs_register_protocol(proto_h501, proto_reg_handoff_h501);
133 prefs_register_uint_preference(h501_module, "udp.port",
135 "Port to be decoded as h501",
137 prefs_register_uint_preference(h501_module, "tcp.port",
139 "Port to be decoded as h501",
141 prefs_register_bool_preference(h501_module, "desegment",
142 "Desegment H.501 over TCP",
143 "Desegment H.501 messages that span more TCP segments",
144 &h501_desegment_tcp);
148 /*--- proto_reg_handoff_h501 -------------------------------------------*/
149 void proto_reg_handoff_h501(void)
151 static gboolean h501_prefs_initialized = FALSE;
153 if (h501_prefs_initialized) {
154 dissector_delete("udp.port", saved_h501_udp_port, h501_udp_handle);
155 dissector_delete("tcp.port", saved_h501_tcp_port, h501_tcp_handle);
157 h501_prefs_initialized = TRUE;
160 /* Set our port number for future use */
161 saved_h501_udp_port = h501_udp_port;
162 dissector_add("udp.port", saved_h501_udp_port, h501_udp_handle);
163 saved_h501_tcp_port = h501_tcp_port;
164 dissector_add("tcp.port", saved_h501_tcp_port, h501_tcp_handle);