1 /* packet-h501.c 2 * Routines for H.501 packet dissection 3 * 2007 Tomas Kukosa 4 * 5 * Wireshark - Network traffic analyzer 6 * By Gerald Combs <gerald@wireshark.org> 7 * Copyright 1998 Gerald Combs 8 * 9 * SPDX-License-Identifier: GPL-2.0-or-later 10 */ 11 12 #include "config.h" 13 14 #include <epan/packet.h> 15 #include <epan/prefs.h> 16 #include <epan/oids.h> 17 #include <epan/asn1.h> 18 19 #include "packet-tpkt.h" 20 #include "packet-per.h" 21 #include "packet-h225.h" 22 #include "packet-h235.h" 23 24 #define PNAME "H.501 Mobility" 25 #define PSNAME "H.501" 26 #define PFNAME "h501" 27 28 void proto_register_h501(void); 29 30 /* Initialize the protocol and registered fields */ 31 static int proto_h501 = -1; 32 #include "packet-h501-hf.c" 33 34 /* Initialize the subtree pointers */ 35 static int ett_h501 = -1; 36 #include "packet-h501-ett.c" 37 38 /* Dissectors */ 39 static dissector_handle_t h501_pdu_handle; 40 41 /* Preferences */ 42 #define H501_PORT 2099 43 static gboolean h501_desegment_tcp = TRUE; 44 45 void proto_reg_handoff_h501(void); 46 47 #include "packet-h501-fn.c" 48 49 static int 50 dissect_h501_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) 51 { 52 proto_item *ti = NULL; 53 proto_tree *h501_tree = NULL; 54 55 col_set_str(pinfo->cinfo, COL_PROTOCOL, PSNAME); 56 57 ti = proto_tree_add_item(tree, proto_h501, tvb, 0, -1, ENC_NA); 58 h501_tree = proto_item_add_subtree(ti, ett_h501); 59 60 return dissect_Message_PDU(tvb, pinfo, h501_tree, NULL); 61 } 62 63 static int 64 dissect_h501_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) 65 { 66 dissect_tpkt_encap(tvb, pinfo, tree, FALSE, h501_pdu_handle); 67 return tvb_captured_length(tvb); 68 } 69 70 static int 71 dissect_h501_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) 72 { 73 dissect_tpkt_encap(tvb, pinfo, tree, h501_desegment_tcp, h501_pdu_handle); 74 return tvb_captured_length(tvb); 75 } 76 77 /*--- proto_register_h501 ----------------------------------------------*/ 78 void proto_register_h501(void) { 79 module_t *h501_module; 80 81 /* List of fields */ 82 static hf_register_info hf[] = { 83 #include "packet-h501-hfarr.c" 84 }; 85 86 /* List of subtrees */ 87 static gint *ett[] = { 88 &ett_h501, 89 #include "packet-h501-ettarr.c" 90 }; 91 92 /* Register protocol */ 93 proto_h501 = proto_register_protocol(PNAME, PSNAME, PFNAME); 94 95 /* Register fields and subtrees */ 96 proto_register_field_array(proto_h501, hf, array_length(hf)); 97 proto_register_subtree_array(ett, array_length(ett)); 98 99 h501_pdu_handle = register_dissector(PFNAME, dissect_h501_pdu, proto_h501); 100 101 h501_module = prefs_register_protocol(proto_h501, NULL); 102 prefs_register_bool_preference(h501_module, "desegment", 103 "Desegment H.501 over TCP", 104 "Desegment H.501 messages that span more TCP segments", 105 &h501_desegment_tcp); 106 107 } 108 109 /*--- proto_reg_handoff_h501 -------------------------------------------*/ 110 void proto_reg_handoff_h501(void) 111 { 112 dissector_handle_t h501_udp_handle; 113 dissector_handle_t h501_tcp_handle; 114 115 h501_udp_handle = create_dissector_handle(dissect_h501_udp, proto_h501); 116 h501_tcp_handle = create_dissector_handle(dissect_h501_tcp, proto_h501); 117 dissector_add_uint_with_preference("tcp.port", H501_PORT, h501_tcp_handle); 118 dissector_add_uint_with_preference("udp.port", H501_PORT, h501_udp_handle); 119 } 120 121