2 * Asterisk -- A telephony toolkit for Linux.
4 * Implementation of Inter-Asterisk eXchange
6 * Copyright (C) 2003, Digium
8 * Mark Spencer <markster@digium.com>
10 * This program is free software, distributed under the terms of
11 * the GNU General Public License
15 * \brief Implementation of the IAX2 protocol
18 #ifndef _IAX2_PARSER_H
19 #define _IAX2_PARSER_H
21 #include "asterisk/linkedlists.h"
34 unsigned int capability
;
39 unsigned short adsicpe
;
42 unsigned int authmethods
;
43 unsigned int encmethods
;
47 struct sockaddr_in
*apparent_addr
;
48 unsigned short refresh
;
49 unsigned short dpstatus
;
50 unsigned short callno
;
52 unsigned char causecode
;
53 unsigned char iax_unknown
;
57 unsigned int transferid
;
58 unsigned int datetime
;
63 unsigned char *fwdata
;
64 unsigned char fwdatalen
;
65 unsigned char *enckey
;
66 unsigned char enckeylen
;
68 unsigned short samprate
;
70 unsigned int rr_jitter
;
73 unsigned short rr_delay
;
74 unsigned int rr_dropped
;
78 #define DIRECTION_INGRESS 1
79 #define DIRECTION_OUTGRESS 2
83 struct iax_session
*session
;
84 struct iax_event
*event
;
89 /* /Our/ call number */
90 unsigned short callno
;
91 /* /Their/ call number */
92 unsigned short dcallno
;
93 /* Start of raw frame (outgoing only) */
95 /* Length of frame (outgoing only) */
97 /* How many retries so far? */
99 /* Outgoing relative timestamp (ms) */
101 /* How long to wait before retrying */
103 /* Are we received out of order? */
104 unsigned int outoforder
:1;
105 /* Have we been sent at all yet? */
106 unsigned int sentyet
:1;
107 /* Non-zero if should be sent to transfer peer */
108 unsigned int transfer
:1;
109 /* Non-zero if this is the final message */
110 unsigned int final
:1;
111 /* Ingress or outgres */
112 unsigned int direction
:2;
113 /* Can this frame be cached? */
114 unsigned int cacheable
:1;
115 /* Outgoing Packet sequence number */
117 /* Next expected incoming packet sequence number */
119 /* Retransmission ID */
122 AST_LIST_ENTRY(iax_frame
) list
;
123 /* Actual, isolated frame header */
125 /*! Amount of space _allocated_ for data */
127 unsigned char unused
[AST_FRIENDLY_OFFSET
];
128 unsigned char afdata
[0]; /* Data for frame */
132 unsigned char buf
[1024];
136 /* Choose a different function for output */
137 void iax_set_output(void (*output
)(const char *data
));
138 /* Choose a different function for errors */
139 void iax_set_error(void (*output
)(const char *data
));
140 void iax_showframe(struct iax_frame
*f
, struct ast_iax2_full_hdr
*fhi
, int rx
, struct sockaddr_in
*sin
, int datalen
);
142 const char *iax_ie2str(int ie
);
144 int iax_ie_append_raw(struct iax_ie_data
*ied
, unsigned char ie
, const void *data
, int datalen
);
145 int iax_ie_append_addr(struct iax_ie_data
*ied
, unsigned char ie
, const struct sockaddr_in
*sin
);
146 int iax_ie_append_int(struct iax_ie_data
*ied
, unsigned char ie
, unsigned int value
);
147 int iax_ie_append_short(struct iax_ie_data
*ied
, unsigned char ie
, unsigned short value
);
148 int iax_ie_append_str(struct iax_ie_data
*ied
, unsigned char ie
, const char *str
);
149 int iax_ie_append_byte(struct iax_ie_data
*ied
, unsigned char ie
, unsigned char dat
);
150 int iax_ie_append(struct iax_ie_data
*ied
, unsigned char ie
);
151 int iax_parse_ies(struct iax_ies
*ies
, unsigned char *data
, int datalen
);
153 int iax_get_frames(void);
154 int iax_get_iframes(void);
155 int iax_get_oframes(void);
157 void iax_frame_wrap(struct iax_frame
*fr
, struct ast_frame
*f
);
158 struct iax_frame
*iax_frame_new(int direction
, int datalen
, unsigned int cacheable
);
159 void iax_frame_free(struct iax_frame
*fr
);