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 #include <sys/cdefs.h>
27 __RCSID("$NetBSD: print-m3ua.c,v 1.2 2014/11/20 03:05:03 christos Exp $");
30 #define NETDISSECT_REWORKED
35 #include <tcpdump-stdinc.h>
37 #include "interface.h"
40 static const char tstr
[] = " [|m3ua]";
41 static const char cstr
[] = " (corrupt)";
45 #define M3UA_REL_1_0 1
47 struct m3ua_common_header
{
55 struct m3ua_param_header
{
61 #define M3UA_MSGC_MGMT 0
62 #define M3UA_MSGC_TRANSFER 1
63 #define M3UA_MSGC_SSNM 2
64 #define M3UA_MSGC_ASPSM 3
65 #define M3UA_MSGC_ASPTM 4
67 #define M3UA_MSGC_RKM 9
69 static const struct tok MessageClasses
[] = {
70 { M3UA_MSGC_MGMT
, "Management" },
71 { M3UA_MSGC_TRANSFER
, "Transfer" },
72 { M3UA_MSGC_SSNM
, "SS7" },
73 { M3UA_MSGC_ASPSM
, "ASP" },
74 { M3UA_MSGC_ASPTM
, "ASP" },
75 { M3UA_MSGC_RKM
, "Routing Key Managment" },
79 /* management messages */
80 #define M3UA_MGMT_ERROR 0
81 #define M3UA_MGMT_NOTIFY 1
83 static const struct tok MgmtMessages
[] = {
84 { M3UA_MGMT_ERROR
, "Error" },
85 { M3UA_MGMT_NOTIFY
, "Notify" },
89 /* transfer messages */
90 #define M3UA_TRANSFER_DATA 1
92 static const struct tok TransferMessages
[] = {
93 { M3UA_TRANSFER_DATA
, "Data" },
97 /* SS7 Signaling Network Management messages */
98 #define M3UA_SSNM_DUNA 1
99 #define M3UA_SSNM_DAVA 2
100 #define M3UA_SSNM_DAUD 3
101 #define M3UA_SSNM_SCON 4
102 #define M3UA_SSNM_DUPU 5
103 #define M3UA_SSNM_DRST 6
105 static const struct tok SS7Messages
[] = {
106 { M3UA_SSNM_DUNA
, "Destination Unavailable" },
107 { M3UA_SSNM_DAVA
, "Destination Available" },
108 { M3UA_SSNM_DAUD
, "Destination State Audit" },
109 { M3UA_SSNM_SCON
, "Signalling Congestion" },
110 { M3UA_SSNM_DUPU
, "Destination User Part Unavailable" },
111 { M3UA_SSNM_DRST
, "Destination Restricted" },
115 /* ASP State Maintenance messages */
116 #define M3UA_ASP_UP 1
117 #define M3UA_ASP_DN 2
118 #define M3UA_ASP_BEAT 3
119 #define M3UA_ASP_UP_ACK 4
120 #define M3UA_ASP_DN_ACK 5
121 #define M3UA_ASP_BEAT_ACK 6
123 static const struct tok ASPStateMessages
[] = {
124 { M3UA_ASP_UP
, "Up" },
125 { M3UA_ASP_DN
, "Down" },
126 { M3UA_ASP_BEAT
, "Heartbeat" },
127 { M3UA_ASP_UP_ACK
, "Up Acknowledgement" },
128 { M3UA_ASP_DN_ACK
, "Down Acknowledgement" },
129 { M3UA_ASP_BEAT_ACK
, "Heartbeat Acknowledgement" },
133 /* ASP Traffic Maintenance messages */
134 #define M3UA_ASP_AC 1
135 #define M3UA_ASP_IA 2
136 #define M3UA_ASP_AC_ACK 3
137 #define M3UA_ASP_IA_ACK 4
139 static const struct tok ASPTrafficMessages
[] = {
140 { M3UA_ASP_AC
, "Active" },
141 { M3UA_ASP_IA
, "Inactive" },
142 { M3UA_ASP_AC_ACK
, "Active Acknowledgement" },
143 { M3UA_ASP_IA_ACK
, "Inactive Acknowledgement" },
147 /* Routing Key Management messages */
148 #define M3UA_RKM_REQ 1
149 #define M3UA_RKM_RSP 2
150 #define M3UA_RKM_DEREQ 3
151 #define M3UA_RKM_DERSP 4
153 static const struct tok RoutingKeyMgmtMessages
[] = {
154 { M3UA_RKM_REQ
, "Registration Request" },
155 { M3UA_RKM_RSP
, "Registration Response" },
156 { M3UA_RKM_DEREQ
, "Deregistration Request" },
157 { M3UA_RKM_DERSP
, "Deregistration Response" },
161 /* M3UA Parameters */
162 #define M3UA_PARAM_INFO 0x0004
163 #define M3UA_PARAM_ROUTING_CTX 0x0006
164 #define M3UA_PARAM_DIAGNOSTIC 0x0007
165 #define M3UA_PARAM_HB_DATA 0x0009
166 #define M3UA_PARAM_TRAFFIC_MODE_TYPE 0x000b
167 #define M3UA_PARAM_ERROR_CODE 0x000c
168 #define M3UA_PARAM_STATUS 0x000d
169 #define M3UA_PARAM_ASP_ID 0x0011
170 #define M3UA_PARAM_AFFECTED_POINT_CODE 0x0012
171 #define M3UA_PARAM_CORR_ID 0x0013
173 #define M3UA_PARAM_NETWORK_APPEARANCE 0x0200
174 #define M3UA_PARAM_USER 0x0204
175 #define M3UA_PARAM_CONGESTION_INDICATION 0x0205
176 #define M3UA_PARAM_CONCERNED_DST 0x0206
177 #define M3UA_PARAM_ROUTING_KEY 0x0207
178 #define M3UA_PARAM_REG_RESULT 0x0208
179 #define M3UA_PARAM_DEREG_RESULT 0x0209
180 #define M3UA_PARAM_LOCAL_ROUTING_KEY_ID 0x020a
181 #define M3UA_PARAM_DST_POINT_CODE 0x020b
182 #define M3UA_PARAM_SI 0x020c
183 #define M3UA_PARAM_ORIGIN_POINT_CODE_LIST 0x020e
184 #define M3UA_PARAM_PROTO_DATA 0x0210
185 #define M3UA_PARAM_REG_STATUS 0x0212
186 #define M3UA_PARAM_DEREG_STATUS 0x0213
188 static const struct tok ParamName
[] = {
189 { M3UA_PARAM_INFO
, "INFO String" },
190 { M3UA_PARAM_ROUTING_CTX
, "Routing Context" },
191 { M3UA_PARAM_DIAGNOSTIC
, "Diagnostic Info" },
192 { M3UA_PARAM_HB_DATA
, "Heartbeat Data" },
193 { M3UA_PARAM_TRAFFIC_MODE_TYPE
, "Traffic Mode Type" },
194 { M3UA_PARAM_ERROR_CODE
, "Error Code" },
195 { M3UA_PARAM_STATUS
, "Status" },
196 { M3UA_PARAM_ASP_ID
, "ASP Identifier" },
197 { M3UA_PARAM_AFFECTED_POINT_CODE
, "Affected Point Code" },
198 { M3UA_PARAM_CORR_ID
, "Correlation ID" },
199 { M3UA_PARAM_NETWORK_APPEARANCE
, "Network Appearance" },
200 { M3UA_PARAM_USER
, "User/Cause" },
201 { M3UA_PARAM_CONGESTION_INDICATION
, "Congestion Indications" },
202 { M3UA_PARAM_CONCERNED_DST
, "Concerned Destination" },
203 { M3UA_PARAM_ROUTING_KEY
, "Routing Key" },
204 { M3UA_PARAM_REG_RESULT
, "Registration Result" },
205 { M3UA_PARAM_DEREG_RESULT
, "Deregistration Result" },
206 { M3UA_PARAM_LOCAL_ROUTING_KEY_ID
, "Local Routing Key Identifier" },
207 { M3UA_PARAM_DST_POINT_CODE
, "Destination Point Code" },
208 { M3UA_PARAM_SI
, "Service Indicators" },
209 { M3UA_PARAM_ORIGIN_POINT_CODE_LIST
, "Originating Point Code List" },
210 { M3UA_PARAM_PROTO_DATA
, "Protocol Data" },
211 { M3UA_PARAM_REG_STATUS
, "Registration Status" },
212 { M3UA_PARAM_DEREG_STATUS
, "Deregistration Status" },
217 tag_value_print(netdissect_options
*ndo
,
218 const u_char
*buf
, const uint16_t tag
, const uint16_t size
)
221 case M3UA_PARAM_NETWORK_APPEARANCE
:
222 case M3UA_PARAM_ROUTING_CTX
:
223 case M3UA_PARAM_CORR_ID
:
224 /* buf and size don't include the header */
227 ND_TCHECK2(*buf
, size
);
228 ND_PRINT((ndo
, "0x%08x", EXTRACT_32BITS(buf
)));
232 ND_PRINT((ndo
, "(length %u)", size
+ (u_int
)sizeof(struct m3ua_param_header
)));
233 ND_TCHECK2(*buf
, size
);
238 ND_PRINT((ndo
, "%s", cstr
));
239 ND_TCHECK2(*buf
, size
);
242 ND_PRINT((ndo
, "%s", tstr
));
247 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
248 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
249 * | Parameter Tag | Parameter Length |
250 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
252 * / Parameter Value /
254 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
257 m3ua_tags_print(netdissect_options
*ndo
,
258 const u_char
*buf
, const u_int size
)
260 const u_char
*p
= buf
;
265 while (p
< buf
+ size
) {
266 if (p
+ sizeof(struct m3ua_param_header
) > buf
+ size
)
268 ND_TCHECK2(*p
, sizeof(struct m3ua_param_header
));
270 hdr_tag
= EXTRACT_16BITS(p
);
271 ND_PRINT((ndo
, "\n\t\t\t%s: ", tok2str(ParamName
, "Unknown Parameter (0x%04x)", hdr_tag
)));
272 /* Parameter Length */
273 hdr_len
= EXTRACT_16BITS(p
+ 2);
274 if (hdr_len
< sizeof(struct m3ua_param_header
))
276 /* Parameter Value */
277 align
= (p
+ hdr_len
- buf
) % 4;
278 align
= align
? 4 - align
: 0;
279 ND_TCHECK2(*p
, hdr_len
+ align
);
280 tag_value_print(ndo
, p
, hdr_tag
, hdr_len
- sizeof(struct m3ua_param_header
));
281 p
+= hdr_len
+ align
;
286 ND_PRINT((ndo
, "%s", cstr
));
287 ND_TCHECK2(*buf
, size
);
290 ND_PRINT((ndo
, "%s", tstr
));
295 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
296 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
297 * | Version | Reserved | Message Class | Message Type |
298 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
300 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
305 m3ua_print(netdissect_options
*ndo
,
306 const u_char
*buf
, const u_int size
)
308 const struct m3ua_common_header
*hdr
= (const struct m3ua_common_header
*) buf
;
309 const struct tok
*dict
;
311 /* size includes the header */
312 if (size
< sizeof(struct m3ua_common_header
))
315 if (hdr
->v
!= M3UA_REL_1_0
)
319 hdr
->msg_class
== M3UA_MSGC_MGMT
? MgmtMessages
:
320 hdr
->msg_class
== M3UA_MSGC_TRANSFER
? TransferMessages
:
321 hdr
->msg_class
== M3UA_MSGC_SSNM
? SS7Messages
:
322 hdr
->msg_class
== M3UA_MSGC_ASPSM
? ASPStateMessages
:
323 hdr
->msg_class
== M3UA_MSGC_ASPTM
? ASPTrafficMessages
:
324 hdr
->msg_class
== M3UA_MSGC_RKM
? RoutingKeyMgmtMessages
:
327 ND_PRINT((ndo
, "\n\t\t%s", tok2str(MessageClasses
, "Unknown message class %i", hdr
->msg_class
)));
329 ND_PRINT((ndo
, " %s Message", tok2str(dict
, "Unknown (0x%02x)", hdr
->msg_type
)));
331 if (size
!= EXTRACT_32BITS(&hdr
->len
))
332 ND_PRINT((ndo
, "\n\t\t\t@@@@@@ Corrupted length %u of message @@@@@@", EXTRACT_32BITS(&hdr
->len
)));
334 m3ua_tags_print(ndo
, buf
+ sizeof(struct m3ua_common_header
), EXTRACT_32BITS(&hdr
->len
) - sizeof(struct m3ua_common_header
));
338 ND_PRINT((ndo
, "%s", cstr
));
339 ND_TCHECK2(*buf
, size
);
342 ND_PRINT((ndo
, "%s", tstr
));