| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Asterisk -- A telephony toolkit for Linux. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Implementation of Inter-Asterisk eXchange | 
					
						
							|  |  |  |  *  | 
					
						
							|  |  |  |  * Copyright (C) 2003, Digium | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2004-10-02 01:56:08 +00:00
										 |  |  |  * Mark Spencer <markster@digium.com> | 
					
						
							| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is free software, distributed under the terms of | 
					
						
							|  |  |  |  * the GNU General Public License | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2005-10-26 13:03:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*!\file
 | 
					
						
							|  |  |  |  * \brief Implementation of the IAX2 protocol | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  |   | 
					
						
							|  |  |  | #ifndef _IAX2_PARSER_H
 | 
					
						
							|  |  |  | #define _IAX2_PARSER_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct iax_ies { | 
					
						
							|  |  |  | 	char *called_number; | 
					
						
							|  |  |  | 	char *calling_number; | 
					
						
							|  |  |  | 	char *calling_ani; | 
					
						
							|  |  |  | 	char *calling_name; | 
					
						
							| 
									
										
										
										
											2004-10-02 01:56:08 +00:00
										 |  |  | 	int calling_ton; | 
					
						
							|  |  |  | 	int calling_tns; | 
					
						
							|  |  |  | 	int calling_pres; | 
					
						
							| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  | 	char *called_context; | 
					
						
							|  |  |  | 	char *username; | 
					
						
							|  |  |  | 	char *password; | 
					
						
							|  |  |  | 	unsigned int capability; | 
					
						
							|  |  |  | 	unsigned int format; | 
					
						
							| 
									
										
										
										
											2005-01-09 10:32:53 +00:00
										 |  |  | 	char *codec_prefs; | 
					
						
							| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  | 	char *language; | 
					
						
							|  |  |  | 	int version; | 
					
						
							|  |  |  | 	unsigned short adsicpe; | 
					
						
							|  |  |  | 	char *dnid; | 
					
						
							| 
									
										
										
										
											2003-05-14 05:33:06 +00:00
										 |  |  | 	char *rdnis; | 
					
						
							| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  | 	unsigned int authmethods; | 
					
						
							| 
									
										
										
										
											2004-12-29 23:02:21 +00:00
										 |  |  | 	unsigned int encmethods; | 
					
						
							| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  | 	char *challenge; | 
					
						
							|  |  |  | 	char *md5_result; | 
					
						
							|  |  |  | 	char *rsa_result; | 
					
						
							|  |  |  | 	struct sockaddr_in *apparent_addr; | 
					
						
							|  |  |  | 	unsigned short refresh; | 
					
						
							|  |  |  | 	unsigned short dpstatus; | 
					
						
							|  |  |  | 	unsigned short callno; | 
					
						
							|  |  |  | 	char *cause; | 
					
						
							| 
									
										
										
										
											2004-12-26 22:33:25 +00:00
										 |  |  | 	unsigned char causecode; | 
					
						
							| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  | 	unsigned char iax_unknown; | 
					
						
							|  |  |  | 	int msgcount; | 
					
						
							|  |  |  | 	int autoanswer; | 
					
						
							|  |  |  | 	int musiconhold; | 
					
						
							| 
									
										
										
										
											2003-03-20 05:56:00 +00:00
										 |  |  | 	unsigned int transferid; | 
					
						
							| 
									
										
										
										
											2003-10-01 22:59:06 +00:00
										 |  |  | 	unsigned int datetime; | 
					
						
							| 
									
										
										
										
											2004-02-24 21:27:16 +00:00
										 |  |  | 	char *devicetype; | 
					
						
							|  |  |  | 	char *serviceident; | 
					
						
							|  |  |  | 	int firmwarever; | 
					
						
							|  |  |  | 	unsigned int fwdesc; | 
					
						
							|  |  |  | 	unsigned char *fwdata; | 
					
						
							|  |  |  | 	unsigned char fwdatalen; | 
					
						
							| 
									
										
										
										
											2004-12-29 23:02:21 +00:00
										 |  |  | 	unsigned char *enckey; | 
					
						
							|  |  |  | 	unsigned char enckeylen; | 
					
						
							| 
									
										
										
										
											2004-05-25 04:34:43 +00:00
										 |  |  | 	unsigned int provver; | 
					
						
							| 
									
										
										
										
											2004-11-19 21:52:25 +00:00
										 |  |  | 	unsigned short samprate; | 
					
						
							| 
									
										
										
										
											2004-07-07 09:34:01 +00:00
										 |  |  | 	int provverpres; | 
					
						
							| 
									
										
										
										
											2005-02-12 18:52:14 +00:00
										 |  |  | 	unsigned int rr_jitter; | 
					
						
							|  |  |  | 	unsigned int rr_loss; | 
					
						
							|  |  |  | 	unsigned int rr_pkts; | 
					
						
							|  |  |  | 	unsigned short rr_delay; | 
					
						
							|  |  |  | 	unsigned int rr_dropped; | 
					
						
							|  |  |  | 	unsigned int rr_ooo; | 
					
						
							| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define DIRECTION_INGRESS 1
 | 
					
						
							|  |  |  | #define DIRECTION_OUTGRESS 2
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-04-19 18:12:41 +00:00
										 |  |  | struct iax_frame { | 
					
						
							|  |  |  | #ifdef LIBIAX
 | 
					
						
							|  |  |  | 	struct iax_session *session; | 
					
						
							|  |  |  | 	struct iax_event *event; | 
					
						
							| 
									
										
										
										
											2005-01-11 17:08:52 +00:00
										 |  |  | #else
 | 
					
						
							|  |  |  | 	int sockfd; | 
					
						
							| 
									
										
										
										
											2003-04-19 18:12:41 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  | 	/* /Our/ call number */ | 
					
						
							|  |  |  | 	unsigned short callno; | 
					
						
							|  |  |  | 	/* /Their/ call number */ | 
					
						
							|  |  |  | 	unsigned short dcallno; | 
					
						
							|  |  |  | 	/* Start of raw frame (outgoing only) */ | 
					
						
							|  |  |  | 	void *data; | 
					
						
							|  |  |  | 	/* Length of frame (outgoing only) */ | 
					
						
							|  |  |  | 	int datalen; | 
					
						
							|  |  |  | 	/* How many retries so far? */ | 
					
						
							|  |  |  | 	int retries; | 
					
						
							|  |  |  | 	/* Outgoing relative timestamp (ms) */ | 
					
						
							|  |  |  | 	unsigned int ts; | 
					
						
							|  |  |  | 	/* How long to wait before retrying */ | 
					
						
							|  |  |  | 	int retrytime; | 
					
						
							|  |  |  | 	/* Are we received out of order?  */ | 
					
						
							|  |  |  | 	int outoforder; | 
					
						
							|  |  |  | 	/* Have we been sent at all yet? */ | 
					
						
							|  |  |  | 	int sentyet; | 
					
						
							|  |  |  | 	/* Outgoing Packet sequence number */ | 
					
						
							|  |  |  | 	int oseqno; | 
					
						
							|  |  |  | 	/* Next expected incoming packet sequence number */ | 
					
						
							|  |  |  | 	int iseqno; | 
					
						
							|  |  |  | 	/* Non-zero if should be sent to transfer peer */ | 
					
						
							|  |  |  | 	int transfer; | 
					
						
							|  |  |  | 	/* Non-zero if this is the final message */ | 
					
						
							|  |  |  | 	int final; | 
					
						
							|  |  |  | 	/* Ingress or outgres */ | 
					
						
							|  |  |  | 	int direction; | 
					
						
							|  |  |  | 	/* Retransmission ID */ | 
					
						
							|  |  |  | 	int retrans; | 
					
						
							|  |  |  | 	/* Easy linking */ | 
					
						
							| 
									
										
										
										
											2003-04-19 18:12:41 +00:00
										 |  |  | 	struct iax_frame *next; | 
					
						
							|  |  |  | 	struct iax_frame *prev; | 
					
						
							| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  | 	/* Actual, isolated frame header */ | 
					
						
							|  |  |  | 	struct ast_frame af; | 
					
						
							|  |  |  | 	unsigned char unused[AST_FRIENDLY_OFFSET]; | 
					
						
							|  |  |  | 	unsigned char afdata[0];	/* Data for frame */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct iax_ie_data { | 
					
						
							|  |  |  | 	unsigned char buf[1024]; | 
					
						
							|  |  |  | 	int pos; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Choose a different function for output */ | 
					
						
							|  |  |  | extern void iax_set_output(void (*output)(const char *data)); | 
					
						
							|  |  |  | /* Choose a different function for errors */ | 
					
						
							|  |  |  | extern void iax_set_error(void (*output)(const char *data)); | 
					
						
							| 
									
										
										
										
											2003-04-19 18:12:41 +00:00
										 |  |  | extern void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen); | 
					
						
							| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | extern const char *iax_ie2str(int ie); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, void *data, int datalen); | 
					
						
							|  |  |  | extern int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, struct sockaddr_in *sin); | 
					
						
							|  |  |  | extern int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value); | 
					
						
							|  |  |  | extern int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value); | 
					
						
							| 
									
										
										
										
											2005-09-02 19:17:19 +00:00
										 |  |  | extern int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, char *str); | 
					
						
							| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  | extern int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat); | 
					
						
							|  |  |  | extern int iax_ie_append(struct iax_ie_data *ied, unsigned char ie); | 
					
						
							| 
									
										
										
										
											2005-09-09 01:07:25 +00:00
										 |  |  | extern int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen); | 
					
						
							| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-04-19 18:12:41 +00:00
										 |  |  | extern int iax_get_frames(void); | 
					
						
							|  |  |  | extern int iax_get_iframes(void); | 
					
						
							|  |  |  | extern int iax_get_oframes(void); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f); | 
					
						
							|  |  |  | extern struct iax_frame *iax_frame_new(int direction, int datalen); | 
					
						
							|  |  |  | extern void iax_frame_free(struct iax_frame *fr); | 
					
						
							| 
									
										
										
										
											2003-03-16 22:37:31 +00:00
										 |  |  | #endif
 |