Wed Aug 7 17:15:42 2019

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

Generated on 7 Aug 2019 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1