Wed Oct 28 11:45:38 2009

Asterisk developer's documentation


iax2-parser.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- A telephony toolkit for Linux.
00003  *
00004  * Implementation of Inter-Asterisk eXchange
00005  * 
00006  * Copyright (C) 2003, Digium
00007  *
00008  * Mark Spencer <markster@digium.com>
00009  *
00010  * This program is free software, distributed under the terms of
00011  * the GNU General Public License
00012  */
00013 
00014 /*!\file
00015  * \brief Implementation of the IAX2 protocol
00016  */
00017  
00018 #ifndef _IAX2_PARSER_H
00019 #define _IAX2_PARSER_H
00020 
00021 #include "asterisk/linkedlists.h"
00022 #include "asterisk/aes.h"
00023 
00024 struct iax_ies {
00025    char *called_number;
00026    char *calling_number;
00027    char *calling_ani;
00028    char *calling_name;
00029    int calling_ton;
00030    int calling_tns;
00031    int calling_pres;
00032    char *called_context;
00033    char *username;
00034    char *password;
00035    unsigned int capability;
00036    unsigned int format;
00037    char *codec_prefs;
00038    char *language;
00039    int version;
00040    unsigned short adsicpe;
00041    char *dnid;
00042    char *rdnis;
00043    unsigned int authmethods;
00044    unsigned int encmethods;
00045    char *challenge;
00046    char *md5_result;
00047    char *rsa_result;
00048    struct sockaddr_in *apparent_addr;
00049    unsigned short refresh;
00050    unsigned short dpstatus;
00051    unsigned short callno;
00052    char *cause;
00053    unsigned char causecode;
00054    unsigned char iax_unknown;
00055    int msgcount;
00056    int autoanswer;
00057    int musiconhold;
00058    unsigned int transferid;
00059    unsigned int datetime;
00060    char *devicetype;
00061    char *serviceident;
00062    int firmwarever;
00063    unsigned int fwdesc;
00064    unsigned char *fwdata;
00065    unsigned char fwdatalen;
00066    unsigned char *enckey;
00067    unsigned char enckeylen;
00068    unsigned int provver;
00069    unsigned short samprate;
00070    int provverpres;
00071    unsigned int rr_jitter;
00072    unsigned int rr_loss;
00073    unsigned int rr_pkts;
00074    unsigned short rr_delay;
00075    unsigned int rr_dropped;
00076    unsigned int rr_ooo;
00077    struct ast_variable *vars;
00078    char *osptokenblock[IAX_MAX_OSPBLOCK_NUM];
00079    unsigned int ospblocklength[IAX_MAX_OSPBLOCK_NUM];
00080    unsigned char calltoken;
00081    unsigned char *calltokendata;
00082 };
00083 
00084 #define DIRECTION_INGRESS 1
00085 #define DIRECTION_OUTGRESS 2
00086 
00087 struct iax_frame {
00088 #ifdef LIBIAX
00089    struct iax_session *session;
00090    struct iax_event *event;
00091 #else
00092    int sockfd;
00093 #endif
00094 
00095    /*! /Our/ call number */
00096    unsigned short callno;
00097    /*! /Their/ call number */
00098    unsigned short dcallno;
00099    /*! Start of raw frame (outgoing only) */
00100    void *data;
00101    /*! Length of frame (outgoing only) */
00102    int datalen;
00103    /*! How many retries so far? */
00104    int retries;
00105    /*! Outgoing relative timestamp (ms) */
00106    unsigned int ts;
00107    /*! How long to wait before retrying */
00108    int retrytime;
00109    /*! Are we received out of order?  */
00110    unsigned int outoforder:1;
00111    /*! Have we been sent at all yet? */
00112    unsigned int sentyet:1;
00113    /*! Non-zero if should be sent to transfer peer */
00114    unsigned int transfer:1;
00115    /*! Non-zero if this is the final message */
00116    unsigned int final:1;
00117    /*! Ingress or outgres */
00118    unsigned int direction:2;
00119    /*! Can this frame be cached? */
00120    unsigned int cacheable:1;
00121    /*! Outgoing Packet sequence number */
00122    int oseqno;
00123    /*! Next expected incoming packet sequence number */
00124    int iseqno;
00125    /*! Retransmission ID */
00126    int retrans;
00127    /*! is this packet encrypted or not. if set this varible holds encryption methods*/
00128    int encmethods;
00129    /*! store encrypt key */
00130    ast_aes_encrypt_key ecx;
00131    /*! store decrypt key which corresponds to ecx */
00132    ast_aes_decrypt_key mydcx;
00133    /*! random data for encryption pad */
00134    unsigned char semirand[32];
00135    /*! Easy linking */
00136    AST_LIST_ENTRY(iax_frame) list;
00137    /*! Actual, isolated frame header */
00138    struct ast_frame af;
00139    /*! Amount of space _allocated_ for data */
00140    size_t afdatalen;
00141    unsigned char unused[AST_FRIENDLY_OFFSET];
00142    unsigned char afdata[0];   /* Data for frame */
00143 };
00144 
00145 struct iax_ie_data {
00146    unsigned char buf[1024];
00147    int pos;
00148 };
00149 
00150 /* Choose a different function for output */
00151 void iax_set_output(void (*output)(const char *data));
00152 /* Choose a different function for errors */
00153 void iax_set_error(void (*output)(const char *data));
00154 void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen);
00155 void iax_frame_subclass2str(enum iax_frame_subclass subclass, char *str, size_t len);
00156 
00157 const char *iax_ie2str(int ie);
00158 
00159 int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen);
00160 int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct sockaddr_in *sin);
00161 int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value);
00162 int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value);
00163 int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str);
00164 int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat);
00165 int iax_ie_append(struct iax_ie_data *ied, unsigned char ie);
00166 int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen);
00167 
00168 int iax_get_frames(void);
00169 int iax_get_iframes(void);
00170 int iax_get_oframes(void);
00171 
00172 void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f);
00173 struct iax_frame *iax_frame_new(int direction, int datalen, unsigned int cacheable);
00174 void iax_frame_free(struct iax_frame *fr);
00175 #endif

Generated on Wed Oct 28 11:45:38 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6