2 * Routines for Message Transfer Part Level 3 dissection
4 * It is (hopefully) compliant to:
7 * GF 001-9001 (Chinese ITU variant)
8 * JT-Q704 and NTT-Q704 (Japan)
10 * Note that the division of the Japan SLS into the SLC and A/B bit (for
11 * management messages) is not done.
13 * Copyright 2001, Michael Tuexen <tuexen [AT] fh-muenster.de>
14 * Updated for ANSI, Chinese ITU, and Japan support by
15 * Jeff Morriss <jeff.morriss.ws [AT] gmail.com>
17 * Wireshark - Network traffic analyzer
18 * By Gerald Combs <gerald@wireshark.org>
19 * Copyright 1998 Gerald Combs
21 * Copied from README.developer
23 * SPDX-License-Identifier: GPL-2.0-or-later
28 #include <epan/packet.h>
29 #include <epan/stat_tap_ui.h>
31 #include <epan/prefs.h>
32 #include <epan/address_types.h>
33 #include <wiretap/wtap.h>
34 #include <epan/addr_resolv.h>
36 #include <wsutil/array.h>
38 #include "packet-q708.h"
39 #include "packet-sccp.h"
40 #include "packet-frame.h"
42 void proto_register_mtp3(void);
43 void proto_reg_handoff_mtp3(void);
45 /* Initialize the protocol and registered fields */
46 static int proto_mtp3
;
50 static dissector_handle_t mtp3_handle
;
52 static module_t
*mtp3_module
;
54 static int hf_mtp3_service_indicator
;
55 static int hf_mtp3_network_indicator
;
56 static int hf_mtp3_itu_spare
;
57 static int hf_mtp3_itu_priority
;
58 static int hf_mtp3_ansi_priority
;
59 static int hf_mtp3_itu_pc
;
60 static int hf_mtp3_24bit_pc
;
61 static int hf_mtp3_itu_opc
;
62 static int hf_mtp3_24bit_opc
;
63 static int hf_mtp3_ansi_opc
;
64 static int hf_mtp3_chinese_opc
;
65 static int hf_mtp3_opc_network
;
66 static int hf_mtp3_opc_cluster
;
67 static int hf_mtp3_opc_member
;
68 static int hf_mtp3_itu_dpc
;
69 static int hf_mtp3_24bit_dpc
;
70 static int hf_mtp3_ansi_dpc
;
71 static int hf_mtp3_chinese_dpc
;
72 static int hf_mtp3_dpc_network
;
73 static int hf_mtp3_dpc_cluster
;
74 static int hf_mtp3_dpc_member
;
75 static int hf_mtp3_itu_sls
;
76 static int hf_mtp3_ansi_5_bit_sls
;
77 static int hf_mtp3_ansi_8_bit_sls
;
78 static int hf_mtp3_chinese_itu_sls
;
79 static int hf_mtp3_japan_dpc
;
80 static int hf_mtp3_japan_opc
;
81 static int hf_mtp3_japan_pc
;
82 static int hf_mtp3_japan_4_bit_sls
;
83 static int hf_mtp3_japan_4_bit_sls_spare
;
84 static int hf_mtp3_japan_5_bit_sls
;
85 static int hf_mtp3_japan_5_bit_sls_spare
;
86 static int hf_mtp3_heuristic_standard
;
88 /* Initialize the subtree pointers */
90 static int ett_mtp3_sio
;
91 static int ett_mtp3_label
;
92 static int ett_mtp3_label_dpc
;
93 static int ett_mtp3_label_opc
;
95 static dissector_table_t mtp3_sio_dissector_table
;
97 static int mtp3_address_type
= -1;
100 ITU_PC_STRUCTURE_NONE
= 1,
101 ITU_PC_STRUCTURE_3_8_3
= 2,
102 ITU_PC_STRUCTURE_4_3_4_3
= 3
103 } ITU_PC_Structure_Type
;
106 JAPAN_PC_STRUCTURE_NONE
= 1,
107 JAPAN_PC_STRUCTURE_7_4_5
= 2,
108 JAPAN_PC_STRUCTURE_3_4_4_5
= 3
109 } JAPAN_PC_Structure_Type
;
111 static int itu_pc_structure
= ITU_PC_STRUCTURE_NONE
;
112 static int japan_pc_structure
= JAPAN_PC_STRUCTURE_NONE
;
114 #include "packet-mtp3.h"
116 int mtp3_standard
= ITU_STANDARD
;
117 bool mtp3_heuristic_standard
;
119 static int pref_mtp3_standard
;
121 const value_string mtp3_standard_vals
[] = {
122 { ITU_STANDARD
, "ITU_STANDARD" },
123 { ANSI_STANDARD
, "ANSI_STANDARD" },
124 { CHINESE_ITU_STANDARD
, "CHINESE_ITU_STANDARD" },
125 { JAPAN_STANDARD
, "JAPAN_STANDARD" },
129 static bool mtp3_use_ansi_5_bit_sls
;
130 static bool mtp3_use_japan_5_bit_sls
;
131 static bool mtp3_show_itu_priority
;
132 static int mtp3_addr_fmt
= MTP3_ADDR_FMT_DASHED
;
137 #define ROUTING_LABEL_OFFSET (SIO_OFFSET + SIO_LENGTH)
139 #define ITU_ROUTING_LABEL_LENGTH 4
140 #define ITU_HEADER_LENGTH (SIO_LENGTH + ITU_ROUTING_LABEL_LENGTH)
142 #define ITU_SLS_OFFSET (SIO_OFFSET + ITU_HEADER_LENGTH - SLS_LENGTH)
143 #define ITU_MTP_PAYLOAD_OFFSET (SIO_OFFSET + ITU_HEADER_LENGTH)
145 #define ANSI_ROUTING_LABEL_LENGTH (ANSI_PC_LENGTH + ANSI_PC_LENGTH + SLS_LENGTH)
146 #define ANSI_HEADER_LENGTH (SIO_LENGTH + ANSI_ROUTING_LABEL_LENGTH)
148 #define ANSI_DPC_OFFSET ROUTING_LABEL_OFFSET
149 #define ANSI_OPC_OFFSET (ANSI_DPC_OFFSET + ANSI_PC_LENGTH)
150 #define ANSI_SLS_OFFSET (ANSI_OPC_OFFSET + ANSI_PC_LENGTH)
151 #define ANSI_MTP_PAYLOAD_OFFSET (SIO_OFFSET + ANSI_HEADER_LENGTH)
153 #define JAPAN_SLS_SPARE_LENGTH 1
154 #define JAPAN_ROUTING_LABEL_LENGTH (JAPAN_PC_LENGTH + JAPAN_PC_LENGTH + JAPAN_SLS_SPARE_LENGTH)
155 #define JAPAN_HEADER_LENGTH (SIO_LENGTH + JAPAN_ROUTING_LABEL_LENGTH)
157 #define JAPAN_OPC_OFFSET (ROUTING_LABEL_OFFSET + JAPAN_PC_LENGTH)
158 #define JAPAN_SLS_OFFSET (JAPAN_OPC_OFFSET + JAPAN_PC_LENGTH)
159 #define JAPAN_SPARE_OFFSET (ROUTING_LABEL_OFFSET + JAPAN_ROUTING_LABEL_LENGTH)
160 #define JAPAN_MTP_PAYLOAD_OFFSET (SIO_OFFSET + JAPAN_HEADER_LENGTH)
162 #define SERVICE_INDICATOR_MASK 0x0F
163 #define SPARE_MASK 0x30
164 #define ANSI_PRIORITY_MASK SPARE_MASK
165 #define NETWORK_INDICATOR_MASK 0xC0
166 #define ITU_DPC_MASK 0x00003FFF
167 #define ITU_OPC_MASK 0x0FFFC000
168 #define ITU_SLS_MASK 0xF0000000
170 #define ANSI_5BIT_SLS_MASK 0x1F
171 #define ANSI_8BIT_SLS_MASK 0xFF
172 #define CHINESE_ITU_SLS_MASK 0xF
173 #define JAPAN_4_BIT_SLS_MASK 0xF
174 #define JAPAN_4_BIT_SLS_SPARE_MASK 0xF0
175 #define JAPAN_5_BIT_SLS_MASK 0x1F
176 #define JAPAN_5_BIT_SLS_SPARE_MASK 0xE0
178 /* the higher values are taken from the M3UA RFC */
179 static const value_string mtp3_service_indicator_code_vals
[] = {
180 { MTP_SI_SNM
, "Signalling Network Management Message (SNM)" },
181 { MTP_SI_MTN
, "Maintenance Regular Message (MTN)" },
182 { MTP_SI_MTNS
, "Maintenance Special Message (MTNS)" },
183 { MTP_SI_SCCP
, "SCCP" },
184 { MTP_SI_TUP
, "TUP" },
185 { MTP_SI_ISUP
, "ISUP" },
186 { MTP_SI_DUP_CC
, "DUP (call and circuit related messages)" },
187 { MTP_SI_DUP_FAC
, "DUP (facility registration and cancellation message)" },
188 { MTP_SI_MTP_TEST
, "MTP testing user part" },
189 { MTP_SI_ISUP_B
, "Broadband ISUP" },
190 { MTP_SI_ISUP_S
, "Satellite ISUP" },
192 { MTP_SI_AAL2
, "AAL type2 Signaling" },
193 { MTP_SI_BICC
, "Bearer Independent Call Control (BICC)" },
194 { MTP_SI_GCP
, "Gateway Control Protocol" },
199 const value_string mtp3_service_indicator_code_short_vals
[] = {
200 { MTP_SI_SNM
, "SNM" },
201 { MTP_SI_MTN
, "MTN" },
202 { MTP_SI_MTNS
, "MTNS" },
203 { MTP_SI_SCCP
, "SCCP" },
204 { MTP_SI_TUP
, "TUP" },
205 { MTP_SI_ISUP
, "ISUP" },
206 { MTP_SI_DUP_CC
, "DUP (CC)" },
207 { MTP_SI_DUP_FAC
, "DUP (FAC/CANC)" },
208 { MTP_SI_MTP_TEST
, "MTP Test" },
209 { MTP_SI_ISUP_B
, "ISUP-b" },
210 { MTP_SI_ISUP_S
, "ISUP-s" },
211 { MTP_SI_AAL2
, "AAL type 2" },
212 { MTP_SI_BICC
, "BICC" },
213 { MTP_SI_GCP
, "GCP" },
217 const value_string mtp3_network_indicator_vals
[] = {
218 { MTP3_NI_INT0
, "International network" },
219 { MTP3_NI_INT1
, "Spare (for international use only)" },
220 { MTP3_NI_NAT0
, "National network" },
221 { MTP3_NI_NAT1
, "Reserved for national use" },
227 * helper routine to format a point code in structured form
231 mtp3_pc_to_str_buf(const uint32_t pc
, char *buf
, int buf_len
)
233 switch (mtp3_standard
)
236 switch (itu_pc_structure
) {
237 case ITU_PC_STRUCTURE_NONE
:
238 snprintf(buf
, buf_len
, "%u", pc
);
240 case ITU_PC_STRUCTURE_3_8_3
:
241 /* this format is used in international ITU networks */
242 snprintf(buf
, buf_len
, "%u-%u-%u", (pc
& 0x3800)>>11, (pc
& 0x7f8) >> 3, (pc
& 0x07) >> 0);
244 case ITU_PC_STRUCTURE_4_3_4_3
:
245 /* this format is used in some national ITU networks, the German one for example. */
246 snprintf(buf
, buf_len
, "%u-%u-%u-%u", (pc
& 0x3c00) >>10, (pc
& 0x0380) >> 7, (pc
& 0x0078) >> 3, (pc
& 0x0007) >> 0);
249 DISSECTOR_ASSERT_NOT_REACHED();
253 case CHINESE_ITU_STANDARD
:
254 snprintf(buf
, buf_len
, "%u-%u-%u", (pc
& ANSI_NETWORK_MASK
) >> 16, (pc
& ANSI_CLUSTER_MASK
) >> 8, (pc
& ANSI_MEMBER_MASK
));
257 switch (japan_pc_structure
) {
258 case JAPAN_PC_STRUCTURE_NONE
:
259 snprintf(buf
, buf_len
, "%u", pc
);
261 case JAPAN_PC_STRUCTURE_7_4_5
:
262 /* This format is specified by NTT */
263 snprintf(buf
, buf_len
, "%u-%u-%u", (pc
& 0xfe00)>>9, (pc
& 0x1e0)>>5, (pc
& 0x1f));
265 case JAPAN_PC_STRUCTURE_3_4_4_5
:
266 /* Where does this format come from? */
267 snprintf(buf
, buf_len
, "%u-%u-%u-%u", (pc
& 0xe000)>>13, (pc
& 0x1e00)>>9, (pc
& 0x1e0)>>5, (pc
& 0x1f));
270 DISSECTOR_ASSERT_NOT_REACHED();
274 DISSECTOR_ASSERT_NOT_REACHED();
278 #define MAX_STRUCTURED_PC_LENGTH 20
281 mtp3_pc_to_str(const uint32_t pc
)
285 str
=(char *)wmem_alloc(wmem_packet_scope(), MAX_STRUCTURED_PC_LENGTH
);
286 mtp3_pc_to_str_buf(pc
, str
, MAX_STRUCTURED_PC_LENGTH
);
291 mtp3_pc_structured(void)
293 if ((mtp3_standard
== ITU_STANDARD
) && (itu_pc_structure
== ITU_PC_STRUCTURE_NONE
))
295 else if ((mtp3_standard
== JAPAN_STANDARD
) && (japan_pc_structure
== JAPAN_PC_STRUCTURE_NONE
))
302 * helper routine to format address to string
306 mtp3_addr_to_str_buf(const mtp3_addr_pc_t
*addr_pc_p
,
307 char *buf
, int buf_len
)
309 switch (mtp3_addr_fmt
)
311 case MTP3_ADDR_FMT_DEC
:
312 switch (addr_pc_p
->type
)
315 snprintf(buf
, buf_len
, "%u", addr_pc_p
->pc
& ITU_PC_MASK
);
318 snprintf(buf
, buf_len
, "%u", addr_pc_p
->pc
& JAPAN_PC_MASK
);
321 /* assuming 24-bit */
322 snprintf(buf
, buf_len
, "%u", addr_pc_p
->pc
& ANSI_PC_MASK
);
327 case MTP3_ADDR_FMT_HEX
:
328 switch (addr_pc_p
->type
)
331 snprintf(buf
, buf_len
, "%x", addr_pc_p
->pc
& ITU_PC_MASK
);
334 snprintf(buf
, buf_len
, "%x", addr_pc_p
->pc
& JAPAN_PC_MASK
);
337 /* assuming 24-bit */
338 snprintf(buf
, buf_len
, "%x", addr_pc_p
->pc
& ANSI_PC_MASK
);
343 case MTP3_ADDR_FMT_NI_DEC
:
344 switch (addr_pc_p
->type
)
347 snprintf(buf
, buf_len
, "%u:%u", addr_pc_p
->ni
, addr_pc_p
->pc
& ITU_PC_MASK
);
350 snprintf(buf
, buf_len
, "%u:%u", addr_pc_p
->ni
, addr_pc_p
->pc
& JAPAN_PC_MASK
);
353 /* assuming 24-bit */
354 snprintf(buf
, buf_len
, "%u:%u", addr_pc_p
->ni
, addr_pc_p
->pc
& ANSI_PC_MASK
);
359 case MTP3_ADDR_FMT_NI_HEX
:
360 switch (addr_pc_p
->type
)
363 snprintf(buf
, buf_len
, "%u:%x", addr_pc_p
->ni
, addr_pc_p
->pc
& ITU_PC_MASK
);
366 snprintf(buf
, buf_len
, "%u:%x", addr_pc_p
->ni
, addr_pc_p
->pc
& JAPAN_PC_MASK
);
369 /* assuming 24-bit */
370 snprintf(buf
, buf_len
, "%u:%x", addr_pc_p
->ni
, addr_pc_p
->pc
& ANSI_PC_MASK
);
378 case MTP3_ADDR_FMT_DASHED
:
379 mtp3_pc_to_str_buf(addr_pc_p
->pc
, buf
, buf_len
);
385 mtp3_pc_hash(const mtp3_addr_pc_t
*addr_pc_p
) {
388 switch (addr_pc_p
->type
)
391 pc
= (addr_pc_p
->pc
& ITU_PC_MASK
) | ((addr_pc_p
->ni
% 4) << 14) ;
394 /* assuming 24-bit */
395 pc
= (addr_pc_p
->pc
& ANSI_PC_MASK
) | ((addr_pc_p
->ni
) << 24) ;
402 static int mtp3_addr_to_str(const address
* addr
, char *buf
, int buf_len
)
404 mtp3_addr_to_str_buf((const mtp3_addr_pc_t
*)addr
->data
, buf
, buf_len
);
405 return (int)(strlen(buf
)+1);
408 static int mtp3_str_addr_len(const address
* addr _U_
)
413 static const char* mtp3_addr_col_filter_str(const address
* addr _U_
, bool is_src
)
421 int mtp3_addr_len(void)
423 return sizeof(mtp3_addr_pc_t
);
426 static const char* mtp3_addr_name_res_str(const address
* addr
)
428 const mtp3_addr_pc_t
*mtp3_addr
= (const mtp3_addr_pc_t
*)addr
->data
;
431 tmp
= get_hostname_ss7pc(mtp3_addr
->ni
, mtp3_addr
->pc
);
433 if (tmp
[0] == '\0') {
435 str
= (char *)wmem_alloc(NULL
, MAXNAMELEN
);
436 mtp3_addr_to_str_buf(mtp3_addr
, str
, MAXNAMELEN
);
437 fill_unresolved_ss7pc(str
, mtp3_addr
->ni
, mtp3_addr
->pc
);
438 wmem_free(NULL
, str
);
439 return get_hostname_ss7pc(mtp3_addr
->ni
, mtp3_addr
->pc
);
445 static int mtp3_addr_name_res_len(void)
453 /* Common function for dissecting 3-byte (ANSI or China) PCs. */
455 dissect_mtp3_3byte_pc(tvbuff_t
*tvb
, unsigned offset
, proto_tree
*tree
, int ett_pc
, int hf_pc_string
, int hf_pc_network
,
456 int hf_pc_cluster
, int hf_pc_member
, int hf_dpc
, int hf_pc
)
459 proto_item
*pc_item
, *hidden_item
;
461 char pc_string
[MAX_STRUCTURED_PC_LENGTH
];
463 pc
= tvb_get_letoh24(tvb
, offset
);
464 mtp3_pc_to_str_buf(pc
, pc_string
, sizeof(pc_string
));
466 pc_item
= proto_tree_add_string(tree
, hf_pc_string
, tvb
, offset
, ANSI_PC_LENGTH
, pc_string
);
468 /* Add alternate formats of the PC
469 * NOTE: each of these formats is shown to the user,
470 * so I think that using hidden fields in this case is OK.
472 snprintf(pc_string
, sizeof(pc_string
), "%u", pc
);
473 proto_item_append_text(pc_item
, " (%s)", pc_string
);
474 hidden_item
= proto_tree_add_string(tree
, hf_pc_string
, tvb
, offset
, ANSI_PC_LENGTH
, pc_string
);
475 proto_item_set_hidden(hidden_item
);
477 snprintf(pc_string
, sizeof(pc_string
), "0x%x", pc
);
478 proto_item_append_text(pc_item
, " (%s)", pc_string
);
479 hidden_item
= proto_tree_add_string(tree
, hf_pc_string
, tvb
, offset
, ANSI_PC_LENGTH
, pc_string
);
480 proto_item_set_hidden(hidden_item
);
482 pc_tree
= proto_item_add_subtree(pc_item
, ett_pc
);
484 proto_tree_add_uint(pc_tree
, hf_pc_network
, tvb
, offset
+ ANSI_NETWORK_OFFSET
, ANSI_NCM_LENGTH
, pc
);
485 proto_tree_add_uint(pc_tree
, hf_pc_cluster
, tvb
, offset
+ ANSI_CLUSTER_OFFSET
, ANSI_NCM_LENGTH
, pc
);
486 proto_tree_add_uint(pc_tree
, hf_pc_member
, tvb
, offset
+ ANSI_MEMBER_OFFSET
, ANSI_NCM_LENGTH
, pc
);
488 /* add full integer values of DPC as hidden for filtering purposes */
490 hidden_item
= proto_tree_add_uint(pc_tree
, hf_dpc
, tvb
, offset
, ANSI_PC_LENGTH
, pc
);
491 proto_item_set_hidden(hidden_item
);
494 hidden_item
= proto_tree_add_uint(pc_tree
, hf_pc
, tvb
, offset
, ANSI_PC_LENGTH
, pc
);
495 proto_item_set_hidden(hidden_item
);
500 dissect_mtp3_sio(tvbuff_t
*tvb
, proto_tree
*mtp3_tree
,
501 mtp3_addr_pc_t
*mtp3_addr_opc
, mtp3_addr_pc_t
*mtp3_addr_dpc
)
504 proto_tree
*sio_tree
;
506 sio_tree
= proto_tree_add_subtree(mtp3_tree
, tvb
, SIO_OFFSET
, SIO_LENGTH
, ett_mtp3_sio
, NULL
, "Service information octet");
508 sio
= tvb_get_uint8(tvb
, SIO_OFFSET
);
509 proto_tree_add_uint(sio_tree
, hf_mtp3_network_indicator
, tvb
, SIO_OFFSET
, SIO_LENGTH
, sio
);
511 mtp3_addr_opc
->ni
= (sio
& NETWORK_INDICATOR_MASK
) >> 6;
512 mtp3_addr_dpc
->ni
= (sio
& NETWORK_INDICATOR_MASK
) >> 6;
514 switch(mtp3_standard
){
516 proto_tree_add_uint(sio_tree
, hf_mtp3_ansi_priority
, tvb
, SIO_OFFSET
, SIO_LENGTH
, sio
);
519 case CHINESE_ITU_STANDARD
:
520 if (mtp3_show_itu_priority
)
521 proto_tree_add_uint(sio_tree
, hf_mtp3_itu_priority
, tvb
, SIO_OFFSET
, SIO_LENGTH
, sio
);
523 proto_tree_add_uint(sio_tree
, hf_mtp3_itu_spare
, tvb
, SIO_OFFSET
, SIO_LENGTH
, sio
);
526 /* The Japan variant has priority but it's on the LI which belongs to
527 * layer 2. Not sure what we can do about that...
529 proto_tree_add_uint(sio_tree
, hf_mtp3_itu_spare
, tvb
, SIO_OFFSET
, SIO_LENGTH
, sio
);
533 proto_tree_add_uint(sio_tree
, hf_mtp3_service_indicator
, tvb
, SIO_OFFSET
, SIO_LENGTH
, sio
);
537 dissect_mtp3_routing_label(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*mtp3_tree
,
538 mtp3_addr_pc_t
*mtp3_addr_opc
, mtp3_addr_pc_t
*mtp3_addr_dpc
)
540 uint32_t label
, dpc
, opc
;
541 proto_item
*label_dpc_item
, *label_opc_item
;
542 proto_item
*hidden_item
;
543 proto_tree
*label_tree
;
544 proto_tree
*pc_subtree
;
549 switch (mtp3_standard
) {
551 label_tree
= proto_tree_add_subtree(mtp3_tree
, tvb
, ROUTING_LABEL_OFFSET
, ITU_ROUTING_LABEL_LENGTH
, ett_mtp3_label
, NULL
, "Routing label");
553 label
= tvb_get_letohl(tvb
, ROUTING_LABEL_OFFSET
);
555 opc
= (label
& ITU_OPC_MASK
) >> 14;
556 dpc
= label
& ITU_DPC_MASK
;
558 hidden_item
= proto_tree_add_uint(label_tree
, hf_mtp3_itu_pc
, tvb
, ROUTING_LABEL_OFFSET
, ITU_ROUTING_LABEL_LENGTH
, opc
);
559 proto_item_set_hidden(hidden_item
);
560 hidden_item
= proto_tree_add_uint(label_tree
, hf_mtp3_itu_pc
, tvb
, ROUTING_LABEL_OFFSET
, ITU_ROUTING_LABEL_LENGTH
, dpc
);
561 proto_item_set_hidden(hidden_item
);
563 label_dpc_item
= proto_tree_add_uint(label_tree
, hf_mtp3_itu_dpc
, tvb
, ROUTING_LABEL_OFFSET
, ITU_ROUTING_LABEL_LENGTH
, label
);
564 if (mtp3_pc_structured())
565 proto_item_append_text(label_dpc_item
, " (%s)", mtp3_pc_to_str(dpc
));
567 if(mtp3_addr_dpc
->ni
== MTP3_NI_INT0
) {
568 pc_subtree
= proto_item_add_subtree(label_dpc_item
, ett_mtp3_label_dpc
);
569 analyze_q708_ispc(tvb
, pc_subtree
, ROUTING_LABEL_OFFSET
, ITU_ROUTING_LABEL_LENGTH
, dpc
);
573 label_opc_item
= proto_tree_add_uint(label_tree
, hf_mtp3_itu_opc
, tvb
, ROUTING_LABEL_OFFSET
, ITU_ROUTING_LABEL_LENGTH
, label
);
574 if (mtp3_pc_structured())
575 proto_item_append_text(label_opc_item
, " (%s)", mtp3_pc_to_str(opc
));
577 if(mtp3_addr_opc
->ni
== MTP3_NI_INT0
) {
578 pc_subtree
= proto_item_add_subtree(label_opc_item
, ett_mtp3_label_opc
);
579 analyze_q708_ispc(tvb
, pc_subtree
, ROUTING_LABEL_OFFSET
, ITU_ROUTING_LABEL_LENGTH
, opc
);
582 proto_tree_add_uint(label_tree
, hf_mtp3_itu_sls
, tvb
, ROUTING_LABEL_OFFSET
, ITU_ROUTING_LABEL_LENGTH
, label
);
586 case CHINESE_ITU_STANDARD
:
587 if (mtp3_standard
== ANSI_STANDARD
)
589 hf_dpc_string
= hf_mtp3_ansi_dpc
;
590 hf_opc_string
= hf_mtp3_ansi_opc
;
591 } else /* CHINESE_ITU_STANDARD */ {
592 hf_dpc_string
= hf_mtp3_chinese_dpc
;
593 hf_opc_string
= hf_mtp3_chinese_opc
;
596 /* Create the Routing Label Tree */
597 label_tree
= proto_tree_add_subtree(mtp3_tree
, tvb
, ROUTING_LABEL_OFFSET
, ANSI_ROUTING_LABEL_LENGTH
, ett_mtp3_label
, NULL
, "Routing label");
599 /* create and fill the DPC tree */
600 dissect_mtp3_3byte_pc(tvb
, ANSI_DPC_OFFSET
, label_tree
, ett_mtp3_label_dpc
, hf_dpc_string
, hf_mtp3_dpc_network
,
601 hf_mtp3_dpc_cluster
, hf_mtp3_dpc_member
, hf_mtp3_24bit_dpc
, hf_mtp3_24bit_pc
);
602 /* Store dpc for mtp3_addr below */
603 dpc
= tvb_get_letoh24(tvb
, ANSI_DPC_OFFSET
);
605 /* create and fill the OPC tree */
606 dissect_mtp3_3byte_pc(tvb
, ANSI_OPC_OFFSET
, label_tree
, ett_mtp3_label_opc
, hf_opc_string
, hf_mtp3_opc_network
,
607 hf_mtp3_opc_cluster
, hf_mtp3_opc_member
, hf_mtp3_24bit_opc
, hf_mtp3_24bit_pc
);
608 /* Store opc for mtp3_addr below */
609 opc
= tvb_get_letoh24(tvb
, ANSI_OPC_OFFSET
);
612 if (mtp3_standard
== ANSI_STANDARD
) {
613 if (mtp3_use_ansi_5_bit_sls
)
614 proto_tree_add_item(label_tree
, hf_mtp3_ansi_5_bit_sls
, tvb
, ANSI_SLS_OFFSET
, SLS_LENGTH
, ENC_LITTLE_ENDIAN
);
616 proto_tree_add_item(label_tree
, hf_mtp3_ansi_8_bit_sls
, tvb
, ANSI_SLS_OFFSET
, SLS_LENGTH
, ENC_LITTLE_ENDIAN
);
617 } else /* CHINESE_ITU_STANDARD */ {
618 proto_tree_add_item(label_tree
, hf_mtp3_chinese_itu_sls
, tvb
, ANSI_SLS_OFFSET
, SLS_LENGTH
, ENC_LITTLE_ENDIAN
);
623 label_tree
= proto_tree_add_subtree(mtp3_tree
, tvb
, ROUTING_LABEL_OFFSET
, JAPAN_ROUTING_LABEL_LENGTH
, ett_mtp3_label
, NULL
, "Routing label");
625 label_dpc_item
= proto_tree_add_item(label_tree
, hf_mtp3_japan_dpc
, tvb
, ROUTING_LABEL_OFFSET
, JAPAN_PC_LENGTH
, ENC_LITTLE_ENDIAN
);
626 dpc
= tvb_get_letohs(tvb
, ROUTING_LABEL_OFFSET
);
627 if (mtp3_pc_structured()) {
628 proto_item_append_text(label_dpc_item
, " (%s)", mtp3_pc_to_str(dpc
));
631 label_opc_item
= proto_tree_add_item(label_tree
, hf_mtp3_japan_opc
, tvb
, JAPAN_OPC_OFFSET
, JAPAN_PC_LENGTH
, ENC_LITTLE_ENDIAN
);
632 opc
= tvb_get_letohs(tvb
, JAPAN_OPC_OFFSET
);
633 if (mtp3_pc_structured()) {
634 proto_item_append_text(label_opc_item
, " (%s)", mtp3_pc_to_str(opc
));
637 hidden_item
= proto_tree_add_item(label_tree
, hf_mtp3_japan_pc
, tvb
, ROUTING_LABEL_OFFSET
, JAPAN_PC_LENGTH
, ENC_LITTLE_ENDIAN
);
638 proto_item_set_hidden(hidden_item
);
639 hidden_item
= proto_tree_add_item(label_tree
, hf_mtp3_japan_pc
, tvb
, JAPAN_OPC_OFFSET
, JAPAN_PC_LENGTH
, ENC_LITTLE_ENDIAN
);
640 proto_item_set_hidden(hidden_item
);
642 if (mtp3_use_japan_5_bit_sls
) {
643 proto_tree_add_item(label_tree
, hf_mtp3_japan_5_bit_sls
, tvb
, JAPAN_SLS_OFFSET
, JAPAN_SLS_SPARE_LENGTH
, ENC_LITTLE_ENDIAN
);
644 proto_tree_add_item(label_tree
, hf_mtp3_japan_5_bit_sls_spare
, tvb
, JAPAN_SLS_OFFSET
, JAPAN_SLS_SPARE_LENGTH
, ENC_LITTLE_ENDIAN
);
646 proto_tree_add_item(label_tree
, hf_mtp3_japan_4_bit_sls
, tvb
, JAPAN_SLS_OFFSET
, JAPAN_SLS_SPARE_LENGTH
, ENC_LITTLE_ENDIAN
);
647 proto_tree_add_item(label_tree
, hf_mtp3_japan_4_bit_sls_spare
, tvb
, JAPAN_SLS_OFFSET
, JAPAN_SLS_SPARE_LENGTH
, ENC_LITTLE_ENDIAN
);
652 DISSECTOR_ASSERT_NOT_REACHED();
655 mtp3_addr_opc
->type
= (Standard_Type
)mtp3_standard
;
656 mtp3_addr_opc
->pc
= opc
;
657 set_address(&pinfo
->src
, mtp3_address_type
, mtp3_addr_len(), (uint8_t *) mtp3_addr_opc
);
659 mtp3_addr_dpc
->type
= (Standard_Type
)mtp3_standard
;
660 mtp3_addr_dpc
->pc
= dpc
;
661 set_address(&pinfo
->dst
, mtp3_address_type
, mtp3_addr_len(), (uint8_t *) mtp3_addr_dpc
);
665 dissect_mtp3_payload(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
668 uint8_t service_indicator
;
669 tvbuff_t
*payload_tvb
= NULL
;
671 sio
= tvb_get_uint8(tvb
, SIO_OFFSET
);
672 service_indicator
= sio
& SERVICE_INDICATOR_MASK
;
674 switch (mtp3_standard
) {
676 payload_tvb
= tvb_new_subset_remaining(tvb
, ITU_MTP_PAYLOAD_OFFSET
);
679 case CHINESE_ITU_STANDARD
:
680 payload_tvb
= tvb_new_subset_remaining(tvb
, ANSI_MTP_PAYLOAD_OFFSET
);
683 payload_tvb
= tvb_new_subset_remaining(tvb
, JAPAN_MTP_PAYLOAD_OFFSET
);
686 DISSECTOR_ASSERT_NOT_REACHED();
689 col_set_str(pinfo
->cinfo
, COL_INFO
, "DATA ");
691 if (!dissector_try_uint(mtp3_sio_dissector_table
, service_indicator
, payload_tvb
, pinfo
, tree
))
692 call_data_dissector(payload_tvb
, pinfo
, tree
);
696 heur_mtp3_standard(tvbuff_t
*tvb
, packet_info
*pinfo
, uint8_t si
)
703 payload
= tvb_new_subset_remaining(tvb
, ITU_HEADER_LENGTH
);
704 if (looks_like_valid_sccp(pinfo
->num
, payload
, ITU_STANDARD
)) {
707 payload
= tvb_new_subset_remaining(tvb
, ANSI_HEADER_LENGTH
);
708 if (looks_like_valid_sccp(pinfo
->num
, payload
, ANSI_STANDARD
)) {
709 return ANSI_STANDARD
;
711 payload
= tvb_new_subset_remaining(tvb
, ANSI_HEADER_LENGTH
);
712 if (looks_like_valid_sccp(pinfo
->num
, payload
, CHINESE_ITU_STANDARD
)) {
713 return CHINESE_ITU_STANDARD
;
715 payload
= tvb_new_subset_remaining(tvb
, JAPAN_HEADER_LENGTH
);
716 if (looks_like_valid_sccp(pinfo
->num
, payload
, JAPAN_STANDARD
)) {
717 return JAPAN_STANDARD
;
720 return HEURISTIC_FAILED_STANDARD
;
724 return HEURISTIC_FAILED_STANDARD
;
730 reset_mtp3_standard(void)
732 mtp3_standard
= pref_mtp3_standard
;
735 /* Code to actually dissect the packets */
737 dissect_mtp3(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
739 mtp3_tap_rec_t
* tap_rec
= wmem_new0(pinfo
->pool
, mtp3_tap_rec_t
);
740 int heuristic_standard
;
742 mtp3_addr_pc_t
* mtp3_addr_dpc
;
743 mtp3_addr_pc_t
* mtp3_addr_opc
;
745 /* Set up structures needed to add the protocol subtree and manage it */
746 proto_item
*mtp3_item
= NULL
, *gen_item
;
747 proto_tree
*mtp3_tree
;
749 pref_mtp3_standard
= mtp3_standard
;
751 mtp3_item
= proto_tree_add_item(tree
, proto_mtp3
, tvb
, 0, -1, ENC_NA
);
753 si
= tvb_get_uint8(tvb
, SIO_OFFSET
) & SERVICE_INDICATOR_MASK
;
754 if (mtp3_heuristic_standard
) {
755 heuristic_standard
= heur_mtp3_standard(tvb
, pinfo
, si
);
756 if (heuristic_standard
== HEURISTIC_FAILED_STANDARD
) {
757 gen_item
= proto_tree_add_uint_format(tree
, hf_mtp3_heuristic_standard
, tvb
, 0, 0, mtp3_standard
,
758 "Could not determine Heuristic using %s", val_to_str_const(mtp3_standard
, mtp3_standard_vals
, "unknown"));
760 gen_item
= proto_tree_add_uint_format(tree
, hf_mtp3_heuristic_standard
, tvb
, 0, 0, heuristic_standard
,
761 "%s", val_to_str_const(heuristic_standard
, mtp3_standard_vals
, "unknown"));
762 mtp3_standard
= heuristic_standard
;
764 /* Register a frame-end routine to ensure mtp3_standard is set
765 * back even if an exception is thrown.
767 register_frame_end_routine(pinfo
, reset_mtp3_standard
);
769 proto_item_set_generated(gen_item
);
772 /* Make entries in Protocol column on summary display */
773 switch(mtp3_standard
) {
775 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MTP3 (Int. ITU)");
776 proto_item_set_len(mtp3_item
, ITU_HEADER_LENGTH
);
779 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MTP3 (ANSI)");
780 proto_item_set_len(mtp3_item
, ANSI_HEADER_LENGTH
);
782 case CHINESE_ITU_STANDARD
:
783 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MTP3 (Chin. ITU)");
784 proto_item_set_len(mtp3_item
, ANSI_HEADER_LENGTH
);
787 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MTP3 (Japan)");
788 proto_item_set_len(mtp3_item
, JAPAN_HEADER_LENGTH
);
792 /* create display subtree for the protocol */
793 mtp3_tree
= proto_item_add_subtree(mtp3_item
, ett_mtp3
);
795 mtp3_addr_opc
= wmem_new0(pinfo
->pool
, mtp3_addr_pc_t
);
796 mtp3_addr_dpc
= wmem_new0(pinfo
->pool
, mtp3_addr_pc_t
);
798 /* Dissect the packet (even if !tree so can call sub-dissectors and update
799 * the source and destination address columns) */
800 dissect_mtp3_sio(tvb
, mtp3_tree
, mtp3_addr_opc
, mtp3_addr_dpc
);
801 dissect_mtp3_routing_label(tvb
, pinfo
, mtp3_tree
, mtp3_addr_opc
, mtp3_addr_dpc
);
803 memcpy(&(tap_rec
->addr_opc
), mtp3_addr_opc
, sizeof(mtp3_addr_pc_t
));
804 memcpy(&(tap_rec
->addr_dpc
), mtp3_addr_dpc
, sizeof(mtp3_addr_pc_t
));
806 tap_rec
->mtp3_si_code
= (tvb_get_uint8(tvb
, SIO_OFFSET
) & SERVICE_INDICATOR_MASK
);
807 tap_rec
->size
= tvb_reported_length(tvb
);
809 tap_queue_packet(mtp3_tap
, pinfo
, tap_rec
);
811 dissect_mtp3_payload(tvb
, pinfo
, tree
);
813 mtp3_standard
= pref_mtp3_standard
;
814 return tvb_captured_length(tvb
);
829 static stat_tap_table_item mtp3_stat_fields
[] = {
830 {TABLE_ITEM_STRING
, TAP_ALIGN_LEFT
, "OPC", "%-25s"},
831 {TABLE_ITEM_STRING
, TAP_ALIGN_LEFT
, "DPC", "%-25s"},
832 {TABLE_ITEM_STRING
, TAP_ALIGN_LEFT
, "SI", "%-25s"},
833 {TABLE_ITEM_UINT
, TAP_ALIGN_RIGHT
, "MSUs", "%d"},
834 {TABLE_ITEM_UINT
, TAP_ALIGN_RIGHT
, "Bytes", "%d"},
835 {TABLE_ITEM_FLOAT
, TAP_ALIGN_RIGHT
, "Avg Bytes", "%f"},
838 static void mtp3_stat_init(stat_tap_table_ui
* new_stat
)
840 const char *table_name
= "MTP3 Statistics";
841 int num_fields
= array_length(mtp3_stat_fields
);
842 stat_tap_table
*table
;
844 table
= stat_tap_find_table(new_stat
, table_name
);
846 if (new_stat
->stat_tap_reset_table_cb
) {
847 new_stat
->stat_tap_reset_table_cb(table
);
852 table
= stat_tap_init_table(table_name
, num_fields
, 0, NULL
);
853 stat_tap_add_table(new_stat
, table
);
856 static tap_packet_status
857 mtp3_stat_packet(void *tapdata
, packet_info
*pinfo _U_
, epan_dissect_t
*edt _U_
, const void *m3tr_ptr
, tap_flags_t flags _U_
)
859 stat_data_t
* stat_data
= (stat_data_t
*)tapdata
;
860 const mtp3_tap_rec_t
*m3tr
= (const mtp3_tap_rec_t
*)m3tr_ptr
;
863 stat_tap_table
* table
;
864 stat_tap_table_item_type
* item_data
;
867 double avg_bytes
= 0.0;
869 if (m3tr
->mtp3_si_code
>= MTP3_NUM_SI_CODE
)
872 * we thought this si_code was not used ?
873 * is MTP3_NUM_SI_CODE out of date ?
875 return TAP_PACKET_DONT_REDRAW
;
879 * look for opc/dpc pair
881 table
= g_array_index(stat_data
->stat_tap_data
->tables
, stat_tap_table
*, 0);
882 for (element
= 0; element
< table
->num_elements
; element
++)
884 stat_tap_table_item_type
*opc_data
, *dpc_data
, *si_data
;
885 opc_data
= stat_tap_get_field_data(table
, element
, OPC_COLUMN
);
886 dpc_data
= stat_tap_get_field_data(table
, element
, DPC_COLUMN
);
887 si_data
= stat_tap_get_field_data(table
, element
, SI_COLUMN
);
889 if (memcmp(&m3tr
->addr_opc
, opc_data
->user_data
.ptr_value
, sizeof(mtp3_addr_pc_t
)) == 0)
891 if (memcmp(&m3tr
->addr_dpc
, dpc_data
->user_data
.ptr_value
, sizeof(mtp3_addr_pc_t
)) == 0)
893 if (m3tr
->mtp3_si_code
== si_data
->user_data
.uint_value
)
904 /* XXX The old version added a row per SI. */
905 int num_fields
= array_length(mtp3_stat_fields
);
906 stat_tap_table_item_type items
[array_length(mtp3_stat_fields
)];
911 memset(items
, 0, sizeof(items
));
913 items
[OPC_COLUMN
].type
= TABLE_ITEM_STRING
;
914 items
[DPC_COLUMN
].type
= TABLE_ITEM_STRING
;
915 items
[SI_COLUMN
].type
= TABLE_ITEM_STRING
;
916 items
[NUM_MSUS_COLUMN
].type
= TABLE_ITEM_UINT
;
917 items
[NUM_BYTES_COLUMN
].type
= TABLE_ITEM_UINT
;
918 items
[AVG_BYTES_COLUMN
].type
= TABLE_ITEM_FLOAT
;
920 stat_tap_init_table_row(table
, element
, num_fields
, items
);
922 item_data
= stat_tap_get_field_data(table
, element
, OPC_COLUMN
);
923 mtp3_addr_to_str_buf(&m3tr
->addr_opc
, str
, 256);
924 item_data
->value
.string_value
= g_strdup(str
);
925 item_data
->user_data
.ptr_value
= g_memdup2(&m3tr
->addr_opc
, sizeof(mtp3_tap_rec_t
));
926 stat_tap_set_field_data(table
, element
, OPC_COLUMN
, item_data
);
928 item_data
= stat_tap_get_field_data(table
, element
, DPC_COLUMN
);
929 mtp3_addr_to_str_buf(&m3tr
->addr_dpc
, str
, 256);
930 item_data
->value
.string_value
= g_strdup(str
);
931 item_data
->user_data
.ptr_value
= g_memdup2(&m3tr
->addr_dpc
, sizeof(mtp3_tap_rec_t
));
932 stat_tap_set_field_data(table
, element
, DPC_COLUMN
, item_data
);
934 sis
= try_val_to_str(m3tr
->mtp3_si_code
, mtp3_service_indicator_code_short_vals
);
936 col_str
= g_strdup(sis
);
938 col_str
= ws_strdup_printf("Unknown service indicator %d", m3tr
->mtp3_si_code
);
941 item_data
= stat_tap_get_field_data(table
, element
, SI_COLUMN
);
942 item_data
->value
.string_value
= col_str
;
943 item_data
->user_data
.uint_value
= m3tr
->mtp3_si_code
;
944 stat_tap_set_field_data(table
, element
, SI_COLUMN
, item_data
);
947 item_data
= stat_tap_get_field_data(table
, element
, NUM_MSUS_COLUMN
);
948 item_data
->value
.uint_value
++;
949 msu_count
= item_data
->value
.uint_value
;
950 stat_tap_set_field_data(table
, element
, NUM_MSUS_COLUMN
, item_data
);
952 item_data
= stat_tap_get_field_data(table
, element
, NUM_BYTES_COLUMN
);
953 item_data
->value
.uint_value
+= m3tr
->size
;
954 byte_count
= item_data
->value
.uint_value
;
955 stat_tap_set_field_data(table
, element
, NUM_BYTES_COLUMN
, item_data
);
958 avg_bytes
= (double) byte_count
/ msu_count
;
960 item_data
= stat_tap_get_field_data(table
, element
, AVG_BYTES_COLUMN
);
961 item_data
->value
.float_value
= avg_bytes
;
962 stat_tap_set_field_data(table
, element
, AVG_BYTES_COLUMN
, item_data
);
964 return TAP_PACKET_REDRAW
;
968 mtp3_stat_reset(stat_tap_table
* table
)
971 stat_tap_table_item_type
* item_data
;
973 for (element
= 0; element
< table
->num_elements
; element
++)
975 item_data
= stat_tap_get_field_data(table
, element
, NUM_MSUS_COLUMN
);
976 item_data
->value
.uint_value
= 0;
977 stat_tap_set_field_data(table
, element
, NUM_MSUS_COLUMN
, item_data
);
979 item_data
= stat_tap_get_field_data(table
, element
, NUM_BYTES_COLUMN
);
980 item_data
->value
.uint_value
= 0;
981 stat_tap_set_field_data(table
, element
, NUM_BYTES_COLUMN
, item_data
);
986 mtp3_stat_free_table_item(stat_tap_table
* table _U_
, unsigned row _U_
, unsigned column
, stat_tap_table_item_type
* field_data
)
991 g_free((char*)field_data
->user_data
.ptr_value
);
994 g_free((char*)field_data
->value
.string_value
);
1003 proto_register_mtp3(void)
1006 /* Setup list of header fields See Section 1.6.1 for details*/
1007 static hf_register_info hf
[] = {
1008 { &hf_mtp3_service_indicator
, { "Service indicator", "mtp3.service_indicator", FT_UINT8
, BASE_HEX
, VALS(mtp3_service_indicator_code_vals
), SERVICE_INDICATOR_MASK
, NULL
, HFILL
}},
1009 { &hf_mtp3_network_indicator
, { "Network indicator", "mtp3.network_indicator", FT_UINT8
, BASE_HEX
, VALS(mtp3_network_indicator_vals
), NETWORK_INDICATOR_MASK
, NULL
, HFILL
}},
1010 { &hf_mtp3_itu_spare
, { "Spare", "mtp3.spare", FT_UINT8
, BASE_HEX
, NULL
, SPARE_MASK
, NULL
, HFILL
}},
1011 { &hf_mtp3_itu_priority
, { "ITU priority", "mtp3.priority", FT_UINT8
, BASE_DEC
, NULL
, SPARE_MASK
, NULL
, HFILL
}},
1012 { &hf_mtp3_ansi_priority
, { "ANSI Priority", "mtp3.priority", FT_UINT8
, BASE_DEC
, NULL
, ANSI_PRIORITY_MASK
, NULL
, HFILL
}},
1013 { &hf_mtp3_itu_opc
, { "OPC", "mtp3.opc", FT_UINT32
, BASE_DEC
, NULL
, ITU_OPC_MASK
, NULL
, HFILL
}},
1014 { &hf_mtp3_itu_pc
, { "PC", "mtp3.pc", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1015 { &hf_mtp3_24bit_pc
, { "PC", "mtp3.pc", FT_UINT32
, BASE_DEC
, NULL
, ANSI_PC_MASK
, NULL
, HFILL
}},
1016 { &hf_mtp3_24bit_opc
, { "OPC", "mtp3.opc", FT_UINT32
, BASE_DEC
, NULL
, ANSI_PC_MASK
, NULL
, HFILL
}},
1017 { &hf_mtp3_ansi_opc
, { "OPC", "mtp3.ansi_opc", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1018 { &hf_mtp3_chinese_opc
, { "OPC", "mtp3.chinese_opc", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1019 { &hf_mtp3_opc_network
, { "OPC Network", "mtp3.opc.network", FT_UINT24
, BASE_DEC
, NULL
, ANSI_NETWORK_MASK
, NULL
, HFILL
}},
1020 { &hf_mtp3_opc_cluster
, { "OPC Cluster", "mtp3.opc.cluster", FT_UINT24
, BASE_DEC
, NULL
, ANSI_CLUSTER_MASK
, NULL
, HFILL
}},
1021 { &hf_mtp3_opc_member
, { "OPC Member", "mtp3.opc.member", FT_UINT24
, BASE_DEC
, NULL
, ANSI_MEMBER_MASK
, NULL
, HFILL
}},
1022 { &hf_mtp3_japan_opc
, { "OPC", "mtp3.opc", FT_UINT16
, BASE_DEC
, NULL
, JAPAN_PC_MASK
, NULL
, HFILL
}},
1023 { &hf_mtp3_japan_pc
, { "PC", "mtp3.pc", FT_UINT16
, BASE_DEC
, NULL
, JAPAN_PC_MASK
, NULL
, HFILL
}},
1024 { &hf_mtp3_itu_dpc
, { "DPC", "mtp3.dpc", FT_UINT32
, BASE_DEC
, NULL
, ITU_DPC_MASK
, NULL
, HFILL
}},
1025 { &hf_mtp3_24bit_dpc
, { "DPC", "mtp3.dpc", FT_UINT32
, BASE_DEC
, NULL
, ANSI_PC_MASK
, NULL
, HFILL
}},
1026 { &hf_mtp3_ansi_dpc
, { "DPC", "mtp3.ansi_dpc", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1027 { &hf_mtp3_chinese_dpc
, { "DPC", "mtp3.chinese_dpc", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1028 { &hf_mtp3_dpc_network
, { "DPC Network", "mtp3.dpc.network", FT_UINT24
, BASE_DEC
, NULL
, ANSI_NETWORK_MASK
, NULL
, HFILL
}},
1029 { &hf_mtp3_dpc_cluster
, { "DPC Cluster", "mtp3.dpc.cluster", FT_UINT24
, BASE_DEC
, NULL
, ANSI_CLUSTER_MASK
, NULL
, HFILL
}},
1030 { &hf_mtp3_dpc_member
, { "DPC Member", "mtp3.dpc.member", FT_UINT24
, BASE_DEC
, NULL
, ANSI_MEMBER_MASK
, NULL
, HFILL
}},
1031 { &hf_mtp3_japan_dpc
, { "DPC", "mtp3.dpc", FT_UINT16
, BASE_DEC
, NULL
, JAPAN_PC_MASK
, NULL
, HFILL
}},
1032 { &hf_mtp3_itu_sls
, { "Signalling Link Selector", "mtp3.sls", FT_UINT32
, BASE_DEC
, NULL
, ITU_SLS_MASK
, NULL
, HFILL
}},
1033 { &hf_mtp3_japan_4_bit_sls
, { "Signalling Link Selector", "mtp3.sls", FT_UINT8
, BASE_DEC
, NULL
, JAPAN_4_BIT_SLS_MASK
, NULL
, HFILL
}},
1034 { &hf_mtp3_japan_4_bit_sls_spare
, { "SLS Spare", "mtp3.sls_spare", FT_UINT8
, BASE_HEX
, NULL
, JAPAN_4_BIT_SLS_SPARE_MASK
, NULL
, HFILL
}},
1035 { &hf_mtp3_japan_5_bit_sls
, { "Signalling Link Selector", "mtp3.sls", FT_UINT8
, BASE_DEC
, NULL
, JAPAN_5_BIT_SLS_MASK
, NULL
, HFILL
}},
1036 { &hf_mtp3_japan_5_bit_sls_spare
, { "SLS Spare", "mtp3.sls_spare", FT_UINT8
, BASE_HEX
, NULL
, JAPAN_5_BIT_SLS_SPARE_MASK
, NULL
, HFILL
}},
1037 { &hf_mtp3_ansi_5_bit_sls
, { "Signalling Link Selector", "mtp3.sls", FT_UINT8
, BASE_DEC
, NULL
, ANSI_5BIT_SLS_MASK
, NULL
, HFILL
}},
1038 { &hf_mtp3_ansi_8_bit_sls
, { "Signalling Link Selector", "mtp3.sls", FT_UINT8
, BASE_DEC
, NULL
, ANSI_8BIT_SLS_MASK
, NULL
, HFILL
}},
1039 { &hf_mtp3_chinese_itu_sls
, { "Signalling Link Selector", "mtp3.sls", FT_UINT8
, BASE_DEC
, NULL
, CHINESE_ITU_SLS_MASK
, NULL
, HFILL
}},
1040 { &hf_mtp3_heuristic_standard
, { "Heuristic standard", "mtp3.heuristic_standard",FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1043 /* Setup protocol subtree array */
1044 static int *ett
[] = {
1048 &ett_mtp3_label_dpc
,
1052 static const enum_val_t mtp3_options
[] = {
1053 { "itu", "ITU", ITU_STANDARD
},
1054 { "ansi", "ANSI", ANSI_STANDARD
},
1055 { "chinese-itu", "Chinese ITU", CHINESE_ITU_STANDARD
},
1056 { "japan", "Japan", JAPAN_STANDARD
},
1060 static const enum_val_t mtp3_addr_fmt_str_e
[] = {
1061 { "decimal", "Decimal", MTP3_ADDR_FMT_DEC
},
1062 { "hexadecimal", "Hexadecimal", MTP3_ADDR_FMT_HEX
},
1063 { "ni-decimal", "NI-Decimal", MTP3_ADDR_FMT_NI_DEC
},
1064 { "ni-hexadecimal", "NI-Hexadecimal", MTP3_ADDR_FMT_NI_HEX
},
1065 { "dashed", "Dashed", MTP3_ADDR_FMT_DASHED
},
1069 static const enum_val_t itu_pc_structures
[] = {
1070 { "unstructured", "Unstructured", ITU_PC_STRUCTURE_NONE
},
1071 { "3-8-3", "3-8-3", ITU_PC_STRUCTURE_3_8_3
},
1072 { "4-3-4-3", "4-3-4-3", ITU_PC_STRUCTURE_4_3_4_3
},
1076 static const enum_val_t japan_pc_structures
[] = {
1077 { "unstructured", "Unstructured", JAPAN_PC_STRUCTURE_NONE
},
1078 { "7-4-5", "7-4-5", JAPAN_PC_STRUCTURE_7_4_5
},
1079 { "3-4-4-5", "3-4-4-5", JAPAN_PC_STRUCTURE_3_4_4_5
},
1083 static tap_param mtp3_stat_params
[] = {
1084 { PARAM_FILTER
, "filter", "Filter", NULL
, true }
1087 static stat_tap_table_ui mtp3_stat_table
= {
1088 REGISTER_TELEPHONY_GROUP_MTP3
,
1095 mtp3_stat_free_table_item
,
1097 array_length(mtp3_stat_fields
), mtp3_stat_fields
,
1098 array_length(mtp3_stat_params
), mtp3_stat_params
,
1103 /* Register the protocol name and description */
1104 proto_mtp3
= proto_register_protocol("Message Transfer Part Level 3",
1106 mtp3_handle
= register_dissector("mtp3", dissect_mtp3
, proto_mtp3
);
1108 /* Required function calls to register the header fields and subtrees used */
1109 proto_register_field_array(proto_mtp3
, hf
, array_length(hf
));
1110 proto_register_subtree_array(ett
, array_length(ett
));
1112 mtp3_sio_dissector_table
= register_dissector_table("mtp3.service_indicator",
1113 "MTP3 Service indicator",
1114 proto_mtp3
, FT_UINT8
, BASE_HEX
);
1116 mtp3_address_type
= address_type_dissector_register("AT_SS7PC", "SS7 Point Code", mtp3_addr_to_str
, mtp3_str_addr_len
, NULL
, mtp3_addr_col_filter_str
,
1117 mtp3_addr_len
, mtp3_addr_name_res_str
, mtp3_addr_name_res_len
);
1120 mtp3_tap
= register_tap("mtp3");
1122 mtp3_module
= prefs_register_protocol(proto_mtp3
, NULL
);
1124 prefs_register_bool_preference(mtp3_module
, "heuristic_standard",
1125 "Try to determine the MTP3 standard heuristically",
1126 "This only works for SCCP traffic for now",
1127 &mtp3_heuristic_standard
);
1129 prefs_register_enum_preference(mtp3_module
, "standard", "MTP3 standard",
1130 "The SS7 standard used in MTP3 packets",
1131 &mtp3_standard
, mtp3_options
, false);
1133 prefs_register_enum_preference(mtp3_module
, "itu_pc_structure", "ITU Pointcode structure",
1134 "The structure of the pointcodes in ITU networks",
1135 &itu_pc_structure
, itu_pc_structures
, false);
1137 prefs_register_enum_preference(mtp3_module
, "japan_pc_structure", "Japan Pointcode structure",
1138 "The structure of the pointcodes in Japan networks",
1139 &japan_pc_structure
, japan_pc_structures
, false);
1141 prefs_register_bool_preference(mtp3_module
, "ansi_5_bit_sls",
1142 "Use 5-bit SLS (ANSI only)",
1143 "Use 5-bit (instead of 8-bit) SLS in ANSI MTP3 packets",
1144 &mtp3_use_ansi_5_bit_sls
);
1146 prefs_register_bool_preference(mtp3_module
, "japan_5_bit_sls",
1147 "Use 5-bit SLS (Japan only)",
1148 "Use 5-bit (instead of 4-bit) SLS in Japan MTP3 packets",
1149 &mtp3_use_japan_5_bit_sls
);
1151 prefs_register_enum_preference(mtp3_module
, "addr_format", "Address Format",
1152 "Format for point code in the address columns",
1153 &mtp3_addr_fmt
, mtp3_addr_fmt_str_e
, false);
1155 prefs_register_bool_preference(mtp3_module
, "itu_priority",
1156 "Show MSU priority (national option, ITU and China ITU only)",
1157 "Decode the spare bits of the SIO as the MSU priority (a national option in ITU)",
1158 &mtp3_show_itu_priority
);
1160 register_stat_tap_table_ui(&mtp3_stat_table
);
1164 proto_reg_handoff_mtp3(void)
1166 dissector_add_uint("wtap_encap", WTAP_ENCAP_MTP3
, mtp3_handle
);
1167 dissector_add_string("tali.opcode", "mtp3", mtp3_handle
);
1171 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1176 * indent-tabs-mode: nil
1179 * ex: set shiftwidth=2 tabstop=8 expandtab:
1180 * :indentSize=2:tabSize=8:noTabs=true: