| File: | builds/wireshark/wireshark/epan/dissectors/packet-megaco.c |
| Warning: | line 2199, column 21 Value stored to 'LBRKT_found' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* packet-megaco.c |
| 2 | * Routines for megaco packet disassembly |
| 3 | * RFC 3015 |
| 4 | * |
| 5 | * Christian Falckenberg, 2002/10/17 |
| 6 | * Copyright (c) 2002 by Christian Falckenberg |
| 7 | * <[email protected]> |
| 8 | * |
| 9 | * Christoph Wiest, 2003/06/28 |
| 10 | * Modified 2003 by Christoph Wiest |
| 11 | * <[email protected]> |
| 12 | * Modified 2004 by Anders Broman |
| 13 | * <[email protected]> |
| 14 | * To handle TPKT headers if over TCP |
| 15 | * Modified 2005 by Karl Knoebl |
| 16 | * <[email protected]> |
| 17 | * provide info to COL_INFO and some "prettification" |
| 18 | * |
| 19 | * Copyright (c) 2006 Anders Broman <[email protected]> |
| 20 | * |
| 21 | * Wireshark - Network traffic analyzer |
| 22 | * By Gerald Combs <[email protected]> |
| 23 | * Copyright 1999 Gerald Combs |
| 24 | * |
| 25 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 26 | */ |
| 27 | |
| 28 | |
| 29 | #include "config.h" |
| 30 | |
| 31 | #include <stdlib.h> |
| 32 | |
| 33 | #include <epan/packet.h> |
| 34 | #include <epan/tap.h> |
| 35 | #include <epan/rtd_table.h> |
| 36 | #include <epan/prefs.h> |
| 37 | #include <epan/prefs-int.h> |
| 38 | #include <epan/exported_pdu.h> |
| 39 | #include <epan/asn1.h> |
| 40 | #include <epan/charsets.h> |
| 41 | #include <epan/unit_strings.h> |
| 42 | |
| 43 | #include <wsutil/array.h> |
| 44 | #include <wsutil/strtoi.h> |
| 45 | #include "packet-ber.h" |
| 46 | #include "packet-tpkt.h" |
| 47 | #include "packet-h245.h" |
| 48 | #include "packet-h248.h" |
| 49 | #include "packet-ip.h" |
| 50 | #include "packet-media-type.h" |
| 51 | #include "packet-sdp.h" |
| 52 | #include "packet-sctp.h" |
| 53 | |
| 54 | void proto_register_megaco(void); |
| 55 | void proto_reg_handoff_megaco(void); |
| 56 | |
| 57 | #define PORT_MEGACO_TXT2944 2944 |
| 58 | #define PORT_MEGACO_BIN2945 2945 |
| 59 | |
| 60 | static pref_t *sip_hide_generated_call_ids; |
| 61 | |
| 62 | |
| 63 | /* Define the megaco proto */ |
| 64 | static int proto_megaco; |
| 65 | |
| 66 | /* Define headers for megaco */ |
| 67 | static int hf_megaco_start; |
| 68 | static int hf_megaco_version; |
| 69 | static int hf_megaco_transaction; |
| 70 | static int hf_megaco_transid; |
| 71 | static int hf_megaco_Context; |
| 72 | static int hf_megaco_Context_generated; |
| 73 | /* static int hf_megaco_command_line; */ |
| 74 | static int hf_megaco_command; |
| 75 | static int hf_megaco_command_optional; |
| 76 | static int hf_megaco_wildcard_response; |
| 77 | static int hf_megaco_termid; |
| 78 | |
| 79 | |
| 80 | |
| 81 | /* Define headers in subtree for megaco */ |
| 82 | static int hf_megaco_modem_descriptor; |
| 83 | static int hf_megaco_multiplex_descriptor; |
| 84 | static int hf_megaco_media_descriptor; |
| 85 | static int hf_megaco_Local_descriptor; |
| 86 | static int hf_megaco_events_descriptor; |
| 87 | static int hf_megaco_signal_descriptor; |
| 88 | static int hf_megaco_audit_descriptor; |
| 89 | /* static int hf_megaco_servicechange_descriptor; */ |
| 90 | static int hf_megaco_digitmap_descriptor; |
| 91 | static int hf_megaco_statistics_descriptor; |
| 92 | static int hf_megaco_observedevents_descriptor; |
| 93 | static int hf_megaco_topology_descriptor; |
| 94 | static int hf_megaco_error_descriptor; |
| 95 | static int hf_megaco_error_code; |
| 96 | static int hf_megaco_error_string; |
| 97 | static int hf_megaco_TerminationState_descriptor; |
| 98 | static int hf_megaco_Remote_descriptor; |
| 99 | static int hf_megaco_LocalControl_descriptor; |
| 100 | static int hf_megaco_packages_descriptor; |
| 101 | static int hf_megaco_Service_State; |
| 102 | static int hf_megaco_Event_Buffer_Control; |
| 103 | static int hf_megaco_mode; |
| 104 | static int hf_megaco_reserve_group; |
| 105 | static int hf_megaco_h324_muxtbl_in; |
| 106 | static int hf_megaco_h324_muxtbl_out; |
| 107 | static int hf_megaco_ds_dscp; |
| 108 | static int hf_megaco_gm_saf; |
| 109 | static int hf_megaco_gm_sam; |
| 110 | static int hf_megaco_gm_spf; |
| 111 | static int hf_megaco_gm_spr; |
| 112 | static int hf_megaco_gm_esas; |
| 113 | static int hf_megaco_tman_pol; |
| 114 | static int hf_megaco_gm_rsb; |
| 115 | static int hf_megaco_tman_sdr; |
| 116 | static int hf_megaco_tman_mbs; |
| 117 | static int hf_megaco_tman_pdr; |
| 118 | static int hf_megaco_tman_dvt; |
| 119 | static int hf_megaco_ipdc_realm; |
| 120 | static int hf_megaco_h324_h223capr; |
| 121 | static int hf_megaco_reserve_value; |
| 122 | static int hf_megaco_streamid; |
| 123 | static int hf_megaco_requestid; |
| 124 | static int hf_megaco_pkgdname; |
| 125 | static int hf_megaco_mId; |
| 126 | static int hf_megaco_h245; |
| 127 | static int hf_megaco_h223Capability; |
| 128 | static int hf_megaco_audititem; |
| 129 | static int hf_megaco_priority; |
| 130 | |
| 131 | /* Define the trees for megaco */ |
| 132 | static int ett_megaco; |
| 133 | static int ett_megaco_message; |
| 134 | static int ett_megaco_message_body; |
| 135 | static int ett_megaco_context; |
| 136 | static int ett_megaco_command_line; |
| 137 | static int ett_megaco_mediadescriptor; |
| 138 | static int ett_megaco_descriptors; |
| 139 | static int ett_megaco_raw_text; |
| 140 | static int ett_megaco_error_descriptor; |
| 141 | static int ett_megaco_TerminationState; |
| 142 | static int ett_megaco_Localdescriptor; |
| 143 | static int ett_megaco_Remotedescriptor; |
| 144 | static int ett_megaco_LocalControldescriptor; |
| 145 | static int ett_megaco_auditdescriptor; |
| 146 | static int ett_megaco_eventsdescriptor; |
| 147 | static int ett_megaco_statisticsdescriptor; |
| 148 | static int ett_megaco_observedeventsdescriptor; |
| 149 | static int ett_megaco_observedevent; |
| 150 | static int ett_megaco_packagesdescriptor; |
| 151 | static int ett_megaco_requestedevent; |
| 152 | static int ett_megaco_signalsdescriptor; |
| 153 | static int ett_megaco_requestedsignal; |
| 154 | static int ett_megaco_h245; |
| 155 | |
| 156 | static gcp_hf_ett_t megaco_ctx_ids; |
| 157 | |
| 158 | static expert_field ei_megaco_errored_command; |
| 159 | static expert_field ei_megaco_no_command; |
| 160 | static expert_field ei_megaco_no_descriptor; |
| 161 | static expert_field ei_megaco_error_descriptor_transaction_list; |
| 162 | static expert_field ei_megaco_parse_error; |
| 163 | static expert_field ei_megaco_audit_descriptor; |
| 164 | static expert_field ei_megaco_signal_descriptor; |
| 165 | static expert_field ei_megaco_reason_invalid; |
| 166 | static expert_field ei_megaco_error_code_invalid; |
| 167 | static expert_field ei_megaco_invalid_sdr; |
| 168 | |
| 169 | static dissector_handle_t megaco_text_handle; |
| 170 | |
| 171 | static int megaco_tap; |
| 172 | static int exported_pdu_tap = -1; |
| 173 | |
| 174 | |
| 175 | /* patterns used for tvb_ws_mempbrk_pattern_uint8 */ |
| 176 | static ws_mempbrk_pattern pbrk_whitespace; |
| 177 | static ws_mempbrk_pattern pbrk_braces; |
| 178 | |
| 179 | /* Used when command type is needed to differentiate parsing, extend as needed */ |
| 180 | typedef enum |
| 181 | { |
| 182 | MEGACO_CMD_NOT_SET = 0, |
| 183 | MEGACO_CMD_PRIORITY, |
| 184 | } megaco_commands_enum_t; |
| 185 | |
| 186 | /* |
| 187 | * Here are the global variables associated with |
| 188 | * the various user definable characteristics of the dissection |
| 189 | * |
| 190 | * H.248/MEGACO has two kinds of message formats: text and binary (ASN.1). |
| 191 | * The binary message format is dissected in packet-h248.c |
| 192 | * |
| 193 | * global_megaco_raw_text determines whether we are going to display |
| 194 | * the raw text of the megaco message, much like the HTTP dissector does. |
| 195 | * |
| 196 | * global_megaco_dissect_tree determines whether we are going to display |
| 197 | * a detailed tree that expresses a somewhat more semantically meaningful |
| 198 | * decode. |
| 199 | */ |
| 200 | static bool_Bool global_megaco_raw_text = true1; |
| 201 | static bool_Bool global_megaco_dissect_tree = true1; |
| 202 | |
| 203 | static const value_string megaco_context_vals[] = { |
| 204 | { CHOOSE_CONTEXT0xFFFFFFFE, "Choose one" }, |
| 205 | { ALL_CONTEXTS0xFFFFFFFF, "All" }, |
| 206 | { NULL_CONTEXT0, "NULL" }, |
| 207 | |
| 208 | { 0, NULL((void*)0) } |
| 209 | }; |
| 210 | |
| 211 | /* Some basic utility functions that are specific to this dissector */ |
| 212 | static int megaco_tvb_skip_wsp(tvbuff_t *tvb, int offset); |
| 213 | static int megaco_tvb_skip_wsp_return(tvbuff_t *tvb, int offset); |
| 214 | |
| 215 | #define NUM_TIMESTATS12 12 |
| 216 | |
| 217 | static const value_string megaco_message_type[] = { |
| 218 | { 0, "ADD "}, |
| 219 | { 1, "MOVE"}, |
| 220 | { 2, "MDFY"}, |
| 221 | { 3, "SUBT"}, |
| 222 | { 4, "AUCP"}, |
| 223 | { 5, "AUVL"}, |
| 224 | { 6, "NTFY"}, |
| 225 | { 7, "SVCC"}, |
| 226 | { 8, "TOPO"}, |
| 227 | { 9, "NONE"}, |
| 228 | { 10, "ALL "}, |
| 229 | { 0, NULL((void*)0)} |
| 230 | }; |
| 231 | |
| 232 | #define GCP_CMD_REPLY_CASEcase GCP_CMD_ADD_REPLY: case GCP_CMD_MOVE_REPLY: case GCP_CMD_MOD_REPLY : case GCP_CMD_SUB_REPLY: case GCP_CMD_AUDITCAP_REPLY: case GCP_CMD_AUDITVAL_REPLY : case GCP_CMD_NOTIFY_REPLY: case GCP_CMD_SVCCHG_REPLY: case GCP_CMD_TOPOLOGY_REPLY : case GCP_CMD_REPLY: \ |
| 233 | case GCP_CMD_ADD_REPLY: \ |
| 234 | case GCP_CMD_MOVE_REPLY: \ |
| 235 | case GCP_CMD_MOD_REPLY: \ |
| 236 | case GCP_CMD_SUB_REPLY: \ |
| 237 | case GCP_CMD_AUDITCAP_REPLY: \ |
| 238 | case GCP_CMD_AUDITVAL_REPLY: \ |
| 239 | case GCP_CMD_NOTIFY_REPLY: \ |
| 240 | case GCP_CMD_SVCCHG_REPLY: \ |
| 241 | case GCP_CMD_TOPOLOGY_REPLY: \ |
| 242 | case GCP_CMD_REPLY: |
| 243 | |
| 244 | #define GCP_CMD_REQ_CASEcase GCP_CMD_ADD_REQ: case GCP_CMD_MOVE_REQ: case GCP_CMD_MOD_REQ : case GCP_CMD_SUB_REQ: case GCP_CMD_AUDITCAP_REQ: case GCP_CMD_AUDITVAL_REQ : case GCP_CMD_NOTIFY_REQ: case GCP_CMD_SVCCHG_REQ: case GCP_CMD_TOPOLOGY_REQ : case GCP_CMD_CTX_ATTR_AUDIT_REQ: case GCP_CMD_OTHER_REQ: \ |
| 245 | case GCP_CMD_ADD_REQ: \ |
| 246 | case GCP_CMD_MOVE_REQ: \ |
| 247 | case GCP_CMD_MOD_REQ: \ |
| 248 | case GCP_CMD_SUB_REQ: \ |
| 249 | case GCP_CMD_AUDITCAP_REQ: \ |
| 250 | case GCP_CMD_AUDITVAL_REQ: \ |
| 251 | case GCP_CMD_NOTIFY_REQ: \ |
| 252 | case GCP_CMD_SVCCHG_REQ: \ |
| 253 | case GCP_CMD_TOPOLOGY_REQ: \ |
| 254 | case GCP_CMD_CTX_ATTR_AUDIT_REQ: \ |
| 255 | case GCP_CMD_OTHER_REQ: |
| 256 | |
| 257 | static bool_Bool |
| 258 | megacostat_is_duplicate_reply(const gcp_cmd_t* cmd) |
| 259 | { |
| 260 | switch (cmd->type) { |
| 261 | |
| 262 | GCP_CMD_REPLY_CASEcase GCP_CMD_ADD_REPLY: case GCP_CMD_MOVE_REPLY: case GCP_CMD_MOD_REPLY : case GCP_CMD_SUB_REPLY: case GCP_CMD_AUDITCAP_REPLY: case GCP_CMD_AUDITVAL_REPLY : case GCP_CMD_NOTIFY_REPLY: case GCP_CMD_SVCCHG_REPLY: case GCP_CMD_TOPOLOGY_REPLY : case GCP_CMD_REPLY: |
| 263 | { |
| 264 | gcp_cmd_msg_t *cmd_msg; |
| 265 | /* cycle through commands to find same command in the transaction */ |
| 266 | for (cmd_msg = cmd->trx->cmds; |
| 267 | (cmd_msg != NULL((void*)0)) && (cmd_msg->cmd->msg->framenum != cmd->msg->framenum); |
| 268 | cmd_msg = cmd_msg->next) { |
| 269 | if (cmd_msg->cmd->type == cmd->type) |
| 270 | return true1; |
| 271 | } |
| 272 | |
| 273 | return false0; |
| 274 | } |
| 275 | break; |
| 276 | default: |
| 277 | return false0; |
| 278 | break; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | static bool_Bool |
| 283 | megacostat_had_request(const gcp_cmd_t* cmd) |
| 284 | { |
| 285 | switch (cmd->type) { |
| 286 | |
| 287 | GCP_CMD_REPLY_CASEcase GCP_CMD_ADD_REPLY: case GCP_CMD_MOVE_REPLY: case GCP_CMD_MOD_REPLY : case GCP_CMD_SUB_REPLY: case GCP_CMD_AUDITCAP_REPLY: case GCP_CMD_AUDITVAL_REPLY : case GCP_CMD_NOTIFY_REPLY: case GCP_CMD_SVCCHG_REPLY: case GCP_CMD_TOPOLOGY_REPLY : case GCP_CMD_REPLY: |
| 288 | { |
| 289 | gcp_cmd_msg_t *cmd_msg; |
| 290 | /* cycle through commands to find a request in the transaction */ |
| 291 | for (cmd_msg = cmd->trx->cmds; |
| 292 | (cmd_msg != NULL((void*)0)) && (cmd_msg->cmd->msg->framenum != cmd->msg->framenum); |
| 293 | cmd_msg = cmd_msg->next) { |
| 294 | |
| 295 | switch (cmd_msg->cmd->type) { |
| 296 | |
| 297 | GCP_CMD_REQ_CASEcase GCP_CMD_ADD_REQ: case GCP_CMD_MOVE_REQ: case GCP_CMD_MOD_REQ : case GCP_CMD_SUB_REQ: case GCP_CMD_AUDITCAP_REQ: case GCP_CMD_AUDITVAL_REQ : case GCP_CMD_NOTIFY_REQ: case GCP_CMD_SVCCHG_REQ: case GCP_CMD_TOPOLOGY_REQ : case GCP_CMD_CTX_ATTR_AUDIT_REQ: case GCP_CMD_OTHER_REQ: |
| 298 | return true1; |
| 299 | break; |
| 300 | default: |
| 301 | return false0; |
| 302 | break; |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | return false0; |
| 307 | } |
| 308 | break; |
| 309 | default: |
| 310 | return false0; |
| 311 | break; |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | static void |
| 316 | megacostat_filtercheck(const char *opt_arg _U___attribute__((unused)), const char **filter _U___attribute__((unused)), char** err) |
| 317 | { |
| 318 | pref_t *megaco_ctx_track, *h248_ctx_track; |
| 319 | |
| 320 | megaco_ctx_track = prefs_find_preference(prefs_find_module("megaco"), "ctx_info"); |
| 321 | h248_ctx_track = prefs_find_preference(prefs_find_module("h248"), "ctx_info"); |
| 322 | |
| 323 | if (!megaco_ctx_track || !h248_ctx_track) { |
| 324 | /* No such preferences */ |
| 325 | return; |
| 326 | } |
| 327 | |
| 328 | if (!prefs_get_bool_value(megaco_ctx_track, pref_current) || !prefs_get_bool_value(h248_ctx_track, pref_current)) { |
| 329 | *err = ws_strdup_printf("Track Context option at Protocols -> MEGACO and Protocols -> H248 preferences\n"wmem_strdup_printf(((void*)0), "Track Context option at Protocols -> MEGACO and Protocols -> H248 preferences\n" "has to be set to true to enable measurement of service response times.\n" ) |
| 330 | "has to be set to true to enable measurement of service response times.\n")wmem_strdup_printf(((void*)0), "Track Context option at Protocols -> MEGACO and Protocols -> H248 preferences\n" "has to be set to true to enable measurement of service response times.\n" ); |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | static tap_packet_status |
| 335 | megacostat_packet(void *pms, packet_info *pinfo, epan_dissect_t *edt _U___attribute__((unused)), const void *pmi, tap_flags_t flags _U___attribute__((unused))) |
| 336 | { |
| 337 | rtd_data_t* rtd_data = (rtd_data_t*)pms; |
| 338 | rtd_stat_table* ms = &rtd_data->stat_table; |
| 339 | const gcp_cmd_t *mi=(const gcp_cmd_t*)pmi; |
| 340 | nstime_t delta; |
| 341 | tap_packet_status ret = TAP_PACKET_DONT_REDRAW; |
| 342 | |
| 343 | switch (mi->type) { |
| 344 | |
| 345 | GCP_CMD_REQ_CASEcase GCP_CMD_ADD_REQ: case GCP_CMD_MOVE_REQ: case GCP_CMD_MOD_REQ : case GCP_CMD_SUB_REQ: case GCP_CMD_AUDITCAP_REQ: case GCP_CMD_AUDITVAL_REQ : case GCP_CMD_NOTIFY_REQ: case GCP_CMD_SVCCHG_REQ: case GCP_CMD_TOPOLOGY_REQ : case GCP_CMD_CTX_ATTR_AUDIT_REQ: case GCP_CMD_OTHER_REQ: |
| 346 | if(!mi->trx->initial) { |
| 347 | /* Track Context is probably disabled, we cannot |
| 348 | * measure service response time */ |
| 349 | return TAP_PACKET_DONT_REDRAW; |
| 350 | } |
| 351 | |
| 352 | else if(mi->trx->initial->framenum != mi->msg->framenum){ |
| 353 | /* Duplicate is ignored */ |
| 354 | ms->time_stats[0].req_dup_num++; |
| 355 | } |
| 356 | else { |
| 357 | ms->time_stats[0].open_req_num++; |
| 358 | } |
| 359 | break; |
| 360 | |
| 361 | GCP_CMD_REPLY_CASEcase GCP_CMD_ADD_REPLY: case GCP_CMD_MOVE_REPLY: case GCP_CMD_MOD_REPLY : case GCP_CMD_SUB_REPLY: case GCP_CMD_AUDITCAP_REPLY: case GCP_CMD_AUDITVAL_REPLY : case GCP_CMD_NOTIFY_REPLY: case GCP_CMD_SVCCHG_REPLY: case GCP_CMD_TOPOLOGY_REPLY : case GCP_CMD_REPLY: |
| 362 | if(megacostat_is_duplicate_reply(mi)){ |
| 363 | /* Duplicate is ignored */ |
| 364 | ms->time_stats[0].rsp_dup_num++; |
| 365 | } |
| 366 | else if (!megacostat_had_request(mi)) { |
| 367 | /* no request was seen */ |
| 368 | ms->time_stats[0].disc_rsp_num++; |
| 369 | } |
| 370 | else { |
| 371 | ms->time_stats[0].open_req_num--; |
| 372 | /* calculate time delta between request and response */ |
| 373 | nstime_delta(&delta, &pinfo->abs_ts, &mi->trx->initial->frametime); |
| 374 | |
| 375 | switch(mi->type) { |
| 376 | |
| 377 | case GCP_CMD_ADD_REPLY: |
| 378 | time_stat_update(&(ms->time_stats[0].rtd[0]),&delta, pinfo); |
| 379 | break; |
| 380 | case GCP_CMD_MOVE_REPLY: |
| 381 | time_stat_update(&(ms->time_stats[0].rtd[1]),&delta, pinfo); |
| 382 | break; |
| 383 | case GCP_CMD_MOD_REPLY: |
| 384 | time_stat_update(&(ms->time_stats[0].rtd[2]),&delta, pinfo); |
| 385 | break; |
| 386 | case GCP_CMD_SUB_REPLY: |
| 387 | time_stat_update(&(ms->time_stats[0].rtd[3]),&delta, pinfo); |
| 388 | break; |
| 389 | case GCP_CMD_AUDITCAP_REPLY: |
| 390 | time_stat_update(&(ms->time_stats[0].rtd[4]),&delta, pinfo); |
| 391 | break; |
| 392 | case GCP_CMD_AUDITVAL_REPLY: |
| 393 | time_stat_update(&(ms->time_stats[0].rtd[5]),&delta, pinfo); |
| 394 | break; |
| 395 | case GCP_CMD_NOTIFY_REPLY: |
| 396 | time_stat_update(&(ms->time_stats[0].rtd[6]),&delta, pinfo); |
| 397 | break; |
| 398 | case GCP_CMD_SVCCHG_REPLY: |
| 399 | time_stat_update(&(ms->time_stats[0].rtd[7]),&delta, pinfo); |
| 400 | break; |
| 401 | case GCP_CMD_TOPOLOGY_REPLY: |
| 402 | time_stat_update(&(ms->time_stats[0].rtd[8]),&delta, pinfo); |
| 403 | break; |
| 404 | case GCP_CMD_REPLY: |
| 405 | time_stat_update(&(ms->time_stats[0].rtd[9]),&delta, pinfo); |
| 406 | break; |
| 407 | default: |
| 408 | time_stat_update(&(ms->time_stats[0].rtd[11]),&delta, pinfo); |
| 409 | } |
| 410 | |
| 411 | time_stat_update(&(ms->time_stats[0].rtd[10]),&delta, pinfo); |
| 412 | ret = TAP_PACKET_REDRAW; |
| 413 | } |
| 414 | break; |
| 415 | |
| 416 | default: |
| 417 | break; |
| 418 | } |
| 419 | |
| 420 | return ret; |
| 421 | } |
| 422 | |
| 423 | /* Call the export PDU tap with relevant data */ |
| 424 | static void |
| 425 | export_megaco_pdu(packet_info *pinfo, tvbuff_t *tvb) |
| 426 | { |
| 427 | exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, "megaco", EXP_PDU_TAG_DISSECTOR_NAME12); |
| 428 | |
| 429 | exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb); |
| 430 | exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb); |
| 431 | exp_pdu_data->pdu_tvb = tvb; |
| 432 | |
| 433 | tap_queue_packet(exported_pdu_tap, pinfo, exp_pdu_data); |
| 434 | |
| 435 | } |
| 436 | |
| 437 | /* |
| 438 | * The various functions that either dissect some |
| 439 | * subpart of MEGACO. These aren't really proto dissectors but they |
| 440 | * are written in the same style. |
| 441 | * |
| 442 | */ |
| 443 | static void |
| 444 | dissect_megaco_descriptors(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, proto_tree *top_tree, uint32_t context); |
| 445 | static void |
| 446 | dissect_megaco_digitmapdescriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int tvb_RBRKT, int tvb_previous_offset); |
| 447 | static void |
| 448 | dissect_megaco_topologydescriptor(tvbuff_t *tvb, proto_tree *tree, int tvb_RBRKT, int tvb_previous_offset); |
| 449 | static void |
| 450 | dissect_megaco_errordescriptor(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, unsigned tvb_RBRKT, unsigned tvb_previous_offset); |
| 451 | static void |
| 452 | dissect_megaco_statisticsdescriptor(tvbuff_t *tvb, proto_tree *megaco_tree_command_line); |
| 453 | static void |
| 454 | dissect_megaco_TerminationStatedescriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); |
| 455 | static void |
| 456 | dissect_megaco_LocalRemotedescriptor(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, uint32_t context, bool_Bool is_local); |
| 457 | static void |
| 458 | dissect_megaco_LocalControldescriptor(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, proto_tree *top_tree); |
| 459 | static void |
| 460 | dissect_megaco_Packagesdescriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned tvb_next_offset, unsigned tvb_current_offset); |
| 461 | static void |
| 462 | tvb_raw_text_add(tvbuff_t *tvb, proto_tree *tree); |
| 463 | static int |
| 464 | dissect_megaco_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data); |
| 465 | static int |
| 466 | megaco_tvb_find_token(tvbuff_t *tvb, int offset, int maxlength); |
| 467 | static dissector_handle_t data_handle; |
| 468 | static dissector_handle_t sdp_handle; |
| 469 | static dissector_handle_t h245_handle; |
| 470 | static dissector_handle_t h248_handle; |
| 471 | static dissector_handle_t h248_otp_handle; |
| 472 | |
| 473 | static bool_Bool keep_persistent_data; |
| 474 | |
| 475 | /* |
| 476 | * dissect_megaco_text over TCP, there will be a TPKT header there |
| 477 | * |
| 478 | */ |
| 479 | static int dissect_megaco_text_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U___attribute__((unused))) |
| 480 | { |
| 481 | |
| 482 | /* This code is copied from the Q.931 dissector, some parts skipped. |
| 483 | * Check whether this looks like a TPKT-encapsulated |
| 484 | * MEGACO packet. |
| 485 | * |
| 486 | * The minimum length of a MEGACO message is 6?: |
| 487 | * Re-assembly ? |
| 488 | */ |
| 489 | if (is_tpkt(tvb, 6, NULL((void*)0))) { |
| 490 | /* |
| 491 | * It's not a TPKT packet; |
| 492 | * Is in MEGACO ? |
| 493 | */ |
| 494 | dissect_megaco_text(tvb, pinfo, tree, data); |
| 495 | } |
| 496 | dissect_tpkt_encap(tvb, pinfo, tree, true1, megaco_text_handle); |
| 497 | |
| 498 | return tvb_captured_length(tvb); |
| 499 | } |
| 500 | |
| 501 | #define NO_MATCH0 0 |
| 502 | #define ERRORTOKEN1 1 |
| 503 | #define TRANSTOKEN2 2 |
| 504 | #define REPLYTOKEN3 3 |
| 505 | #define PENDINGTOKEN4 4 |
| 506 | #define RESPONSEACKTOKEN5 5 |
| 507 | |
| 508 | typedef struct { |
| 509 | const char *name; |
| 510 | const char *compact_name; |
| 511 | } megaco_tokens_t; |
| 512 | |
| 513 | static const megaco_tokens_t megaco_messageBody_names[] = { |
| 514 | { "Unknown-token", NULL((void*)0) }, /* 0 Pad so that the real headers start at index 1 */ |
| 515 | { "Error", "ER" }, /* 1 */ |
| 516 | { "Transaction", "T" }, /* 2 */ |
| 517 | { "Reply", "P" }, /* 3 */ |
| 518 | { "Pending", "PN" }, /* 4 */ |
| 519 | { "TransactionResponseAck", "K" }, /* 5 */ |
| 520 | }; |
| 521 | |
| 522 | /* Returns index of megaco_tokens_t */ |
| 523 | static unsigned find_megaco_messageBody_names(tvbuff_t *tvb, unsigned offset, unsigned header_len) |
| 524 | { |
| 525 | unsigned i; |
| 526 | |
| 527 | for (i = 1; i < array_length(megaco_messageBody_names)(sizeof (megaco_messageBody_names) / sizeof (megaco_messageBody_names )[0]); i++) { |
| 528 | if (header_len == strlen(megaco_messageBody_names[i].name) && |
| 529 | tvb_strncaseeql(tvb, offset, megaco_messageBody_names[i].name, header_len) == 0) |
| 530 | return i; |
| 531 | if (megaco_messageBody_names[i].compact_name != NULL((void*)0) && |
| 532 | header_len == strlen(megaco_messageBody_names[i].compact_name) && |
| 533 | tvb_strncaseeql(tvb, offset, megaco_messageBody_names[i].compact_name, header_len) == 0) |
| 534 | return i; |
| 535 | } |
| 536 | |
| 537 | return NO_MATCH0; |
| 538 | } |
| 539 | |
| 540 | static proto_item * |
| 541 | megaco_tree_add_string(proto_tree *tree, int hfindex, tvbuff_t *tvb, unsigned start, unsigned length, const char *value) |
| 542 | { |
| 543 | proto_item *pi; |
| 544 | |
| 545 | pi = proto_tree_add_string(tree, hfindex, tvb, start, length, value); |
| 546 | if (!global_megaco_dissect_tree) { |
| 547 | proto_item_set_hidden(pi); |
| 548 | } |
| 549 | |
| 550 | return pi; |
| 551 | } |
| 552 | |
| 553 | static proto_item * |
| 554 | my_proto_tree_add_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, |
| 555 | unsigned start, unsigned length, uint32_t value) |
| 556 | { |
| 557 | proto_item *pi; |
| 558 | |
| 559 | pi = proto_tree_add_uint(tree, hfindex, tvb, start, 1, value); |
| 560 | /* String length may be longer than FT_UINT will allow */ |
| 561 | proto_item_set_len(pi, length); |
| 562 | |
| 563 | if (!global_megaco_dissect_tree) { |
| 564 | proto_item_set_hidden(pi); |
| 565 | } |
| 566 | |
| 567 | return pi; |
| 568 | } |
| 569 | |
| 570 | /* |
| 571 | * dissect_megaco_text - The dissector for the MEGACO Protocol, using |
| 572 | * text encoding. |
| 573 | */ |
| 574 | static int |
| 575 | dissect_megaco_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U___attribute__((unused))) |
| 576 | { |
| 577 | unsigned tvb_len, len; |
| 578 | unsigned tvb_previous_offset, tvb_current_offset, tvb_offset, tvb_next_offset; |
| 579 | unsigned tokenlen, toffset; |
| 580 | unsigned context_offset, context_length, save_offset, save_length; |
| 581 | unsigned tvb_command_start_offset, tvb_command_end_offset; |
| 582 | unsigned tvb_transaction_end_offset; |
| 583 | proto_tree *megaco_tree, *message_body_tree, *megaco_tree_command_line; |
| 584 | proto_item *ti, *sub_ti; |
| 585 | |
| 586 | uint8_t word[15]; |
| 587 | uint8_t TermID[30]; |
| 588 | uint8_t tempchar; |
| 589 | unsigned tvb_RBRKT, tvb_LBRKT, RBRKT_counter, LBRKT_counter; |
| 590 | unsigned token_index=0; |
| 591 | uint32_t dword; |
| 592 | unsigned char needle; |
| 593 | |
| 594 | gcp_msg_t *msg = NULL((void*)0); |
| 595 | gcp_trx_t *trx = NULL((void*)0); |
| 596 | gcp_ctx_t *ctx = NULL((void*)0); |
| 597 | gcp_cmd_t *cmd = NULL((void*)0); |
| 598 | gcp_term_t *term = NULL((void*)0); |
| 599 | gcp_trx_type_t trx_type = GCP_TRX_NONE; |
| 600 | uint32_t trx_id = 0, pending_id; |
| 601 | uint32_t ctx_id = 0; |
| 602 | gcp_cmd_type_t cmd_type = GCP_CMD_NONE; |
| 603 | gcp_wildcard_t wild_term = GCP_WILDCARD_NONE; |
| 604 | bool_Bool short_form; |
| 605 | |
| 606 | megaco_commands_enum_t megaco_command = MEGACO_CMD_NOT_SET; |
| 607 | /* Initialize variables */ |
| 608 | tvb_len = tvb_reported_length(tvb); |
| 609 | megaco_tree = NULL((void*)0); |
| 610 | ti = NULL((void*)0); |
| 611 | tvb_offset = 0; |
| 612 | RBRKT_counter = 0; |
| 613 | LBRKT_counter = 0; |
| 614 | |
| 615 | /* Check if H.248 in otp(Erlang) internal format |
| 616 | * XXX Needs improvement? |
| 617 | * Ref: |
| 618 | * http://www.erlang.org/doc/apps/megaco/part_frame.html |
| 619 | * 4.1 Internal form of messages |
| 620 | * 4.2 The different encodings |
| 621 | */ |
| 622 | dword = tvb_get_ntoh24(tvb,0); |
| 623 | if ((dword == 0x836803)&&(h248_otp_handle)){ |
| 624 | call_dissector(h248_otp_handle, tvb, pinfo, tree); |
| 625 | return tvb_captured_length(tvb); |
| 626 | } |
| 627 | |
| 628 | msg = gcp_msg(pinfo, tvb_raw_offset(tvb), keep_persistent_data); |
| 629 | |
| 630 | /* |
| 631 | * Check to see whether we're really dealing with MEGACO by looking |
| 632 | * for the "MEGACO" string or a "!".This needs to be improved when supporting |
| 633 | * binary encodings. Bugfix add skipping of leading spaces. |
| 634 | */ |
| 635 | tvb_offset = megaco_tvb_skip_wsp(tvb, tvb_offset); |
| 636 | |
| 637 | if(!tvb_get_raw_bytes_as_stringz(tvb,tvb_offset,sizeof(word),word)) return tvb_captured_length(tvb); |
| 638 | |
| 639 | /* Quick fix for MEGACO packet with Authentication Header, |
| 640 | * marked as "AU" or "Authentication". |
| 641 | */ |
| 642 | if ((tvb_strncaseeql(tvb, tvb_offset, "Authentication", 14) == 0) || |
| 643 | (tvb_strncaseeql(tvb, tvb_offset, "AU", 2) == 0)) { |
| 644 | unsigned counter; |
| 645 | uint8_t next; |
| 646 | |
| 647 | /* move offset to end of auth header (EOL or WSP) */ |
| 648 | for ( counter = tvb_offset; counter < tvb_len; counter++ ) { |
| 649 | needle = tvb_get_uint8(tvb, counter); |
| 650 | if (needle == ' ' || needle == '\r' || needle == '\n') { |
| 651 | next = tvb_get_uint8(tvb, counter+1); |
| 652 | if (next == ' ' || next == '\r' || next == '\n') { |
| 653 | continue; |
| 654 | } |
| 655 | tvb_offset = counter + 1; |
| 656 | break; |
| 657 | } |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | short_form = (tvb_get_uint8(tvb, tvb_offset ) == '!'); |
| 662 | |
| 663 | if (tvb_strncaseeql(tvb, tvb_offset, "MEGACO", 6) != 0 && !short_form){ |
| 664 | int8_t ber_class; |
| 665 | bool_Bool pc; |
| 666 | int32_t tag; |
| 667 | dissector_handle_t handle = data_handle; |
| 668 | |
| 669 | get_ber_identifier(tvb, 0, &ber_class, &pc, &tag); |
| 670 | |
| 671 | if (ber_class == BER_CLASS_UNI0 && pc && tag == BER_UNI_TAG_SEQUENCE16 ) { |
| 672 | handle = h248_handle; |
| 673 | } |
| 674 | |
| 675 | call_dissector(handle,tvb,pinfo,tree); |
| 676 | return tvb_captured_length(tvb); |
| 677 | } |
| 678 | |
| 679 | |
| 680 | /* Display MEGACO in protocol column */ |
| 681 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "MEGACO"); |
| 682 | |
| 683 | /* Report this packet to the tap */ |
| 684 | if (!pinfo->flags.in_error_pkt) { |
| 685 | if (have_tap_listener(exported_pdu_tap)) { |
| 686 | export_megaco_pdu(pinfo, tvb); |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | /* Build the info tree if we've been given a root */ |
| 691 | /* Create megaco subtree */ |
| 692 | ti = proto_tree_add_item(tree,proto_megaco,tvb, 0, -1, ENC_NA0x00000000); |
| 693 | megaco_tree = proto_item_add_subtree(ti, ett_megaco); |
| 694 | |
| 695 | /* Format of 'message' is = MegacopToken SLASH Version SEP mId SEP messageBody */ |
| 696 | /* MegacopToken = "MEGACO" or "!" */ |
| 697 | /* According to H248.1-200205 Annex B Text encoding ( protocol version 2 ) */ |
| 698 | |
| 699 | /* Find version */ |
| 700 | if (!tvb_find_uint8_remaining(tvb, 0, '/', &tvb_previous_offset)) { |
| 701 | expert_add_info_format(pinfo, ti, &ei_megaco_parse_error, |
| 702 | "Sorry, no \"/\" in the MEGACO header, I can't parse this packet"); |
| 703 | return tvb_captured_length(tvb); |
| 704 | } |
| 705 | |
| 706 | megaco_tree_add_string(megaco_tree, hf_megaco_start, tvb, 0, tvb_previous_offset+1, |
| 707 | (char*)tvb_get_string_enc(pinfo->pool, tvb, 0, tvb_previous_offset, ENC_UTF_80x00000002|ENC_NA0x00000000)); |
| 708 | |
| 709 | /* skip / */ |
| 710 | tvb_previous_offset++; |
| 711 | |
| 712 | /* assume at least one digit in version */ |
| 713 | tvb_current_offset = tvb_previous_offset + 1; |
| 714 | |
| 715 | if (g_ascii_isdigit(tvb_get_uint8(tvb, tvb_current_offset))((g_ascii_table[(guchar) (tvb_get_uint8(tvb, tvb_current_offset ))] & G_ASCII_DIGIT) != 0)) { |
| 716 | /* 2-digit version */ |
| 717 | tvb_current_offset++; |
| 718 | } |
| 719 | |
| 720 | megaco_tree_add_string(megaco_tree, hf_megaco_version, tvb, tvb_previous_offset, tvb_current_offset - tvb_previous_offset, |
| 721 | (char*)tvb_get_string_enc(pinfo->pool, tvb, tvb_previous_offset, tvb_current_offset - tvb_previous_offset, ENC_UTF_80x00000002|ENC_NA0x00000000)); |
| 722 | |
| 723 | tvb_previous_offset = tvb_current_offset; |
| 724 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_previous_offset); |
| 725 | |
| 726 | if (tvb_previous_offset == tvb_current_offset) { |
| 727 | expert_add_info_format(pinfo, ti, &ei_megaco_parse_error, |
| 728 | "[ Parse error: missing SEP in MEGACO header ]"); |
| 729 | return tvb_current_offset; |
| 730 | } |
| 731 | |
| 732 | tvb_previous_offset = tvb_current_offset; |
| 733 | |
| 734 | /* mId should follow here, |
| 735 | * mId = (( domainAddress / domainName ) [":" portNumber]) / mtpAddress / deviceName |
| 736 | * domainAddress = "[" (IPv4address / IPv6address) "]" |
| 737 | * domainName = "<" (ALPHA / DIGIT) *63(ALPHA / DIGIT / "-" /".") ">" |
| 738 | * mtpAddress = MTPToken LBRKT 4*8 (HEXDIG) RBRKT |
| 739 | * MTPToken = ("MTP") |
| 740 | * deviceName = pathNAME |
| 741 | * pathNAME = ["*"] NAME *("/" / "*"/ ALPHA / DIGIT /"_" / "$" )["@" pathDomainName ] |
| 742 | */ |
| 743 | |
| 744 | if (!tvb_ws_mempbrk_uint8_length(tvb, tvb_current_offset, tvb_len, &pbrk_whitespace, &tvb_current_offset, &needle)) { |
| 745 | expert_add_info_format(pinfo, ti, &ei_megaco_parse_error, |
| 746 | "[ Parse error: no body in MEGACO message (missing SEP after mId) ]"); |
| 747 | return tvb_captured_length(tvb); |
| 748 | } |
| 749 | |
| 750 | tvb_next_offset = megaco_tvb_skip_wsp(tvb, tvb_current_offset); |
| 751 | |
| 752 | /* At this point we should point to the "\n" ending the mId element |
| 753 | * or to the next character after white space SEP |
| 754 | */ |
| 755 | megaco_tree_add_string(megaco_tree, hf_megaco_mId, tvb, tvb_previous_offset, tvb_current_offset - tvb_previous_offset, |
| 756 | (char*)tvb_get_string_enc(pinfo->pool, tvb, tvb_previous_offset, tvb_current_offset - tvb_previous_offset, ENC_UTF_80x00000002|ENC_NA0x00000000)); |
| 757 | |
| 758 | col_clear(pinfo->cinfo, COL_INFO); |
| 759 | do{ |
| 760 | tvb_previous_offset = tvb_next_offset; |
| 761 | |
| 762 | /* Next part is |
| 763 | * : messageBody = ( errorDescriptor / transactionList ) |
| 764 | * errorDescriptor = ErrorToken EQUAL ErrorCode LBRKT [quotedString] RBRKT |
| 765 | * ErrorToken = ("Error" / "ER") |
| 766 | * |
| 767 | * transactionList = 1*( transactionRequest / transactionReply / |
| 768 | * transactionPending / transactionResponseAck ) |
| 769 | * |
| 770 | * transactionResponseAck = ResponseAckToken LBRKT |
| 771 | * transactionAck*(COMMA transactionAck) RBRKT |
| 772 | * ResponseAckToken = ("TransactionResponseAck"/ "K") |
| 773 | * |
| 774 | * transactionPending = PendingToken EQUAL TransactionID LBRKT RBRKT |
| 775 | * PendingToken = ("Pending" / "PN") |
| 776 | * |
| 777 | * transactionReply = ReplyToken EQUAL TransactionID LBRKT |
| 778 | * [ ImmAckRequiredToken COMMA]( errorDescriptor / actionReplyList ) RBRKT |
| 779 | * ReplyToken = ("Reply" / "P") |
| 780 | * |
| 781 | * transactionRequest = TransToken EQUAL TransactionID LBRKT |
| 782 | * actionRequest *(COMMA actionRequest) RBRKT |
| 783 | * TransToken = ("Transaction" / "T") |
| 784 | */ |
| 785 | |
| 786 | /* Find token length */ |
| 787 | for (tvb_offset=tvb_previous_offset; tvb_offset < tvb_len-1; tvb_offset++){ |
| 788 | if (!g_ascii_isalpha(tvb_get_uint8(tvb, tvb_offset ))((g_ascii_table[(guchar) (tvb_get_uint8(tvb, tvb_offset ))] & G_ASCII_ALPHA) != 0)){ |
| 789 | break; |
| 790 | } |
| 791 | } |
| 792 | tokenlen = tvb_offset - tvb_previous_offset; |
| 793 | token_index = find_megaco_messageBody_names(tvb, tvb_previous_offset, tokenlen); |
| 794 | /* Debug code |
| 795 | ws_warning("token_index %u",token_index); |
| 796 | */ |
| 797 | |
| 798 | tvb_find_uint8_length(tvb, tvb_offset, tvb_len, '{', &tvb_LBRKT); |
| 799 | tvb_current_offset = tvb_LBRKT; |
| 800 | tvb_transaction_end_offset = megaco_tvb_find_token(tvb, tvb_LBRKT - 1, tvb_len); |
| 801 | |
| 802 | switch ( token_index ){ |
| 803 | /* errorDescriptor */ |
| 804 | case ERRORTOKEN1: |
| 805 | col_set_str(pinfo->cinfo, COL_INFO, "Error "); |
| 806 | |
| 807 | tvb_current_offset = megaco_tvb_find_token(tvb, tvb_offset, tvb_len); /*tvb_find_uint8(tvb, tvb_offset+1, tvb_len, '}');*/ |
| 808 | |
| 809 | ti = proto_tree_add_format_text(megaco_tree, tvb, tvb_previous_offset, tvb_current_offset-tvb_previous_offset); |
| 810 | message_body_tree = proto_item_add_subtree(ti, ett_megaco_message_body); |
| 811 | |
| 812 | if (tree) { |
| 813 | megaco_tree_add_string(message_body_tree, hf_megaco_transaction, tvb, tvb_previous_offset, tokenlen, "Error" ); |
| 814 | |
| 815 | tvb_command_start_offset = tvb_previous_offset; |
| 816 | dissect_megaco_errordescriptor(tvb, pinfo, megaco_tree, tvb_len-1, tvb_command_start_offset); |
| 817 | } |
| 818 | return tvb_captured_length(tvb); |
| 819 | /* transactionResponseAck |
| 820 | * transactionResponseAck = ResponseAckToken LBRKT transactionAck |
| 821 | * *(COMMA transactionAck) RBRKT |
| 822 | * transactionAck = transactionID / (transactionID "-" transactionID) |
| 823 | */ |
| 824 | case RESPONSEACKTOKEN5: |
| 825 | tvb_find_uint8_length(tvb, tvb_offset, tvb_transaction_end_offset, '{', &tvb_LBRKT); |
| 826 | tvb_offset = tvb_LBRKT; |
| 827 | save_offset = tvb_previous_offset; |
| 828 | save_length = tvb_current_offset-tvb_previous_offset; |
| 829 | |
| 830 | megaco_tree_add_string(megaco_tree, hf_megaco_transaction, tvb, save_offset, save_length, "TransactionResponseAck" ); |
| 831 | |
| 832 | tvb_previous_offset = megaco_tvb_skip_wsp(tvb, tvb_offset+1); |
| 833 | tvb_find_uint8_length(tvb, tvb_offset + 1, tvb_len, '}', &tvb_current_offset); |
| 834 | /*tvb_current_offset = megaco_tvb_find_token(tvb, tvb_offset, tvb_transaction_end_offset);*/ |
| 835 | tvb_current_offset = megaco_tvb_skip_wsp_return(tvb, tvb_current_offset)-1; /* cut last RBRKT */ |
| 836 | len = tvb_current_offset - tvb_previous_offset; |
| 837 | |
| 838 | pending_id = (unsigned)strtoul(tvb_format_text(pinfo->pool, tvb,tvb_previous_offset,len),NULL((void*)0),10); |
| 839 | col_append_sep_fstr(pinfo->cinfo, COL_INFO, " ", "%d TransactionResponseAck", pending_id); |
| 840 | |
| 841 | my_proto_tree_add_uint(megaco_tree, hf_megaco_transid, tvb, save_offset, save_length, pending_id); |
| 842 | |
| 843 | if(global_megaco_raw_text){ |
| 844 | tvb_raw_text_add(tvb, megaco_tree); |
| 845 | } |
| 846 | return tvb_captured_length(tvb); |
| 847 | /* Pe and PN is transactionPending, P+"any char" is transactionReply */ |
| 848 | case PENDINGTOKEN4: |
| 849 | |
| 850 | tvb_find_uint8_length(tvb, tvb_previous_offset, tvb_transaction_end_offset, '=', &tvb_offset); |
| 851 | tvb_offset += 1; |
| 852 | tvb_offset = megaco_tvb_skip_wsp(tvb, tvb_offset); |
| 853 | tvb_find_uint8_length(tvb, tvb_offset, tvb_transaction_end_offset, '{', &tvb_LBRKT); |
| 854 | tvb_current_offset = tvb_LBRKT; |
| 855 | save_offset = tvb_previous_offset; |
| 856 | save_length = tvb_current_offset-tvb_previous_offset; |
| 857 | |
| 858 | megaco_tree_add_string(megaco_tree, hf_megaco_transaction, tvb, save_offset, save_length, "Reply" ); |
| 859 | |
| 860 | tvb_current_offset = megaco_tvb_skip_wsp_return(tvb, tvb_current_offset-1); |
| 861 | len = tvb_current_offset - tvb_offset; |
| 862 | |
| 863 | pending_id = (unsigned)strtoul(tvb_format_text(pinfo->pool, tvb,tvb_offset,len),NULL((void*)0),10); |
| 864 | col_append_sep_fstr(pinfo->cinfo, COL_INFO, " ", "%d Pending", pending_id); |
| 865 | |
| 866 | my_proto_tree_add_uint(megaco_tree, hf_megaco_transid, tvb, save_offset, save_length, pending_id); |
| 867 | return tvb_captured_length(tvb); |
| 868 | |
| 869 | /* transactionReply */ |
| 870 | case REPLYTOKEN3: |
| 871 | trx_type = GCP_TRX_REPLY; |
| 872 | tvb_find_uint8_length(tvb, tvb_offset, tvb_transaction_end_offset, '{', &tvb_LBRKT); |
| 873 | save_offset = tvb_previous_offset; |
| 874 | save_length = tvb_LBRKT-tvb_previous_offset; |
| 875 | |
| 876 | megaco_tree_add_string(megaco_tree, hf_megaco_transaction, tvb, save_offset, save_length, "Reply" ); |
| 877 | |
| 878 | tvb_find_uint8_length(tvb, tvb_previous_offset, tvb_transaction_end_offset, '=', &tvb_offset); |
| 879 | tvb_offset = megaco_tvb_skip_wsp(tvb, tvb_offset); |
| 880 | tvb_current_offset = megaco_tvb_skip_wsp_return(tvb, tvb_LBRKT-1); |
| 881 | len = tvb_current_offset - tvb_offset; |
| 882 | |
| 883 | trx_id = (unsigned)strtoul(tvb_format_text(pinfo->pool, tvb,tvb_offset,len),NULL((void*)0),10); |
| 884 | col_add_fstr(pinfo->cinfo, COL_INFO, "%d Reply ", trx_id); |
| 885 | |
| 886 | my_proto_tree_add_uint(megaco_tree, hf_megaco_transid, tvb, save_offset, save_length, trx_id); |
| 887 | |
| 888 | /* Find if we have a errorDescriptor or actionReplyList */ |
| 889 | tvb_offset = megaco_tvb_skip_wsp(tvb, tvb_LBRKT+1); |
| 890 | tempchar = tvb_get_uint8(tvb,tvb_offset); |
| 891 | if ((tempchar == 'E')||(tempchar == 'e')){ |
| 892 | dissect_megaco_errordescriptor(tvb, pinfo, megaco_tree, tvb_transaction_end_offset-1, tvb_offset); |
| 893 | return tvb_captured_length(tvb); |
| 894 | } |
| 895 | /* Offset should be at first printable char after { */ |
| 896 | tvb_previous_offset = tvb_offset; |
| 897 | break; |
| 898 | case TRANSTOKEN2: |
| 899 | /* TransactionRequest */ |
| 900 | trx_type = GCP_TRX_REQUEST; |
| 901 | save_offset = tvb_previous_offset; |
| 902 | save_length = tvb_current_offset-tvb_previous_offset; |
| 903 | megaco_tree_add_string(megaco_tree, hf_megaco_transaction, tvb, |
| 904 | save_offset, save_length, "Request" ); |
| 905 | |
| 906 | tvb_find_uint8_length(tvb, tvb_offset, tvb_transaction_end_offset, '=', &tvb_offset); |
| 907 | tvb_offset += 1; |
| 908 | tvb_offset = megaco_tvb_skip_wsp(tvb, tvb_offset); |
| 909 | tvb_current_offset = megaco_tvb_skip_wsp_return(tvb, tvb_current_offset-1); |
| 910 | len = tvb_current_offset - tvb_offset; |
| 911 | |
| 912 | trx_id = (unsigned)strtoul(tvb_format_text(pinfo->pool, tvb,tvb_offset,len),NULL((void*)0),10); |
| 913 | col_append_sep_fstr(pinfo->cinfo, COL_INFO, " ", "%d Request", trx_id); |
| 914 | |
| 915 | my_proto_tree_add_uint(megaco_tree, hf_megaco_transid, tvb, save_offset, save_length, trx_id); |
| 916 | /* Offset should be at first printable char after { */ |
| 917 | tvb_previous_offset = megaco_tvb_skip_wsp(tvb, tvb_LBRKT+1); |
| 918 | |
| 919 | break; |
| 920 | default : /* NO_MATCH */ |
| 921 | proto_tree_add_expert_format_remaining(tree, pinfo, &ei_megaco_error_descriptor_transaction_list, tvb, 0, |
| 922 | "Sorry, can't understand errorDescriptor / transactionList = %s, can't parse it pos %u", |
| 923 | tvb_format_text(pinfo->pool, tvb,tvb_previous_offset,2),tvb_previous_offset); |
| 924 | return tvb_captured_length(tvb); |
| 925 | } /* end switch */ |
| 926 | /* Only these remains now |
| 927 | * transactionReply = ReplyToken EQUAL TransactionID LBRKT |
| 928 | * [ ImmAckRequiredToken COMMA]( errorDescriptor / actionReplyList ) RBRKT |
| 929 | * ReplyToken = ("Reply" / "P") |
| 930 | * |
| 931 | * errorDescriptor = ErrorToken EQUAL ErrorCode |
| 932 | * LBRKT [quotedString] RBRKT |
| 933 | * |
| 934 | * transactionRequest = TransToken EQUAL TransactionID LBRKT |
| 935 | * actionRequest *(COMMA actionRequest) RBRKT |
| 936 | * TransToken = ("Transaction" / "T") |
| 937 | */ |
| 938 | |
| 939 | trx = gcp_trx(msg , trx_id , trx_type, pinfo, keep_persistent_data); |
| 940 | |
| 941 | /* Find Context */ |
| 942 | nextcontext: |
| 943 | |
| 944 | |
| 945 | |
| 946 | /* Check result???*/ |
| 947 | tvb_find_uint8_length(tvb, tvb_previous_offset, tvb_transaction_end_offset, '{', &tvb_next_offset); |
| 948 | context_offset = tvb_previous_offset; |
| 949 | context_length = tvb_next_offset-tvb_previous_offset+1; |
| 950 | |
| 951 | tvb_find_uint8_length(tvb, tvb_current_offset, tvb_transaction_end_offset, '=', &tvb_previous_offset); |
| 952 | tvb_previous_offset += 1; |
| 953 | tvb_previous_offset = megaco_tvb_skip_wsp(tvb, tvb_previous_offset); |
| 954 | |
| 955 | if (tvb_current_offset >= tvb_next_offset) { |
| 956 | proto_tree_add_expert_format(megaco_tree, pinfo, &ei_megaco_parse_error, |
| 957 | tvb, context_offset, context_length, "Parse error: Invalid offset"); |
| 958 | return tvb_captured_length(tvb); |
| 959 | } |
| 960 | tvb_current_offset = tvb_next_offset; |
| 961 | |
| 962 | |
| 963 | tokenlen = tvb_current_offset - tvb_previous_offset; |
| 964 | tempchar = tvb_get_uint8(tvb, tvb_previous_offset ); |
| 965 | |
| 966 | if (tvb_get_uint8(tvb, tvb_current_offset-1 ) == ' '){ |
| 967 | tokenlen--; |
| 968 | } |
| 969 | |
| 970 | switch ( tempchar ){ |
| 971 | case '$': |
| 972 | ctx_id = CHOOSE_CONTEXT0xFFFFFFFE; |
| 973 | break; |
| 974 | case '*': |
| 975 | ctx_id = ALL_CONTEXTS0xFFFFFFFF; |
| 976 | break; |
| 977 | case '-': |
| 978 | ctx_id = NULL_CONTEXT0; |
| 979 | break; |
| 980 | default: |
| 981 | ctx_id = (unsigned)strtoul(tvb_format_text(pinfo->pool, tvb, tvb_previous_offset, tokenlen),NULL((void*)0),10); |
| 982 | } |
| 983 | |
| 984 | my_proto_tree_add_uint(megaco_tree, hf_megaco_Context, tvb, context_offset, context_length, ctx_id); |
| 985 | sub_ti = my_proto_tree_add_uint(megaco_tree, hf_megaco_Context_generated, tvb, context_offset, context_length, ctx_id); |
| 986 | proto_item_set_generated(sub_ti); |
| 987 | col_append_fstr(pinfo->cinfo, COL_INFO, " |=%s", val_to_str(pinfo->pool, ctx_id, megaco_context_vals, "%d")); |
| 988 | |
| 989 | ctx = gcp_ctx(msg,trx,ctx_id,pinfo,keep_persistent_data); |
| 990 | |
| 991 | /* Find Commands */ |
| 992 | |
| 993 | /* If Transaction is Request, Reply or Pending */ |
| 994 | tvb_command_start_offset = megaco_tvb_skip_wsp(tvb, tvb_current_offset +1); |
| 995 | tvb_command_end_offset = tvb_command_start_offset; |
| 996 | |
| 997 | tvb_LBRKT = tvb_command_start_offset; |
| 998 | tvb_RBRKT = tvb_command_start_offset; |
| 999 | |
| 1000 | /* The following loop find the individual contexts, commands and call the for every Descriptor a subroutine */ |
| 1001 | |
| 1002 | do { |
| 1003 | if ( !tvb_find_uint8_length(tvb, tvb_command_end_offset + 1, tvb_transaction_end_offset, ',', &tvb_command_end_offset) || tvb_command_end_offset > tvb_transaction_end_offset){ |
| 1004 | tvb_command_end_offset = tvb_transaction_end_offset ; |
| 1005 | } |
| 1006 | |
| 1007 | /* checking how many left brackets are before the next comma */ |
| 1008 | while (tvb_find_uint8_length(tvb, tvb_LBRKT + 1 + 1, tvb_transaction_end_offset, '{', &toffset) |
| 1009 | && toffset < tvb_command_end_offset){ |
| 1010 | |
| 1011 | tvb_LBRKT = toffset; |
| 1012 | LBRKT_counter++; |
| 1013 | } |
| 1014 | |
| 1015 | /* checking how many right brackets are before the next comma */ |
| 1016 | |
| 1017 | while ( (tvb_find_uint8_length(tvb, tvb_RBRKT+1,tvb_transaction_end_offset, '}', &toffset)) |
| 1018 | && toffset <= tvb_command_end_offset |
| 1019 | && LBRKT_counter != 0){ |
| 1020 | |
| 1021 | tvb_find_uint8_length(tvb, tvb_RBRKT + 1, tvb_transaction_end_offset, '}', &tvb_RBRKT); |
| 1022 | RBRKT_counter++; |
| 1023 | |
| 1024 | |
| 1025 | } |
| 1026 | |
| 1027 | /* If equal or more right brackets before the comma, one command is complete */ |
| 1028 | |
| 1029 | if ( LBRKT_counter <= RBRKT_counter ){ |
| 1030 | |
| 1031 | tvb_find_uint8_length(tvb, tvb_command_start_offset, tvb_transaction_end_offset, '{', &tvb_current_offset); |
| 1032 | |
| 1033 | |
| 1034 | /* includes no descriptors */ |
| 1035 | |
| 1036 | if ( LBRKT_counter == 0 ){ |
| 1037 | |
| 1038 | tvb_current_offset = tvb_command_end_offset; |
| 1039 | |
| 1040 | /* the last command in a context */ |
| 1041 | if (tvb_find_uint8_length(tvb, tvb_command_start_offset, tvb_transaction_end_offset, '}', &toffset) |
| 1042 | && toffset < tvb_current_offset){ |
| 1043 | |
| 1044 | tvb_previous_offset = toffset; |
| 1045 | |
| 1046 | len = tvb_previous_offset - tvb_command_start_offset; |
| 1047 | |
| 1048 | tvb_previous_offset = megaco_tvb_skip_wsp_return(tvb, tvb_previous_offset -1); |
| 1049 | |
| 1050 | tokenlen = tvb_previous_offset - tvb_command_start_offset; |
| 1051 | |
| 1052 | } |
| 1053 | |
| 1054 | /* not the last command in a context*/ |
| 1055 | |
| 1056 | else{ |
| 1057 | len = tvb_current_offset - tvb_command_start_offset; |
| 1058 | tvb_current_offset = megaco_tvb_skip_wsp_return(tvb, tvb_current_offset -1); |
| 1059 | |
| 1060 | tokenlen = tvb_current_offset - tvb_command_start_offset; |
| 1061 | } |
| 1062 | } |
| 1063 | |
| 1064 | /* command includes descriptors */ |
| 1065 | |
| 1066 | else{ |
| 1067 | len = tvb_current_offset - tvb_command_start_offset; |
| 1068 | tvb_current_offset = megaco_tvb_skip_wsp_return(tvb, tvb_current_offset -1); |
| 1069 | |
| 1070 | tokenlen = tvb_current_offset - tvb_command_start_offset; |
| 1071 | } |
| 1072 | |
| 1073 | /* if a next context is specified */ |
| 1074 | |
| 1075 | if ( tvb_get_uint8(tvb, tvb_command_start_offset ) == 'C'){ |
| 1076 | tvb_current_offset = tvb_command_start_offset; |
| 1077 | tvb_previous_offset = tvb_command_start_offset; |
| 1078 | LBRKT_counter = 0; |
| 1079 | RBRKT_counter = 0; |
| 1080 | goto nextcontext; |
| 1081 | } |
| 1082 | |
| 1083 | megaco_tree_command_line = proto_tree_add_subtree(megaco_tree, tvb, tvb_command_start_offset, len+1, ett_megaco_command_line, &sub_ti, "Command: "); |
| 1084 | megaco_command = MEGACO_CMD_NOT_SET; |
| 1085 | /* creation of the megaco_tree_command_line additionally Command and Transaction ID will be printed in this line */ |
| 1086 | /* Changed to use the lines above. this code is saved if there is complaints |
| 1087 | sub_ti = proto_tree_add_item(megaco_tree,hf_megaco_command_line,tvb,tvb_command_start_offset,tokenlen, ENC_UTF_8); |
| 1088 | megaco_tree_command_line = proto_item_add_subtree(sub_ti, ett_megaco_command_line); |
| 1089 | */ |
| 1090 | if (!global_megaco_dissect_tree) { |
| 1091 | proto_item_set_hidden(sub_ti); |
| 1092 | } |
| 1093 | |
| 1094 | tvb_next_offset = tvb_command_start_offset + tokenlen; |
| 1095 | |
| 1096 | /* Try to dissect Topology Descriptor before the command */ |
| 1097 | tempchar = tvb_get_uint8(tvb, tvb_command_start_offset); |
| 1098 | if ( (tempchar >= 'a')&& (tempchar <= 'z')){ |
| 1099 | tempchar = tempchar - 0x20; |
| 1100 | } |
| 1101 | if ( tempchar == 'T') { |
| 1102 | tempchar = tvb_get_uint8(tvb, tvb_command_start_offset+1); |
| 1103 | |
| 1104 | if ( (tempchar >= 'a')&& (tempchar <= 'z')) |
| 1105 | tempchar = tempchar - 0x20; |
| 1106 | |
| 1107 | if ( tempchar == 'P' || tempchar == 'O'){ |
| 1108 | unsigned tvb_topology_end_offset; |
| 1109 | if ( !tvb_find_uint8_length(tvb, tvb_command_start_offset, tvb_transaction_end_offset, '}', &tvb_topology_end_offset) ){ |
| 1110 | expert_add_info_format(pinfo, sub_ti, &ei_megaco_parse_error, "Parse error: Missing \"}\""); |
| 1111 | return tvb_captured_length(tvb); |
| 1112 | } |
| 1113 | |
| 1114 | if ( !tvb_find_uint8_length(tvb, tvb_command_start_offset, tvb_transaction_end_offset, '}', &tvb_command_start_offset)){ |
| 1115 | expert_add_info_format(pinfo, sub_ti, &ei_megaco_parse_error, "Parse error: Missing \"{\""); |
| 1116 | return tvb_captured_length(tvb); |
| 1117 | } |
| 1118 | |
| 1119 | dissect_megaco_topologydescriptor(tvb, megaco_tree_command_line, tvb_topology_end_offset-1, tvb_command_start_offset+1); |
| 1120 | |
| 1121 | /* Command after Topology Descriptor */ |
| 1122 | if ( !tvb_find_uint8_length(tvb, tvb_topology_end_offset + 1, tvb_transaction_end_offset, ',', &tvb_command_start_offset)){ |
| 1123 | /* No Command present after Topology Descriptor */ |
| 1124 | break; |
| 1125 | |
| 1126 | } else { |
| 1127 | /* Try to find the first char of the command */ |
| 1128 | tvb_command_start_offset = megaco_tvb_skip_wsp(tvb, tvb_command_start_offset + 1); |
| 1129 | RBRKT_counter = 0; |
| 1130 | LBRKT_counter = 0; |
| 1131 | tvb_LBRKT = tvb_command_start_offset; |
| 1132 | tvb_RBRKT = tvb_command_start_offset; |
| 1133 | /*tvb_next_offset = tvb_find_uint8(tvb, tvb_command_start_offset, tvb_transaction_end_offset, '{');*/ |
| 1134 | continue; |
| 1135 | } |
| 1136 | |
| 1137 | } |
| 1138 | } |
| 1139 | |
| 1140 | /* Additional value */ |
| 1141 | if ( tvb_get_uint8(tvb, tvb_command_start_offset ) == 'O'){ |
| 1142 | |
| 1143 | proto_tree_add_item(megaco_tree_command_line, hf_megaco_command_optional, tvb, tvb_command_start_offset, 2, ENC_NA0x00000000); |
| 1144 | tvb_command_start_offset = tvb_command_start_offset+2; |
| 1145 | |
| 1146 | } |
| 1147 | |
| 1148 | /* Additional value */ |
| 1149 | if ( tvb_get_uint8(tvb, tvb_command_start_offset ) == 'W'){ |
| 1150 | |
| 1151 | proto_tree_add_item(megaco_tree_command_line, hf_megaco_wildcard_response, tvb, tvb_command_start_offset, 2, ENC_NA0x00000000 ); |
| 1152 | tvb_command_start_offset = tvb_command_start_offset+2; |
| 1153 | } |
| 1154 | |
| 1155 | if (!tvb_find_uint8_length(tvb, tvb_command_start_offset + 1, tvb_transaction_end_offset, '=', &tvb_offset)) { |
| 1156 | proto_tree_add_expert_format(megaco_tree, pinfo, &ei_megaco_parse_error, tvb, tvb_command_start_offset, len+1, "Parse error: Missing \"=\""); |
| 1157 | return tvb_captured_length(tvb); |
| 1158 | } |
| 1159 | tvb_offset = megaco_tvb_skip_wsp_return(tvb, tvb_offset -1); |
| 1160 | tokenlen = tvb_offset - tvb_command_start_offset; |
| 1161 | |
| 1162 | tempchar = tvb_get_uint8(tvb, tvb_command_start_offset); |
| 1163 | if ( (tempchar >= 'a')&& (tempchar <= 'z')) |
| 1164 | tempchar = tempchar - 0x20; |
| 1165 | |
| 1166 | if ( tempchar != 'E' ){ |
| 1167 | /* Short form used */ |
| 1168 | if (short_form){ |
| 1169 | |
| 1170 | switch ( tempchar ){ |
| 1171 | |
| 1172 | case 'A': |
| 1173 | |
| 1174 | tempchar = tvb_get_uint8(tvb, tvb_command_start_offset+1); |
| 1175 | if ( (tempchar >= 'a')&& (tempchar <= 'z')) |
| 1176 | tempchar = tempchar - 0x20; |
| 1177 | |
| 1178 | switch ( tempchar ){ |
| 1179 | |
| 1180 | case 'V': |
| 1181 | switch(trx_type) { |
| 1182 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_AUDITVAL_REPLY; break; |
| 1183 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_AUDITVAL_REQ; break; |
| 1184 | default: cmd_type = GCP_CMD_NONE; break; |
| 1185 | } |
| 1186 | |
| 1187 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_command, tvb, |
| 1188 | tvb_command_start_offset, tokenlen, "AuditValue"); |
| 1189 | col_append_str(pinfo->cinfo, COL_INFO, " AuditValue"); |
| 1190 | proto_item_append_text(sub_ti, "AuditValue"); |
| 1191 | break; |
| 1192 | |
| 1193 | case 'C': |
| 1194 | switch(trx_type) { |
| 1195 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_AUDITCAP_REQ; break; |
| 1196 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_AUDITCAP_REPLY; break; |
| 1197 | default: cmd_type = GCP_CMD_NONE; break; |
| 1198 | } |
| 1199 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_command, tvb, |
| 1200 | tvb_command_start_offset, tokenlen, "AuditCapability"); |
| 1201 | col_append_str(pinfo->cinfo, COL_INFO, " AuditCapability"); |
| 1202 | proto_item_append_text(sub_ti, "AuditCapability"); |
| 1203 | break; |
| 1204 | |
| 1205 | default: |
| 1206 | switch(trx_type) { |
| 1207 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_ADD_REQ; break; |
| 1208 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_ADD_REPLY; break; |
| 1209 | default: cmd_type = GCP_CMD_NONE; break; |
| 1210 | } |
| 1211 | |
| 1212 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_command, tvb, |
| 1213 | tvb_command_start_offset, tokenlen, "Add"); |
| 1214 | col_append_str(pinfo->cinfo, COL_INFO, " Add"); |
| 1215 | proto_item_append_text(sub_ti, "Add"); |
| 1216 | break; |
| 1217 | } |
| 1218 | break; |
| 1219 | |
| 1220 | case 'I': |
| 1221 | /* "IEPS" */ |
| 1222 | tempchar = tvb_get_uint8(tvb, tvb_command_start_offset+1); |
| 1223 | if(tempchar == 'E'){ |
| 1224 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_command, tvb, |
| 1225 | tvb_command_start_offset, tokenlen, "IEPSCall"); |
| 1226 | col_append_str(pinfo->cinfo, COL_INFO, " IEPSCall"); |
| 1227 | proto_item_append_text(sub_ti, "IEPSCall"); |
| 1228 | } |
| 1229 | cmd_type = GCP_CMD_NONE; |
| 1230 | break; |
| 1231 | case 'N': |
| 1232 | switch(trx_type) { |
| 1233 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_NOTIFY_REQ; break; |
| 1234 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_NOTIFY_REPLY; break; |
| 1235 | default: cmd_type = GCP_CMD_NONE; break; |
| 1236 | } |
| 1237 | |
| 1238 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_command, tvb, |
| 1239 | tvb_command_start_offset, tokenlen, "Notify"); |
| 1240 | col_append_str(pinfo->cinfo, COL_INFO, " Notify"); |
| 1241 | proto_item_append_text(sub_ti, "Notify"); |
| 1242 | break; |
| 1243 | |
| 1244 | case 'M': |
| 1245 | |
| 1246 | tempchar = tvb_get_uint8(tvb, tvb_command_start_offset+1); |
| 1247 | if ( (tempchar >= 'a')&& (tempchar <= 'z')) |
| 1248 | tempchar = tempchar - 0x20; |
| 1249 | |
| 1250 | switch ( tempchar ){ |
| 1251 | case 'F': |
| 1252 | switch(trx_type) { |
| 1253 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_MOD_REQ; break; |
| 1254 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_MOD_REPLY; break; |
| 1255 | default: cmd_type = GCP_CMD_NONE; break; |
| 1256 | } |
| 1257 | |
| 1258 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_command, tvb, |
| 1259 | tvb_command_start_offset, tokenlen, "Modify"); |
| 1260 | col_append_str(pinfo->cinfo, COL_INFO, " Modify"); |
| 1261 | proto_item_append_text(sub_ti, "Modify"); |
| 1262 | break; |
| 1263 | |
| 1264 | case 'V': |
| 1265 | switch(trx_type) { |
| 1266 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_MOVE_REQ; break; |
| 1267 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_MOVE_REPLY; break; |
| 1268 | default: cmd_type = GCP_CMD_NONE; break; |
| 1269 | } |
| 1270 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_command, tvb, |
| 1271 | tvb_command_start_offset, tokenlen, "Move"); |
| 1272 | col_append_str(pinfo->cinfo, COL_INFO, " Move"); |
| 1273 | proto_item_append_text(sub_ti, "Move"); |
| 1274 | break; |
| 1275 | } |
| 1276 | break; |
| 1277 | |
| 1278 | case 'P': |
| 1279 | cmd_type = GCP_CMD_NONE; |
| 1280 | /* |
| 1281 | PackagesToken = ("Packages" / "PG") |
| 1282 | PendingToken = ("Pending" / "PN") |
| 1283 | PriorityToken = ("Priority" / "PR") |
| 1284 | ProfileToken = ("Profile" / "PF") |
| 1285 | */ |
| 1286 | tempchar = tvb_get_uint8(tvb, tvb_command_start_offset+1); |
| 1287 | if ( (tempchar >= 'a')&& (tempchar <= 'z')) |
| 1288 | tempchar = tempchar - 0x20; |
| 1289 | |
| 1290 | switch ( tempchar ){ |
| 1291 | case 'G': |
| 1292 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_command, tvb, |
| 1293 | tvb_command_start_offset, tokenlen, "Packages"); |
| 1294 | col_append_str(pinfo->cinfo, COL_INFO, " Packages"); |
| 1295 | proto_item_append_text(sub_ti, "Packages"); |
| 1296 | break; |
| 1297 | case 'N': |
| 1298 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_command, tvb, |
| 1299 | tvb_command_start_offset, tokenlen, "Pending"); |
| 1300 | col_append_str(pinfo->cinfo, COL_INFO, " Pending"); |
| 1301 | proto_item_append_text(sub_ti, "Pending"); |
| 1302 | break; |
| 1303 | case 'R': |
| 1304 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_command, tvb, |
| 1305 | tvb_command_start_offset, tokenlen, "Priority"); |
| 1306 | col_append_str(pinfo->cinfo, COL_INFO, " Priority"); |
| 1307 | proto_item_append_text(sub_ti, "Priority"); |
| 1308 | megaco_command = MEGACO_CMD_PRIORITY; |
| 1309 | break; |
| 1310 | case 'F': |
| 1311 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_command, tvb, |
| 1312 | tvb_command_start_offset, tokenlen, "Profile"); |
| 1313 | col_append_str(pinfo->cinfo, COL_INFO, " Profile"); |
| 1314 | proto_item_append_text(sub_ti, "Profile"); |
| 1315 | break; |
| 1316 | } |
| 1317 | break; |
| 1318 | |
| 1319 | case 'S': |
| 1320 | tempchar = tvb_get_uint8(tvb, tvb_command_start_offset+1); |
| 1321 | if ( (tempchar >= 'a')&& (tempchar <= 'z')) |
| 1322 | tempchar = tempchar - 0x20; |
| 1323 | |
| 1324 | switch ( tempchar ){ |
| 1325 | |
| 1326 | case 'C': |
| 1327 | switch(trx_type) { |
| 1328 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_SVCCHG_REQ; break; |
| 1329 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_SVCCHG_REPLY; break; |
| 1330 | default: cmd_type = GCP_CMD_NONE; break; |
| 1331 | } |
| 1332 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_command, tvb, |
| 1333 | tvb_command_start_offset, tokenlen, "ServiceChange"); |
| 1334 | col_append_str(pinfo->cinfo, COL_INFO, " ServiceChange"); |
| 1335 | proto_item_append_text(sub_ti, "ServiceChange"); |
| 1336 | break; |
| 1337 | |
| 1338 | default: |
| 1339 | switch(trx_type) { |
| 1340 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_SUB_REQ; break; |
| 1341 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_SUB_REPLY; break; |
| 1342 | default: cmd_type = GCP_CMD_NONE; break; |
| 1343 | } |
| 1344 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_command, tvb, |
| 1345 | tvb_command_start_offset, tokenlen, "Subtract"); |
| 1346 | col_append_str(pinfo->cinfo, COL_INFO, " Subtract"); |
| 1347 | proto_item_append_text(sub_ti, "Subtract"); |
| 1348 | break; |
| 1349 | } |
| 1350 | break; |
| 1351 | |
| 1352 | default: |
| 1353 | proto_item_append_text(sub_ti, "<None> 0x%02x", tempchar); |
| 1354 | expert_add_info(pinfo, sub_ti, &ei_megaco_no_command); |
| 1355 | return tvb_captured_length(tvb); |
| 1356 | } |
| 1357 | } |
| 1358 | else{ |
| 1359 | char* command = tvb_format_text(pinfo->pool, tvb, tvb_command_start_offset, tokenlen); |
| 1360 | |
| 1361 | if ( g_str_equal(command,"Subtract")(strcmp ((const char *) (command), (const char *) ("Subtract" )) == 0) ) { |
| 1362 | switch(trx_type) { |
| 1363 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_SUB_REQ; break; |
| 1364 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_SUB_REPLY; break; |
| 1365 | default: cmd_type = GCP_CMD_NONE; break; |
| 1366 | } |
| 1367 | } else if ( g_str_equal(command,"AuditValue")(strcmp ((const char *) (command), (const char *) ("AuditValue" )) == 0) ) { |
| 1368 | switch(trx_type) { |
| 1369 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_AUDITVAL_REPLY; break; |
| 1370 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_AUDITVAL_REQ; break; |
| 1371 | default: cmd_type = GCP_CMD_NONE; break; |
| 1372 | } |
| 1373 | } else if ( g_str_equal(command,"AuditCapability")(strcmp ((const char *) (command), (const char *) ("AuditCapability" )) == 0) ) { |
| 1374 | switch(trx_type) { |
| 1375 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_AUDITCAP_REQ; break; |
| 1376 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_AUDITCAP_REPLY; break; |
| 1377 | default: cmd_type = GCP_CMD_NONE; break; |
| 1378 | } |
| 1379 | } else if ( g_str_equal(command,"Add")(strcmp ((const char *) (command), (const char *) ("Add")) == 0) ) { |
| 1380 | switch(trx_type) { |
| 1381 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_ADD_REQ; break; |
| 1382 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_ADD_REPLY; break; |
| 1383 | default: cmd_type = GCP_CMD_NONE; break; |
| 1384 | } |
| 1385 | } else if ( g_str_equal(command,"Notify")(strcmp ((const char *) (command), (const char *) ("Notify")) == 0) ) { |
| 1386 | switch(trx_type) { |
| 1387 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_NOTIFY_REQ; break; |
| 1388 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_NOTIFY_REPLY; break; |
| 1389 | default: cmd_type = GCP_CMD_NONE; break; |
| 1390 | } |
| 1391 | } else if ( g_str_equal(command,"Modify")(strcmp ((const char *) (command), (const char *) ("Modify")) == 0) ) { |
| 1392 | switch(trx_type) { |
| 1393 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_MOD_REQ; break; |
| 1394 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_MOD_REPLY; break; |
| 1395 | default: cmd_type = GCP_CMD_NONE; break; |
| 1396 | } |
| 1397 | } else if ( g_str_equal(command,"Move")(strcmp ((const char *) (command), (const char *) ("Move")) == 0) ) { |
| 1398 | switch(trx_type) { |
| 1399 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_MOVE_REQ; break; |
| 1400 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_MOVE_REPLY; break; |
| 1401 | default: cmd_type = GCP_CMD_NONE; break; |
| 1402 | } |
| 1403 | } else if ( g_str_equal(command,"ServiceChange")(strcmp ((const char *) (command), (const char *) ("ServiceChange" )) == 0) ) { |
| 1404 | switch(trx_type) { |
| 1405 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_SVCCHG_REQ; break; |
| 1406 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_SVCCHG_REPLY; break; |
| 1407 | default: cmd_type = GCP_CMD_NONE; break; |
| 1408 | } |
| 1409 | } else { |
| 1410 | switch(trx_type) { |
| 1411 | case GCP_TRX_REQUEST: cmd_type = GCP_CMD_OTHER_REQ; break; |
| 1412 | case GCP_TRX_REPLY: cmd_type = GCP_CMD_REPLY; break; |
| 1413 | default: cmd_type = GCP_CMD_NONE; break; |
| 1414 | } |
| 1415 | } |
| 1416 | |
| 1417 | |
| 1418 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_command, tvb, |
| 1419 | tvb_command_start_offset, tokenlen, command); |
| 1420 | col_append_fstr(pinfo->cinfo, COL_INFO, " %s", command); |
| 1421 | proto_item_append_text(sub_ti, " %s", command); |
| 1422 | } |
| 1423 | |
| 1424 | if (cmd_type == GCP_CMD_NONE && trx_type == GCP_TRX_REPLY) { |
| 1425 | cmd_type = GCP_CMD_REPLY; |
| 1426 | } |
| 1427 | |
| 1428 | if (cmd_type != GCP_CMD_NONE) { |
| 1429 | cmd = gcp_cmd(msg, trx, ctx, cmd_type, tvb_command_start_offset, pinfo, keep_persistent_data); |
| 1430 | tap_queue_packet(megaco_tap, pinfo, cmd); |
| 1431 | } |
| 1432 | |
| 1433 | if (!tvb_find_uint8_length(tvb, tvb_command_start_offset, tvb_transaction_end_offset, '=', &tvb_offset)) { |
| 1434 | expert_add_info_format(pinfo, sub_ti, &ei_megaco_parse_error, "Parse error: Missing \"=\""); |
| 1435 | return tvb_captured_length(tvb); |
| 1436 | } |
| 1437 | |
| 1438 | tvb_offset = megaco_tvb_skip_wsp(tvb, tvb_offset+1); |
| 1439 | tokenlen = tvb_next_offset - tvb_offset; |
| 1440 | if (tokenlen == 0) { |
| 1441 | expert_add_info_format(pinfo, sub_ti, &ei_megaco_parse_error, "Parse error: Invalid token length (%d)", tokenlen+1); |
| 1442 | return tvb_captured_length(tvb); |
| 1443 | } |
| 1444 | |
| 1445 | tempchar = tvb_get_uint8(tvb, tvb_offset); |
| 1446 | if ( (tempchar >= 'a')&& (tempchar <= 'z')) |
| 1447 | tempchar = tempchar - 0x20; |
| 1448 | |
| 1449 | term = wmem_new0(pinfo->pool, gcp_term_t)((gcp_term_t*)wmem_alloc0((pinfo->pool), sizeof(gcp_term_t ))); |
| 1450 | wild_term = GCP_WILDCARD_NONE; |
| 1451 | term->type = GCP_TERM_TYPE_UNKNOWN0; |
| 1452 | int bytelen; |
| 1453 | |
| 1454 | switch ( tempchar ){ |
| 1455 | |
| 1456 | case 'E': |
| 1457 | if ((tokenlen+1 > (int) sizeof(TermID))) { |
| 1458 | expert_add_info_format(pinfo, sub_ti, &ei_megaco_parse_error, "Parse error: Invalid TermID length (%d)", tokenlen+1); |
| 1459 | return tvb_captured_length(tvb); |
| 1460 | } |
| 1461 | bytelen = tvb_get_raw_bytes_as_stringz(tvb,tvb_offset,tokenlen+1,TermID); |
| 1462 | TermID[0] = 'e'; |
| 1463 | |
| 1464 | term->buffer = get_utf_8_string(pinfo->pool, TermID, bytelen); |
| 1465 | term->len = (int)strlen((char*)term->buffer); |
| 1466 | term->str = (const char *)term->buffer; |
| 1467 | |
| 1468 | gcp_cmd_add_term(msg, trx, cmd, term, wild_term, pinfo, keep_persistent_data); |
| 1469 | |
| 1470 | /*** TERM ***/ |
| 1471 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_termid, tvb, |
| 1472 | tvb_offset, tokenlen, term->str); |
| 1473 | break; |
| 1474 | |
| 1475 | case '*': |
| 1476 | wild_term = GCP_WILDCARD_ALL; |
| 1477 | term->len = 1; |
| 1478 | term->buffer = (const uint8_t*)(term->str = "*"); |
| 1479 | |
| 1480 | gcp_cmd_add_term(msg, trx, cmd, term, wild_term, pinfo, keep_persistent_data); |
| 1481 | |
| 1482 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_termid, tvb, |
| 1483 | tvb_offset, tokenlen, |
| 1484 | "WildCard all"); |
| 1485 | col_append_str(pinfo->cinfo, COL_INFO, "=*"); |
| 1486 | break; |
| 1487 | |
| 1488 | case '$': |
| 1489 | wild_term = GCP_WILDCARD_CHOOSE; |
| 1490 | |
| 1491 | term->len = 1; |
| 1492 | term->buffer = (const uint8_t*)(term->str = "$"); |
| 1493 | |
| 1494 | gcp_cmd_add_term(msg, trx, cmd, term, wild_term, pinfo, keep_persistent_data); |
| 1495 | |
| 1496 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_termid, tvb, |
| 1497 | tvb_offset, tokenlen, |
| 1498 | "WildCard any"); |
| 1499 | col_append_str(pinfo->cinfo, COL_INFO, "=$"); |
| 1500 | break; |
| 1501 | case 'O': |
| 1502 | break; |
| 1503 | |
| 1504 | default: |
| 1505 | /*** TERM ***/ |
| 1506 | switch (megaco_command) { |
| 1507 | case MEGACO_CMD_PRIORITY: |
| 1508 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_priority, tvb, |
| 1509 | tvb_offset, tokenlen, |
| 1510 | tvb_format_text(pinfo->pool, tvb, tvb_offset, |
| 1511 | tokenlen)); |
| 1512 | break; |
| 1513 | default: |
| 1514 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_termid, tvb, |
| 1515 | tvb_offset, tokenlen, |
| 1516 | tvb_format_text(pinfo->pool, tvb, tvb_offset, |
| 1517 | tokenlen)); |
| 1518 | |
| 1519 | term->len = tokenlen; |
| 1520 | term->buffer = (const uint8_t*)(term->str = tvb_format_text(pinfo->pool, tvb, tvb_offset, tokenlen)); |
| 1521 | |
| 1522 | gcp_cmd_add_term(msg, trx, cmd, term, wild_term, pinfo, keep_persistent_data); |
| 1523 | break; |
| 1524 | } |
| 1525 | |
| 1526 | col_append_fstr(pinfo->cinfo, COL_INFO, "=%s",tvb_format_text(pinfo->pool, tvb, tvb_offset,tokenlen)); |
| 1527 | break; |
| 1528 | } |
| 1529 | |
| 1530 | } |
| 1531 | /* Dissect the Descriptors */ |
| 1532 | |
| 1533 | |
| 1534 | if ( LBRKT_counter != 0 && tvb_current_offset != tvb_command_end_offset){ |
| 1535 | |
| 1536 | unsigned tvb_descriptors_start_offset, tvb_descriptors_end_offset; |
| 1537 | tvb_find_uint8_length(tvb, tvb_command_start_offset, tvb_transaction_end_offset, '{', &tvb_descriptors_start_offset); |
| 1538 | |
| 1539 | tvb_descriptors_end_offset = tvb_descriptors_start_offset; |
| 1540 | if ( tvb_descriptors_end_offset > tvb_transaction_end_offset ) |
| 1541 | tvb_descriptors_end_offset = tvb_transaction_end_offset; |
| 1542 | |
| 1543 | while ( LBRKT_counter > 0 ){ |
| 1544 | |
| 1545 | tvb_find_uint8_length(tvb, tvb_descriptors_end_offset + 1, tvb_transaction_end_offset, '}', &tvb_descriptors_end_offset); |
| 1546 | LBRKT_counter--; |
| 1547 | |
| 1548 | } |
| 1549 | |
| 1550 | tempchar = tvb_get_uint8(tvb, tvb_command_start_offset); |
| 1551 | |
| 1552 | if ( tempchar == 'E'|| tempchar == 'e'){ |
| 1553 | /* errorDescriptor */ |
| 1554 | tvb_descriptors_start_offset = tvb_command_start_offset - 1; |
| 1555 | } |
| 1556 | dissect_megaco_descriptors(tvb_new_subset_length(tvb, tvb_descriptors_start_offset, tvb_descriptors_end_offset - tvb_descriptors_start_offset + 1), megaco_tree_command_line, pinfo, tree, ctx_id); |
| 1557 | } |
| 1558 | RBRKT_counter = 0; |
| 1559 | LBRKT_counter = 0; |
| 1560 | tvb_command_start_offset = megaco_tvb_skip_wsp(tvb, tvb_command_end_offset +1); |
| 1561 | tvb_LBRKT = tvb_command_start_offset; |
| 1562 | tvb_RBRKT = tvb_command_start_offset; |
| 1563 | |
| 1564 | } |
| 1565 | |
| 1566 | } while ( tvb_command_end_offset < tvb_transaction_end_offset ); |
| 1567 | |
| 1568 | if (keep_persistent_data) { |
| 1569 | gcp_msg_to_str(msg,pinfo->pool,keep_persistent_data); |
| 1570 | gcp_analyze_msg(megaco_tree, pinfo, tvb, msg, &megaco_ctx_ids, &ei_megaco_errored_command); |
| 1571 | } |
| 1572 | |
| 1573 | tvb_next_offset = tvb_transaction_end_offset; |
| 1574 | } |
| 1575 | while( tvb_transaction_end_offset > 0 && tvb_transaction_end_offset < tvb_len - 2); |
| 1576 | |
| 1577 | if(global_megaco_raw_text){ |
| 1578 | tvb_raw_text_add(tvb, megaco_tree); |
| 1579 | } |
| 1580 | |
| 1581 | return tvb_captured_length(tvb); |
| 1582 | } |
| 1583 | |
| 1584 | #define MEGACO_MODEM_TOKEN1 1 |
| 1585 | #define MEGACO_MUX_TOKEN2 2 |
| 1586 | #define MEGACO_MEDIA_TOKEN3 3 |
| 1587 | #define MEGACO_SIGNALS_TOKEN4 4 |
| 1588 | #define MEGACO_SERVICES_TOKEN5 5 |
| 1589 | #define MEGACO_STATS_TOKEN6 6 |
| 1590 | #define MEGACO_ERROR_TOKEN7 7 |
| 1591 | #define MEGACO_EVENTS_TOKEN8 8 |
| 1592 | #define MEGACO_AUDIT_TOKEN9 9 |
| 1593 | #define MEGACO_DIGITMAP_TOKEN10 10 |
| 1594 | #define MEGACO_OE_TOKEN11 11 |
| 1595 | #define MEGACO_TOPOLOGY_TOKEN12 12 |
| 1596 | #define MEGACO_PACKAGES_TOKEN13 13 |
| 1597 | |
| 1598 | static const megaco_tokens_t megaco_descriptors_names[] = { |
| 1599 | { "Unknown-token", NULL((void*)0) }, /* 0 Pad so that the real headers start at index 1 */ |
| 1600 | { "Modem", "MD" }, /* 1 */ |
| 1601 | { "Mux", "MX" }, /* 2 */ |
| 1602 | { "Media", "M" }, /* 3 */ |
| 1603 | { "Signals", "SG" }, /* 4 */ |
| 1604 | { "Services", "SV" }, /* 5 */ |
| 1605 | { "Statistics", "SA" }, /* 6 */ |
| 1606 | { "Error", "ER" }, /* 7 */ |
| 1607 | { "Events", "E" }, /* 8 */ |
| 1608 | { "Audit", "AT" }, /* 9 */ |
| 1609 | { "DigitMap", "DM" }, /* 10 */ |
| 1610 | { "ObservedEvents", "OE" }, /* 11 */ |
| 1611 | { "Topology", "TP" }, /* 12 */ |
| 1612 | { "Packages", "PG" }, /* 13 */ |
| 1613 | }; |
| 1614 | |
| 1615 | /* Returns index of megaco_tokens_t */ |
| 1616 | /* note - also called by dissect_megaco_auditdescriptor */ |
| 1617 | static int find_megaco_descriptors_names(tvbuff_t *tvb, int offset, unsigned header_len) |
| 1618 | { |
| 1619 | unsigned i; |
| 1620 | |
| 1621 | for (i = 1; i < array_length(megaco_descriptors_names)(sizeof (megaco_descriptors_names) / sizeof (megaco_descriptors_names )[0]); i++) { |
| 1622 | if (header_len == strlen(megaco_descriptors_names[i].name) && |
| 1623 | tvb_strncaseeql(tvb, offset, megaco_descriptors_names[i].name, header_len) == 0) |
| 1624 | return i; |
| 1625 | if (megaco_descriptors_names[i].compact_name != NULL((void*)0) && |
| 1626 | header_len == strlen(megaco_descriptors_names[i].compact_name) && |
| 1627 | tvb_strncaseeql(tvb, offset, megaco_descriptors_names[i].compact_name, header_len) == 0) |
| 1628 | return i; |
| 1629 | } |
| 1630 | return -1; |
| 1631 | } |
| 1632 | |
| 1633 | static void |
| 1634 | dissect_megaco_modemdescriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *megaco_tree_command_line, int tvb_RBRKT, int tvb_previous_offset) |
| 1635 | { |
| 1636 | |
| 1637 | int tokenlen; |
| 1638 | |
| 1639 | tokenlen = (tvb_RBRKT+1) - tvb_previous_offset; |
| 1640 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_modem_descriptor, tvb, |
| 1641 | tvb_previous_offset, tokenlen, |
| 1642 | tvb_format_text(pinfo->pool, tvb, tvb_previous_offset, |
| 1643 | tokenlen)); |
| 1644 | |
| 1645 | } |
| 1646 | static void |
| 1647 | dissect_megaco_multiplexdescriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *megaco_tree_command_line, int tvb_RBRKT, int tvb_previous_offset) |
| 1648 | { |
| 1649 | |
| 1650 | int tokenlen; |
| 1651 | |
| 1652 | tokenlen = (tvb_RBRKT+1) - tvb_previous_offset; |
| 1653 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_multiplex_descriptor, tvb, |
| 1654 | tvb_previous_offset, tokenlen, |
| 1655 | tvb_format_text(pinfo->pool, tvb, tvb_previous_offset, |
| 1656 | tokenlen)); |
| 1657 | |
| 1658 | } |
| 1659 | |
| 1660 | /* mediaDescriptor = MediaToken LBRKT mediaParm *(COMMA mediaParm) RBRKT |
| 1661 | * MediaToken = ("Media" / "M") |
| 1662 | * |
| 1663 | * mediaParm = (streamParm / streamDescriptor /terminationStateDescriptor) |
| 1664 | * |
| 1665 | * ; at-most one terminationStateDescriptor |
| 1666 | * ; and either streamParm(s) or streamDescriptor(s) but not both |
| 1667 | * streamParm = ( localDescriptor / remoteDescriptor /localControlDescriptor ) |
| 1668 | * localDescriptor = LocalToken LBRKT octetString RBRKT |
| 1669 | * LocalToken = ("Local" / "L") |
| 1670 | * octetString = *(nonEscapeChar) |
| 1671 | * nonEscapeChar = ( "\}" / %x01-7C / %x7E-FF ) |
| 1672 | * remoteDescriptor = RemoteToken LBRKT octetString RBRKT |
| 1673 | * RemoteToken = ("Remote" / "R") |
| 1674 | * localControlDescriptor = LocalControlToken LBRKT localParm*(COMMA localParm) RBRKT |
| 1675 | * LocalControlToken = ("LocalControl" / "O") |
| 1676 | * localParm = ( streamMode / propertyParm / reservedValueMode |
| 1677 | * streamDescriptor = StreamToken EQUAL StreamID LBRKT streamParm*(COMMA streamParm) RBRKT |
| 1678 | * StreamToken = ("Stream" / "ST") |
| 1679 | * terminationStateDescriptor = TerminationStateToken LBRKTterminationStateParm |
| 1680 | * *( COMMA terminationStateParm ) RBRKT |
| 1681 | * TerminationStateToken = ("TerminationState" / "TS") |
| 1682 | * terminationStateParm =(propertyParm / serviceStates / eventBufferControl ) |
| 1683 | */ |
| 1684 | |
| 1685 | #define MEGACO_LOCAL_TOKEN1 1 |
| 1686 | #define MEGACO_REMOTE_TOKEN2 2 |
| 1687 | #define MEGACO_LOCAL_CONTROL_TOKEN3 3 |
| 1688 | #define MEGACO_STREAM_TOKEN4 4 |
| 1689 | #define MEGACO_TERMINATION_STATE_DESC5 5 |
| 1690 | // MEGACO_STATS_TOKEN is already defined as 6 above |
| 1691 | |
| 1692 | static const megaco_tokens_t megaco_mediaParm_names[] = { |
| 1693 | { "Unknown-token", NULL((void*)0) }, /* 0 Pad so that the real headers start at index 1 */ |
| 1694 | { "Local", "L" }, /* 1 */ |
| 1695 | { "Remote", "R" }, /* 2 */ |
| 1696 | { "LocalControl", "O" }, /* 3 */ |
| 1697 | { "Stream", "ST" }, /* 4 */ |
| 1698 | { "TerminationState", "TS" }, /* 5 */ |
| 1699 | { "Statistics", "SA" }, /* 6 */ |
| 1700 | }; |
| 1701 | |
| 1702 | /* Returns index of megaco_tokens_t */ |
| 1703 | static unsigned find_megaco_mediaParm_names(tvbuff_t *tvb, int offset, unsigned header_len) |
| 1704 | { |
| 1705 | unsigned i; |
| 1706 | |
| 1707 | for (i = 1; i < array_length(megaco_mediaParm_names)(sizeof (megaco_mediaParm_names) / sizeof (megaco_mediaParm_names )[0]); i++) { |
| 1708 | if (header_len == strlen(megaco_mediaParm_names[i].name) && |
| 1709 | tvb_strncaseeql(tvb, offset, megaco_mediaParm_names[i].name, header_len) == 0) |
| 1710 | return i; |
| 1711 | if (megaco_mediaParm_names[i].compact_name != NULL((void*)0) && |
| 1712 | header_len == strlen(megaco_mediaParm_names[i].compact_name) && |
| 1713 | tvb_strncaseeql(tvb, offset, megaco_mediaParm_names[i].compact_name, header_len) == 0) |
| 1714 | return i; |
| 1715 | } |
| 1716 | |
| 1717 | return 0; |
| 1718 | } |
| 1719 | |
| 1720 | static void |
| 1721 | dissect_megaco_mediadescriptor(tvbuff_t *tvb, proto_tree *megaco_tree_command_line,packet_info *pinfo, unsigned tvb_last_RBRKT, |
| 1722 | unsigned tvb_previous_offset, unsigned start_offset, proto_tree *top_tree, uint32_t context) |
| 1723 | { |
| 1724 | |
| 1725 | unsigned tokenlen, tvb_LBRKT, tvb_RBRKT; |
| 1726 | unsigned tvb_next_offset, tvb_current_offset, tvb_offset, equal_offset, save_offset; |
| 1727 | unsigned mediaParm; |
| 1728 | unsigned streamId; |
| 1729 | |
| 1730 | proto_tree *megaco_mediadescriptor_tree; |
| 1731 | proto_item *megaco_mediadescriptor_ti, *ti; |
| 1732 | |
| 1733 | megaco_mediadescriptor_ti = proto_tree_add_item(megaco_tree_command_line, hf_megaco_media_descriptor, tvb, start_offset, 1, ENC_NA0x00000000); |
| 1734 | megaco_mediadescriptor_tree = proto_item_add_subtree(megaco_mediadescriptor_ti, ett_megaco_mediadescriptor); |
| 1735 | |
| 1736 | while ( tvb_previous_offset < tvb_last_RBRKT){ |
| 1737 | /* Start of token */ |
| 1738 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_previous_offset); |
| 1739 | |
| 1740 | /* Find token length */ |
| 1741 | for (tvb_next_offset=tvb_current_offset; tvb_next_offset < tvb_last_RBRKT; tvb_next_offset++){ |
| 1742 | if (!g_ascii_isalpha(tvb_get_uint8(tvb, tvb_next_offset ))((g_ascii_table[(guchar) (tvb_get_uint8(tvb, tvb_next_offset ) )] & G_ASCII_ALPHA) != 0)){ |
| 1743 | break; |
| 1744 | } |
| 1745 | } |
| 1746 | tokenlen = tvb_next_offset - tvb_current_offset; |
| 1747 | |
| 1748 | mediaParm = find_megaco_mediaParm_names(tvb, tvb_current_offset, tokenlen); |
| 1749 | |
| 1750 | if (!tvb_find_uint8_length(tvb, tvb_next_offset, tvb_last_RBRKT, '{', &tvb_LBRKT)) { |
| 1751 | // Not found, use the end offset. |
| 1752 | tvb_LBRKT = tvb_last_RBRKT; |
| 1753 | } |
| 1754 | |
| 1755 | if (!tvb_find_uint8_length(tvb, tvb_current_offset + 1, tvb_last_RBRKT, '}', &tvb_RBRKT)) { |
| 1756 | // Not found, use the end offset. |
| 1757 | tvb_RBRKT = tvb_last_RBRKT; |
| 1758 | } |
| 1759 | |
| 1760 | tvbuff_t *descriptor_tvb; |
| 1761 | /* Most of the descriptors here (unlike elsewhere in the dissector don't |
| 1762 | * expect to be passed a tvb including the mediaParm token, but the |
| 1763 | * dissect_megaco_statisticsdescriptor does), so we can't have a common |
| 1764 | * subset tvb. |
| 1765 | */ |
| 1766 | switch ( mediaParm ){ |
| 1767 | case MEGACO_LOCAL_TOKEN1: |
| 1768 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_LBRKT+1); |
| 1769 | descriptor_tvb = tvb_new_subset_length(tvb, tvb_current_offset, tvb_RBRKT - tvb_current_offset + 1); |
| 1770 | dissect_megaco_LocalRemotedescriptor(descriptor_tvb, megaco_mediadescriptor_tree, pinfo, |
| 1771 | context, true1); |
| 1772 | tvb_current_offset = tvb_RBRKT; |
| 1773 | break; |
| 1774 | case MEGACO_REMOTE_TOKEN2: |
| 1775 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_LBRKT+1); |
| 1776 | descriptor_tvb = tvb_new_subset_length(tvb, tvb_current_offset, tvb_RBRKT - tvb_current_offset + 1); |
| 1777 | dissect_megaco_LocalRemotedescriptor(descriptor_tvb, megaco_mediadescriptor_tree, pinfo, |
| 1778 | context, false0); |
| 1779 | tvb_current_offset = tvb_RBRKT; |
| 1780 | break; |
| 1781 | case MEGACO_LOCAL_CONTROL_TOKEN3: |
| 1782 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_LBRKT+1); |
| 1783 | descriptor_tvb = tvb_new_subset_length(tvb, tvb_current_offset, tvb_RBRKT - tvb_current_offset + 1); |
| 1784 | dissect_megaco_LocalControldescriptor(descriptor_tvb, megaco_mediadescriptor_tree, pinfo, top_tree); |
| 1785 | tvb_current_offset = tvb_RBRKT; |
| 1786 | break; |
| 1787 | case MEGACO_STREAM_TOKEN4: |
| 1788 | save_offset = tvb_current_offset; |
| 1789 | tvb_find_uint8_length(tvb, tvb_previous_offset, tvb_last_RBRKT, '=', &equal_offset); |
| 1790 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, equal_offset+1); |
| 1791 | tvb_offset = megaco_tvb_skip_wsp_return(tvb, tvb_LBRKT-1); |
| 1792 | tokenlen = tvb_offset - tvb_current_offset; |
| 1793 | |
| 1794 | streamId = (unsigned)strtoul(tvb_format_text(pinfo->pool, tvb, tvb_current_offset,tokenlen),NULL((void*)0),10); |
| 1795 | ti = proto_tree_add_uint(megaco_mediadescriptor_tree, hf_megaco_streamid, tvb, |
| 1796 | save_offset, 1, streamId); |
| 1797 | proto_item_set_len(ti, tvb_offset-save_offset); |
| 1798 | tvb_previous_offset = tvb_LBRKT+1; |
| 1799 | continue; |
| 1800 | case MEGACO_TERMINATION_STATE_DESC5: |
| 1801 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_LBRKT+1); |
| 1802 | descriptor_tvb = tvb_new_subset_length(tvb, tvb_current_offset, tvb_RBRKT - tvb_current_offset + 1); |
| 1803 | dissect_megaco_TerminationStatedescriptor(descriptor_tvb, pinfo, megaco_mediadescriptor_tree); |
| 1804 | tvb_current_offset = tvb_RBRKT; |
| 1805 | break; |
| 1806 | case MEGACO_STATS_TOKEN6: |
| 1807 | // dissect_megaco_statisticsdescriptor wants the previous |
| 1808 | // offset, don't skip forward. |
| 1809 | //tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_LBRKT+1); |
| 1810 | descriptor_tvb = tvb_new_subset_length(tvb, tvb_current_offset, tvb_RBRKT - tvb_current_offset + 1); |
| 1811 | dissect_megaco_statisticsdescriptor(descriptor_tvb, megaco_mediadescriptor_tree); |
| 1812 | tvb_current_offset = tvb_RBRKT; |
| 1813 | break; |
| 1814 | default: |
| 1815 | break; |
| 1816 | }; |
| 1817 | /* more parameters ? */ |
| 1818 | if ( !tvb_find_uint8_length(tvb, tvb_current_offset + 1, tvb_last_RBRKT, ',', &tvb_next_offset)){ |
| 1819 | /* (raw formatting removed) |
| 1820 | tokenlen = tvb_next_offset - tvb_RBRKT+1; |
| 1821 | proto_tree_add_format_text(megaco_mediadescriptor_tree, tvb, tvb_RBRKT, tokenlen); */ |
| 1822 | tvb_previous_offset = tvb_next_offset+1; |
| 1823 | } else{ |
| 1824 | if (tvb_next_offset > tvb_last_RBRKT) { |
| 1825 | tvb_next_offset = tvb_last_RBRKT; |
| 1826 | } |
| 1827 | /* Add the trailing '}' (raw formatting removed) */ |
| 1828 | /* proto_tree_add_format_text(megaco_mediadescriptor_tree, tvb, tvb_RBRKT, 1); */ |
| 1829 | tvb_previous_offset = tvb_last_RBRKT; |
| 1830 | } |
| 1831 | |
| 1832 | } /* End while */ |
| 1833 | |
| 1834 | proto_item_set_end(megaco_mediadescriptor_ti, tvb, tvb_previous_offset); |
| 1835 | } |
| 1836 | |
| 1837 | static void |
| 1838 | dissect_megaco_h245(tvbuff_t *tvb, packet_info *pinfo, proto_tree *megaco_tree, int offset, int len, proto_tree *top_tree) |
| 1839 | { |
| 1840 | /*proto_item *item;*/ |
| 1841 | /*proto_tree *tree;*/ |
| 1842 | char *msg = tvb_format_text(pinfo->pool, tvb, offset, len); |
| 1843 | |
| 1844 | /*item= */proto_tree_add_item(megaco_tree, hf_megaco_h245, tvb, offset, len, ENC_NA0x00000000); |
| 1845 | /*tree = proto_item_add_subtree(item, ett_megaco_h245); */ |
| 1846 | |
| 1847 | /* arbitrary maximum length */ |
| 1848 | if(len<20480){ |
| 1849 | int i; |
| 1850 | tvbuff_t *h245_tvb; |
| 1851 | uint8_t *buf = (uint8_t *)wmem_alloc(pinfo->pool, 10240); |
| 1852 | |
| 1853 | /* first, skip to where the encoded pdu starts, this is |
| 1854 | the first hex digit after the '=' char. |
| 1855 | */ |
| 1856 | while(1){ |
| 1857 | if((*msg==0)||(*msg=='\n')){ |
| 1858 | return; |
| 1859 | } |
| 1860 | if(*msg=='='){ |
| 1861 | msg++; |
| 1862 | break; |
| 1863 | } |
| 1864 | msg++; |
| 1865 | } |
| 1866 | while(1){ |
| 1867 | if((*msg==0)||(*msg=='\n')){ |
| 1868 | return; |
| 1869 | } |
| 1870 | if( ((*msg>='0')&&(*msg<='9')) |
| 1871 | || ((*msg>='a')&&(*msg<='f')) |
| 1872 | || ((*msg>='A')&&(*msg<='F'))){ |
| 1873 | break; |
| 1874 | } |
| 1875 | msg++; |
| 1876 | } |
| 1877 | i=0; |
| 1878 | while( ((*msg>='0')&&(*msg<='9')) |
| 1879 | ||((*msg>='a')&&(*msg<='f')) |
| 1880 | ||((*msg>='A')&&(*msg<='F')) ){ |
| 1881 | int val; |
| 1882 | if((*msg>='0')&&(*msg<='9')){ |
| 1883 | val=(*msg)-'0'; |
| 1884 | } else if((*msg>='a')&&(*msg<='f')){ |
| 1885 | val=(*msg)-'a'+10; |
| 1886 | } else if((*msg>='A')&&(*msg<='F')){ |
| 1887 | val=(*msg)-'A'+10; |
| 1888 | } else { |
| 1889 | return; |
| 1890 | } |
| 1891 | val<<=4; |
| 1892 | msg++; |
| 1893 | if((*msg>='0')&&(*msg<='9')){ |
| 1894 | val|=(*msg)-'0'; |
| 1895 | } else if((*msg>='a')&&(*msg<='f')){ |
| 1896 | val|=(*msg)-'a'+10; |
| 1897 | } else if((*msg>='A')&&(*msg<='F')){ |
| 1898 | val|=(*msg)-'A'+10; |
| 1899 | } else { |
| 1900 | return; |
| 1901 | } |
| 1902 | msg++; |
| 1903 | |
| 1904 | buf[i]=(uint8_t)val; |
| 1905 | i++; |
| 1906 | } |
| 1907 | if(i==0){ |
| 1908 | return; |
| 1909 | } |
| 1910 | h245_tvb = tvb_new_child_real_data(tvb, buf,i,i); |
| 1911 | add_new_data_source(pinfo, h245_tvb, "H.245 over MEGACO"); |
| 1912 | /* should go through a handle, however, the two h245 entry |
| 1913 | points are different, one is over tpkt and the other is raw |
| 1914 | */ |
| 1915 | call_dissector(h245_handle, h245_tvb, pinfo, top_tree); |
| 1916 | /* dissect_h245_MultimediaSystemControlMessage(h245_tvb, pinfo, tree);*/ |
| 1917 | } |
| 1918 | } |
| 1919 | |
| 1920 | static void |
| 1921 | dissect_megaco_h324_h223caprn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *megaco_tree, int offset _U___attribute__((unused)), int len, char *msg) |
| 1922 | { |
| 1923 | asn1_ctx_t actx; |
| 1924 | |
| 1925 | /* arbitrary maximum length */ |
| 1926 | if(len<20480){ |
| 1927 | int i; |
| 1928 | tvbuff_t *h245_tvb; |
| 1929 | uint8_t *buf = (uint8_t *)wmem_alloc(pinfo->pool, 10240); |
| 1930 | |
| 1931 | /* first, skip to where the encoded pdu starts, this is |
| 1932 | the first hex digit after the '=' char. |
| 1933 | */ |
| 1934 | while(1){ |
| 1935 | if((*msg==0)||(*msg=='\n')){ |
| 1936 | return; |
| 1937 | } |
| 1938 | if(*msg=='='){ |
| 1939 | msg++; |
| 1940 | break; |
| 1941 | } |
| 1942 | msg++; |
| 1943 | } |
| 1944 | while(1){ |
| 1945 | if((*msg==0)||(*msg=='\n')){ |
| 1946 | return; |
| 1947 | } |
| 1948 | if( ((*msg>='0')&&(*msg<='9')) |
| 1949 | || ((*msg>='a')&&(*msg<='f')) |
| 1950 | || ((*msg>='A')&&(*msg<='F'))){ |
| 1951 | break; |
| 1952 | } |
| 1953 | msg++; |
| 1954 | } |
| 1955 | i=0; |
| 1956 | while( ((*msg>='0')&&(*msg<='9')) |
| 1957 | ||((*msg>='a')&&(*msg<='f')) |
| 1958 | ||((*msg>='A')&&(*msg<='F')) ){ |
| 1959 | int val; |
| 1960 | if((*msg>='0')&&(*msg<='9')){ |
| 1961 | val=(*msg)-'0'; |
| 1962 | } else if((*msg>='a')&&(*msg<='f')){ |
| 1963 | val=(*msg)-'a'+10; |
| 1964 | } else if((*msg>='A')&&(*msg<='F')){ |
| 1965 | val=(*msg)-'A'+10; |
| 1966 | } else { |
| 1967 | return; |
| 1968 | } |
| 1969 | val<<=4; |
| 1970 | msg++; |
| 1971 | if((*msg>='0')&&(*msg<='9')){ |
| 1972 | val|=(*msg)-'0'; |
| 1973 | } else if((*msg>='a')&&(*msg<='f')){ |
| 1974 | val|=(*msg)-'a'+10; |
| 1975 | } else if((*msg>='A')&&(*msg<='F')){ |
| 1976 | val|=(*msg)-'A'+10; |
| 1977 | } else { |
| 1978 | return; |
| 1979 | } |
| 1980 | msg++; |
| 1981 | |
| 1982 | buf[i]=(uint8_t)val; |
| 1983 | i++; |
| 1984 | } |
| 1985 | if(i==0){ |
| 1986 | return; |
| 1987 | } |
| 1988 | h245_tvb = tvb_new_child_real_data(tvb, buf,i,i); |
| 1989 | add_new_data_source(pinfo, h245_tvb, "H.245 over MEGACO"); |
| 1990 | /* should go through a handle, however, the two h245 entry |
| 1991 | points are different, one is over tpkt and the other is raw |
| 1992 | */ |
| 1993 | asn1_ctx_init(&actx, ASN1_ENC_PER, true1, pinfo); |
| 1994 | dissect_h245_H223Capability(h245_tvb, 0, &actx, megaco_tree, hf_megaco_h223Capability); |
| 1995 | } |
| 1996 | } |
| 1997 | |
| 1998 | static void |
| 1999 | dissect_megaco_eventsdescriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *megaco_tree_command_line, proto_tree *top_tree) |
| 2000 | { |
| 2001 | |
| 2002 | /* eventsDescriptor = EventsToken EQUAL RequestID LBRKT |
| 2003 | * requestedEvent *( COMMA requestedEvent ) RBRKT |
| 2004 | * requestedEvent = pkgdName [ LBRKT eventParameter |
| 2005 | * *( COMMA eventParameter ) RBRKT ] |
| 2006 | */ |
| 2007 | |
| 2008 | unsigned tokenlen, tvb_current_offset, tvb_next_offset, tvb_help_offset, tvb_previous_offset; |
| 2009 | unsigned tvb_events_end_offset, tvb_LBRKT, tvb_RBRKT; |
| 2010 | proto_tree *megaco_eventsdescriptor_tree, *megaco_requestedevent_tree; |
| 2011 | proto_item *megaco_eventsdescriptor_ti, *megaco_requestedevent_ti; |
| 2012 | |
| 2013 | unsigned requested_event_start_offset = 0, |
| 2014 | requested_event_end_offset = 0; |
| 2015 | |
| 2016 | tvb_events_end_offset = tvb_reported_length(tvb); |
| 2017 | |
| 2018 | megaco_eventsdescriptor_ti = proto_tree_add_item(megaco_tree_command_line,hf_megaco_events_descriptor, tvb, 0, tvb_events_end_offset, ENC_NA0x00000000); |
| 2019 | megaco_eventsdescriptor_tree = proto_item_add_subtree(megaco_eventsdescriptor_ti, ett_megaco_eventsdescriptor); |
| 2020 | |
| 2021 | if (tvb_find_uint8_remaining(tvb, 0, '=', &tvb_current_offset)) { |
| 2022 | |
| 2023 | /* If it fails something's malformed, but handle below. */ |
| 2024 | tvb_find_uint8_remaining(tvb, 0, '{', &tvb_next_offset); |
| 2025 | |
| 2026 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_current_offset +1); |
| 2027 | tvb_help_offset = megaco_tvb_skip_wsp_return(tvb, tvb_next_offset - 1); |
| 2028 | |
| 2029 | tokenlen = tvb_help_offset - tvb_current_offset; |
| 2030 | |
| 2031 | /* TODO - An example of where tvb_strtou functions, or perhaps better, |
| 2032 | * finally implementing ENC_STR_NUM, might be useful. The latter could |
| 2033 | * also nicely handle failure cases with expert info. */ |
| 2034 | proto_tree_add_uint(megaco_eventsdescriptor_tree, hf_megaco_requestid, tvb, |
| 2035 | tvb_current_offset, tokenlen, |
| 2036 | (uint32_t) strtoul(tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen), NULL((void*)0), 10)); |
| 2037 | |
| 2038 | if (tvb_next_offset == tvb_events_end_offset) { |
| 2039 | /* No LBRKT before the first requestedEvent (expert info?) */ |
| 2040 | return; |
| 2041 | } |
| 2042 | tvb_RBRKT = tvb_next_offset+1; |
| 2043 | tvb_LBRKT = tvb_next_offset+1; |
| 2044 | tvb_previous_offset = megaco_tvb_skip_wsp(tvb, tvb_next_offset+1); |
| 2045 | |
| 2046 | do { |
| 2047 | |
| 2048 | tvb_find_uint8_remaining(tvb, tvb_RBRKT + 1, '}', &tvb_RBRKT); |
| 2049 | tvb_find_uint8_remaining(tvb, tvb_previous_offset, ',', &tvb_current_offset); |
| 2050 | |
| 2051 | if (!tvb_find_uint8_remaining(tvb, tvb_LBRKT, '{', &tvb_LBRKT) || tvb_LBRKT > tvb_current_offset) { |
| 2052 | /* Descriptor includes no parameters */ |
| 2053 | tvb_RBRKT = megaco_tvb_skip_wsp_return(tvb, tvb_current_offset-1)-1; |
| 2054 | } else { |
| 2055 | /* Descriptor includes Parameters */ |
| 2056 | /* If the next LBRKT is before RBRKT, then there's nested braces. |
| 2057 | * Keep going until balanced or we run out of buffer. */ |
| 2058 | while (tvb_find_uint8_remaining(tvb, tvb_LBRKT+1, '{', &tvb_LBRKT) && tvb_LBRKT < tvb_RBRKT) { |
| 2059 | if (tvb_RBRKT < tvb_events_end_offset) { |
| 2060 | tvb_find_uint8_remaining(tvb, tvb_RBRKT+1, '}', &tvb_RBRKT); |
| 2061 | } |
| 2062 | } |
| 2063 | } |
| 2064 | |
| 2065 | tvb_find_uint8_remaining(tvb, tvb_previous_offset, '{', &tvb_help_offset); |
| 2066 | /* if there are eventparameter */ |
| 2067 | |
| 2068 | if (tvb_help_offset < tvb_RBRKT){ |
| 2069 | |
| 2070 | requested_event_start_offset = tvb_help_offset; |
| 2071 | requested_event_end_offset = tvb_RBRKT; |
| 2072 | tvb_help_offset = megaco_tvb_skip_wsp_return(tvb, tvb_help_offset-1); |
| 2073 | tokenlen = tvb_help_offset - tvb_previous_offset; |
| 2074 | } |
| 2075 | /* no parameters */ |
| 2076 | else { |
| 2077 | tokenlen = tvb_RBRKT+1 - tvb_previous_offset; |
| 2078 | } |
| 2079 | |
| 2080 | megaco_requestedevent_ti = proto_tree_add_item(megaco_eventsdescriptor_tree,hf_megaco_pkgdname,tvb,tvb_previous_offset,tokenlen, ENC_UTF_80x00000002); |
| 2081 | megaco_requestedevent_tree = proto_item_add_subtree(megaco_requestedevent_ti, ett_megaco_requestedevent); |
| 2082 | |
| 2083 | if (tvb_help_offset < tvb_RBRKT) { |
| 2084 | |
| 2085 | requested_event_start_offset = megaco_tvb_skip_wsp(tvb, requested_event_start_offset +1); |
| 2086 | requested_event_end_offset = megaco_tvb_skip_wsp_return(tvb, requested_event_end_offset-1); |
| 2087 | |
| 2088 | if (!tvb_strncaseeql(tvb, requested_event_start_offset, "dm", 2)) { |
| 2089 | dissect_megaco_digitmapdescriptor(tvb, pinfo, megaco_requestedevent_tree, requested_event_end_offset, requested_event_start_offset); |
| 2090 | } |
| 2091 | else{ |
| 2092 | tokenlen = requested_event_end_offset - requested_event_start_offset; |
| 2093 | if(!tvb_strneql(tvb, requested_event_start_offset, "h245", 4)){ |
| 2094 | dissect_megaco_h245(tvb, pinfo, megaco_requestedevent_tree, requested_event_start_offset, tokenlen, top_tree); |
| 2095 | } else { |
| 2096 | proto_tree_add_format_text(megaco_requestedevent_tree, tvb, requested_event_start_offset, tokenlen); |
| 2097 | } |
| 2098 | } |
| 2099 | |
| 2100 | } |
| 2101 | |
| 2102 | tvb_previous_offset = tvb_current_offset; |
| 2103 | tvb_find_uint8_remaining(tvb, tvb_RBRKT, ',', &tvb_current_offset); |
| 2104 | |
| 2105 | if (tvb_current_offset < tvb_previous_offset ) { |
| 2106 | tvb_current_offset = tvb_events_end_offset; |
| 2107 | } |
| 2108 | |
| 2109 | tvb_previous_offset = megaco_tvb_skip_wsp(tvb, tvb_current_offset+1); |
| 2110 | |
| 2111 | tvb_LBRKT = tvb_previous_offset; |
| 2112 | tvb_RBRKT = tvb_previous_offset; |
| 2113 | |
| 2114 | } while ( tvb_current_offset < tvb_events_end_offset ); |
| 2115 | } |
| 2116 | } |
| 2117 | |
| 2118 | static void |
| 2119 | dissect_megaco_signaldescriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *megaco_tree_command_line, unsigned tvb_RBRKT, unsigned tvb_previous_offset, proto_tree *top_tree) |
| 2120 | { |
| 2121 | |
| 2122 | unsigned tokenlen, pkg_tokenlen, tvb_current_offset, tvb_next_offset, tvb_help_offset; |
| 2123 | unsigned tvb_signals_end_offset, tvb_signals_start_offset, tvb_LBRKT; |
| 2124 | bool_Bool found, LBRKT_found; |
| 2125 | proto_tree *megaco_signalsdescriptor_tree, *megaco_requestedsignal_tree; |
| 2126 | proto_item *megaco_signalsdescriptor_ti, *megaco_requestedsignal_ti; |
| 2127 | |
| 2128 | unsigned requested_signal_start_offset = 0, requested_signal_end_offset = 0; |
| 2129 | |
| 2130 | tvb_signals_end_offset = tvb_RBRKT; |
| 2131 | tvb_signals_start_offset = tvb_previous_offset; |
| 2132 | |
| 2133 | if(g_ascii_toupper(tvb_get_uint8(tvb, tvb_previous_offset+1))=='G') |
| 2134 | tokenlen = 2; /* token is compact text (SG) */ |
| 2135 | else |
| 2136 | tokenlen = 7; /* token must be verbose text (Signals) */ |
| 2137 | |
| 2138 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_previous_offset+tokenlen); |
| 2139 | |
| 2140 | if(tvb_get_uint8(tvb, tvb_current_offset)!='{') { /* {} has been omitted */ |
| 2141 | |
| 2142 | megaco_signalsdescriptor_ti = proto_tree_add_item(megaco_tree_command_line, hf_megaco_signal_descriptor, tvb, tvb_signals_start_offset, tokenlen, ENC_NA0x00000000); |
| 2143 | expert_add_info(pinfo, megaco_signalsdescriptor_ti, &ei_megaco_signal_descriptor); |
| 2144 | |
| 2145 | col_append_str(pinfo->cinfo, COL_INFO, " (Signal:none)"); /* then say so */ |
| 2146 | |
| 2147 | return; /* and return */ |
| 2148 | } |
| 2149 | |
| 2150 | LBRKT_found = tvb_find_uint8_length(tvb, tvb_previous_offset, tvb_signals_end_offset, '{', &tvb_LBRKT); |
| 2151 | if (LBRKT_found == false0) { |
| 2152 | // This should not happen, because we should at least find the '{' found |
| 2153 | // above at tvb_current_offset. DISSECTOR_ASSERT? |
| 2154 | return; |
| 2155 | } |
| 2156 | tokenlen = (tvb_LBRKT+1) - tvb_signals_start_offset; |
| 2157 | |
| 2158 | megaco_signalsdescriptor_ti = proto_tree_add_item(megaco_tree_command_line,hf_megaco_signal_descriptor,tvb,tvb_previous_offset,tokenlen, ENC_NA0x00000000); |
| 2159 | megaco_signalsdescriptor_tree = proto_item_add_subtree(megaco_signalsdescriptor_ti, ett_megaco_signalsdescriptor); |
| 2160 | |
| 2161 | tvb_current_offset = tvb_LBRKT; |
| 2162 | tvb_next_offset = megaco_tvb_skip_wsp(tvb, tvb_current_offset+1); |
| 2163 | col_append_fstr(pinfo->cinfo, COL_INFO, " (Signal:%s)",tvb_format_text(pinfo->pool, tvb, tvb_current_offset,tokenlen-tvb_current_offset+tvb_previous_offset)); |
| 2164 | |
| 2165 | |
| 2166 | if ( tvb_current_offset < tvb_signals_end_offset && tvb_next_offset != tvb_signals_end_offset){ |
| 2167 | |
| 2168 | |
| 2169 | tvb_RBRKT = tvb_next_offset+1; |
| 2170 | tvb_LBRKT = tvb_next_offset+1; |
| 2171 | tvb_previous_offset = tvb_next_offset; |
| 2172 | |
| 2173 | |
| 2174 | do { |
| 2175 | |
| 2176 | tvb_find_uint8_length(tvb, tvb_RBRKT+1, tvb_signals_end_offset, '}', &tvb_RBRKT); |
| 2177 | LBRKT_found = tvb_find_uint8_length(tvb, tvb_LBRKT, tvb_signals_end_offset, '{', &tvb_LBRKT); |
| 2178 | |
| 2179 | found = tvb_find_uint8_length(tvb, tvb_previous_offset, tvb_signals_end_offset, ',', &tvb_current_offset); |
| 2180 | |
| 2181 | if (found == false0 || tvb_current_offset > tvb_signals_end_offset){ |
| 2182 | tvb_current_offset = tvb_signals_end_offset; |
| 2183 | } |
| 2184 | |
| 2185 | |
| 2186 | /* Descriptor includes no parameters */ |
| 2187 | |
| 2188 | if ( tvb_LBRKT > tvb_current_offset || LBRKT_found == false0 ){ |
| 2189 | |
| 2190 | tvb_RBRKT = megaco_tvb_skip_wsp_return(tvb, tvb_current_offset-1)-1; |
| 2191 | } |
| 2192 | |
| 2193 | /* Descriptor includes Parameters */ |
| 2194 | |
| 2195 | if ( (tvb_current_offset > tvb_LBRKT && LBRKT_found == true1)){ |
| 2196 | |
| 2197 | while ( tvb_LBRKT == true1 && tvb_RBRKT > tvb_LBRKT ){ |
| 2198 | |
| 2199 | LBRKT_found = tvb_find_uint8_length(tvb, tvb_LBRKT+1, tvb_signals_end_offset, '{', &tvb_LBRKT); |
Value stored to 'LBRKT_found' is never read | |
| 2200 | if ( tvb_LBRKT < tvb_RBRKT && tvb_LBRKT == true1) |
| 2201 | tvb_find_uint8_length(tvb, tvb_RBRKT+1, tvb_signals_end_offset, '}', &tvb_RBRKT); |
| 2202 | } |
| 2203 | |
| 2204 | } |
| 2205 | |
| 2206 | found = tvb_find_uint8_length(tvb, tvb_previous_offset, tvb_signals_end_offset, '{', &tvb_help_offset); |
| 2207 | |
| 2208 | /* if there are signalparameter */ |
| 2209 | |
| 2210 | if ( tvb_help_offset < tvb_RBRKT && found == true1 ){ |
| 2211 | |
| 2212 | requested_signal_start_offset = tvb_help_offset; |
| 2213 | requested_signal_end_offset = tvb_RBRKT; |
| 2214 | tvb_help_offset = megaco_tvb_skip_wsp_return(tvb, tvb_help_offset-1); |
| 2215 | pkg_tokenlen = tvb_help_offset - tvb_previous_offset; |
| 2216 | } |
| 2217 | /* no parameters */ |
| 2218 | else { |
| 2219 | pkg_tokenlen = tvb_RBRKT+1 - tvb_previous_offset; |
| 2220 | } |
| 2221 | |
| 2222 | megaco_requestedsignal_ti = proto_tree_add_item(megaco_signalsdescriptor_tree,hf_megaco_pkgdname,tvb,tvb_previous_offset,pkg_tokenlen, ENC_UTF_80x00000002); |
| 2223 | megaco_requestedsignal_tree = proto_item_add_subtree(megaco_requestedsignal_ti, ett_megaco_requestedsignal); |
| 2224 | |
| 2225 | if ( tvb_help_offset < tvb_RBRKT && found == true1){ |
| 2226 | requested_signal_start_offset = megaco_tvb_skip_wsp(tvb, requested_signal_start_offset +1); |
| 2227 | requested_signal_end_offset = megaco_tvb_skip_wsp_return(tvb, requested_signal_end_offset-1); |
| 2228 | |
| 2229 | tokenlen = requested_signal_end_offset - requested_signal_start_offset; |
| 2230 | |
| 2231 | if(!tvb_strneql(tvb, requested_signal_start_offset, "h245", 4)){ |
| 2232 | dissect_megaco_h245(tvb, pinfo, megaco_requestedsignal_tree, requested_signal_start_offset, tokenlen, top_tree); |
| 2233 | } else { |
| 2234 | proto_tree_add_format_text( megaco_requestedsignal_tree, tvb, requested_signal_start_offset, tokenlen); |
| 2235 | } |
| 2236 | /* Print the trailing '}' (raw formatting removed) */ |
| 2237 | /* proto_tree_add_format_text( megaco_requestedsignal_tree, tvb, tvb_RBRKT, 1); */ |
| 2238 | } |
| 2239 | |
| 2240 | found = tvb_find_uint8_length(tvb, tvb_RBRKT, tvb_signals_end_offset, ',', &tvb_current_offset); |
| 2241 | |
| 2242 | if (found == false0 || tvb_current_offset > tvb_signals_end_offset || tvb_current_offset < tvb_previous_offset){ |
| 2243 | tvb_current_offset = tvb_signals_end_offset; |
| 2244 | } |
| 2245 | |
| 2246 | tvb_previous_offset = megaco_tvb_skip_wsp(tvb, tvb_current_offset+1); |
| 2247 | |
| 2248 | tvb_LBRKT = tvb_previous_offset; |
| 2249 | tvb_RBRKT = tvb_previous_offset; |
| 2250 | /* Print the trailing '}' (raw formatting removed) */ |
| 2251 | /* proto_tree_add_format_text(megaco_tree_command_line, tvb, tvb_signals_end_offset, 1); */ |
| 2252 | |
| 2253 | } while ( tvb_current_offset < tvb_signals_end_offset ); |
| 2254 | }else{ |
| 2255 | /* signals{} (raw formatting removed) |
| 2256 | proto_tree_add_format_text(megaco_tree_command_line, tvb, tvb_signals_end_offset, 1); */ |
| 2257 | } |
| 2258 | |
| 2259 | |
| 2260 | } |
| 2261 | |
| 2262 | /* |
| 2263 | auditDescriptor = AuditToken LBRKT [ auditItem *(COMMA auditItem) ] RBRKT |
| 2264 | |
| 2265 | V1: |
| 2266 | auditItem = ( MuxToken / ModemToken / MediaToken / |
| 2267 | SignalsToken / EventBufferToken / |
| 2268 | DigitMapToken / StatsToken / EventsToken / |
| 2269 | ObservedEventsToken / PackagesToken ) |
| 2270 | |
| 2271 | V3: |
| 2272 | auditItem = ( auditReturnItem / SignalsToken / EventBufferToken / |
| 2273 | EventsToken / indAudterminationAudit ) |
| 2274 | |
| 2275 | auditReturnItem = ( MuxToken / ModemToken / MediaToken / DigitMapToken / |
| 2276 | StatsToken / ObservedEventsToken / PackagesToken ) |
| 2277 | |
| 2278 | indAudauditReturnParameter |
| 2279 | = ( indAudmediaDescriptor / indAudeventsDescriptor / |
| 2280 | indAudsignalsDescriptor / indAuddigitMapDescriptor / |
| 2281 | indAudeventBufferDescriptor / |
| 2282 | indAudstatisticsDescriptor / indAudpackagesDescriptor ) |
| 2283 | */ |
| 2284 | static void |
| 2285 | dissect_megaco_auditdescriptor(tvbuff_t *tvb, proto_tree *megaco_tree, packet_info *pinfo _U___attribute__((unused)), proto_tree *top_tree, uint32_t context) |
| 2286 | { |
| 2287 | int token_index; |
| 2288 | unsigned tokenlen, tvb_offset, tvb_stop, tvb_end, tvb_next, tvb_token_end; |
| 2289 | proto_tree *megaco_auditdescriptor_tree, *megaco_auditdescriptor_ti; |
| 2290 | bool_Bool descriptor; |
| 2291 | |
| 2292 | /* find opening LBRKT - is this already checked by caller? */ |
| 2293 | if(!tvb_find_uint8_remaining(tvb, 0, '{', &tvb_next)) { |
| 2294 | /* complain and give up if not there */ |
| 2295 | expert_add_info(pinfo, megaco_tree, &ei_megaco_audit_descriptor); |
| 2296 | return; |
| 2297 | } |
| 2298 | |
| 2299 | tokenlen = tvb_reported_length(tvb); |
| 2300 | |
| 2301 | megaco_auditdescriptor_ti = proto_tree_add_item( megaco_tree, hf_megaco_audit_descriptor, tvb, 0, tokenlen, ENC_NA0x00000000); |
| 2302 | megaco_auditdescriptor_tree = proto_item_add_subtree( megaco_auditdescriptor_ti, ett_megaco_auditdescriptor ); |
| 2303 | |
| 2304 | tvb_offset = tvb_next; |
| 2305 | tvb_stop = tokenlen - 1; |
| 2306 | |
| 2307 | while( tvb_offset < tvb_stop ) |
| 2308 | { |
| 2309 | tvb_offset = megaco_tvb_skip_wsp(tvb, tvb_offset+1); /* find start of an auditItem */ |
| 2310 | if( tvb_get_uint8(tvb, tvb_offset) != '}' ) /* got something */ |
| 2311 | { |
| 2312 | /* end of an auditItem */ |
| 2313 | if(!tvb_find_uint8_remaining(tvb, tvb_offset, ',', &tvb_next)) { |
| 2314 | /* last item doesn't have a comma */ |
| 2315 | tvb_next = tvb_stop; |
| 2316 | } |
| 2317 | |
| 2318 | tvb_end = megaco_tvb_skip_wsp_return(tvb, tvb_next-1); /* trim any trailing whitespace */ |
| 2319 | |
| 2320 | if (!tvb_find_uint8_length(tvb, tvb_offset, tvb_next - tvb_offset + 1, '{', NULL((void*)0))) { |
| 2321 | /* auditItem has no parameters (i.e., is a Token) */ |
| 2322 | descriptor = false0; |
| 2323 | tvb_token_end = tvb_end; |
| 2324 | } else { |
| 2325 | /* auditItem includes Parameters (i.e., is a Descriptor) */ |
| 2326 | descriptor = true1; |
| 2327 | for (tvb_token_end=tvb_offset; tvb_token_end < tvb_end ; tvb_token_end++){ |
| 2328 | if (!g_ascii_isalpha(tvb_get_uint8(tvb, tvb_token_end ))((g_ascii_table[(guchar) (tvb_get_uint8(tvb, tvb_token_end )) ] & G_ASCII_ALPHA) != 0)){ |
| 2329 | break; |
| 2330 | } |
| 2331 | } |
| 2332 | } |
| 2333 | |
| 2334 | tokenlen = tvb_token_end - tvb_offset; /* get length of token */ |
| 2335 | |
| 2336 | token_index = find_megaco_descriptors_names(tvb, tvb_offset, tokenlen); /* lookup the token */ |
| 2337 | if( token_index == -1 ) /* if not found then 0 => Unknown */ |
| 2338 | token_index = 0; |
| 2339 | |
| 2340 | if (descriptor) { |
| 2341 | tvbuff_t *descriptor_tvb = tvb_new_subset_length(tvb, tvb_offset, tvb_end - tvb_offset + 1); |
| 2342 | switch ( token_index ){ |
| 2343 | case MEGACO_MEDIA_TOKEN3: |
| 2344 | { |
| 2345 | unsigned temp_offset; |
| 2346 | tvb_find_uint8_remaining(tvb, tvb_offset, '{', &temp_offset); |
| 2347 | unsigned save_offset = tvb_offset; |
| 2348 | |
| 2349 | tvb_offset = megaco_tvb_skip_wsp(tvb, temp_offset +1); |
| 2350 | dissect_megaco_mediadescriptor(tvb, megaco_auditdescriptor_tree, pinfo, tvb_end, tvb_offset, save_offset, top_tree, context); |
| 2351 | break; |
| 2352 | } |
| 2353 | case MEGACO_SIGNALS_TOKEN4: |
| 2354 | dissect_megaco_signaldescriptor(tvb, pinfo, megaco_auditdescriptor_tree, tvb_end, tvb_offset, top_tree); |
| 2355 | break; |
| 2356 | case MEGACO_STATS_TOKEN6: |
| 2357 | dissect_megaco_statisticsdescriptor(descriptor_tvb, megaco_auditdescriptor_tree); |
| 2358 | break; |
| 2359 | case MEGACO_EVENTS_TOKEN8: |
| 2360 | dissect_megaco_eventsdescriptor(descriptor_tvb, pinfo, megaco_auditdescriptor_tree, top_tree); |
| 2361 | break; |
| 2362 | case MEGACO_DIGITMAP_TOKEN10: |
| 2363 | dissect_megaco_digitmapdescriptor(tvb, pinfo, megaco_auditdescriptor_tree, tvb_end, tvb_offset); |
| 2364 | break; |
| 2365 | case MEGACO_PACKAGES_TOKEN13: |
| 2366 | dissect_megaco_Packagesdescriptor(tvb, pinfo, megaco_auditdescriptor_tree, tvb_end, tvb_offset); |
| 2367 | break; |
| 2368 | default: |
| 2369 | tokenlen = tvb_end - tvb_offset; |
| 2370 | proto_tree_add_string(megaco_auditdescriptor_tree, hf_megaco_audititem, tvb, |
| 2371 | tvb_offset, tokenlen, megaco_descriptors_names[token_index].name); /* and display the long form */ |
| 2372 | break; |
| 2373 | } |
| 2374 | } else { |
| 2375 | proto_tree_add_string(megaco_auditdescriptor_tree, hf_megaco_audititem, tvb, |
| 2376 | tvb_offset, tokenlen, megaco_descriptors_names[token_index].name); /* and display the long form */ |
| 2377 | } |
| 2378 | |
| 2379 | tvb_offset = tvb_next; /* advance pointer */ |
| 2380 | } |
| 2381 | } |
| 2382 | } |
| 2383 | |
| 2384 | /* |
| 2385 | * serviceChangeDescriptor = ServicesToken LBRKT serviceChangeParm |
| 2386 | * *(COMMA serviceChangeParm) RBRKT |
| 2387 | * |
| 2388 | * ServicesToken = ("Services" / "SV") |
| 2389 | * |
| 2390 | * serviceChangeParm = (serviceChangeMethod / serviceChangeReason / |
| 2391 | * serviceChangeDelay / serviceChangeAddress / |
| 2392 | * serviceChangeProfile / extension / TimeStamp / |
| 2393 | * serviceChangeMgcId / serviceChangeVersion ) |
| 2394 | * |
| 2395 | */ |
| 2396 | #define MEGACO_REASON_TOKEN1 1 |
| 2397 | #define MEGACO_DELAY_TOKEN2 2 |
| 2398 | #define MEGACO_SC_ADDR_TOKEN3 3 |
| 2399 | #define MEGACO_MGC_ID_TOKEN4 4 |
| 2400 | #define MEGACO_PROFILE_TOKEN5 5 |
| 2401 | #define MEGACO_VERSION_TOKEN6 6 |
| 2402 | #define MEGACO_METHOD_TOKEN7 7 |
| 2403 | |
| 2404 | static const megaco_tokens_t megaco_serviceChangeParm_names[] = { |
| 2405 | { "Unknown-token", NULL((void*)0) }, /* 0 Pad so that the real headers start at index 1 */ |
| 2406 | /* streamMode */ |
| 2407 | { "Reason", "RE" }, /* 1 ReasonToken*/ |
| 2408 | { "Delay", "DL" }, /* 2 DelayToken */ |
| 2409 | { "ServiceChangeAddress", "AD" }, /* 3 ServiceChangeAddressToken */ |
| 2410 | { "MgcIdToTry", "MG" }, /* 4 MgcIdToken */ |
| 2411 | { "Profile", "PF" }, /* 5 ProfileToken */ |
| 2412 | { "Version", "V" }, /* 6 VersionToken */ |
| 2413 | { "Method", "MT" }, /* 7 MethodToken */ |
| 2414 | }; |
| 2415 | |
| 2416 | /* Returns index of megaco_tokens_t */ |
| 2417 | static int find_megaco_megaco_serviceChangeParm_names(tvbuff_t *tvb, int offset, unsigned header_len) |
| 2418 | { |
| 2419 | unsigned i; |
| 2420 | |
| 2421 | for (i = 1; i < array_length(megaco_serviceChangeParm_names)(sizeof (megaco_serviceChangeParm_names) / sizeof (megaco_serviceChangeParm_names )[0]); i++) { |
| 2422 | if (header_len == strlen(megaco_serviceChangeParm_names[i].name) && |
| 2423 | tvb_strncaseeql(tvb, offset, megaco_serviceChangeParm_names[i].name, header_len) == 0) |
| 2424 | return i; |
| 2425 | if (megaco_serviceChangeParm_names[i].compact_name != NULL((void*)0) && |
| 2426 | header_len == strlen(megaco_serviceChangeParm_names[i].compact_name) && |
| 2427 | tvb_strncaseeql(tvb, offset, megaco_serviceChangeParm_names[i].compact_name, header_len) == 0) |
| 2428 | return i; |
| 2429 | } |
| 2430 | |
| 2431 | return -1; |
| 2432 | } |
| 2433 | /* |
| 2434 | * ServiceChangeReasons References |
| 2435 | * -------------------- ---------- |
| 2436 | */ |
| 2437 | static const value_string MEGACO_ServiceChangeReasons_vals[] = { |
| 2438 | {900, "Service Restored"}, |
| 2439 | {901, "Cold Boot"}, |
| 2440 | {902, "Warm Boot"}, |
| 2441 | {903, "MGC Directed Change"}, |
| 2442 | {904, "Termination malfunctioning"}, |
| 2443 | {905, "Termination taken out of service"}, |
| 2444 | {906, "Loss of lower layer connectivity (e.g. downstream sync)"}, |
| 2445 | {907, "Transmission Failure"}, |
| 2446 | {908, "MG Impending Failure"}, |
| 2447 | {909, "MGC Impending Failure"}, |
| 2448 | {910, "Media Capability Failure"}, |
| 2449 | {911, "Modem Capability Failure"}, |
| 2450 | {912, "Mux Capability Failure"}, |
| 2451 | {913, "Signal Capability Failure"}, |
| 2452 | {914, "Event Capability Failure"}, |
| 2453 | {915, "State Loss"}, |
| 2454 | {916, "Packages Change"}, |
| 2455 | {917, "Capabilities Change"}, |
| 2456 | {918, "Cancel Graceful"}, |
| 2457 | {919, "Warm Failover"}, |
| 2458 | {920, "Cold Failover"}, |
| 2459 | { 0, NULL((void*)0) } |
| 2460 | }; |
| 2461 | |
| 2462 | static void |
| 2463 | dissect_megaco_servicechangedescriptor(tvbuff_t *tvb, packet_info* pinfo, proto_tree *megaco_tree, int tvb_RBRKT, |
| 2464 | int tvb_previous_offset) |
| 2465 | { |
| 2466 | |
| 2467 | int tokenlen, tvb_LBRKT, tvb_offset; |
| 2468 | int token_index; |
| 2469 | int tvb_current_offset; |
| 2470 | bool_Bool more_params = true1; |
| 2471 | proto_item* item; |
| 2472 | int reason; |
| 2473 | bool_Bool reason_valid; |
| 2474 | uint8_t ServiceChangeReason_str[4]; |
| 2475 | |
| 2476 | tvb_LBRKT = tvb_find_uint8(tvb, tvb_previous_offset, tvb_RBRKT, '{'); |
| 2477 | /* |
| 2478 | if (tvb_LBRKT == -1) |
| 2479 | return; |
| 2480 | */ |
| 2481 | tokenlen = (tvb_LBRKT + 1) - tvb_previous_offset; |
| 2482 | proto_tree_add_format_text(megaco_tree, tvb, tvb_previous_offset, tokenlen); |
| 2483 | |
| 2484 | /* Start dissecting serviceChangeParm */ |
| 2485 | tvb_previous_offset = tvb_LBRKT + 1; |
| 2486 | while (more_params){ |
| 2487 | tvb_previous_offset = megaco_tvb_skip_wsp(tvb, tvb_previous_offset); |
| 2488 | /* Find token length */ |
| 2489 | for (tvb_offset=tvb_previous_offset; tvb_offset < tvb_RBRKT; tvb_offset++){ |
| 2490 | if (!g_ascii_isalpha(tvb_get_uint8(tvb, tvb_offset ))((g_ascii_table[(guchar) (tvb_get_uint8(tvb, tvb_offset ))] & G_ASCII_ALPHA) != 0)){ |
| 2491 | break; |
| 2492 | } |
| 2493 | } |
| 2494 | tokenlen = tvb_offset - tvb_previous_offset; |
| 2495 | token_index = find_megaco_megaco_serviceChangeParm_names(tvb, tvb_previous_offset, tokenlen); |
| 2496 | |
| 2497 | tvb_offset = tvb_find_uint8(tvb, tvb_offset, tvb_RBRKT, ','); |
| 2498 | if ((tvb_offset == -1)||(tvb_offset >=tvb_RBRKT)){ |
| 2499 | more_params = false0; |
| 2500 | tvb_offset = megaco_tvb_skip_wsp_return(tvb, tvb_RBRKT-1); |
| 2501 | } |
| 2502 | tokenlen = tvb_offset - tvb_previous_offset; |
| 2503 | if (more_params == true1 ) |
| 2504 | /* Include ',' */ |
| 2505 | tokenlen++; |
| 2506 | switch(token_index){ |
| 2507 | case MEGACO_REASON_TOKEN1: |
| 2508 | /* ReasonToken EQUAL VALUE |
| 2509 | * VALUE = quotedString / 1*(SafeChar) |
| 2510 | */ |
| 2511 | item = proto_tree_add_format_text(megaco_tree, tvb, tvb_previous_offset, tokenlen); |
| 2512 | |
| 2513 | /* As the reason code ( if a digit ) can be in quoted string or 'just' digit |
| 2514 | * look for a nine and hope for the best. |
| 2515 | */ |
| 2516 | tvb_current_offset = tvb_find_uint8(tvb, tvb_previous_offset, tvb_RBRKT, '9'); |
| 2517 | if ( tvb_current_offset == -1) |
| 2518 | break; |
| 2519 | |
| 2520 | tvb_get_raw_bytes_as_stringz(tvb,tvb_current_offset,4,ServiceChangeReason_str); |
| 2521 | reason_valid = ws_strtoi32((char*)ServiceChangeReason_str, NULL((void*)0), &reason); |
| 2522 | proto_item_append_text(item,"[ %s ]", val_to_str(pinfo->pool, reason, MEGACO_ServiceChangeReasons_vals,"Unknown (%u)")); |
| 2523 | if (!reason_valid) |
| 2524 | expert_add_info(pinfo, item, &ei_megaco_reason_invalid); |
| 2525 | break; |
| 2526 | case MEGACO_DELAY_TOKEN2: |
| 2527 | case MEGACO_SC_ADDR_TOKEN3: |
| 2528 | case MEGACO_MGC_ID_TOKEN4: |
| 2529 | case MEGACO_PROFILE_TOKEN5: |
| 2530 | case MEGACO_VERSION_TOKEN6: |
| 2531 | case MEGACO_METHOD_TOKEN7: |
| 2532 | /* No special dissection: fall through */ |
| 2533 | default: |
| 2534 | /* Unknown or: |
| 2535 | * extension = extensionParameter parmValue |
| 2536 | * extensionParameter = "X" ("-" / "+") 1*6(ALPHA / DIGIT) |
| 2537 | */ |
| 2538 | proto_tree_add_format_text(megaco_tree, tvb, tvb_previous_offset, tokenlen); |
| 2539 | break; |
| 2540 | } |
| 2541 | |
| 2542 | tvb_previous_offset = tvb_offset +1; |
| 2543 | |
| 2544 | }/*End while */ |
| 2545 | |
| 2546 | /* extension = extensionParameter parmValue |
| 2547 | * extensionParameter = "X" ("-" / "+") 1*6(ALPHA / DIGIT) |
| 2548 | */ |
| 2549 | |
| 2550 | /* |
| 2551 | tokenlen = (tvb_RBRKT+1) - tvb_previous_offset; |
| 2552 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_servicechange_descriptor, tvb, |
| 2553 | tvb_previous_offset, tokenlen, |
| 2554 | tvb_format_text(pinfo->pool, tvb, tvb_previous_offset, |
| 2555 | tokenlen)); |
| 2556 | */ |
| 2557 | proto_tree_add_format_text(megaco_tree, tvb, tvb_RBRKT, 1); |
| 2558 | |
| 2559 | } |
| 2560 | static void |
| 2561 | dissect_megaco_digitmapdescriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *megaco_tree_command_line, int tvb_RBRKT, int tvb_previous_offset) |
| 2562 | { |
| 2563 | |
| 2564 | int tokenlen; |
| 2565 | |
| 2566 | tokenlen = tvb_RBRKT - tvb_previous_offset; |
| 2567 | proto_tree_add_string(megaco_tree_command_line, hf_megaco_digitmap_descriptor, tvb, |
| 2568 | tvb_previous_offset, tokenlen, |
| 2569 | tvb_format_text(pinfo->pool, tvb, tvb_previous_offset, |
| 2570 | tokenlen)); |
| 2571 | |
| 2572 | } |
| 2573 | |
| 2574 | static void |
| 2575 | dissect_megaco_statisticsdescriptor(tvbuff_t *tvb, proto_tree *megaco_tree_command_line) |
| 2576 | { |
| 2577 | unsigned tokenlen; |
| 2578 | proto_tree *megaco_statisticsdescriptor_tree; |
| 2579 | proto_item *megaco_statisticsdescriptor_ti; |
| 2580 | unsigned tvb_help_offset, param_start_offset, param_end_offset = 0; |
| 2581 | |
| 2582 | /* statisticsDescriptor = StatsToken LBRKT statisticsParameter |
| 2583 | * *(COMMA statisticsParameter ) RBRKT |
| 2584 | * statisticsParameter = pkgdName EQUAL VALUE |
| 2585 | */ |
| 2586 | tokenlen = tvb_reported_length(tvb); |
| 2587 | |
| 2588 | megaco_statisticsdescriptor_ti = proto_tree_add_item(megaco_tree_command_line,hf_megaco_statistics_descriptor,tvb,0,tokenlen, ENC_NA0x00000000); |
| 2589 | megaco_statisticsdescriptor_tree = proto_item_add_subtree(megaco_statisticsdescriptor_ti, ett_megaco_statisticsdescriptor); |
| 2590 | |
| 2591 | tvb_find_uint8_remaining(tvb, 0, '{', &tvb_help_offset); |
| 2592 | do { |
| 2593 | param_start_offset = megaco_tvb_skip_wsp(tvb, tvb_help_offset+1); |
| 2594 | |
| 2595 | /* Find the COMMA that ends the parameter if not the last */ |
| 2596 | if (!tvb_find_uint8_remaining(tvb, param_start_offset, ',', &tvb_help_offset)) { |
| 2597 | /* Reached end, RBRKT separator should be at tvb_help_offset - 1. */ |
| 2598 | param_end_offset = megaco_tvb_skip_wsp_return(tvb, tvb_help_offset - 2); |
| 2599 | } else { |
| 2600 | param_end_offset = megaco_tvb_skip_wsp_return(tvb, tvb_help_offset - 1); |
| 2601 | } |
| 2602 | tokenlen = param_end_offset - param_start_offset; |
| 2603 | |
| 2604 | proto_tree_add_format_text(megaco_statisticsdescriptor_tree, tvb,param_start_offset, tokenlen); |
| 2605 | |
| 2606 | } while (tvb_captured_length_remaining(tvb, tvb_help_offset)); |
| 2607 | } |
| 2608 | |
| 2609 | static void |
| 2610 | dissect_megaco_observedeventsdescriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *megaco_tree_command_line, proto_tree *top_tree) |
| 2611 | { |
| 2612 | |
| 2613 | /* observedEventsDescriptor = ObservedEventsToken EQUAL RequestID |
| 2614 | * LBRKT observedEvent *(COMMA observedEvent) RBRKT |
| 2615 | * |
| 2616 | * ;time per event, because it might be buffered |
| 2617 | * observedEvent = [ TimeStamp LWSP COLON] LWSP |
| 2618 | * pkgdName [ LBRKT observedEventParameter |
| 2619 | * *(COMMA observedEventParameter) RBRKT ] |
| 2620 | */ |
| 2621 | |
| 2622 | unsigned tokenlen, pkg_tokenlen, tvb_current_offset, tvb_next_offset, tvb_help_offset, tvb_previous_offset; |
| 2623 | unsigned tvb_observedevents_end_offset, tvb_LBRKT, tvb_RBRKT; |
| 2624 | proto_tree *megaco_observedeventsdescriptor_tree, *megaco_observedevent_tree; |
| 2625 | proto_item *megaco_observedeventsdescriptor_ti, *megaco_observedevent_ti; |
| 2626 | |
| 2627 | unsigned requested_event_start_offset, requested_event_end_offset, param_start_offset, param_end_offset; |
| 2628 | |
| 2629 | requested_event_start_offset = 0; |
| 2630 | requested_event_end_offset = 0; |
| 2631 | |
| 2632 | tvb_observedevents_end_offset = tvb_reported_length(tvb); |
| 2633 | |
| 2634 | megaco_observedeventsdescriptor_ti = proto_tree_add_item(megaco_tree_command_line, hf_megaco_observedevents_descriptor, tvb, 0, tvb_observedevents_end_offset, ENC_NA0x00000000); |
| 2635 | megaco_observedeventsdescriptor_tree = proto_item_add_subtree(megaco_observedeventsdescriptor_ti, ett_megaco_observedeventsdescriptor); |
| 2636 | |
| 2637 | if (tvb_find_uint8_remaining(tvb, 0, '=', &tvb_current_offset)) { |
| 2638 | |
| 2639 | /* If this fails, something's malformed; handle below. */ |
| 2640 | tvb_find_uint8_remaining(tvb, 0, '{', &tvb_next_offset); |
| 2641 | |
| 2642 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_current_offset + 1); |
| 2643 | tvb_help_offset = megaco_tvb_skip_wsp_return(tvb, tvb_next_offset - 1); |
| 2644 | |
| 2645 | tokenlen = tvb_help_offset - tvb_current_offset; |
| 2646 | |
| 2647 | proto_tree_add_uint(megaco_observedeventsdescriptor_tree, hf_megaco_requestid, tvb, |
| 2648 | tvb_current_offset, tokenlen, |
| 2649 | (uint32_t) strtoul(tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen), NULL((void*)0), 10)); |
| 2650 | |
| 2651 | if (tvb_next_offset == tvb_observedevents_end_offset) { |
| 2652 | /* No LBRKT before the first observedEvent (expert info?) */ |
| 2653 | return; |
| 2654 | } |
| 2655 | tvb_previous_offset = megaco_tvb_skip_wsp(tvb, tvb_next_offset+1); |
| 2656 | |
| 2657 | do { |
| 2658 | |
| 2659 | tvb_find_uint8_remaining(tvb, tvb_previous_offset, '}', &tvb_RBRKT); |
| 2660 | tvb_find_uint8_remaining(tvb, tvb_previous_offset, ',', &tvb_current_offset); |
| 2661 | |
| 2662 | if (!tvb_find_uint8_remaining(tvb, tvb_previous_offset, '{', &tvb_LBRKT) || tvb_LBRKT > tvb_current_offset) { |
| 2663 | /* Descriptor includes no parameters */ |
| 2664 | tvb_RBRKT = megaco_tvb_skip_wsp_return(tvb, tvb_current_offset-1)-1; |
| 2665 | } else { |
| 2666 | /* Descriptor includes Parameters */ |
| 2667 | /* If the next LBRKT is before RBRKT, then there's nested braves. |
| 2668 | * Keep going until balanced or we run out of buffer. */ |
| 2669 | while (tvb_find_uint8_remaining(tvb, tvb_LBRKT+1, '{', &tvb_LBRKT) && tvb_LBRKT < tvb_RBRKT) { |
| 2670 | if (tvb_RBRKT < tvb_observedevents_end_offset) { |
| 2671 | tvb_find_uint8_remaining(tvb, tvb_RBRKT+1, '}', &tvb_RBRKT); |
| 2672 | } |
| 2673 | } |
| 2674 | |
| 2675 | } |
| 2676 | |
| 2677 | tvb_find_uint8_remaining(tvb, tvb_previous_offset, '{', &tvb_help_offset); |
| 2678 | tvb_LBRKT = tvb_help_offset; |
| 2679 | /* if there are eventparameter */ |
| 2680 | |
| 2681 | if (tvb_help_offset < tvb_RBRKT) { |
| 2682 | |
| 2683 | requested_event_start_offset = tvb_help_offset; |
| 2684 | requested_event_end_offset = tvb_RBRKT; |
| 2685 | tvb_help_offset = megaco_tvb_skip_wsp_return(tvb, tvb_help_offset-1); |
| 2686 | pkg_tokenlen = tvb_help_offset - tvb_previous_offset; |
| 2687 | tokenlen = tvb_LBRKT+1 - tvb_previous_offset; |
| 2688 | } |
| 2689 | /* no parameters */ |
| 2690 | else { |
| 2691 | tokenlen = pkg_tokenlen = tvb_RBRKT+1 - tvb_previous_offset; |
| 2692 | } |
| 2693 | |
| 2694 | megaco_observedevent_ti = proto_tree_add_format_text(megaco_observedeventsdescriptor_tree, tvb, tvb_previous_offset, tokenlen); |
| 2695 | |
| 2696 | megaco_observedevent_tree = proto_item_add_subtree(megaco_observedevent_ti, ett_megaco_observedevent); |
| 2697 | |
| 2698 | proto_tree_add_item(megaco_observedevent_tree,hf_megaco_pkgdname,tvb,tvb_previous_offset,pkg_tokenlen, ENC_UTF_80x00000002); |
| 2699 | |
| 2700 | if (tvb_help_offset < tvb_RBRKT) { |
| 2701 | |
| 2702 | requested_event_start_offset = megaco_tvb_skip_wsp(tvb, requested_event_start_offset +1)-1; |
| 2703 | requested_event_end_offset = megaco_tvb_skip_wsp_return(tvb, requested_event_end_offset-1); |
| 2704 | |
| 2705 | tvb_help_offset = requested_event_start_offset; |
| 2706 | |
| 2707 | do { |
| 2708 | param_start_offset = megaco_tvb_skip_wsp(tvb, tvb_help_offset+1); |
| 2709 | |
| 2710 | tvb_find_uint8_length(tvb, tvb_help_offset + 1, requested_event_end_offset - (tvb_help_offset + 1), ',', &tvb_help_offset); |
| 2711 | |
| 2712 | param_end_offset = megaco_tvb_skip_wsp(tvb, tvb_help_offset-1); |
| 2713 | |
| 2714 | tokenlen = param_end_offset - param_start_offset+1; |
| 2715 | if(!tvb_strneql(tvb, param_start_offset, "h245", 4)){ |
| 2716 | dissect_megaco_h245(tvb, pinfo, megaco_observedevent_tree, param_start_offset, tokenlen, top_tree); |
| 2717 | } else { |
| 2718 | proto_tree_add_format_text(megaco_observedevent_tree, tvb, param_start_offset, tokenlen); |
| 2719 | } |
| 2720 | |
| 2721 | |
| 2722 | } while ( tvb_help_offset < requested_event_end_offset ); |
| 2723 | } |
| 2724 | |
| 2725 | tvb_previous_offset = tvb_current_offset; |
| 2726 | tvb_find_uint8_remaining(tvb, tvb_RBRKT, ',', &tvb_current_offset); |
| 2727 | if (tvb_current_offset < tvb_previous_offset) { |
| 2728 | expert_add_info_format(pinfo, megaco_observedevent_ti, &ei_megaco_parse_error, "Parse error: Invalid offset"); |
| 2729 | return; |
| 2730 | } |
| 2731 | |
| 2732 | tvb_previous_offset = megaco_tvb_skip_wsp(tvb, tvb_current_offset+1); |
| 2733 | /* Print the trailing '}' (raw formatting removed) */ |
| 2734 | /* proto_tree_add_format_text(megaco_tree_command_line, tvb, tvb_observedevents_end_offset, 1); */ |
| 2735 | |
| 2736 | } while ( tvb_current_offset < tvb_observedevents_end_offset ); |
| 2737 | } |
| 2738 | } |
| 2739 | static void |
| 2740 | dissect_megaco_topologydescriptor(tvbuff_t *tvb, proto_tree *megaco_tree_command_line, int tvb_RBRKT, int tvb_previous_offset) |
| 2741 | { |
| 2742 | |
| 2743 | int tokenlen; |
| 2744 | |
| 2745 | tokenlen = (tvb_RBRKT+1) - tvb_previous_offset; |
| 2746 | proto_tree_add_item(megaco_tree_command_line, hf_megaco_topology_descriptor, tvb, |
| 2747 | tvb_previous_offset, tokenlen, ENC_ASCII0x00000000); |
| 2748 | |
| 2749 | } |
| 2750 | static void |
| 2751 | dissect_megaco_Packagesdescriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *megaco_tree_command_line, unsigned tvb_RBRKT, unsigned tvb_previous_offset) |
| 2752 | { |
| 2753 | |
| 2754 | unsigned tokenlen, tvb_current_offset, tvb_next_offset, tvb_help_offset; |
| 2755 | unsigned tvb_packages_end_offset, tvb_LBRKT; |
| 2756 | bool_Bool found, tvb_LBRKT_found; |
| 2757 | |
| 2758 | proto_tree *megaco_packagesdescriptor_tree; |
| 2759 | proto_item *megaco_packagesdescriptor_ti, *ti; |
| 2760 | |
| 2761 | tokenlen = (tvb_RBRKT+1) - tvb_previous_offset; |
| 2762 | |
| 2763 | megaco_packagesdescriptor_ti = proto_tree_add_item(megaco_tree_command_line,hf_megaco_packages_descriptor,tvb,tvb_previous_offset,tokenlen, ENC_UTF_80x00000002); |
| 2764 | megaco_packagesdescriptor_tree = proto_item_add_subtree(megaco_packagesdescriptor_ti, ett_megaco_packagesdescriptor); |
| 2765 | |
| 2766 | found = tvb_find_uint8_length(tvb, tvb_previous_offset, tvb_RBRKT, '=', &tvb_current_offset); |
| 2767 | tvb_next_offset = tvb_find_uint8_length(tvb, tvb_previous_offset, tvb_RBRKT, '{', &tvb_next_offset); |
| 2768 | |
| 2769 | if ( tvb_current_offset < tvb_RBRKT && found == true1 ){ |
| 2770 | |
| 2771 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_current_offset +1); |
| 2772 | tvb_help_offset = megaco_tvb_skip_wsp_return(tvb, tvb_next_offset-1); |
| 2773 | |
| 2774 | tokenlen = tvb_help_offset - tvb_current_offset; |
| 2775 | |
| 2776 | ti = proto_tree_add_uint(megaco_packagesdescriptor_tree, hf_megaco_requestid, tvb, |
| 2777 | tvb_current_offset, 1, |
| 2778 | (uint32_t) strtoul(tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen), NULL((void*)0), 10)); |
| 2779 | proto_item_set_len(ti, tokenlen); |
| 2780 | |
| 2781 | tvb_packages_end_offset = tvb_RBRKT; |
| 2782 | |
| 2783 | tvb_RBRKT = tvb_next_offset+1; |
| 2784 | tvb_LBRKT = tvb_next_offset+1; |
| 2785 | tvb_previous_offset = megaco_tvb_skip_wsp(tvb, tvb_next_offset+1); |
| 2786 | |
| 2787 | |
| 2788 | do { |
| 2789 | |
| 2790 | tvb_find_uint8_length(tvb, tvb_RBRKT+1, tvb_packages_end_offset, '}', &tvb_RBRKT); |
| 2791 | tvb_LBRKT_found = tvb_find_uint8_length(tvb, tvb_LBRKT, tvb_packages_end_offset, '{', &tvb_LBRKT); |
| 2792 | |
| 2793 | found = tvb_find_uint8_length(tvb, tvb_previous_offset, tvb_packages_end_offset, ',', &tvb_current_offset); |
| 2794 | |
| 2795 | if (found == false0 || tvb_current_offset > tvb_packages_end_offset){ |
| 2796 | tvb_current_offset = tvb_packages_end_offset; |
| 2797 | } |
| 2798 | |
| 2799 | |
| 2800 | /* Descriptor includes no parameters */ |
| 2801 | |
| 2802 | if ( tvb_LBRKT > tvb_current_offset || tvb_LBRKT_found == false0){ |
| 2803 | |
| 2804 | tvb_RBRKT = megaco_tvb_skip_wsp_return(tvb, tvb_current_offset-1)-1; |
| 2805 | } |
| 2806 | |
| 2807 | /* Descriptor includes Parameters */ |
| 2808 | |
| 2809 | if ( (tvb_current_offset > tvb_LBRKT && tvb_LBRKT_found == true1)){ |
| 2810 | |
| 2811 | while (tvb_LBRKT_found == true1 && tvb_RBRKT > tvb_LBRKT ){ |
| 2812 | |
| 2813 | tvb_LBRKT_found = tvb_find_uint8_length(tvb, tvb_LBRKT+1, tvb_packages_end_offset, '{', &tvb_LBRKT); |
| 2814 | if ( tvb_LBRKT < tvb_RBRKT && tvb_LBRKT_found == true1) |
| 2815 | tvb_find_uint8_length(tvb, tvb_RBRKT+1, tvb_packages_end_offset, '}', &tvb_RBRKT); |
| 2816 | } |
| 2817 | |
| 2818 | } |
| 2819 | |
| 2820 | tokenlen = tvb_RBRKT+1 - tvb_previous_offset; |
| 2821 | |
| 2822 | proto_tree_add_format_text(megaco_packagesdescriptor_tree, tvb, tvb_previous_offset, tokenlen); |
| 2823 | |
| 2824 | found = tvb_find_uint8_length(tvb, tvb_RBRKT, tvb_packages_end_offset, ',', &tvb_current_offset); |
| 2825 | |
| 2826 | if (found == false0 || tvb_current_offset > tvb_packages_end_offset ){ |
| 2827 | tvb_current_offset = tvb_packages_end_offset; |
| 2828 | } |
| 2829 | |
| 2830 | tvb_previous_offset = megaco_tvb_skip_wsp(tvb, tvb_current_offset+1); |
| 2831 | |
| 2832 | tvb_LBRKT = tvb_previous_offset; |
| 2833 | tvb_RBRKT = tvb_previous_offset; |
| 2834 | |
| 2835 | } while ( tvb_current_offset < tvb_packages_end_offset ); |
| 2836 | } |
| 2837 | |
| 2838 | } |
| 2839 | /* The list of error code values is fetched from http://www.iana.org/assignments/megaco-h248 */ |
| 2840 | /* 2003-08-28 */ |
| 2841 | |
| 2842 | static const value_string MEGACO_error_code_vals[] = { |
| 2843 | |
| 2844 | {400, "Syntax error in message"}, |
| 2845 | {401, "Protocol Error"}, |
| 2846 | {402, "Unauthorized"}, |
| 2847 | {403, "Syntax error in transaction request"}, |
| 2848 | {406, "Version Not Supported"}, |
| 2849 | {410, "Incorrect identifier"}, |
| 2850 | {411, "The transaction refers to an unknown ContextId"}, |
| 2851 | {412, "No ContextIDs available"}, |
| 2852 | {421, "Unknown action or illegal combination of actions"}, |
| 2853 | {422, "Syntax Error in Action"}, |
| 2854 | {430, "Unknown TerminationID"}, |
| 2855 | {431, "No TerminationID matched a wildcard"}, |
| 2856 | {432, "Out of TerminationIDs or No TerminationID available"}, |
| 2857 | {433, "TerminationID is already in a Context"}, |
| 2858 | {434, "Max number of Terminations in a Context exceeded"}, |
| 2859 | {435, "Termination ID is not in specified Context"}, |
| 2860 | {440, "Unsupported or unknown Package"}, |
| 2861 | {441, "Missing Remote or Local Descriptor"}, |
| 2862 | {442, "Syntax Error in Command"}, |
| 2863 | {443, "Unsupported or Unknown Command"}, |
| 2864 | {444, "Unsupported or Unknown Descriptor"}, |
| 2865 | {445, "Unsupported or Unknown Property"}, |
| 2866 | {446, "Unsupported or Unknown Parameter"}, |
| 2867 | {447, "Descriptor not legal in this command"}, |
| 2868 | {448, "Descriptor appears twice in a command"}, |
| 2869 | {450, "No such property in this package"}, |
| 2870 | {451, "No such event in this package"}, |
| 2871 | {452, "No such signal in this package"}, |
| 2872 | {453, "No such statistic in this package"}, |
| 2873 | {454, "No such parameter value in this package"}, |
| 2874 | {455, "Property illegal in this Descriptor"}, |
| 2875 | {456, "Property appears twice in this Descriptor"}, |
| 2876 | {457, "Missing parameter in signal or event"}, |
| 2877 | {458, "Unexpected Event/Request ID"}, |
| 2878 | {459, "Unsupported or Unknown Profile"}, |
| 2879 | {471, "Implied Add for Multiplex failure"}, |
| 2880 | |
| 2881 | {500, "Internal software Failure in MG"}, |
| 2882 | {501, "Not Implemented"}, |
| 2883 | {502, "Not ready."}, |
| 2884 | {503, "Service Unavailable"}, |
| 2885 | {504, "Command Received from unauthorized entity"}, |
| 2886 | {505, "Transaction Request Received before a Service Change Reply has been received"}, |
| 2887 | {506, "Number of Transaction Pendings Exceeded"}, |
| 2888 | {510, "Insufficient resources"}, |
| 2889 | {512, "Media Gateway unequipped to detect requested Event"}, |
| 2890 | {513, "Media Gateway unequipped to generate requested Signals"}, |
| 2891 | {514, "Media Gateway cannot send the specified announcement"}, |
| 2892 | {515, "Unsupported Media Type"}, |
| 2893 | {517, "Unsupported or invalid mode"}, |
| 2894 | {518, "Event buffer full"}, |
| 2895 | {519, "Out of space to store digit map"}, |
| 2896 | {520, "Digit Map undefined in the MG"}, |
| 2897 | {521, "Termination is ServiceChanging"}, |
| 2898 | {526, "Insufficient bandwidth"}, |
| 2899 | {529, "Internal hardware failure in MG"}, |
| 2900 | {530, "Temporary Network failure"}, |
| 2901 | {531, "Permanent Network failure"}, |
| 2902 | {532, "Audited Property, Statistic, Event or Signal does not exist"}, |
| 2903 | {533, "Response exceeds maximum transport PDU size"}, |
| 2904 | {534, "Illegal write or read only property"}, |
| 2905 | {540, "Unexpected initial hook state"}, |
| 2906 | {581, "Does Not Exist"}, |
| 2907 | |
| 2908 | {600, "Illegal syntax within an announcement specification"}, |
| 2909 | {601, "Variable type not supported"}, |
| 2910 | {602, "Variable value out of range"}, |
| 2911 | {603, "Category not supported"}, |
| 2912 | {604, "Selector type not supported"}, |
| 2913 | {605, "Selector value not supported"}, |
| 2914 | {606, "Unknown segment ID"}, |
| 2915 | {607, "Mismatch between play specification and provisioned data"}, |
| 2916 | {608, "Provisioning error"}, |
| 2917 | {609, "Invalid offset"}, |
| 2918 | {610, "No free segment IDs"}, |
| 2919 | {611, "Temporary segment not found"}, |
| 2920 | {612, "Segment in use"}, |
| 2921 | {613, "ISP port limit overrun"}, |
| 2922 | {614, "No modems available"}, |
| 2923 | {615, "Calling number unacceptable"}, |
| 2924 | {616, "Called number unacceptable"}, |
| 2925 | { 0, NULL((void*)0) } |
| 2926 | }; |
| 2927 | |
| 2928 | |
| 2929 | |
| 2930 | static void |
| 2931 | dissect_megaco_errordescriptor(tvbuff_t *tvb, packet_info* pinfo, proto_tree *megaco_tree_command_line, |
| 2932 | unsigned tvb_RBRKT, unsigned tvb_previous_offset) |
| 2933 | { |
| 2934 | |
| 2935 | unsigned tokenlen; |
| 2936 | int error_code; |
| 2937 | uint8_t error[4]; |
| 2938 | unsigned tvb_current_offset; |
| 2939 | proto_item* item; |
| 2940 | proto_tree* error_tree; |
| 2941 | bool_Bool error_code_valid; |
| 2942 | |
| 2943 | tvb_find_uint8_length(tvb, tvb_previous_offset , tvb_RBRKT, '=', &tvb_current_offset); |
| 2944 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_current_offset +1); |
| 2945 | |
| 2946 | tokenlen = (tvb_RBRKT) - tvb_previous_offset+1; |
| 2947 | |
| 2948 | item = proto_tree_add_item(megaco_tree_command_line, hf_megaco_error_descriptor, tvb, |
| 2949 | tvb_previous_offset, tokenlen, ENC_NA0x00000000); |
| 2950 | error_tree = proto_item_add_subtree(item, ett_megaco_error_descriptor); |
| 2951 | |
| 2952 | /* Get the error code */ |
| 2953 | tvb_get_raw_bytes_as_stringz(tvb,tvb_current_offset,4,error); |
| 2954 | error_code_valid = ws_strtoi32((char*)error, NULL((void*)0), &error_code); |
| 2955 | item = proto_tree_add_uint(error_tree, hf_megaco_error_code, tvb, tvb_current_offset, 3, error_code); |
| 2956 | if (!error_code_valid) |
| 2957 | expert_add_info(pinfo, item, &ei_megaco_error_code_invalid); |
| 2958 | |
| 2959 | /* Get the error string (even though we have a value_string that should match) */ |
| 2960 | tvb_find_uint8_length(tvb, tvb_current_offset, tvb_RBRKT, '\"', &tvb_previous_offset); |
| 2961 | tvb_find_uint8_length(tvb, tvb_previous_offset+1, tvb_RBRKT, '\"', &tvb_current_offset); |
| 2962 | |
| 2963 | tokenlen = tvb_current_offset - tvb_previous_offset-1; |
| 2964 | proto_tree_add_item(error_tree, hf_megaco_error_string, tvb, tvb_previous_offset+1, tokenlen, ENC_UTF_80x00000002); |
| 2965 | } |
| 2966 | |
| 2967 | static void |
| 2968 | dissect_megaco_TerminationStatedescriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *megaco_mediadescriptor_tree) |
| 2969 | { |
| 2970 | unsigned tokenlen; |
| 2971 | unsigned tvb_offset, tvb_current_offset=0; |
| 2972 | uint8_t tempchar; |
| 2973 | |
| 2974 | proto_tree *megaco_TerminationState_tree, *megaco_TerminationState_ti; |
| 2975 | |
| 2976 | tokenlen = tvb_reported_length(tvb); |
| 2977 | megaco_TerminationState_ti = proto_tree_add_item(megaco_mediadescriptor_tree,hf_megaco_TerminationState_descriptor,tvb, 0, tokenlen, ENC_NA0x00000000); |
| 2978 | megaco_TerminationState_tree = proto_item_add_subtree(megaco_TerminationState_ti, ett_megaco_TerminationState); |
| 2979 | |
| 2980 | while (tvb_find_uint8_remaining(tvb, tvb_current_offset, '=', &tvb_offset)){ |
| 2981 | |
| 2982 | tempchar = tvb_get_uint8(tvb, tvb_current_offset); |
| 2983 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 2984 | if ((tempchar >= 'a') && (tempchar <= 'z')) |
| 2985 | tempchar = tempchar - 0x20; |
| 2986 | |
| 2987 | if (tvb_find_uint8_remaining(tvb, tvb_current_offset, ',', &tvb_offset)) { |
| 2988 | tvb_offset--; |
| 2989 | } |
| 2990 | tokenlen = tvb_offset - tvb_current_offset; |
| 2991 | switch ( tempchar ){ |
| 2992 | |
| 2993 | case 'S': |
| 2994 | proto_tree_add_string(megaco_TerminationState_tree, hf_megaco_Service_State, tvb, |
| 2995 | tvb_current_offset, tokenlen, |
| 2996 | tvb_format_text(pinfo->pool, tvb, tvb_current_offset, |
| 2997 | tokenlen)); |
| 2998 | break; |
| 2999 | |
| 3000 | case 'B': |
| 3001 | proto_tree_add_string(megaco_TerminationState_tree, hf_megaco_Event_Buffer_Control, tvb, |
| 3002 | tvb_current_offset, tokenlen, |
| 3003 | tvb_format_text(pinfo->pool, tvb, tvb_current_offset, |
| 3004 | tokenlen)); |
| 3005 | break; |
| 3006 | |
| 3007 | case 'E': |
| 3008 | proto_tree_add_string(megaco_TerminationState_tree, hf_megaco_Event_Buffer_Control, tvb, |
| 3009 | tvb_current_offset, tokenlen, |
| 3010 | tvb_format_text(pinfo->pool, tvb, tvb_current_offset, |
| 3011 | tokenlen)); |
| 3012 | break; |
| 3013 | |
| 3014 | default: |
| 3015 | proto_tree_add_format_text(megaco_TerminationState_tree, tvb, tvb_current_offset, tokenlen); |
| 3016 | break; |
| 3017 | } |
| 3018 | |
| 3019 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset + 1); |
| 3020 | } |
| 3021 | /* (raw formatting removed) |
| 3022 | proto_tree_add_format_text(megaco_mediadescriptor_tree, tvb, tvb_next_offset, 1); */ |
| 3023 | } |
| 3024 | |
| 3025 | static void |
| 3026 | dissect_megaco_LocalRemotedescriptor(tvbuff_t *tvb, proto_tree *megaco_mediadescriptor_tree, packet_info *pinfo, |
| 3027 | uint32_t context, bool_Bool is_local) |
| 3028 | { |
| 3029 | int tokenlen; |
| 3030 | tvbuff_t *next_tvb; |
| 3031 | media_content_info_t content_info = { MEDIA_CONTAINER_SIP_DATA, NULL((void*)0), NULL((void*)0), NULL((void*)0) }; |
| 3032 | |
| 3033 | sdp_setup_info_t setup_info; |
| 3034 | |
| 3035 | /* Only fill in the info when we have valid contex */ |
| 3036 | if ((context != 0) && (context < 0xfffffffe)) { |
| 3037 | setup_info = (sdp_setup_info_t){ |
| 3038 | .hf_id = hf_megaco_Context_generated, |
| 3039 | .hf_type = SDP_TRACE_ID_HF_TYPE_UINT32, |
| 3040 | .trace_id.num = context, |
| 3041 | }; |
| 3042 | if (!sip_hide_generated_call_ids) { |
| 3043 | setup_info.add_hidden = false0; |
| 3044 | } else { |
| 3045 | setup_info.add_hidden = prefs_get_bool_value(sip_hide_generated_call_ids, pref_current); |
| 3046 | } |
| 3047 | content_info.data = &setup_info; |
| 3048 | } |
| 3049 | |
| 3050 | proto_tree *megaco_localdescriptor_tree; |
| 3051 | proto_item *megaco_localdescriptor_item; |
| 3052 | |
| 3053 | tokenlen = tvb_reported_length(tvb); |
| 3054 | |
| 3055 | if (is_local) { |
| 3056 | megaco_localdescriptor_item = proto_tree_add_item(megaco_mediadescriptor_tree, hf_megaco_Local_descriptor, tvb, 0, tokenlen, ENC_NA0x00000000); |
| 3057 | megaco_localdescriptor_tree = proto_item_add_subtree(megaco_localdescriptor_item, ett_megaco_Localdescriptor); |
| 3058 | } else { |
| 3059 | megaco_localdescriptor_item = proto_tree_add_item(megaco_mediadescriptor_tree, hf_megaco_Remote_descriptor, tvb, 0, tokenlen, ENC_NA0x00000000); |
| 3060 | megaco_localdescriptor_tree = proto_item_add_subtree(megaco_localdescriptor_item, ett_megaco_Remotedescriptor); |
| 3061 | } |
| 3062 | |
| 3063 | if ( tokenlen > 3 ){ |
| 3064 | /* An SDP is supposed to end with a line end. MEGACO allows LWS as part |
| 3065 | * of RBRKT but the SDP dissector doesn't like lines with only tabs or |
| 3066 | * spaces. Remove WSP before the end but then restore the line end. |
| 3067 | * (Restoring is optional, the SDP dissector doesn't really need the |
| 3068 | * last line end.) |
| 3069 | */ |
| 3070 | int sdp_end_offset = megaco_tvb_skip_wsp_return(tvb, tokenlen - 2); |
| 3071 | tvb_find_line_end(tvb, sdp_end_offset, tokenlen, &sdp_end_offset, false0); |
| 3072 | next_tvb = tvb_new_subset_length(tvb, 0, sdp_end_offset); |
| 3073 | call_dissector_with_data(sdp_handle, next_tvb, pinfo, megaco_localdescriptor_tree, &content_info); |
| 3074 | } |
| 3075 | } |
| 3076 | |
| 3077 | /* |
| 3078 | * localControlDescriptor = LocalControlToken LBRKT localParm |
| 3079 | * *(COMMA localParm) RBRKT |
| 3080 | * ; at-most-once per item |
| 3081 | * localParm = ( streamMode / propertyParm / reservedValueMode / reservedGroupMode ) |
| 3082 | */ |
| 3083 | |
| 3084 | #define MEGACO_MODETOKEN1 1 |
| 3085 | #define MEGACO_RESERVEDVALUETOKEN2 2 |
| 3086 | #define MEGACO_RESERVEDGROUPTOKEN3 3 |
| 3087 | #define MEGACO_H324_H223CAPR4 4 |
| 3088 | #define MEGACO_H324_MUXTBL_IN5 5 |
| 3089 | #define MEGACO_H324_MUXTBL_OUT6 6 |
| 3090 | #define MEGACO_DS_DSCP7 7 |
| 3091 | #define MEGACO_GM_SAF8 8 |
| 3092 | #define MEGACO_GM_SAM9 9 |
| 3093 | #define MEGACO_GM_SPF10 10 |
| 3094 | #define MEGACO_GM_SPR11 11 |
| 3095 | #define MEGACO_GM_ESAS12 12 |
| 3096 | #define MEGACO_GM_LSA13 13 |
| 3097 | #define MEGACO_GM_ESPS14 14 |
| 3098 | #define MEGACO_GM_LSP15 15 |
| 3099 | #define MEGACO_GM_RSB16 16 |
| 3100 | #define MEGACO_TMAN_POL17 17 |
| 3101 | #define MEGACO_TMAN_SDR18 18 |
| 3102 | #define MEGACO_TMAN_MBS19 19 |
| 3103 | #define MEGACO_TMAN_PDR20 20 |
| 3104 | #define MEGACO_TMAN_DVT21 21 |
| 3105 | #define MEGACO_IPDC_REALM22 22 |
| 3106 | |
| 3107 | static const megaco_tokens_t megaco_localParam_names[] = { |
| 3108 | { "Unknown-token", NULL((void*)0) }, /* 0 Pad so that the real headers start at index 1 */ |
| 3109 | /* streamMode */ |
| 3110 | { "Mode", "MO" }, /* 1 */ |
| 3111 | { "ReservedValue", "RV" }, /* 2 */ |
| 3112 | { "ReservedGroup", "RG" }, /* 3 */ |
| 3113 | /* propertyParm = pkgdName parmValue |
| 3114 | * Add more package names as needed. |
| 3115 | */ |
| 3116 | { "h324/h223capr", NULL((void*)0) }, /* 4 */ |
| 3117 | { "h324/muxtbl_in", NULL((void*)0) }, /* 5 */ |
| 3118 | { "h324/muxtbl_out", NULL((void*)0) }, /* 6 */ |
| 3119 | { "ds/dscp", NULL((void*)0) }, /* 7 */ |
| 3120 | { "gm/saf", NULL((void*)0) }, /* 8 */ |
| 3121 | { "gm/sam", NULL((void*)0) }, /* 9 */ |
| 3122 | { "gm/spf", NULL((void*)0) }, /* 10 */ |
| 3123 | { "gm/spr", NULL((void*)0) }, /* 11 */ |
| 3124 | { "gm/esas", NULL((void*)0) }, /* 12 */ |
| 3125 | { "gm/lsa", NULL((void*)0) }, /* 13 */ |
| 3126 | { "gm/esps", NULL((void*)0) }, /* 14 */ |
| 3127 | { "gm/lsp", NULL((void*)0) }, /* 15 */ |
| 3128 | { "gm/rsb", NULL((void*)0) }, /* 16 */ |
| 3129 | { "tman/pol", NULL((void*)0) }, /* 17 */ |
| 3130 | { "tman/sdr", NULL((void*)0) }, /* 18 */ |
| 3131 | { "tman/mbs", NULL((void*)0) }, /* 19 */ |
| 3132 | { "tman/pdr", NULL((void*)0) }, /* 20 */ |
| 3133 | { "tman/dvt", NULL((void*)0) }, /* 21 */ |
| 3134 | { "ipdc/realm", NULL((void*)0) }, /* 22 */ |
| 3135 | }; |
| 3136 | |
| 3137 | /* Returns index of megaco_tokens_t */ |
| 3138 | static int find_megaco_localParam_names(tvbuff_t *tvb, int offset, unsigned header_len) |
| 3139 | { |
| 3140 | unsigned i; |
| 3141 | |
| 3142 | for (i = 1; i < array_length(megaco_localParam_names)(sizeof (megaco_localParam_names) / sizeof (megaco_localParam_names )[0]); i++) { |
| 3143 | if (header_len == strlen(megaco_localParam_names[i].name) && |
| 3144 | tvb_strncaseeql(tvb, offset, megaco_localParam_names[i].name, header_len) == 0) |
| 3145 | return i; |
| 3146 | if (megaco_localParam_names[i].compact_name != NULL((void*)0) && |
| 3147 | header_len == strlen(megaco_localParam_names[i].compact_name) && |
| 3148 | tvb_strncaseeql(tvb, offset, megaco_localParam_names[i].compact_name, header_len) == 0) |
| 3149 | return i; |
| 3150 | } |
| 3151 | |
| 3152 | return -1; |
| 3153 | } |
| 3154 | |
| 3155 | static void |
| 3156 | dissect_megaco_LocalControldescriptor(tvbuff_t *tvb, proto_tree *megaco_mediadescriptor_tree, packet_info *pinfo, proto_tree *top_tree) |
| 3157 | { |
| 3158 | unsigned tokenlen; |
| 3159 | unsigned token_name_len; |
| 3160 | unsigned tvb_offset = 0, tvb_help_offset, tvb_current_offset = 0; |
| 3161 | int token_index = 0; |
| 3162 | char *msg; |
| 3163 | proto_item* item; |
| 3164 | uint8_t code_str[3]; |
| 3165 | |
| 3166 | proto_tree *megaco_LocalControl_tree; |
| 3167 | proto_item *megaco_LocalControl_item; |
| 3168 | |
| 3169 | tokenlen = tvb_reported_length(tvb); |
| 3170 | |
| 3171 | megaco_LocalControl_item = proto_tree_add_item(megaco_mediadescriptor_tree, hf_megaco_LocalControl_descriptor, tvb, 0, tokenlen, ENC_NA0x00000000); |
| 3172 | megaco_LocalControl_tree = proto_item_add_subtree(megaco_LocalControl_item, ett_megaco_LocalControldescriptor); |
| 3173 | |
| 3174 | while (tvb_captured_length_remaining(tvb, tvb_offset) > 1) { |
| 3175 | |
| 3176 | tvb_help_offset = tvb_current_offset; |
| 3177 | |
| 3178 | /* |
| 3179 | * Find local parameter name |
| 3180 | * localParm = ( streamMode / propertyParm / reservedValueMode / reservedGroupMode ) |
| 3181 | * pkgdName = (PackageName SLASH ItemID) ;specific item |
| 3182 | * / (PackageName SLASH "*") ;all events in package |
| 3183 | * / ("*" SLASH "*") ; all events supported by the MG |
| 3184 | */ |
| 3185 | /* Find token length */ |
| 3186 | for (tvb_offset=tvb_current_offset; tvb_captured_length_remaining(tvb, tvb_offset); tvb_offset++){ |
| 3187 | uint8_t octet; |
| 3188 | octet = tvb_get_uint8(tvb, tvb_offset); |
| 3189 | if (!g_ascii_isalnum(octet)((g_ascii_table[(guchar) (octet)] & G_ASCII_ALNUM) != 0)){ |
| 3190 | if ((octet!='/')&&(octet!='_')){ |
| 3191 | break; |
| 3192 | } |
| 3193 | } |
| 3194 | } |
| 3195 | token_name_len = tvb_offset - tvb_current_offset; |
| 3196 | token_index = find_megaco_localParam_names(tvb, tvb_current_offset, token_name_len); |
| 3197 | /* Find start of parameter value */ |
| 3198 | if (!tvb_find_uint8_remaining(tvb, tvb_offset, '=', &tvb_offset)) { |
| 3199 | expert_add_info(pinfo, megaco_LocalControl_item, &ei_megaco_parse_error); |
| 3200 | return; |
| 3201 | } |
| 3202 | /* Start search after '=' in case there is no SP*/ |
| 3203 | tvb_offset++; |
| 3204 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset); |
| 3205 | |
| 3206 | /* find if there are more parameters or not */ |
| 3207 | if (!tvb_find_uint8_remaining(tvb, tvb_current_offset, ',', &tvb_offset)) { |
| 3208 | tvb_offset--; |
| 3209 | } |
| 3210 | |
| 3211 | tokenlen = megaco_tvb_skip_wsp_return(tvb,tvb_offset-1) - tvb_current_offset; |
| 3212 | switch ( token_index ){ |
| 3213 | |
| 3214 | case MEGACO_MODETOKEN1: /* Mode */ |
| 3215 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_mode, tvb, |
| 3216 | tvb_help_offset, tvb_offset-tvb_help_offset, |
| 3217 | tvb_format_text(pinfo->pool, tvb, tvb_current_offset, |
| 3218 | tokenlen)); |
| 3219 | col_append_fstr(pinfo->cinfo, COL_INFO, " (Mode:%s)",tvb_format_text(pinfo->pool, tvb, tvb_current_offset,tokenlen)); |
| 3220 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3221 | break; |
| 3222 | |
| 3223 | case MEGACO_RESERVEDVALUETOKEN2: /* ReservedValue */ |
| 3224 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_reserve_value, tvb, |
| 3225 | tvb_help_offset, tvb_offset-tvb_help_offset, |
| 3226 | tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3227 | |
| 3228 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3229 | break; |
| 3230 | case MEGACO_RESERVEDGROUPTOKEN3: /* ReservedGroup */ |
| 3231 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_reserve_group, tvb, |
| 3232 | tvb_help_offset, tvb_offset-tvb_help_offset, |
| 3233 | tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3234 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3235 | break; |
| 3236 | |
| 3237 | case MEGACO_H324_H223CAPR4: /* h324/h223capr */ |
| 3238 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_h324_h223capr, tvb, |
| 3239 | tvb_help_offset, tvb_offset-tvb_help_offset, |
| 3240 | tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3241 | |
| 3242 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3243 | tokenlen = tvb_offset - tvb_help_offset; |
| 3244 | msg=tvb_format_text(pinfo->pool, tvb,tvb_help_offset, tokenlen); |
| 3245 | dissect_megaco_h324_h223caprn(tvb, pinfo, megaco_mediadescriptor_tree, tvb_help_offset, tokenlen, msg); |
| 3246 | |
| 3247 | break; |
| 3248 | |
| 3249 | case MEGACO_H324_MUXTBL_IN5: /* h324/muxtbl_in */ |
| 3250 | |
| 3251 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_h324_muxtbl_in, tvb, |
| 3252 | tvb_help_offset, tvb_offset-tvb_help_offset, |
| 3253 | tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3254 | |
| 3255 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3256 | |
| 3257 | tokenlen = tvb_offset - tvb_help_offset; |
| 3258 | /* Call the existing routine with tree = NULL to avoid an entry to the tree */ |
| 3259 | dissect_megaco_h245(tvb, pinfo, NULL((void*)0), tvb_help_offset, tokenlen, top_tree); |
| 3260 | |
| 3261 | break; |
| 3262 | |
| 3263 | case MEGACO_H324_MUXTBL_OUT6: |
| 3264 | |
| 3265 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_h324_muxtbl_out, tvb, |
| 3266 | tvb_current_offset, tokenlen, |
| 3267 | tvb_format_text(pinfo->pool, tvb, tvb_current_offset, |
| 3268 | tokenlen)); |
| 3269 | |
| 3270 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3271 | |
| 3272 | tokenlen = tvb_offset - tvb_help_offset; |
| 3273 | /* Call the existing routine with tree = NULL to avoid an entry to the tree */ |
| 3274 | dissect_megaco_h245(tvb, pinfo, NULL((void*)0), tvb_help_offset, tokenlen, top_tree); |
| 3275 | |
| 3276 | break; |
| 3277 | |
| 3278 | case MEGACO_DS_DSCP7: |
| 3279 | tvb_get_raw_bytes_as_stringz(tvb,tvb_current_offset,3,code_str); |
| 3280 | item = proto_tree_add_uint(megaco_LocalControl_tree, hf_megaco_ds_dscp, tvb, |
| 3281 | tvb_help_offset, 1, (uint32_t) strtoul((char*)code_str,NULL((void*)0),16)); |
| 3282 | proto_item_set_len(item, tvb_offset-tvb_help_offset); |
| 3283 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3284 | break; |
| 3285 | |
| 3286 | case MEGACO_GM_SAF8: |
| 3287 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_gm_saf, tvb, |
| 3288 | tvb_help_offset, tvb_offset-tvb_help_offset, tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3289 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3290 | break; |
| 3291 | case MEGACO_GM_SAM9: |
| 3292 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_gm_sam, tvb, |
| 3293 | tvb_help_offset, tvb_offset-tvb_help_offset, tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3294 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3295 | break; |
| 3296 | case MEGACO_GM_SPF10: |
| 3297 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_gm_spf, tvb, |
| 3298 | tvb_help_offset, tvb_offset-tvb_help_offset, tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3299 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3300 | break; |
| 3301 | case MEGACO_GM_SPR11: |
| 3302 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_gm_spr, tvb, |
| 3303 | tvb_help_offset, tvb_offset-tvb_help_offset, tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3304 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3305 | break; |
| 3306 | case MEGACO_GM_ESAS12: |
| 3307 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_gm_esas, tvb, |
| 3308 | tvb_help_offset, tvb_offset-tvb_help_offset, tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3309 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3310 | break; |
| 3311 | case MEGACO_GM_RSB16: |
| 3312 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_gm_rsb, tvb, |
| 3313 | tvb_help_offset, tvb_offset - tvb_help_offset, tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3314 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset + 1); |
| 3315 | break; |
| 3316 | case MEGACO_TMAN_POL17: |
| 3317 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_tman_pol, tvb, |
| 3318 | tvb_help_offset, tvb_offset-tvb_help_offset, tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3319 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3320 | break; |
| 3321 | case MEGACO_TMAN_SDR18: |
| 3322 | { |
| 3323 | int32_t sdr; |
| 3324 | bool_Bool sdr_valid; |
| 3325 | proto_item* pi; |
| 3326 | |
| 3327 | sdr_valid = ws_strtoi32(tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen), NULL((void*)0), &sdr); |
| 3328 | pi =proto_tree_add_int(megaco_LocalControl_tree, hf_megaco_tman_sdr, tvb, tvb_help_offset, |
| 3329 | tvb_offset - tvb_help_offset, sdr); |
| 3330 | proto_item_append_text(pi, " [%i b/s]", sdr*8); |
| 3331 | if (!sdr_valid) { |
| 3332 | expert_add_info(pinfo, pi, &ei_megaco_invalid_sdr); |
| 3333 | } |
| 3334 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset + 1); |
| 3335 | } |
| 3336 | break; |
| 3337 | case MEGACO_TMAN_MBS19: |
| 3338 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_tman_mbs, tvb, |
| 3339 | tvb_help_offset, tvb_offset-tvb_help_offset, tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3340 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3341 | break; |
| 3342 | case MEGACO_TMAN_PDR20: |
| 3343 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_tman_pdr, tvb, |
| 3344 | tvb_help_offset, tvb_offset-tvb_help_offset, tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3345 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3346 | break; |
| 3347 | case MEGACO_TMAN_DVT21: |
| 3348 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_tman_dvt, tvb, |
| 3349 | tvb_help_offset, tvb_offset-tvb_help_offset, tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3350 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3351 | break; |
| 3352 | case MEGACO_IPDC_REALM22: |
| 3353 | proto_tree_add_string(megaco_LocalControl_tree, hf_megaco_ipdc_realm, tvb, |
| 3354 | tvb_help_offset, tvb_offset-tvb_help_offset, tvb_format_text(pinfo->pool, tvb, tvb_current_offset, tokenlen)); |
| 3355 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3356 | break; |
| 3357 | |
| 3358 | default: |
| 3359 | tokenlen = tvb_offset - tvb_help_offset; |
| 3360 | proto_tree_add_format_text(megaco_LocalControl_tree, tvb, tvb_help_offset, tokenlen); |
| 3361 | tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_offset +1); |
| 3362 | |
| 3363 | break; |
| 3364 | } |
| 3365 | } |
| 3366 | } |
| 3367 | |
| 3368 | static void |
| 3369 | dissect_megaco_descriptors(tvbuff_t *tvb, proto_tree *megaco_command_tree, packet_info *pinfo, proto_tree *top_tree, uint32_t context) |
| 3370 | { |
| 3371 | int tvb_len, token_index, tvb_offset, temp_offset; |
| 3372 | int tvb_current_offset,tvb_previous_offset,save_offset,tokenlen; |
| 3373 | int tvb_RBRKT, tvb_LBRKT; |
| 3374 | tvbuff_t* descriptor_tvb; |
| 3375 | proto_tree* descriptor_tree; |
| 3376 | proto_item* descriptor_item; |
| 3377 | |
| 3378 | tvb_len = tvb_reported_length(tvb); |
| 3379 | int tvb_descriptors_end_offset = tvb_len - 1; |
| 3380 | |
| 3381 | descriptor_tree = proto_tree_add_subtree(megaco_command_tree, tvb, 0, tvb_len, |
| 3382 | ett_megaco_descriptors, &descriptor_item, "Descriptors"); |
| 3383 | |
| 3384 | tvb_LBRKT = megaco_tvb_skip_wsp(tvb, 1); |
| 3385 | |
| 3386 | tvb_previous_offset = tvb_LBRKT; |
| 3387 | tvb_RBRKT = 0; |
| 3388 | |
| 3389 | do { |
| 3390 | /* Find the end of this descriptor / start of next. */ |
| 3391 | tvb_current_offset = tvb_find_uint8(tvb, tvb_previous_offset, tvb_len, ','); |
| 3392 | |
| 3393 | if (tvb_current_offset == -1) { |
| 3394 | tvb_current_offset = tvb_descriptors_end_offset; |
| 3395 | } |
| 3396 | if (tvb_current_offset <= tvb_previous_offset) { |
| 3397 | expert_add_info_format(pinfo, descriptor_item, &ei_megaco_parse_error, "Parse error: Invalid offset"); |
| 3398 | return; |
| 3399 | } |
| 3400 | |
| 3401 | /* Look for parameters in the next description */ |
| 3402 | tvb_LBRKT = tvb_find_uint8(tvb, tvb_previous_offset, |
| 3403 | tvb_current_offset - tvb_previous_offset, '{'); |
| 3404 | tvb_RBRKT = tvb_find_uint8(tvb, tvb_RBRKT+1, tvb_len, '}'); |
| 3405 | if (tvb_RBRKT == -1) |
| 3406 | tvb_RBRKT = tvb_descriptors_end_offset; |
| 3407 | |
| 3408 | if (tvb_LBRKT == -1) { |
| 3409 | /* Descriptor includes no parameters */ |
| 3410 | if (tvb_current_offset > tvb_RBRKT){ |
| 3411 | tvb_current_offset = tvb_RBRKT; |
| 3412 | } |
| 3413 | tvb_RBRKT = megaco_tvb_skip_wsp_return(tvb, tvb_current_offset-1)-1; |
| 3414 | } else { |
| 3415 | /* Descriptor includes Parameters */ |
| 3416 | while ( tvb_LBRKT != -1 && tvb_RBRKT > tvb_LBRKT ){ |
| 3417 | |
| 3418 | tvb_LBRKT = tvb_find_uint8(tvb, tvb_LBRKT+1, tvb_len, '{'); |
| 3419 | if ( tvb_LBRKT < tvb_RBRKT && tvb_LBRKT != -1) |
| 3420 | tvb_RBRKT = tvb_find_uint8(tvb, tvb_RBRKT+1, tvb_len, '}'); |
| 3421 | } |
| 3422 | } |
| 3423 | if (tvb_RBRKT == -1) |
| 3424 | tvb_RBRKT = tvb_descriptors_end_offset; |
| 3425 | |
| 3426 | /* Find token length */ |
| 3427 | for (tvb_offset=tvb_previous_offset; tvb_offset < tvb_descriptors_end_offset; tvb_offset++){ |
| 3428 | if (!g_ascii_isalpha(tvb_get_uint8(tvb, tvb_offset ))((g_ascii_table[(guchar) (tvb_get_uint8(tvb, tvb_offset ))] & G_ASCII_ALPHA) != 0)){ |
| 3429 | break; |
| 3430 | } |
| 3431 | } |
| 3432 | tokenlen = tvb_offset - tvb_previous_offset; |
| 3433 | token_index = find_megaco_descriptors_names(tvb, tvb_previous_offset, tokenlen); |
| 3434 | descriptor_tvb = tvb_new_subset_length(tvb, tvb_previous_offset, tvb_RBRKT - tvb_previous_offset + 1); |
| 3435 | switch ( token_index ){ |
| 3436 | case MEGACO_MODEM_TOKEN1: |
| 3437 | dissect_megaco_modemdescriptor(tvb, pinfo, descriptor_tree, tvb_RBRKT, tvb_previous_offset); |
| 3438 | break; |
| 3439 | case MEGACO_MUX_TOKEN2: |
| 3440 | dissect_megaco_multiplexdescriptor(tvb, pinfo, descriptor_tree, tvb_RBRKT, tvb_previous_offset); |
| 3441 | break; |
| 3442 | case MEGACO_MEDIA_TOKEN3: |
| 3443 | /*TODO: Move this to the top when all branches fixed !!!*/ |
| 3444 | temp_offset = tvb_find_uint8(tvb, tvb_previous_offset,tvb_descriptors_end_offset, '{'); |
| 3445 | save_offset = tvb_previous_offset; |
| 3446 | |
| 3447 | tvb_previous_offset = megaco_tvb_skip_wsp(tvb, temp_offset +1); |
| 3448 | dissect_megaco_mediadescriptor(tvb, descriptor_tree, pinfo, tvb_RBRKT, tvb_previous_offset, save_offset, top_tree, context); |
| 3449 | break; |
| 3450 | case MEGACO_SIGNALS_TOKEN4: |
| 3451 | dissect_megaco_signaldescriptor(tvb, pinfo, descriptor_tree, tvb_RBRKT, tvb_previous_offset, top_tree); |
| 3452 | break; |
| 3453 | case MEGACO_SERVICES_TOKEN5: |
| 3454 | dissect_megaco_servicechangedescriptor(tvb, pinfo, descriptor_tree, tvb_RBRKT, tvb_previous_offset); |
| 3455 | break; |
| 3456 | case MEGACO_STATS_TOKEN6: |
| 3457 | dissect_megaco_statisticsdescriptor(descriptor_tvb, descriptor_tree); |
| 3458 | break; |
| 3459 | case MEGACO_ERROR_TOKEN7: |
| 3460 | dissect_megaco_errordescriptor(tvb, pinfo, descriptor_tree, tvb_RBRKT, tvb_previous_offset); |
| 3461 | break; |
| 3462 | case MEGACO_EVENTS_TOKEN8: |
| 3463 | dissect_megaco_eventsdescriptor(descriptor_tvb, pinfo, descriptor_tree, top_tree); |
| 3464 | break; |
| 3465 | case MEGACO_AUDIT_TOKEN9: |
| 3466 | dissect_megaco_auditdescriptor(descriptor_tvb, descriptor_tree, pinfo, top_tree, context); |
| 3467 | break; |
| 3468 | case MEGACO_DIGITMAP_TOKEN10: |
| 3469 | dissect_megaco_digitmapdescriptor(tvb, pinfo, descriptor_tree, tvb_RBRKT, tvb_previous_offset); |
| 3470 | break; |
| 3471 | case MEGACO_OE_TOKEN11: |
| 3472 | /* ObservedEventsToken */ |
| 3473 | dissect_megaco_observedeventsdescriptor(descriptor_tvb, pinfo, descriptor_tree, top_tree); |
| 3474 | break; |
| 3475 | case MEGACO_TOPOLOGY_TOKEN12: |
| 3476 | dissect_megaco_topologydescriptor(tvb, descriptor_tree, tvb_RBRKT, tvb_previous_offset); |
| 3477 | break; |
| 3478 | case MEGACO_PACKAGES_TOKEN13: |
| 3479 | dissect_megaco_Packagesdescriptor(tvb, pinfo, descriptor_tree, tvb_RBRKT, tvb_previous_offset); |
| 3480 | break; |
| 3481 | default: |
| 3482 | tokenlen = (tvb_RBRKT+1) - tvb_previous_offset; |
| 3483 | proto_tree_add_expert(descriptor_tree, pinfo, &ei_megaco_no_descriptor, tvb, tvb_previous_offset, tokenlen); |
| 3484 | break; |
| 3485 | } |
| 3486 | |
| 3487 | tvb_current_offset = tvb_find_uint8(tvb, tvb_RBRKT, tvb_len, ','); |
| 3488 | if (tvb_current_offset == -1) { |
| 3489 | tvb_current_offset = tvb_descriptors_end_offset; |
| 3490 | } |
| 3491 | tvb_previous_offset = megaco_tvb_skip_wsp(tvb, tvb_current_offset+1); |
| 3492 | tvb_RBRKT = tvb_previous_offset; |
| 3493 | |
| 3494 | } while ( tvb_current_offset < tvb_descriptors_end_offset ); |
| 3495 | |
| 3496 | } |
| 3497 | |
| 3498 | /* Copied from MGCP dissector, prints whole message in raw text */ |
| 3499 | |
| 3500 | static void tvb_raw_text_add(tvbuff_t *tvb, proto_tree *tree){ |
| 3501 | |
| 3502 | int tvb_linebegin,tvb_lineend,linelen; |
| 3503 | proto_tree* text_tree; |
| 3504 | |
| 3505 | tvb_linebegin = 0; |
| 3506 | |
| 3507 | if (tree) { |
| 3508 | text_tree = proto_tree_add_subtree(tree, tvb, 0, -1, ett_megaco_raw_text, NULL((void*)0), "-------------- (RAW text output) ---------------"); |
| 3509 | |
| 3510 | do { |
| 3511 | linelen = tvb_find_line_end(tvb,tvb_linebegin,-1,&tvb_lineend,false0); |
| 3512 | proto_tree_add_format_wsp_text(text_tree, tvb, tvb_linebegin, linelen); |
| 3513 | tvb_linebegin = tvb_lineend; |
| 3514 | } while (tvb_offset_exists(tvb, tvb_lineend) && linelen > 0); |
| 3515 | } |
| 3516 | } |
| 3517 | |
| 3518 | /* |
| 3519 | * megaco_tvb_skip_wsp - Returns the position in tvb of the first non-whitespace |
| 3520 | * character following offset or offset + maxlength -1 whichever |
| 3521 | * is smaller. |
| 3522 | * |
| 3523 | * Parameters: |
| 3524 | * tvb - The tvbuff in which we are skipping whitespaces, tab and end_of_line characters. |
| 3525 | * offset - The offset in tvb from which we begin trying to skip whitespace. |
| 3526 | * |
| 3527 | * Returns: The position in tvb of the first non-whitespace |
| 3528 | */ |
| 3529 | static int megaco_tvb_skip_wsp(tvbuff_t* tvb, int offset ){ |
| 3530 | int counter = offset; |
| 3531 | int end = tvb_reported_length(tvb); |
| 3532 | |
| 3533 | for(counter = offset; counter < end && |
| 3534 | (g_ascii_isspace(tvb_get_uint8(tvb,counter))((g_ascii_table[(guchar) (tvb_get_uint8(tvb,counter))] & G_ASCII_SPACE ) != 0)); counter++); |
| 3535 | return (counter); |
| 3536 | } |
| 3537 | |
| 3538 | static int megaco_tvb_skip_wsp_return(tvbuff_t* tvb, int offset){ |
| 3539 | int counter = offset; |
| 3540 | int end = 0; |
| 3541 | |
| 3542 | for(counter = offset; counter > end && |
| 3543 | (g_ascii_isspace(tvb_get_uint8(tvb,counter))((g_ascii_table[(guchar) (tvb_get_uint8(tvb,counter))] & G_ASCII_SPACE ) != 0)); counter--); |
| 3544 | counter++; |
| 3545 | return (counter); |
| 3546 | } |
| 3547 | |
| 3548 | static int megaco_tvb_find_token(tvbuff_t* tvb, int offset, int maxlength){ |
| 3549 | int counter = 0; |
| 3550 | int pos = offset; |
| 3551 | unsigned char needle; |
| 3552 | |
| 3553 | do { |
| 3554 | pos = tvb_ws_mempbrk_pattern_uint8(tvb, pos + 1, maxlength, &pbrk_braces, &needle); |
| 3555 | if(pos == -1) |
| 3556 | return -1; |
| 3557 | switch(needle){ |
| 3558 | case '{': |
| 3559 | counter++; |
| 3560 | break; |
| 3561 | case '}': |
| 3562 | counter--; |
| 3563 | break; |
| 3564 | default: |
| 3565 | break; |
| 3566 | } |
| 3567 | } while (counter>0); |
| 3568 | if(counter<0) |
| 3569 | return -1; |
| 3570 | else |
| 3571 | { |
| 3572 | pos = megaco_tvb_skip_wsp(tvb,pos+1); |
| 3573 | return pos; |
| 3574 | } |
| 3575 | } |
| 3576 | |
| 3577 | static void |
| 3578 | megaco_fmt_content( char *result, uint32_t context ) |
| 3579 | { |
| 3580 | switch(context) |
| 3581 | { |
| 3582 | case CHOOSE_CONTEXT0xFFFFFFFE: |
| 3583 | case ALL_CONTEXTS0xFFFFFFFF: |
| 3584 | case NULL_CONTEXT0: |
| 3585 | (void) g_strlcpy(result, val_to_str_const(context, megaco_context_vals, "Unknown"), ITEM_LABEL_LENGTH240); |
| 3586 | break; |
| 3587 | default: |
| 3588 | snprintf( result, ITEM_LABEL_LENGTH240, "%d", context); |
| 3589 | } |
| 3590 | } |
| 3591 | |
| 3592 | void |
| 3593 | proto_register_megaco(void) |
| 3594 | { |
| 3595 | static hf_register_info hf[] = { |
| 3596 | { &hf_megaco_audititem, |
| 3597 | { "Audit Item", "megaco.audititem", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3598 | "Identity of item to be audited", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3599 | { &hf_megaco_audit_descriptor, |
| 3600 | { "Audit Descriptor", "megaco.audit", FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
| 3601 | "Audit Descriptor of the megaco Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3602 | #if 0 |
| 3603 | { &hf_megaco_command_line, |
| 3604 | { "Command line", "megaco.command_line", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3605 | "Commands of this message", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3606 | #endif |
| 3607 | { &hf_megaco_command, |
| 3608 | { "Command", "megaco.command", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3609 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3610 | { &hf_megaco_command_optional, |
| 3611 | { "Optional Command", "megaco.command_optional", FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
| 3612 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3613 | { &hf_megaco_wildcard_response, |
| 3614 | { "Wildcarded response to a command", "megaco.wildcard_response", FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
| 3615 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3616 | |
| 3617 | { &hf_megaco_Context, |
| 3618 | { "Context", "megaco.context", FT_UINT32, BASE_CUSTOM, CF_FUNC(megaco_fmt_content)((const void *) (size_t) (megaco_fmt_content)), 0x0, |
| 3619 | "Context ID of this message", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3620 | { &hf_megaco_Context_generated, |
| 3621 | { "Generated Context", "megaco.context.generated", FT_UINT32, BASE_CUSTOM, CF_FUNC(megaco_fmt_content)((const void *) (size_t) (megaco_fmt_content)), 0x0, |
| 3622 | "Used to track Context ID across protocols", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3623 | { &hf_megaco_digitmap_descriptor, |
| 3624 | { "DigitMap Descriptor", "megaco.digitmap", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3625 | "DigitMap Descriptor of the megaco Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3626 | { &hf_megaco_error_descriptor, |
| 3627 | { "ERROR Descriptor", "megaco.error", FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
| 3628 | "Error Descriptor of the megaco Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3629 | { &hf_megaco_error_code, |
| 3630 | { "ERROR Code", "megaco.error_code", FT_UINT32, BASE_DEC, VALS(MEGACO_error_code_vals)((0 ? (const struct _value_string*)0 : ((MEGACO_error_code_vals )))), 0x0, |
| 3631 | "Error Code of the megaco Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3632 | { &hf_megaco_error_string, |
| 3633 | { "ERROR String", "megaco.error_string", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3634 | "Error String of the megaco Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3635 | { &hf_megaco_Event_Buffer_Control, |
| 3636 | { "Event Buffer Control", "megaco.eventbuffercontrol", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3637 | "Event Buffer Control in Termination State Descriptor", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3638 | { &hf_megaco_events_descriptor, |
| 3639 | { "Events Descriptor", "megaco.events", FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
| 3640 | "Events Descriptor of the megaco Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3641 | { &hf_megaco_Local_descriptor, |
| 3642 | { "Local Descriptor", "megaco.localdescriptor", FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
| 3643 | "Local Descriptor in Media Descriptor", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3644 | { &hf_megaco_LocalControl_descriptor, |
| 3645 | { "Local Control Descriptor", "megaco.localcontroldescriptor", FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
| 3646 | "Local Control Descriptor in Media Descriptor", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3647 | { &hf_megaco_media_descriptor, |
| 3648 | { "Media Descriptor", "megaco.media", FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
| 3649 | "Media Descriptor of the megaco Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3650 | { &hf_megaco_modem_descriptor, |
| 3651 | { "Modem Descriptor", "megaco.modem", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3652 | "Modem Descriptor of the megaco Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3653 | { &hf_megaco_mode, |
| 3654 | { "Mode", "megaco.mode", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3655 | "Mode sendonly/receiveonly/inactive/loopback", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3656 | { &hf_megaco_multiplex_descriptor, |
| 3657 | { "Multiplex Descriptor", "megaco.multiplex", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3658 | "Multiplex Descriptor of the megaco Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3659 | { &hf_megaco_observedevents_descriptor, |
| 3660 | { "Observed Events Descriptor", "megaco.observedevents", FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
| 3661 | "Observed Events Descriptor of the megaco Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3662 | { &hf_megaco_packages_descriptor, |
| 3663 | { "Packages Descriptor", "megaco.packagesdescriptor", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3664 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3665 | { &hf_megaco_pkgdname, |
| 3666 | { "pkgdName", "megaco.pkgdname", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3667 | "PackageName SLASH ItemID", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3668 | { &hf_megaco_Remote_descriptor, |
| 3669 | { "Remote Descriptor", "megaco.remotedescriptor", FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
| 3670 | "Remote Descriptor in Media Descriptor", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3671 | { &hf_megaco_reserve_group, |
| 3672 | { "Reserve Group", "megaco.reservegroup", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3673 | "Reserve Group on or off", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3674 | { &hf_megaco_h324_muxtbl_in, |
| 3675 | { "h324/muxtbl_in", "megaco.h324_muxtbl_in", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3676 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3677 | { &hf_megaco_h324_muxtbl_out, |
| 3678 | { "h324/muxtbl_out", "megaco.h324_muxtbl_out", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3679 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3680 | { &hf_megaco_ds_dscp, |
| 3681 | { "Differentiated Services Code Point", "megaco.ds_dscp", FT_UINT32, BASE_HEX|BASE_EXT_STRING0x00000200, &dscp_vals_ext, 0x0, |
| 3682 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3683 | { &hf_megaco_gm_saf, |
| 3684 | { "Remote Source Address Filtering", "megaco.gm_saf", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3685 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3686 | { &hf_megaco_gm_sam, |
| 3687 | { "Remote Source Address Mask", "megaco.gm_sam", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3688 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3689 | { &hf_megaco_gm_spf, |
| 3690 | { "Remote Source Port Filtering", "megaco.gm_spf", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3691 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3692 | { &hf_megaco_gm_spr, |
| 3693 | { "Remote Source Port Range", "megaco.gm_spr", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3694 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3695 | { &hf_megaco_gm_esas, |
| 3696 | { "Explicit Source Address Setting", "megaco.gm_esas", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3697 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3698 | { &hf_megaco_tman_pol, |
| 3699 | { "Policing", "megaco.tman_pol", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3700 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3701 | { &hf_megaco_gm_rsb, |
| 3702 | { "RTCP Allocation Specific Behaviour", "megaco.gm_rsb", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3703 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3704 | { &hf_megaco_tman_sdr, |
| 3705 | { "Sustainable Data Rate", "megaco.tman_sdr", FT_INT32, BASE_DEC|BASE_UNIT_STRING0x00001000, UNS(&units_byte_bytespsecond)((0 ? (const struct unit_name_string*)0 : ((&units_byte_bytespsecond )))), 0x0, |
| 3706 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3707 | { &hf_megaco_tman_mbs, |
| 3708 | { "Maximum Burst Rate", "megaco.tman_mbs", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3709 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3710 | { &hf_megaco_tman_pdr, |
| 3711 | { "Peak Data Rate", "megaco.tman_pdr", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3712 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3713 | { &hf_megaco_tman_dvt, |
| 3714 | { "Delay Variation Tolerance", "megaco.tman_dvt", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3715 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3716 | { &hf_megaco_ipdc_realm, |
| 3717 | { "IP Realm Identifier", "megaco.ipdc_realm", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3718 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3719 | { &hf_megaco_h324_h223capr, |
| 3720 | { "h324/h223capr", "megaco.h324_h223capr", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3721 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3722 | { &hf_megaco_reserve_value, |
| 3723 | { "Reserve Value", "megaco.reservevalue", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3724 | "Reserve Value on or off", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3725 | { &hf_megaco_requestid, |
| 3726 | { "RequestID", "megaco.requestid", FT_UINT32, BASE_DEC, NULL((void*)0), 0x0, |
| 3727 | "RequestID in Events or Observedevents Descriptor", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3728 | #if 0 |
| 3729 | { &hf_megaco_servicechange_descriptor, |
| 3730 | { "Service Change Descriptor", "megaco.servicechange", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3731 | "Service Change Descriptor of the megaco Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3732 | #endif |
| 3733 | { &hf_megaco_Service_State, |
| 3734 | { "Service State", "megaco.servicestates", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3735 | "Service States in Termination State Descriptor", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3736 | { &hf_megaco_signal_descriptor, |
| 3737 | { "Signal Descriptor", "megaco.signal", FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
| 3738 | "Signal Descriptor of the megaco Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3739 | { &hf_megaco_statistics_descriptor, |
| 3740 | { "Statistics Descriptor", "megaco.statistics", FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
| 3741 | "Statistics Descriptor of the megaco Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3742 | { &hf_megaco_streamid, |
| 3743 | { "StreamID", "megaco.streamid", FT_UINT32, BASE_DEC, NULL((void*)0), 0x0, |
| 3744 | "StreamID in the Media Descriptor", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3745 | { &hf_megaco_termid, |
| 3746 | { "Termination ID", "megaco.termid", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3747 | "Termination ID of this Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3748 | { &hf_megaco_TerminationState_descriptor, |
| 3749 | { "Termination State Descriptor", "megaco.terminationstate", FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
| 3750 | "Termination State Descriptor in Media Descriptor", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3751 | { &hf_megaco_topology_descriptor, |
| 3752 | { "Topology Descriptor", "megaco.topology", FT_STRING, BASE_STR_WSP, NULL((void*)0), 0x0, |
| 3753 | "Topology Descriptor of the megaco Command", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3754 | { &hf_megaco_transaction, |
| 3755 | { "Transaction", "megaco.transaction", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3756 | "Message Originator", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3757 | { &hf_megaco_transid, |
| 3758 | { "Transaction ID", "megaco.transid", FT_UINT32, BASE_DEC, NULL((void*)0), 0x0, |
| 3759 | "Transaction ID of this message", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3760 | { &hf_megaco_mId, |
| 3761 | { "MediagatewayID", "megaco.mId", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3762 | "Mediagateway ID", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3763 | { &hf_megaco_version, |
| 3764 | { "Version", "megaco.version", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3765 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3766 | { &hf_megaco_start, |
| 3767 | { "Start token", "megaco.start_token", FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
| 3768 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3769 | { &hf_megaco_h245, |
| 3770 | { "h245", "megaco.h245", FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
| 3771 | "Embedded H.245 message", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3772 | { &hf_megaco_h223Capability, |
| 3773 | { "h223Capability", "megaco.h245.h223Capability", FT_NONE, BASE_NONE, NULL((void*)0), 0, |
| 3774 | "megaco.h245.H223Capability", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3775 | { &hf_megaco_priority, |
| 3776 | { "Priority", "megaco.priority", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
| 3777 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
| 3778 | |
| 3779 | GCP_HF_ARR_ELEMS("megaco",megaco_ctx_ids){ &(megaco_ctx_ids.hf.ctx), { "Context", "megaco" ".ctx", FT_UINT32, BASE_HEX, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE , -1, ((void*)0) }}, { &(megaco_ctx_ids.hf.ctx_term), { "Termination" , "megaco" ".ctx.term", FT_STRING, BASE_NONE, ((void*)0), 0, ( (void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, { & (megaco_ctx_ids.hf.ctx_term_type), { "Type", "megaco" ".ctx.term.type" , FT_UINT32, BASE_HEX, ((0 ? (const struct _value_string*)0 : ((gcp_term_types)))), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE , -1, ((void*)0) }}, { &(megaco_ctx_ids.hf.ctx_term_bir), { "BIR", "megaco" ".ctx.term.bir", FT_STRING, BASE_NONE, ((void *)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } }, { &(megaco_ctx_ids.hf.ctx_term_nsap), { "NSAP", "megaco" ".ctx.term.nsap", FT_STRING, BASE_NONE, ((void*)0), 0, ((void *)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, { &(megaco_ctx_ids .hf.ctx_cmd), { "Command in Frame", "megaco" ".ctx.cmd", FT_FRAMENUM , BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE , -1, ((void*)0) }}, |
| 3780 | |
| 3781 | /* Add more fields here */ |
| 3782 | }; |
| 3783 | static int *ett[] = { |
| 3784 | &ett_megaco, |
| 3785 | &ett_megaco_message, |
| 3786 | &ett_megaco_message_body, |
| 3787 | &ett_megaco_context, |
| 3788 | &ett_megaco_command_line, |
| 3789 | &ett_megaco_descriptors, |
| 3790 | &ett_megaco_raw_text, |
| 3791 | &ett_megaco_error_descriptor, |
| 3792 | &ett_megaco_mediadescriptor, |
| 3793 | &ett_megaco_TerminationState, |
| 3794 | &ett_megaco_Remotedescriptor, |
| 3795 | &ett_megaco_Localdescriptor, |
| 3796 | &ett_megaco_LocalControldescriptor, |
| 3797 | &ett_megaco_auditdescriptor, |
| 3798 | &ett_megaco_eventsdescriptor, |
| 3799 | &ett_megaco_statisticsdescriptor, |
| 3800 | &ett_megaco_observedeventsdescriptor, |
| 3801 | &ett_megaco_observedevent, |
| 3802 | &ett_megaco_packagesdescriptor, |
| 3803 | &ett_megaco_requestedevent, |
| 3804 | &ett_megaco_signalsdescriptor, |
| 3805 | &ett_megaco_requestedsignal, |
| 3806 | &ett_megaco_h245, |
| 3807 | GCP_ETT_ARR_ELEMS(megaco_ctx_ids)&(megaco_ctx_ids.ett.ctx),&(megaco_ctx_ids.ett.ctx_cmds ),&(megaco_ctx_ids.ett.ctx_terms),&(megaco_ctx_ids.ett .ctx_term), |
| 3808 | }; |
| 3809 | |
| 3810 | static ei_register_info ei[] = { |
| 3811 | { &ei_megaco_errored_command, { "megaco.errored_command", PI_RESPONSE_CODE0x03000000, PI_WARN0x00600000, "Errored Command", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE , BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE , -1, ((void*)0)}} }}, |
| 3812 | { &ei_megaco_parse_error, { "megaco.parse_error", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "Parse error", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE , BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE , -1, ((void*)0)}} }}, |
| 3813 | { &ei_megaco_error_descriptor_transaction_list, { "megaco.error_descriptor_transaction_list.invalid", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "Sorry, can't understand errorDescriptor / transactionList", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE , BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE , -1, ((void*)0)}} }}, |
| 3814 | { &ei_megaco_audit_descriptor, { "megaco.audit.malformed", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "Badly constructed audit descriptor (no { )", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE , BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE , -1, ((void*)0)}} }}, |
| 3815 | { &ei_megaco_signal_descriptor, { "megaco.signal_descriptor.empty", PI_PROTOCOL0x09000000, PI_NOTE0x00400000, "Empty Signal Descriptor", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE , BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE , -1, ((void*)0)}} }}, |
| 3816 | { &ei_megaco_no_command, { "megaco.no_command", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "No Command detectable", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE , BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE , -1, ((void*)0)}} }}, |
| 3817 | { &ei_megaco_no_descriptor, { "megaco.no_descriptor", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "No Descriptor detectable", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE , BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE , -1, ((void*)0)}} }}, |
| 3818 | { &ei_megaco_reason_invalid, { "megaco.change_reason.invalid", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "Invalid Service Change Reason", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE , BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE , -1, ((void*)0)}} }}, |
| 3819 | { &ei_megaco_error_code_invalid,{ "megaco.error_code.invalid", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "Invalid error code", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE , BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE , -1, ((void*)0)}} } }, |
| 3820 | { &ei_megaco_invalid_sdr, { "megaco.sdr.invalid", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "Invalid Sustainable Data Rate", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE , BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE , -1, ((void*)0)}} }} |
| 3821 | }; |
| 3822 | |
| 3823 | module_t *megaco_module; |
| 3824 | expert_module_t* expert_megaco; |
| 3825 | |
| 3826 | proto_megaco = proto_register_protocol("MEGACO", "MEGACO", "megaco"); |
| 3827 | |
| 3828 | megaco_text_handle = register_dissector("megaco", dissect_megaco_text, proto_megaco); |
| 3829 | |
| 3830 | proto_register_field_array(proto_megaco, hf, array_length(hf)(sizeof (hf) / sizeof (hf)[0])); |
| 3831 | proto_register_subtree_array(ett, array_length(ett)(sizeof (ett) / sizeof (ett)[0])); |
| 3832 | expert_megaco = expert_register_protocol(proto_megaco); |
| 3833 | expert_register_field_array(expert_megaco, ei, array_length(ei)(sizeof (ei) / sizeof (ei)[0])); |
| 3834 | |
| 3835 | /* Register our configuration options, particularly our ports */ |
| 3836 | |
| 3837 | megaco_module = prefs_register_protocol(proto_megaco, NULL((void*)0)); |
| 3838 | |
| 3839 | prefs_register_bool_preference(megaco_module, "display_raw_text", |
| 3840 | "Display raw text for MEGACO message", |
| 3841 | "Specifies that the raw text of the " |
| 3842 | "MEGACO message should be displayed " |
| 3843 | "instead of (or in addition to) the " |
| 3844 | "dissection tree", |
| 3845 | &global_megaco_raw_text); |
| 3846 | |
| 3847 | prefs_register_bool_preference(megaco_module, "display_dissect_tree", |
| 3848 | "Display tree dissection for MEGACO message", |
| 3849 | "Specifies that the dissection tree of the " |
| 3850 | "MEGACO message should be displayed " |
| 3851 | "instead of (or in addition to) the " |
| 3852 | "raw text", |
| 3853 | &global_megaco_dissect_tree); |
| 3854 | prefs_register_bool_preference(megaco_module, "ctx_info", |
| 3855 | "Track Context", |
| 3856 | "Maintain relationships between transactions and contexts " |
| 3857 | "and display an extra tree showing context data", |
| 3858 | &keep_persistent_data); |
| 3859 | |
| 3860 | megaco_tap = register_tap("megaco"); |
| 3861 | |
| 3862 | /* compile patterns */ |
| 3863 | ws_mempbrk_compile(&pbrk_whitespace, " \t\r\n"); |
| 3864 | ws_mempbrk_compile(&pbrk_braces, "{}"); |
| 3865 | |
| 3866 | register_rtd_table(proto_megaco, NULL((void*)0), 1, NUM_TIMESTATS12, megaco_message_type, megacostat_packet, megacostat_filtercheck); |
| 3867 | } |
| 3868 | |
| 3869 | /* Register all the bits needed with the filtering engine */ |
| 3870 | /* The registration hand-off routine */ |
| 3871 | void |
| 3872 | proto_reg_handoff_megaco(void) |
| 3873 | { |
| 3874 | dissector_handle_t megaco_text_tcp_handle; |
| 3875 | |
| 3876 | sdp_handle = find_dissector_add_dependency("sdp", proto_megaco); |
| 3877 | h245_handle = find_dissector_add_dependency("h245dg", proto_megaco); |
| 3878 | h248_handle = find_dissector_add_dependency("h248", proto_megaco); |
| 3879 | h248_otp_handle = find_dissector_add_dependency("h248_otp", proto_megaco); |
| 3880 | data_handle = find_dissector("data"); |
| 3881 | |
| 3882 | megaco_text_tcp_handle = create_dissector_handle(dissect_megaco_text_tcp, proto_megaco); |
| 3883 | |
| 3884 | dissector_add_uint_with_preference("tcp.port", PORT_MEGACO_TXT2944, megaco_text_tcp_handle); |
| 3885 | dissector_add_uint_with_preference("udp.port", PORT_MEGACO_TXT2944, megaco_text_handle); |
| 3886 | dissector_add_uint_with_preference("sctp.port", PORT_MEGACO_TXT2944, megaco_text_handle); |
| 3887 | dissector_add_uint("sctp.ppi", H248_PAYLOAD_PROTOCOL_ID7, megaco_text_handle); |
| 3888 | |
| 3889 | exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_LAYER_7"OSI layer 7"); |
| 3890 | |
| 3891 | sip_hide_generated_call_ids = prefs_find_preference(prefs_find_module("sip"), "hide_generated_call_id"); |
| 3892 | |
| 3893 | } |
| 3894 | |
| 3895 | /* |
| 3896 | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
| 3897 | * |
| 3898 | * Local variables: |
| 3899 | * c-basic-offset: 4 |
| 3900 | * tab-width: 8 |
| 3901 | * indent-tabs-mode: nil |
| 3902 | * End: |
| 3903 | * |
| 3904 | * vi: set shiftwidth=4 tabstop=8 expandtab: |
| 3905 | * :indentSize=4:tabSize=8:noTabs=true: |
| 3906 | */ |