Tue Sep 30 01:19:37 2008

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 
00023 struct iax_ies {
00024    char *called_number;
00025    char *calling_number;
00026    char *calling_ani;
00027    char *calling_name;
00028    int calling_ton;
00029    int calling_tns;
00030    int calling_pres;
00031    char *called_context;
00032    char *username;
00033    char *password;
00034    unsigned int capability;
00035    unsigned int format;
00036    char *codec_prefs;
00037    char *language;
00038    int version;
00039    unsigned short adsicpe;
00040    char *dnid;
00041    char *rdnis;
00042    unsigned int authmethods;
00043    unsigned int encmethods;
00044    char *challenge;
00045    char *md5_result;
00046    char *rsa_result;
00047    struct sockaddr_in *apparent_addr;
00048    unsigned short refresh;
00049    unsigned short dpstatus;
00050    unsigned short callno;
00051    char *cause;
00052    unsigned char causecode;
00053    unsigned char iax_unknown;
00054    int msgcount;
00055    int autoanswer;
00056    int musiconhold;
00057    unsigned int transferid;
00058    unsigned int datetime;
00059    char *devicetype;
00060    char *serviceident;
00061    int firmwarever;
00062    unsigned int fwdesc;
00063    unsigned char *fwdata;
00064    unsigned char fwdatalen;
00065    unsigned char *enckey;
00066    unsigned char enckeylen;
00067    unsigned int provver;
00068    unsigned short samprate;
00069    int provverpres;
00070    unsigned int rr_jitter;
00071    unsigned int rr_loss;
00072    unsigned int rr_pkts;
00073    unsigned short rr_delay;
00074    unsigned int rr_dropped;
00075    unsigned int rr_ooo;
00076 };
00077 
00078 #define DIRECTION_INGRESS 1
00079 #define DIRECTION_OUTGRESS 2
00080 
00081 struct iax_frame {
00082 #ifdef LIBIAX
00083    struct iax_session *session;
00084    struct iax_event *event;
00085 #else
00086    int sockfd;
00087 #endif
00088 
00089    /* /Our/ call number */
00090    unsigned short callno;
00091    /* /Their/ call number */
00092    unsigned short dcallno;
00093    /* Start of raw frame (outgoing only) */
00094    void *data;
00095    /* Length of frame (outgoing only) */
00096    int datalen;
00097    /* How many retries so far? */
00098    int retries;
00099    /* Outgoing relative timestamp (ms) */
00100    unsigned int ts;
00101    /* How long to wait before retrying */
00102    int retrytime;
00103    /* Are we received out of order?  */
00104    unsigned int outoforder:1;
00105    /* Have we been sent at all yet? */
00106    unsigned int sentyet:1;
00107    /* Non-zero if should be sent to transfer peer */
00108    unsigned int transfer:1;
00109    /* Non-zero if this is the final message */
00110    unsigned int final:1;
00111    /* Ingress or outgres */
00112    unsigned int direction:2;
00113    /* Can this frame be cached? */
00114    unsigned int cacheable:1;
00115    /* Outgoing Packet sequence number */
00116    int oseqno;
00117    /* Next expected incoming packet sequence number */
00118    int iseqno;
00119    /* Retransmission ID */
00120    int retrans;
00121    /* Easy linking */
00122    AST_LIST_ENTRY(iax_frame) list;
00123    /* Actual, isolated frame header */
00124    struct ast_frame af;
00125    /*! Amount of space _allocated_ for data */
00126    size_t afdatalen;
00127    unsigned char unused[AST_FRIENDLY_OFFSET];
00128    unsigned char afdata[0];   /* Data for frame */
00129 };
00130 
00131 struct iax_ie_data {
00132    unsigned char buf[1024];
00133    int pos;
00134 };
00135 
00136 /* Choose a different function for output */
00137 void iax_set_output(void (*output)(const char *data));
00138 /* Choose a different function for errors */
00139 void iax_set_error(void (*output)(const char *data));
00140 void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen);
00141 
00142 const char *iax_ie2str(int ie);
00143 
00144 int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen);
00145 int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct sockaddr_in *sin);
00146 int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value);
00147 int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value);
00148 int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str);
00149 int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat);
00150 int iax_ie_append(struct iax_ie_data *ied, unsigned char ie);
00151 int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen);
00152 
00153 int iax_get_frames(void);
00154 int iax_get_iframes(void);
00155 int iax_get_oframes(void);
00156 
00157 void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f);
00158 struct iax_frame *iax_frame_new(int direction, int datalen, unsigned int cacheable);
00159 void iax_frame_free(struct iax_frame *fr);
00160 #endif

Generated on Tue Sep 30 01:19:37 2008 for Asterisk - the Open Source PBX by  doxygen 1.5.6