Harald Welte | 318105d | 2010-12-01 00:02:42 +0100 | [diff] [blame^] | 1 | Index: wireshark/epan/dissectors/packet-gsm_ipa.c |
| 2 | =================================================================== |
| 3 | --- wireshark.orig/epan/dissectors/packet-gsm_ipa.c |
| 4 | +++ wireshark/epan/dissectors/packet-gsm_ipa.c |
| 5 | @@ -32,6 +32,14 @@ |
| 6 | |
| 7 | #include <epan/packet.h> |
| 8 | #include <epan/ipproto.h> |
| 9 | +#include <epan/prefs.h> |
| 10 | + |
| 11 | +#define IPA_TCP_PORTS "3002,3003,3006,5000" |
| 12 | +#define IPA_UDP_PORTS "3006" |
| 13 | + |
| 14 | +static dissector_handle_t ipa_handle; |
| 15 | +static range_t *global_ipa_tcp_ports = NULL; |
| 16 | +static range_t *global_ipa_udp_ports = NULL; |
| 17 | |
| 18 | /* Initialize the protocol and registered fields */ |
| 19 | static int proto_ipa = -1; |
| 20 | @@ -60,11 +68,6 @@ |
| 21 | |
| 22 | static dissector_handle_t sub_handles[SUB_MAX]; |
| 23 | |
| 24 | -#define TCP_PORT_ABISIP_PRIM 3002 |
| 25 | -#define TCP_PORT_ABISIP_SEC 3003 |
| 26 | -#define TCP_PORT_ABISIP_INST 3006 |
| 27 | -#define TCP_PORT_AIP_PRIM 5000 |
| 28 | - |
| 29 | #define ABISIP_RSL_MAX 0x20 |
| 30 | #define IPA_MGCP 0xfc |
| 31 | #define AIP_SCCP 0xfd |
| 32 | @@ -249,8 +252,12 @@ |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | +void proto_reg_handoff_gsm_ipa(void); |
| 37 | + |
| 38 | void proto_register_ipa(void) |
| 39 | { |
| 40 | + module_t *ipa_module; |
| 41 | + |
| 42 | static hf_register_info hf[] = { |
| 43 | {&hf_ipa_data_len, |
| 44 | {"DataLen", "ipa.data_len", |
| 45 | @@ -298,21 +305,71 @@ |
| 46 | proto_register_subtree_array(ett, array_length(ett)); |
| 47 | |
| 48 | register_dissector("gsm_ipa", dissect_ipa, proto_ipa); |
| 49 | + |
| 50 | + range_convert_str(&global_ipa_tcp_ports, IPA_TCP_PORTS, MAX_TCP_PORT); |
| 51 | + range_convert_str(&global_ipa_udp_ports, IPA_UDP_PORTS, MAX_UDP_PORT); |
| 52 | + ipa_module = prefs_register_protocol(proto_ipa, |
| 53 | + proto_reg_handoff_gsm_ipa); |
| 54 | + |
| 55 | + prefs_register_range_preference(ipa_module, "tcp_ports", |
| 56 | + "GSM IPA TCP Port(s)", |
| 57 | + "Set the port(s) for ip.access IPA" |
| 58 | + " (default: " IPA_TCP_PORTS ")", |
| 59 | + &global_ipa_tcp_ports, MAX_TCP_PORT); |
| 60 | + prefs_register_range_preference(ipa_module, "udp_ports", |
| 61 | + "GSM IPA UDP Port(s)", |
| 62 | + "Set the port(s) for ip.access IPA" |
| 63 | + " (default: " IPA_UDP_PORTS ")", |
| 64 | + &global_ipa_udp_ports, MAX_UDP_PORT); |
| 65 | +} |
| 66 | + |
| 67 | +static void ipa_tcp_delete_callback(guint32 port) |
| 68 | +{ |
| 69 | + if (port) |
| 70 | + dissector_delete("tcp.port", port, ipa_handle); |
| 71 | +} |
| 72 | + |
| 73 | +static void ipa_udp_delete_callback(guint32 port) |
| 74 | +{ |
| 75 | + if (port) |
| 76 | + dissector_delete("udp.port", port, ipa_handle); |
| 77 | +} |
| 78 | + |
| 79 | +static void ipa_tcp_add_callback(guint32 port) |
| 80 | +{ |
| 81 | + if (port) |
| 82 | + dissector_add("tcp.port", port, ipa_handle); |
| 83 | +} |
| 84 | + |
| 85 | +static void ipa_udp_add_callback(guint32 port) |
| 86 | +{ |
| 87 | + if (port) |
| 88 | + dissector_add("udp.port", port, ipa_handle); |
| 89 | } |
| 90 | |
| 91 | void proto_reg_handoff_gsm_ipa(void) |
| 92 | { |
| 93 | - dissector_handle_t ipa_handle; |
| 94 | + static gboolean ipa_initialized = FALSE; |
| 95 | + static range_t *ipa_tcp_ports, *ipa_udp_ports; |
| 96 | + |
| 97 | + if (!ipa_initialized) { |
| 98 | + sub_handles[SUB_RSL] = find_dissector("gsm_abis_rsl"); |
| 99 | + sub_handles[SUB_OML] = find_dissector("gsm_abis_oml"); |
| 100 | + sub_handles[SUB_SCCP] = find_dissector("sccp"); |
| 101 | + sub_handles[SUB_MGCP] = find_dissector("mgcp"); |
| 102 | + |
| 103 | + ipa_handle = create_dissector_handle(dissect_ipa, proto_ipa); |
| 104 | + ipa_initialized = TRUE; |
| 105 | + } else { |
| 106 | + range_foreach(ipa_tcp_ports, ipa_tcp_delete_callback); |
| 107 | + g_free(ipa_tcp_ports); |
| 108 | + range_foreach(ipa_udp_ports, ipa_udp_delete_callback); |
| 109 | + g_free(ipa_udp_ports); |
| 110 | + } |
| 111 | + |
| 112 | + ipa_tcp_ports = range_copy(global_ipa_tcp_ports); |
| 113 | + ipa_udp_ports = range_copy(global_ipa_udp_ports); |
| 114 | |
| 115 | - sub_handles[SUB_RSL] = find_dissector("gsm_abis_rsl"); |
| 116 | - sub_handles[SUB_OML] = find_dissector("gsm_abis_oml"); |
| 117 | - sub_handles[SUB_SCCP] = find_dissector("sccp"); |
| 118 | - sub_handles[SUB_MGCP] = find_dissector("mgcp"); |
| 119 | - |
| 120 | - ipa_handle = create_dissector_handle(dissect_ipa, proto_ipa); |
| 121 | - dissector_add("tcp.port", TCP_PORT_ABISIP_PRIM, ipa_handle); |
| 122 | - dissector_add("tcp.port", TCP_PORT_ABISIP_SEC, ipa_handle); |
| 123 | - dissector_add("tcp.port", TCP_PORT_ABISIP_INST, ipa_handle); |
| 124 | - dissector_add("tcp.port", TCP_PORT_AIP_PRIM, ipa_handle); |
| 125 | - dissector_add("udp.port", TCP_PORT_ABISIP_INST, ipa_handle); |
| 126 | + range_foreach(ipa_tcp_ports, ipa_tcp_add_callback); |
| 127 | + range_foreach(ipa_udp_ports, ipa_udp_add_callback); |
| 128 | } |