Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:47:54 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 struct iax_ies {
    00022    char *called_number;
    00023    char *calling_number;
    00024    char *calling_ani;
    00025    char *calling_name;
    00026    int calling_ton;
    00027    int calling_tns;
    00028    int calling_pres;
    00029    char *called_context;
    00030    char *username;
    00031    char *password;
    00032    unsigned int capability;
    00033    unsigned int format;
    00034    char *codec_prefs;
    00035    char *language;
    00036    int version;
    00037    unsigned short adsicpe;
    00038    char *dnid;
    00039    char *rdnis;
    00040    unsigned int authmethods;
    00041    unsigned int encmethods;
    00042    char *challenge;
    00043    char *md5_result;
    00044    char *rsa_result;
    00045    struct sockaddr_in *apparent_addr;
    00046    unsigned short refresh;
    00047    unsigned short dpstatus;
    00048    unsigned short callno;
    00049    char *cause;
    00050    unsigned char causecode;
    00051    unsigned char iax_unknown;
    00052    int msgcount;
    00053    int autoanswer;
    00054    int musiconhold;
    00055    unsigned int transferid;
    00056    unsigned int datetime;
    00057    char *devicetype;
    00058    char *serviceident;
    00059    int firmwarever;
    00060    unsigned int fwdesc;
    00061    unsigned char *fwdata;
    00062    unsigned char fwdatalen;
    00063    unsigned char *enckey;
    00064    unsigned char enckeylen;
    00065    unsigned int provver;
    00066    unsigned short samprate;
    00067    int provverpres;
    00068    unsigned int rr_jitter;
    00069    unsigned int rr_loss;
    00070    unsigned int rr_pkts;
    00071    unsigned short rr_delay;
    00072    unsigned int rr_dropped;
    00073    unsigned int rr_ooo;
    00074    unsigned char calltoken;
    00075    unsigned char *calltokendata;
    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    int outoforder;
    00105    /* Have we been sent at all yet? */
    00106    int sentyet;
    00107    /* Outgoing Packet sequence number */
    00108    int oseqno;
    00109    /* Next expected incoming packet sequence number */
    00110    int iseqno;
    00111    /* Non-zero if should be sent to transfer peer */
    00112    int transfer;
    00113    /* Non-zero if this is the final message */
    00114    int final;
    00115    /* Ingress or outgres */
    00116    int direction;
    00117    /* Retransmission ID */
    00118    int retrans;
    00119    /* Easy linking */
    00120    struct iax_frame *next;
    00121    struct iax_frame *prev;
    00122    /* Actual, isolated frame header */
    00123    struct ast_frame af;
    00124    /* Amount of data _allocated_ for afdata */
    00125    size_t afdatalen;
    00126    unsigned char unused[AST_FRIENDLY_OFFSET];
    00127    unsigned char afdata[0];   /* Data for frame */
    00128 };
    00129
    00130 struct iax_ie_data {
    00131    unsigned char buf[1024];
    00132    int pos;
    00133 };
    00134
    00135 /* Choose a different function for output */
    00136 extern void iax_set_output(void (*output)(const char *data));
    00137 /* Choose a different function for errors */
    00138 extern void iax_set_error(void (*output)(const char *data));
    00139 extern void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen);
    00140
    00141 extern const char *iax_ie2str(int ie);
    00142
    00143 extern int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, void *data, int datalen);
    00144 extern int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, struct sockaddr_in *sin);
    00145 extern int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value);
    00146 extern int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value);
    00147 extern int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, char *str);
    00148 extern int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat);
    00149 extern int iax_ie_append(struct iax_ie_data *ied, unsigned char ie);
    00150 extern int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen);
    00151
    00152 extern int iax_get_frames(void);
    00153 extern int iax_get_iframes(void);
    00154 extern int iax_get_oframes(void);
    00155
    00156 extern void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f);
    00157 extern struct iax_frame *iax_frame_new(int direction, int datalen);
    00158 extern void iax_frame_free(struct iax_frame *fr);
    00159 #endif