2 * Asterisk -- A telephony toolkit for Linux.
4 * Implementation of Inter-Asterisk eXchange
6 * Copyright (C) 2003, Digium
8 * Mark Spencer <markster@linux-support.net>
10 * This program is free software, distributed under the terms of
11 * the GNU General Public License
14 #ifndef _IAX2_PARSER_H
15 #define _IAX2_PARSER_H
25 unsigned int capability;
29 unsigned short adsicpe;
31 unsigned int authmethods;
35 struct sockaddr_in *apparent_addr;
36 unsigned short refresh;
37 unsigned short dpstatus;
38 unsigned short callno;
40 unsigned char iax_unknown;
46 #define DIRECTION_INGRESS 1
47 #define DIRECTION_OUTGRESS 2
49 struct ast_iax2_frame {
50 /* /Our/ call number */
51 unsigned short callno;
52 /* /Their/ call number */
53 unsigned short dcallno;
54 /* Start of raw frame (outgoing only) */
56 /* Length of frame (outgoing only) */
58 /* How many retries so far? */
60 /* Outgoing relative timestamp (ms) */
62 /* How long to wait before retrying */
64 /* Are we received out of order? */
66 /* Have we been sent at all yet? */
68 /* Outgoing Packet sequence number */
70 /* Next expected incoming packet sequence number */
72 /* Non-zero if should be sent to transfer peer */
74 /* Non-zero if this is the final message */
76 /* Ingress or outgres */
78 /* Retransmission ID */
81 struct ast_iax2_frame *next;
82 struct ast_iax2_frame *prev;
83 /* Actual, isolated frame header */
85 unsigned char unused[AST_FRIENDLY_OFFSET];
86 unsigned char afdata[0]; /* Data for frame */
90 unsigned char buf[1024];
94 /* Choose a different function for output */
95 extern void iax_set_output(void (*output)(const char *data));
96 /* Choose a different function for errors */
97 extern void iax_set_error(void (*output)(const char *data));
98 extern void iax_showframe(struct ast_iax2_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen);
100 extern const char *iax_ie2str(int ie);
102 extern int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, void *data, int datalen);
103 extern int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, struct sockaddr_in *sin);
104 extern int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value);
105 extern int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value);
106 extern int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, unsigned char *str);
107 extern int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat);
108 extern int iax_ie_append(struct iax_ie_data *ied, unsigned char ie);
109 extern int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen);