3 * Copyright (C) 2003, Digium
4 * Mark Spencer <markster@digium.com>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #ifndef __PACKET_IAX2_H__
14 #define __PACKET_IAX2_H__
16 #include <epan/tap-voip.h>
17 #include <epan/conversation.h>
19 /* Max version of IAX protocol we support */
20 #define IAX_PROTO_VERSION 2
22 #define IAX_MAX_CALLS 32768
24 #define IAX_FLAG_FULL 0x8000
26 #define IAX_FLAG_RETRANS 0x8000
28 #define IAX_FLAG_SC_LOG 0x80
30 #define IAX_MAX_SHIFT 0x1F
34 #define AST_FRAME_DTMF_END 1 /* A DTMF end event, subclass is the digit */
35 #define AST_FRAME_VOICE 2 /* Voice data, subclass is AST_FORMAT_* */
36 #define AST_FRAME_VIDEO 3 /* Video frame, maybe?? :) */
37 #define AST_FRAME_CONTROL 4 /* A control frame, subclass is AST_CONTROL_* */
38 #define AST_FRAME_NULL 5 /* An empty, useless frame */
39 #define AST_FRAME_IAX 6 /* Inter Aterisk Exchange private frame type */
40 #define AST_FRAME_TEXT 7 /* Text messages */
41 #define AST_FRAME_IMAGE 8 /* Image Frames */
42 #define AST_FRAME_HTML 9 /* HTML Frames */
43 #define AST_FRAME_CNG 10 /* Confort Noise Generation */
44 #define AST_FRAME_MODEM 11 /* Modem-over-IP datastream */
45 #define AST_FRAME_DTMF_BEGIN 12 /* A DTMF begin event, subclass is the digit */
49 /* Subclass for AST_FRAME_IAX */
50 #define IAX_COMMAND_NEW 1
51 #define IAX_COMMAND_PING 2
52 #define IAX_COMMAND_PONG 3
53 #define IAX_COMMAND_ACK 4
54 #define IAX_COMMAND_HANGUP 5
55 #define IAX_COMMAND_REJECT 6
56 #define IAX_COMMAND_ACCEPT 7
57 #define IAX_COMMAND_AUTHREQ 8
58 #define IAX_COMMAND_AUTHREP 9
59 #define IAX_COMMAND_INVAL 10
60 #define IAX_COMMAND_LAGRQ 11
61 #define IAX_COMMAND_LAGRP 12
62 #define IAX_COMMAND_REGREQ 13 /* Registration request */
63 #define IAX_COMMAND_REGAUTH 14 /* Registration authentication required */
64 #define IAX_COMMAND_REGACK 15 /* Registration accepted */
65 #define IAX_COMMAND_REGREJ 16 /* Registration rejected */
66 #define IAX_COMMAND_REGREL 17 /* Force release of registration */
67 #define IAX_COMMAND_VNAK 18 /* If we receive voice before valid first voice frame, send this */
68 #define IAX_COMMAND_DPREQ 19 /* Request status of a dialplan entry */
69 #define IAX_COMMAND_DPREP 20 /* Request status of a dialplan entry */
70 #define IAX_COMMAND_DIAL 21 /* Request a dial on channel brought up TBD */
71 #define IAX_COMMAND_TXREQ 22 /* Transfer Request */
72 #define IAX_COMMAND_TXCNT 23 /* Transfer Connect */
73 #define IAX_COMMAND_TXACC 24 /* Transfer Accepted */
74 #define IAX_COMMAND_TXREADY 25 /* Transfer ready */
75 #define IAX_COMMAND_TXREL 26 /* Transfer release */
76 #define IAX_COMMAND_TXREJ 27 /* Transfer reject */
77 #define IAX_COMMAND_QUELCH 28 /* Stop audio/video transmission */
78 #define IAX_COMMAND_UNQUELCH 29 /* Resume audio/video transmission */
79 #define IAX_COMMAND_POKE 30 /* Like ping, but does not require an open connection */
80 #define IAX_COMMAND_PAGE 31 /* Paging description */
81 #define IAX_COMMAND_MWI 32 /* Stand-alone message waiting indicator */
82 #define IAX_COMMAND_UNSUPPORT 33 /* Unsupported message received */
83 #define IAX_COMMAND_TRANSFER 34 /* Request remote transfer */
84 #define IAX_COMMAND_PROVISION 35 /* Provision device */
85 #define IAX_COMMAND_FWDOWNL 36 /* Download firmware */
86 #define IAX_COMMAND_FWDATA 37 /* Firmware Data */
87 #define IAX_COMMAND_TXMEDIA 38 /* Transfer Media */
88 #define IAX_COMMAND_RTKEY 39 /* Rotate key */
89 #define IAX_COMMAND_CALLTOKEN 40 /* Call token */
91 #define IAX_DEFAULT_REG_EXPIRE 60 /* By default require re-registration once per minute */
93 #define IAX_LINGER_TIMEOUT 10 /* How long to wait before closing bridged call */
95 #define IAX_DEFAULT_PORTNO 4569
97 /* IAX Information elements */
98 #define IAX_IE_CALLED_NUMBER 1 /* Number/extension being called - string */
99 #define IAX_IE_CALLING_NUMBER 2 /* Calling number - string */
100 #define IAX_IE_CALLING_ANI 3 /* Calling number ANI for billing - string */
101 #define IAX_IE_CALLING_NAME 4 /* Name of caller - string */
102 #define IAX_IE_CALLED_CONTEXT 5 /* Context for number - string */
103 #define IAX_IE_USERNAME 6 /* Username (peer or user) for authentication - string */
104 #define IAX_IE_PASSWORD 7 /* Password for authentication - string */
105 #define IAX_IE_CAPABILITY 8 /* Actual codec capability - unsigned int */
106 #define IAX_IE_FORMAT 9 /* Desired codec format - unsigned int */
107 #define IAX_IE_LANGUAGE 10 /* Desired language - string */
108 #define IAX_IE_VERSION 11 /* Protocol version - short */
109 #define IAX_IE_ADSICPE 12 /* CPE ADSI capability - short */
110 #define IAX_IE_DNID 13 /* Originally dialed DNID - string */
111 #define IAX_IE_AUTHMETHODS 14 /* Authentication method(s) - short */
112 #define IAX_IE_CHALLENGE 15 /* Challenge data for MD5/RSA - string */
113 #define IAX_IE_MD5_RESULT 16 /* MD5 challenge result - string */
114 #define IAX_IE_RSA_RESULT 17 /* RSA challenge result - string */
115 #define IAX_IE_APPARENT_ADDR 18 /* Apparent address of peer - struct sockaddr_in */
116 #define IAX_IE_REFRESH 19 /* When to refresh registration - short */
117 #define IAX_IE_DPSTATUS 20 /* Dialplan status - short */
118 #define IAX_IE_CALLNO 21 /* Call number of peer - short */
119 #define IAX_IE_CAUSE 22 /* Cause - string */
120 #define IAX_IE_IAX_UNKNOWN 23 /* Unknown IAX command - byte */
121 #define IAX_IE_MSGCOUNT 24 /* How many messages waiting - short */
122 #define IAX_IE_AUTOANSWER 25 /* Request auto-answering -- none */
123 #define IAX_IE_MUSICONHOLD 26 /* Request musiconhold with QUELCH -- none or string */
124 #define IAX_IE_TRANSFERID 27 /* Transfer Request Identifier -- int */
125 #define IAX_IE_RDNIS 28 /* Referring DNIS -- string */
126 #define IAX_IE_PROVISIONING 29 /* Provisioning info */
127 #define IAX_IE_AESPROVISIONING 30 /* AES Provisioning info */
128 #define IAX_IE_DATETIME 31 /* Date/Time -- unsigned int */
129 #define IAX_IE_DEVICETYPE 32 /* Device Type -- string */
130 #define IAX_IE_SERVICEIDENT 33 /* Service Identifier -- string */
131 #define IAX_IE_FIRMWAREVER 34 /* Firmware revision -- u16 */
132 #define IAX_IE_FWBLOCKDESC 35 /* Firmware block description -- u32 */
133 #define IAX_IE_FWBLOCKDATA 36 /* Firmware block of data -- raw */
134 #define IAX_IE_PROVVER 37 /* Provisioning Version (u32) */
135 #define IAX_IE_CALLINGPRES 38 /* Calling presentation (u8) */
136 #define IAX_IE_CALLINGTON 39 /* Calling type of number (u8) */
137 #define IAX_IE_CALLINGTNS 40 /* Calling transit network select (u16) */
138 #define IAX_IE_SAMPLINGRATE 41 /* Supported sampling rates (u16) */
139 #define IAX_IE_CAUSECODE 42 /* Hangup cause (u8) */
140 #define IAX_IE_ENCRYPTION 43 /* Encryption format (u16) */
141 #define IAX_IE_ENCKEY 44 /* Encryption key (raw) */
142 #define IAX_IE_CODEC_PREFS 45 /* Codec Negotiation */
143 #define IAX_IE_RR_JITTER 46 /* Received jitter (as in RFC1889) u32 */
144 #define IAX_IE_RR_LOSS 47 /* Received loss (high byte loss pct, low 24 bits loss count, as in rfc1889 */
145 #define IAX_IE_RR_PKTS 48 /* Received frames (total frames received) u32 */
146 #define IAX_IE_RR_DELAY 49 /* Max playout delay for received frames (in ms) u16 */
147 #define IAX_IE_RR_DROPPED 50 /* Dropped frames (presumably by jitterbuf) u32 */
148 #define IAX_IE_RR_OOO 51 /* Frames received Out of Order u32 */
149 #define IAX_IE_VARIABLE 52 /* IAX variable transmission */
150 #define IAX_IE_OSPTOKEN 53 /* OSP Token */
151 #define IAX_IE_CALLTOKEN 54 /* Call Token */
152 #define IAX_IE_CAPABILITY2 55 /* Codec capability */
153 #define IAX_IE_FORMAT2 56 /* Desired codec capability */
154 #define IAX_IE_DATAFORMAT 255 /* Data call format -- iax_dataformat_t */
156 /* hangup cause codes */
157 #define AST_CAUSE_UNALLOCATED 1
158 #define AST_CAUSE_NO_ROUTE_TRANSIT_NET 2
159 #define AST_CAUSE_NO_ROUTE_DESTINATION 3
160 #define AST_CAUSE_MISDIALLED_TRUNK_PREFIX 5
161 #define AST_CAUSE_CHANNEL_UNACCEPTABLE 6
162 #define AST_CAUSE_CALL_AWARDED_DELIVERED 7
163 #define AST_CAUSE_PRE_EMPTED 8
164 #define AST_CAUSE_NUMBER_PORTED_NOT_HERE 14
165 #define AST_CAUSE_NORMAL_CLEARING 16
166 #define AST_CAUSE_USER_BUSY 17
167 #define AST_CAUSE_NO_USER_RESPONSE 18
168 #define AST_CAUSE_NO_ANSWER 19
169 #define AST_CAUSE_SUBSCRIBER_ABSENT 20
170 #define AST_CAUSE_CALL_REJECTED 21
171 #define AST_CAUSE_NUMBER_CHANGED 22
172 #define AST_CAUSE_REDIRECTED_TO_NEW_DESTINATION 23
173 #define AST_CAUSE_ANSWERED_ELSEWHERE 26
174 #define AST_CAUSE_DESTINATION_OUT_OF_ORDER 27
175 #define AST_CAUSE_INVALID_NUMBER_FORMAT 28
176 #define AST_CAUSE_FACILITY_REJECTED 29
177 #define AST_CAUSE_RESPONSE_TO_STATUS_ENQUIRY 30
178 #define AST_CAUSE_NORMAL_UNSPECIFIED 31
179 #define AST_CAUSE_NORMAL_CIRCUIT_CONGESTION 34
180 #define AST_CAUSE_NETWORK_OUT_OF_ORDER 38
181 #define AST_CAUSE_NORMAL_TEMPORARY_FAILURE 41
182 #define AST_CAUSE_SWITCH_CONGESTION 42
183 #define AST_CAUSE_ACCESS_INFO_DISCARDED 43
184 #define AST_CAUSE_REQUESTED_CHAN_UNAVAIL 44
185 #define AST_CAUSE_FACILITY_NOT_SUBSCRIBED 50
186 #define AST_CAUSE_OUTGOING_CALL_BARRED 52
187 #define AST_CAUSE_INCOMING_CALL_BARRED 54
188 #define AST_CAUSE_BEARERCAPABILITY_NOTAUTH 57
189 #define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL 58
190 #define AST_CAUSE_BEARERCAPABILITY_NOTIMPL 65
191 #define AST_CAUSE_CHAN_NOT_IMPLEMENTED 66
192 #define AST_CAUSE_FACILITY_NOT_IMPLEMENTED 69
193 #define AST_CAUSE_INVALID_CALL_REFERENCE 81
194 #define AST_CAUSE_INCOMPATIBLE_DESTINATION 88
195 #define AST_CAUSE_INVALID_MSG_UNSPECIFIED 95
196 #define AST_CAUSE_MANDATORY_IE_MISSING 96
197 #define AST_CAUSE_MESSAGE_TYPE_NONEXIST 97
198 #define AST_CAUSE_WRONG_MESSAGE 98
199 #define AST_CAUSE_IE_NONEXIST 99
200 #define AST_CAUSE_INVALID_IE_CONTENTS 100
201 #define AST_CAUSE_WRONG_CALL_STATE 101
202 #define AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE 102
203 #define AST_CAUSE_MANDATORY_IE_LENGTH_ERROR 103
204 #define AST_CAUSE_PROTOCOL_ERROR 111
205 #define AST_CAUSE_INTERWORKING 127
207 #define IAX_AUTH_PLAINTEXT (1 << 0)
208 #define IAX_AUTH_MD5 (1 << 1)
209 #define IAX_AUTH_RSA (1 << 2)
211 #define IAX_META_TRUNK 1 /* Trunk meta-message */
212 #define IAX_META_VIDEO 2 /* Video frame */
214 #define IAX_DPSTATUS_EXISTS (1 << 0)
215 #define IAX_DPSTATUS_CANEXIST (1 << 1)
216 #define IAX_DPSTATUS_NONEXISTANT (1 << 2)
217 #define IAX_DPSTATUS_IGNOREPAT (1 << 14)
218 #define IAX_DPSTATUS_MATCHMORE (1 << 15)
221 IAX2_MINI_VOICE_PACKET
,
223 IAX2_MINI_VIDEO_PACKET
,
227 /* Container for tapping relevant data */
228 typedef struct _iax2_info_t
236 unsigned payload_len
;
237 voip_call_state callState
;
238 const char *messageName
;
239 const char *callingParty
;
240 const char *calledParty
;
241 const uint8_t *payload_data
;
244 /* Container for passing data between dissectors */
245 typedef struct _iax2_dissector_info_t
247 conversation_type ctype
;
249 } iax2_dissector_info_t
;
251 #endif /* __PACKET_IAX2_H__ */