Asterisk - The Open Source Telephony Project GIT-master-f36a736
iax2.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Implementation of Inter-Asterisk eXchange
5 *
6 * Copyright (C) 2003, Digium
7 *
8 * Mark Spencer <markster@linux-support.net>
9 *
10 * This program is free software, distributed under the terms of
11 * the GNU General Public License
12 */
13
14/*! \file
15 * \brief
16 *
17 * Implementation of Inter-Asterisk eXchange, version 2
18 * \ref parser.c
19 * \ref parser.h
20 * \ref chan_iax2.c
21 */
22
23#ifndef _IAX2_H
24#define _IAX2_H
25
26/* Max version of IAX protocol we support */
27#define IAX_PROTO_VERSION 2
28
29/* NOTE: It is recommended that IAX_MAX_CALLS be a power of 2, but it is not
30 * required. The maximum number of calls supported by the protocol is 32768.
31 *
32 * For LOW_MEMORY, we use 2049 for compatibility with earlier code because
33 * callno 2048 leaked out when the intended callno range was 2 - 2047. */
34#if defined(LOW_MEMORY)
35#define IAX_MAX_CALLS 2049
36#else
37#define IAX_MAX_CALLS 32768
38#endif
39
40#define IAX_FLAG_FULL 0x8000
41
42#define IAX_FLAG_RETRANS 0x8000
43
44#define IAX_FLAG_SC_LOG 0x80
45
46#define IAX_MAX_SHIFT 0x3F
47
48#define IAX_WINDOW 64
49
50/*! Subclass for AST_FRAME_IAX */
64 /*! Registration request */
66 /*! Registration authentication required */
68 /*! Registration accepted */
70 /*! Registration rejected */
72 /*! Force release of registration */
74 /*! If we receive voice before valid first voice frame, send this */
76 /*! Request status of a dialplan entry */
78 /*! Status reply of a dialplan entry status request */
80 /*! Request a dial on channel brought up TBD */
82 /*! Transfer Request */
84 /*! Transfer Connect */
86 /*! Transfer Accepted */
88 /*! Transfer ready */
90 /*! Transfer release */
92 /*! Transfer reject */
94 /*! Stop audio/video transmission */
96 /*! Resume audio/video transmission */
98 /*! Like ping, but does not require an open connection */
100 /*! Paging description */
102 /*! Stand-alone message waiting indicator */
104 /*! Unsupported message received */
106 /*! Request remote transfer */
108 /*! Provision device */
110 /*! Download firmware */
112 /*! Firmware Data */
114 /*! Transfer media only */
116 /*! Command to rotate key */
118 /*! Call number token */
120};
121
122/*! By default require re-registration once per minute */
123#define IAX_DEFAULT_REG_EXPIRE 60
124
125/*! How long to wait before closing bridged call */
126#define IAX_LINGER_TIMEOUT 10
127
128#define IAX_DEFAULT_PORTNO 4569
129
130/*! IAX Information elements */
131#define IAX_IE_CALLED_NUMBER 1 /*!< Number/extension being called - string */
132#define IAX_IE_CALLING_NUMBER 2 /*!< Calling number - string */
133#define IAX_IE_CALLING_ANI 3 /*!< Calling number ANI for billing - string */
134#define IAX_IE_CALLING_NAME 4 /*!< Name of caller - string */
135#define IAX_IE_CALLED_CONTEXT 5 /*!< Context for number - string */
136#define IAX_IE_USERNAME 6 /*!< Username (peer or user) for authentication - string */
137#define IAX_IE_PASSWORD 7 /*!< Password for authentication - string */
138#define IAX_IE_CAPABILITY 8 /*!< Actual codec capability - unsigned int */
139#define IAX_IE_FORMAT 9 /*!< Desired codec format - unsigned int */
140#define IAX_IE_LANGUAGE 10 /*!< Desired language - string */
141#define IAX_IE_VERSION 11 /*!< Protocol version - short */
142#define IAX_IE_ADSICPE 12 /*!< CPE ADSI capability - short */
143#define IAX_IE_DNID 13 /*!< Originally dialed DNID - string */
144#define IAX_IE_AUTHMETHODS 14 /*!< Authentication method(s) - short */
145#define IAX_IE_CHALLENGE 15 /*!< Challenge data for MD5/RSA - string */
146#define IAX_IE_MD5_RESULT 16 /*!< MD5 challenge result - string */
147#define IAX_IE_RSA_RESULT 17 /*!< RSA challenge result - string */
148#define IAX_IE_APPARENT_ADDR 18 /*!< Apparent address of peer - struct sockaddr_in */
149#define IAX_IE_REFRESH 19 /*!< When to refresh registration - short */
150#define IAX_IE_DPSTATUS 20 /*!< Dialplan status - short */
151#define IAX_IE_CALLNO 21 /*!< Call number of peer - short */
152#define IAX_IE_CAUSE 22 /*!< Cause - string */
153#define IAX_IE_IAX_UNKNOWN 23 /*!< Unknown IAX command - byte */
154#define IAX_IE_MSGCOUNT 24 /*!< How many messages waiting - short */
155#define IAX_IE_AUTOANSWER 25 /*!< Request auto-answering -- none */
156#define IAX_IE_MUSICONHOLD 26 /*!< Request musiconhold with QUELCH -- none or string */
157#define IAX_IE_TRANSFERID 27 /*!< Transfer Request Identifier -- int */
158#define IAX_IE_RDNIS 28 /*!< Referring DNIS -- string */
159#define IAX_IE_PROVISIONING 29 /*!< Provisioning info */
160#define IAX_IE_AESPROVISIONING 30 /*!< AES Provisioning info */
161#define IAX_IE_DATETIME 31 /*!< Date/Time */
162#define IAX_IE_DEVICETYPE 32 /*!< Device Type -- string */
163#define IAX_IE_SERVICEIDENT 33 /*!< Service Identifier -- string */
164#define IAX_IE_FIRMWAREVER 34 /*!< Firmware revision -- u16 */
165#define IAX_IE_FWBLOCKDESC 35 /*!< Firmware block description -- u32 */
166#define IAX_IE_FWBLOCKDATA 36 /*!< Firmware block of data -- raw */
167#define IAX_IE_PROVVER 37 /*!< Provisioning Version (u32) */
168#define IAX_IE_CALLINGPRES 38 /*!< Calling presentation (u8) */
169#define IAX_IE_CALLINGTON 39 /*!< Calling type of number (u8) */
170#define IAX_IE_CALLINGTNS 40 /*!< Calling transit network select (u16) */
171#define IAX_IE_SAMPLINGRATE 41 /*!< Supported sampling rates (u16) */
172#define IAX_IE_CAUSECODE 42 /*!< Hangup cause (u8) */
173#define IAX_IE_ENCRYPTION 43 /*!< Encryption format (u16) */
174#define IAX_IE_ENCKEY 44 /*!< Encryption key (raw) */
175#define IAX_IE_CODEC_PREFS 45 /*!< Codec Negotiation */
176
177#define IAX_IE_RR_JITTER 46 /*!< Received jitter (as in RFC1889) u32 */
178#define IAX_IE_RR_LOSS 47 /*!< Received loss (high byte loss pct, low 24 bits loss count, as in rfc1889 */
179#define IAX_IE_RR_PKTS 48 /*!< Received frames (total frames received) u32 */
180#define IAX_IE_RR_DELAY 49 /*!< Max playout delay for received frames (in ms) u16 */
181#define IAX_IE_RR_DROPPED 50 /*!< Dropped frames (presumably by jitterbuf) u32 */
182#define IAX_IE_RR_OOO 51 /*!< Frames received Out of Order u32 */
183#define IAX_IE_VARIABLE 52 /*!< Remote variables */
184#define IAX_IE_OSPTOKEN 53 /*!< OSP token */
185#define IAX_IE_CALLTOKEN 54 /*!< Call number security token */
186
187#define IAX_IE_CAPABILITY2 55 /*!< Actual codec capability - u8 version + integer array */
188#define IAX_IE_FORMAT2 56 /*!< Desired codec format - u8 version + integer array */
189
190#define IAX_IE_CALLINGANI2 57 /*!< Calling Originating Line Information (ANI2) digits */
191
192#define IAX_MAX_OSPBLOCK_SIZE 254 /*!< Max OSP token block size, 255 bytes - 1 byte OSP token block index */
193#define IAX_MAX_OSPBLOCK_NUM 4
194#define IAX_MAX_OSPTOKEN_SIZE (IAX_MAX_OSPBLOCK_SIZE * IAX_MAX_OSPBLOCK_NUM)
195#define IAX_MAX_OSPBUFF_SIZE (IAX_MAX_OSPTOKEN_SIZE + 16)
196
197#define IAX_AUTH_PLAINTEXT (1 << 0)
198#define IAX_AUTH_MD5 (1 << 1)
199#define IAX_AUTH_RSA (1 << 2)
200
201#define IAX_ENCRYPT_AES128 (1 << 0)
202#define IAX_ENCRYPT_KEYROTATE (1 << 15) /*!< Keyrotation support */
203
204#define IAX_META_TRUNK 1 /*!< Trunk meta-message */
205#define IAX_META_VIDEO 2 /*!< Video frame */
206
207#define IAX_META_TRUNK_SUPERMINI 0 /*!< This trunk frame contains classic supermini frames */
208#define IAX_META_TRUNK_MINI 1 /*!< This trunk frame contains trunked mini frames */
209
210#define IAX_RATE_8KHZ (1 << 0) /*!< 8khz sampling (default if absent) */
211#define IAX_RATE_11KHZ (1 << 1) /*!< 11.025khz sampling */
212#define IAX_RATE_16KHZ (1 << 2) /*!< 16khz sampling */
213#define IAX_RATE_22KHZ (1 << 3) /*!< 22.05khz sampling */
214#define IAX_RATE_44KHZ (1 << 4) /*!< 44.1khz sampling */
215#define IAX_RATE_48KHZ (1 << 5) /*!< 48khz sampling */
216
217#define IAX_DPSTATUS_EXISTS (1 << 0)
218#define IAX_DPSTATUS_CANEXIST (1 << 1)
219#define IAX_DPSTATUS_NONEXISTENT (1 << 2)
220#define IAX_DPSTATUS_IGNOREPAT (1 << 14)
221#define IAX_DPSTATUS_MATCHMORE (1 << 15)
222
223/*! iax2 format bit field for handling codecs the old way */
224typedef int64_t iax2_format;
225
226/*!\brief iax2 wrapper function for ast_getformatname */
227const char *iax2_getformatname(iax2_format format);
228
229/*! Full frames are always delivered reliably */
231 unsigned short scallno; /*!< Source call number -- high bit must be 1 */
232 unsigned short dcallno; /*!< Destination call number -- high bit is 1 if retransmission */
233 unsigned int ts; /*!< 32-bit timestamp in milliseconds (from 1st transmission) */
234 unsigned char oseqno; /*!< Packet number (outgoing) */
235 unsigned char iseqno; /*!< Packet number (next incoming expected) */
236 unsigned char type; /*!< Frame type */
237 unsigned char csub; /*!< Compressed subclass */
238 unsigned char iedata[0];
239} __attribute__ ((__packed__));
240
241/*! Full frames are always delivered reliably */
243 unsigned short scallno; /*!< Source call number -- high bit must be 1 */
244 unsigned short dcallno; /*!< Destination call number -- high bit is 1 if retransmission */
245 unsigned char encdata[0];
246} __attribute__ ((__packed__));
247
248/*! Mini header is used only for voice frames -- delivered unreliably */
250 unsigned short callno; /*!< Source call number -- high bit must be 0, rest must be non-zero */
251 unsigned short ts; /*!< 16-bit Timestamp (high 16 bits from last ast_iax2_full_hdr) */
252 /* Frametype implicitly VOICE_FRAME */
253 /* subclass implicit from last ast_iax2_full_hdr */
254 unsigned char data[0];
255} __attribute__ ((__packed__));
256
257/*! Mini header is used only for voice frames -- delivered unreliably */
259 unsigned short callno; /*!< Source call number -- high bit must be 0, rest must be non-zero */
260 unsigned char encdata[0];
261} __attribute__ ((__packed__));
262
264 unsigned short zeros; /*!< Zeros field -- must be zero */
265 unsigned char metacmd; /*!< Meta command */
266 unsigned char cmddata; /*!< Command Data */
267 unsigned char data[0];
268} __attribute__ ((__packed__));
269
271 unsigned short zeros; /*!< Zeros field -- must be zero */
272 unsigned short callno; /*!< Video call number */
273 unsigned short ts; /*!< Timestamp and mark if present */
274 unsigned char data[0];
275} __attribute__ ((__packed__));
276
278 unsigned int ts; /*!< 32-bit timestamp for all messages */
279 unsigned char data[0];
280} __attribute__ ((__packed__));
281
283 unsigned short callno; /*!< Call number */
284 unsigned short len; /*!< Length of data for this callno */
285} __attribute__ ((__packed__));
286
287/*! When trunktimestamps are used, we use this format instead */
289 unsigned short len;
290 struct ast_iax2_mini_hdr mini; /*!< this is an actual miniframe */
291} __attribute__ ((__packed__));
292
293#define IAX_FIRMWARE_MAGIC 0x69617879
294
296 unsigned int magic; /*!< Magic number */
297 unsigned short version; /*!< Software version */
298 unsigned char devname[16]; /*!< Device */
299 unsigned int datalen; /*!< Data length of file beyond header */
300 unsigned char chksum[16]; /*!< Checksum of all data */
301 unsigned char data[0];
302} __attribute__ ((__packed__));
303#endif
iax_frame_subclass
Definition: iax2.h:51
@ IAX_COMMAND_MWI
Definition: iax2.h:103
@ IAX_COMMAND_FWDOWNL
Definition: iax2.h:111
@ IAX_COMMAND_TXREL
Definition: iax2.h:91
@ IAX_COMMAND_TXMEDIA
Definition: iax2.h:115
@ IAX_COMMAND_AUTHREP
Definition: iax2.h:60
@ IAX_COMMAND_PROVISION
Definition: iax2.h:109
@ IAX_COMMAND_DPREP
Definition: iax2.h:79
@ IAX_COMMAND_REGAUTH
Definition: iax2.h:67
@ IAX_COMMAND_INVAL
Definition: iax2.h:61
@ IAX_COMMAND_REJECT
Definition: iax2.h:57
@ IAX_COMMAND_FWDATA
Definition: iax2.h:113
@ IAX_COMMAND_ACK
Definition: iax2.h:55
@ IAX_COMMAND_PONG
Definition: iax2.h:54
@ IAX_COMMAND_LAGRQ
Definition: iax2.h:62
@ IAX_COMMAND_HANGUP
Definition: iax2.h:56
@ IAX_COMMAND_TXREADY
Definition: iax2.h:89
@ IAX_COMMAND_TXACC
Definition: iax2.h:87
@ IAX_COMMAND_QUELCH
Definition: iax2.h:95
@ IAX_COMMAND_PING
Definition: iax2.h:53
@ IAX_COMMAND_TRANSFER
Definition: iax2.h:107
@ IAX_COMMAND_LAGRP
Definition: iax2.h:63
@ IAX_COMMAND_TXCNT
Definition: iax2.h:85
@ IAX_COMMAND_REGACK
Definition: iax2.h:69
@ IAX_COMMAND_AUTHREQ
Definition: iax2.h:59
@ IAX_COMMAND_TXREJ
Definition: iax2.h:93
@ IAX_COMMAND_REGREJ
Definition: iax2.h:71
@ IAX_COMMAND_REGREL
Definition: iax2.h:73
@ IAX_COMMAND_CALLTOKEN
Definition: iax2.h:119
@ IAX_COMMAND_DIAL
Definition: iax2.h:81
@ IAX_COMMAND_ACCEPT
Definition: iax2.h:58
@ IAX_COMMAND_UNSUPPORT
Definition: iax2.h:105
@ IAX_COMMAND_NEW
Definition: iax2.h:52
@ IAX_COMMAND_POKE
Definition: iax2.h:99
@ IAX_COMMAND_PAGE
Definition: iax2.h:101
@ IAX_COMMAND_REGREQ
Definition: iax2.h:65
@ IAX_COMMAND_VNAK
Definition: iax2.h:75
@ IAX_COMMAND_UNQUELCH
Definition: iax2.h:97
@ IAX_COMMAND_TXREQ
Definition: iax2.h:83
@ IAX_COMMAND_RTKEY
Definition: iax2.h:117
@ IAX_COMMAND_DPREQ
Definition: iax2.h:77
int64_t iax2_format
Definition: iax2.h:224
const char * iax2_getformatname(iax2_format format)
iax2 wrapper function for ast_getformatname
Definition: chan_iax2.c:1950
unsigned short version
Definition: iax2.h:297
unsigned char devname[16]
Definition: iax2.h:298
unsigned int magic
Definition: iax2.h:296
unsigned int datalen
Definition: iax2.h:299
unsigned char chksum[16]
Definition: iax2.h:300
unsigned char data[0]
Definition: iax2.h:301
unsigned short dcallno
Definition: iax2.h:244
unsigned short scallno
Definition: iax2.h:243
unsigned char encdata[0]
Definition: iax2.h:245
unsigned char iedata[0]
Definition: iax2.h:238
unsigned short dcallno
Definition: iax2.h:232
unsigned short scallno
Definition: iax2.h:231
unsigned int ts
Definition: iax2.h:233
unsigned char iseqno
Definition: iax2.h:235
unsigned char csub
Definition: iax2.h:237
unsigned char oseqno
Definition: iax2.h:234
unsigned char type
Definition: iax2.h:236
unsigned short zeros
Definition: iax2.h:264
unsigned char cmddata
Definition: iax2.h:266
unsigned char metacmd
Definition: iax2.h:265
unsigned char data[0]
Definition: iax2.h:267
Definition: iax2.h:282
unsigned short callno
Definition: iax2.h:283
unsigned short len
Definition: iax2.h:284
unsigned int ts
Definition: iax2.h:278
unsigned char data[0]
Definition: iax2.h:279
unsigned short len
Definition: iax2.h:289
struct ast_iax2_mini_hdr mini
Definition: iax2.h:290
unsigned short callno
Definition: iax2.h:259
unsigned char encdata[0]
Definition: iax2.h:260
unsigned short callno
Definition: iax2.h:250
unsigned short ts
Definition: iax2.h:251
unsigned char data[0]
Definition: iax2.h:254
unsigned short zeros
Definition: iax2.h:271
unsigned short callno
Definition: iax2.h:272
unsigned short ts
Definition: iax2.h:273
unsigned char data[0]
Definition: iax2.h:274