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.
29 #include <tcpdump-stdinc.h>
32 #include "interface.h"
33 #include "addrtoname.h"
36 static const struct tok MgmtMessages
[] = {
37 { M3UA_MGMT_ERROR
, "Error" },
38 { M3UA_MGMT_NOTIFY
, "Notify" },
42 static const struct tok TransferMessages
[] = {
43 { M3UA_TRANSFER_DATA
, "Data" },
47 static const struct tok SS7Messages
[] = {
48 { M3UA_SSNM_DUNA
, "Destination Unavailable" },
49 { M3UA_SSNM_DAVA
, "Destination Available" },
50 { M3UA_SSNM_DAUD
, "Destination State Audit" },
51 { M3UA_SSNM_SCON
, "Signalling Congestion" },
52 { M3UA_SSNM_DUPU
, "Destination User Part Unavailable" },
53 { M3UA_SSNM_DRST
, "Destination Restricted" },
57 static const struct tok ASPStateMessages
[] = {
58 { M3UA_ASP_UP
, "Up" },
59 { M3UA_ASP_DN
, "Down" },
60 { M3UA_ASP_BEAT
, "Heartbeat" },
61 { M3UA_ASP_UP_ACK
, "Up Acknowledgement" },
62 { M3UA_ASP_DN_ACK
, "Down Acknowledgement" },
63 { M3UA_ASP_BEAT_ACK
, "Heartbeat Acknowledgement" },
67 static const struct tok ASPTrafficMessages
[] = {
68 { M3UA_ASP_AC
, "Active" },
69 { M3UA_ASP_IA
, "Inactive" },
70 { M3UA_ASP_AC_ACK
, "Active Acknowledgement" },
71 { M3UA_ASP_IA_ACK
, "Inactive Acknowledgement" },
75 static const struct tok RoutingKeyMgmtMessages
[] = {
76 { M3UA_RKM_REQ
, "Registration Request" },
77 { M3UA_RKM_RSP
, "Registration Response" },
78 { M3UA_RKM_DEREQ
, "Deregistration Request" },
79 { M3UA_RKM_DERSP
, "Deregistration Response" },
83 static const struct tok ParamName
[] = {
84 { M3UA_PARAM_INFO
, "INFO String" },
85 { M3UA_PARAM_ROUTING_CTX
, "Routing Context" },
86 { M3UA_PARAM_DIAGNOSTIC
, "Diagnostic Info" },
87 { M3UA_PARAM_HB_DATA
, "Heartbeat Data" },
88 { M3UA_PARAM_TRAFFIC_MODE_TYPE
, "Traffic Mode Type" },
89 { M3UA_PARAM_ERROR_CODE
, "Error Code" },
90 { M3UA_PARAM_STATUS
, "Status" },
91 { M3UA_PARAM_ASP_ID
, "ASP Identifier" },
92 { M3UA_PARAM_AFFECTED_POINT_CODE
, "Affected Point Code" },
93 { M3UA_PARAM_CORR_ID
, "Correlation ID" },
94 { M3UA_PARAM_NETWORK_APPEARANCE
, "Network Appearance" },
95 { M3UA_PARAM_USER
, "User/Cause" },
96 { M3UA_PARAM_CONGESTION_INDICATION
, "Congestion Indications" },
97 { M3UA_PARAM_CONCERNED_DST
, "Concerned Destination" },
98 { M3UA_PARAM_ROUTING_KEY
, "Routing Key" },
99 { M3UA_PARAM_REG_RESULT
, "Registration Result" },
100 { M3UA_PARAM_DEREG_RESULT
, "Deregistration Result" },
101 { M3UA_PARAM_LOCAL_ROUTING_KEY_ID
, "Local Routing Key Identifier" },
102 { M3UA_PARAM_DST_POINT_CODE
, "Destination Point Code" },
103 { M3UA_PARAM_SI
, "Service Indicators" },
104 { M3UA_PARAM_ORIGIN_POINT_CODE_LIST
, "Originating Point Code List" },
105 { M3UA_PARAM_PROTO_DATA
, "Protocol Data" },
106 { M3UA_PARAM_REG_STATUS
, "Registration Status" },
107 { M3UA_PARAM_DEREG_STATUS
, "Deregistration Status" },
111 static void print_tag_value(const u_char
*buf
, u_int16_t tag
, u_int16_t size
)
114 case M3UA_PARAM_NETWORK_APPEARANCE
:
115 case M3UA_PARAM_ROUTING_CTX
:
116 case M3UA_PARAM_CORR_ID
:
117 printf("0x%08x", EXTRACT_32BITS(buf
));
121 printf("(length %u)", size
);
125 static void print_m3ua_tags(const u_char
*buf
, u_int size
)
127 const u_char
*p
= buf
;
128 while (p
< buf
+ size
) {
129 const struct m3ua_param_header
*hdr
= (const struct m3ua_param_header
*) p
;
130 printf("\n\t\t\t%s: ", tok2str(ParamName
, "Unknown Parameter (0x%04x)", EXTRACT_16BITS(&hdr
->tag
)));
131 print_tag_value(p
+ sizeof(struct m3ua_param_header
), EXTRACT_16BITS(&hdr
->tag
), EXTRACT_16BITS(&hdr
->len
));
132 p
+= EXTRACT_16BITS(&hdr
->len
);
133 int align
= (int) (p
- buf
) % 4;
134 p
+= (align
) ? 4 - align
: 0;
138 void print_m3ua(const u_char
*buf
, u_int size
)
140 const struct m3ua_common_header
*hdr
= (const struct m3ua_common_header
*) buf
;
143 switch (hdr
->msg_class
) {
145 printf("Management %s Message", tok2str(MgmtMessages
, "Unknown (0x%02x)", hdr
->msg_type
));
147 case M3UA_MSGC_TRANSFER
:
148 printf("Transfer %s Message", tok2str(TransferMessages
, "Unknown (0x%02x)", hdr
->msg_type
));
151 printf("SS7 %s Message", tok2str(SS7Messages
, "Unknown (0x%02x)", hdr
->msg_type
));
153 case M3UA_MSGC_ASPSM
:
154 printf("ASP %s Message", tok2str(ASPStateMessages
, "Unknown (0x%02x)", hdr
->msg_type
));
156 case M3UA_MSGC_ASPTM
:
157 printf("ASP %s Message", tok2str(ASPTrafficMessages
, "Unknown (0x%02x)", hdr
->msg_type
));
160 printf("Routing Key Managment %s Message",
161 tok2str(RoutingKeyMgmtMessages
, "Unknown (0x%02x)", hdr
->msg_type
));
164 printf("Unknown message class %i", hdr
->msg_class
);
170 if (size
!= EXTRACT_32BITS(&hdr
->len
))
171 printf("\n\t\t\t@@@@@@ Corrupted length %u of message @@@@@@", EXTRACT_32BITS(&hdr
->len
));
173 print_m3ua_tags(buf
+ sizeof(struct m3ua_common_header
), EXTRACT_32BITS(&hdr
->len
) - sizeof(struct m3ua_common_header
));