1 /* Copyright (c) 2013, The TCPDUMP project
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
7 * 1. Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 #define NETDISSECT_REWORKED
30 #include <tcpdump-stdinc.h>
32 #include "interface.h"
37 struct m3ua_common_header
{
45 struct m3ua_param_header
{
51 #define M3UA_MSGC_MGMT 0
52 #define M3UA_MSGC_TRANSFER 1
53 #define M3UA_MSGC_SSNM 2
54 #define M3UA_MSGC_ASPSM 3
55 #define M3UA_MSGC_ASPTM 4
57 #define M3UA_MSGC_RKM 9
59 static const struct tok MessageClasses
[] = {
60 { M3UA_MSGC_MGMT
, "Management" },
61 { M3UA_MSGC_TRANSFER
, "Transfer" },
62 { M3UA_MSGC_SSNM
, "SS7" },
63 { M3UA_MSGC_ASPSM
, "ASP" },
64 { M3UA_MSGC_ASPTM
, "ASP" },
65 { M3UA_MSGC_RKM
, "Routing Key Managment" },
69 /* management messages */
70 #define M3UA_MGMT_ERROR 0
71 #define M3UA_MGMT_NOTIFY 1
73 static const struct tok MgmtMessages
[] = {
74 { M3UA_MGMT_ERROR
, "Error" },
75 { M3UA_MGMT_NOTIFY
, "Notify" },
79 /* transfer messages */
80 #define M3UA_TRANSFER_DATA 1
82 static const struct tok TransferMessages
[] = {
83 { M3UA_TRANSFER_DATA
, "Data" },
87 /* SS7 Signaling Network Management messages */
88 #define M3UA_SSNM_DUNA 1
89 #define M3UA_SSNM_DAVA 2
90 #define M3UA_SSNM_DAUD 3
91 #define M3UA_SSNM_SCON 4
92 #define M3UA_SSNM_DUPU 5
93 #define M3UA_SSNM_DRST 6
95 static const struct tok SS7Messages
[] = {
96 { M3UA_SSNM_DUNA
, "Destination Unavailable" },
97 { M3UA_SSNM_DAVA
, "Destination Available" },
98 { M3UA_SSNM_DAUD
, "Destination State Audit" },
99 { M3UA_SSNM_SCON
, "Signalling Congestion" },
100 { M3UA_SSNM_DUPU
, "Destination User Part Unavailable" },
101 { M3UA_SSNM_DRST
, "Destination Restricted" },
105 /* ASP State Maintenance messages */
106 #define M3UA_ASP_UP 1
107 #define M3UA_ASP_DN 2
108 #define M3UA_ASP_BEAT 3
109 #define M3UA_ASP_UP_ACK 4
110 #define M3UA_ASP_DN_ACK 5
111 #define M3UA_ASP_BEAT_ACK 6
113 static const struct tok ASPStateMessages
[] = {
114 { M3UA_ASP_UP
, "Up" },
115 { M3UA_ASP_DN
, "Down" },
116 { M3UA_ASP_BEAT
, "Heartbeat" },
117 { M3UA_ASP_UP_ACK
, "Up Acknowledgement" },
118 { M3UA_ASP_DN_ACK
, "Down Acknowledgement" },
119 { M3UA_ASP_BEAT_ACK
, "Heartbeat Acknowledgement" },
123 /* ASP Traffic Maintenance messages */
124 #define M3UA_ASP_AC 1
125 #define M3UA_ASP_IA 2
126 #define M3UA_ASP_AC_ACK 3
127 #define M3UA_ASP_IA_ACK 4
129 static const struct tok ASPTrafficMessages
[] = {
130 { M3UA_ASP_AC
, "Active" },
131 { M3UA_ASP_IA
, "Inactive" },
132 { M3UA_ASP_AC_ACK
, "Active Acknowledgement" },
133 { M3UA_ASP_IA_ACK
, "Inactive Acknowledgement" },
137 /* Routing Key Management messages */
138 #define M3UA_RKM_REQ 1
139 #define M3UA_RKM_RSP 2
140 #define M3UA_RKM_DEREQ 3
141 #define M3UA_RKM_DERSP 4
143 static const struct tok RoutingKeyMgmtMessages
[] = {
144 { M3UA_RKM_REQ
, "Registration Request" },
145 { M3UA_RKM_RSP
, "Registration Response" },
146 { M3UA_RKM_DEREQ
, "Deregistration Request" },
147 { M3UA_RKM_DERSP
, "Deregistration Response" },
151 /* M3UA Parameters */
152 #define M3UA_PARAM_INFO 0x0004
153 #define M3UA_PARAM_ROUTING_CTX 0x0006
154 #define M3UA_PARAM_DIAGNOSTIC 0x0007
155 #define M3UA_PARAM_HB_DATA 0x0009
156 #define M3UA_PARAM_TRAFFIC_MODE_TYPE 0x000b
157 #define M3UA_PARAM_ERROR_CODE 0x000c
158 #define M3UA_PARAM_STATUS 0x000d
159 #define M3UA_PARAM_ASP_ID 0x0011
160 #define M3UA_PARAM_AFFECTED_POINT_CODE 0x0012
161 #define M3UA_PARAM_CORR_ID 0x0013
163 #define M3UA_PARAM_NETWORK_APPEARANCE 0x0200
164 #define M3UA_PARAM_USER 0x0204
165 #define M3UA_PARAM_CONGESTION_INDICATION 0x0205
166 #define M3UA_PARAM_CONCERNED_DST 0x0206
167 #define M3UA_PARAM_ROUTING_KEY 0x0207
168 #define M3UA_PARAM_REG_RESULT 0x0208
169 #define M3UA_PARAM_DEREG_RESULT 0x0209
170 #define M3UA_PARAM_LOCAL_ROUTING_KEY_ID 0x020a
171 #define M3UA_PARAM_DST_POINT_CODE 0x020b
172 #define M3UA_PARAM_SI 0x020c
173 #define M3UA_PARAM_ORIGIN_POINT_CODE_LIST 0x020e
174 #define M3UA_PARAM_PROTO_DATA 0x0210
175 #define M3UA_PARAM_REG_STATUS 0x0212
176 #define M3UA_PARAM_DEREG_STATUS 0x0213
178 static const struct tok ParamName
[] = {
179 { M3UA_PARAM_INFO
, "INFO String" },
180 { M3UA_PARAM_ROUTING_CTX
, "Routing Context" },
181 { M3UA_PARAM_DIAGNOSTIC
, "Diagnostic Info" },
182 { M3UA_PARAM_HB_DATA
, "Heartbeat Data" },
183 { M3UA_PARAM_TRAFFIC_MODE_TYPE
, "Traffic Mode Type" },
184 { M3UA_PARAM_ERROR_CODE
, "Error Code" },
185 { M3UA_PARAM_STATUS
, "Status" },
186 { M3UA_PARAM_ASP_ID
, "ASP Identifier" },
187 { M3UA_PARAM_AFFECTED_POINT_CODE
, "Affected Point Code" },
188 { M3UA_PARAM_CORR_ID
, "Correlation ID" },
189 { M3UA_PARAM_NETWORK_APPEARANCE
, "Network Appearance" },
190 { M3UA_PARAM_USER
, "User/Cause" },
191 { M3UA_PARAM_CONGESTION_INDICATION
, "Congestion Indications" },
192 { M3UA_PARAM_CONCERNED_DST
, "Concerned Destination" },
193 { M3UA_PARAM_ROUTING_KEY
, "Routing Key" },
194 { M3UA_PARAM_REG_RESULT
, "Registration Result" },
195 { M3UA_PARAM_DEREG_RESULT
, "Deregistration Result" },
196 { M3UA_PARAM_LOCAL_ROUTING_KEY_ID
, "Local Routing Key Identifier" },
197 { M3UA_PARAM_DST_POINT_CODE
, "Destination Point Code" },
198 { M3UA_PARAM_SI
, "Service Indicators" },
199 { M3UA_PARAM_ORIGIN_POINT_CODE_LIST
, "Originating Point Code List" },
200 { M3UA_PARAM_PROTO_DATA
, "Protocol Data" },
201 { M3UA_PARAM_REG_STATUS
, "Registration Status" },
202 { M3UA_PARAM_DEREG_STATUS
, "Deregistration Status" },
207 tag_value_print(netdissect_options
*ndo
,
208 const u_char
*buf
, const u_int16_t tag
, const u_int16_t size
)
211 case M3UA_PARAM_NETWORK_APPEARANCE
:
212 case M3UA_PARAM_ROUTING_CTX
:
213 case M3UA_PARAM_CORR_ID
:
214 ND_PRINT((ndo
, "0x%08x", EXTRACT_32BITS(buf
)));
218 ND_PRINT((ndo
, "(length %u)", size
));
223 m3ua_tags_print(netdissect_options
*ndo
,
224 const u_char
*buf
, const u_int size
)
226 const u_char
*p
= buf
;
228 while (p
< buf
+ size
) {
229 const struct m3ua_param_header
*hdr
= (const struct m3ua_param_header
*) p
;
230 ND_PRINT((ndo
, "\n\t\t\t%s: ", tok2str(ParamName
, "Unknown Parameter (0x%04x)", EXTRACT_16BITS(&hdr
->tag
))));
231 tag_value_print(ndo
, p
+ sizeof(struct m3ua_param_header
), EXTRACT_16BITS(&hdr
->tag
), EXTRACT_16BITS(&hdr
->len
));
232 p
+= EXTRACT_16BITS(&hdr
->len
);
233 align
= (p
- buf
) % 4;
234 p
+= (align
) ? 4 - align
: 0;
239 m3ua_print(netdissect_options
*ndo
,
240 const u_char
*buf
, const u_int size
)
242 const struct m3ua_common_header
*hdr
= (const struct m3ua_common_header
*) buf
;
243 const struct tok
*dict
=
244 hdr
->msg_class
== M3UA_MSGC_MGMT
? MgmtMessages
:
245 hdr
->msg_class
== M3UA_MSGC_TRANSFER
? TransferMessages
:
246 hdr
->msg_class
== M3UA_MSGC_SSNM
? SS7Messages
:
247 hdr
->msg_class
== M3UA_MSGC_ASPSM
? ASPStateMessages
:
248 hdr
->msg_class
== M3UA_MSGC_ASPTM
? ASPTrafficMessages
:
249 hdr
->msg_class
== M3UA_MSGC_RKM
? RoutingKeyMgmtMessages
:
252 ND_PRINT((ndo
, "\n\t\t%s", tok2str(MessageClasses
, "Unknown message class %i", hdr
->msg_class
)));
254 ND_PRINT((ndo
, " %s Message", tok2str(dict
, "Unknown (0x%02x)", hdr
->msg_type
)));
256 if (size
!= EXTRACT_32BITS(&hdr
->len
))
257 ND_PRINT((ndo
, "\n\t\t\t@@@@@@ Corrupted length %u of message @@@@@@", EXTRACT_32BITS(&hdr
->len
)));
259 m3ua_tags_print(ndo
, buf
+ sizeof(struct m3ua_common_header
), EXTRACT_32BITS(&hdr
->len
) - sizeof(struct m3ua_common_header
));