| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#ifndef _IAX2_PARSER_H |
| 19 |
#define _IAX2_PARSER_H |
| 20 |
|
| 21 |
#include "asterisk/frame.h" |
| 22 |
#include "asterisk/linkedlists.h" |
| 23 |
#include "asterisk/crypto.h" |
| 24 |
#include "asterisk/netsock2.h" |
| 25 |
#include "iax2.h" |
| 26 |
|
| 27 |
struct iax_ies { |
| 28 |
char *called_number; |
| 29 |
char *calling_number; |
| 30 |
char *calling_ani; |
| 31 |
char *calling_name; |
| 32 |
int calling_ton; |
| 33 |
int calling_tns; |
| 34 |
int calling_pres; |
| 35 |
int calling_ani2; |
| 36 |
char *called_context; |
| 37 |
char *username; |
| 38 |
char *password; |
| 39 |
iax2_format capability; |
| 40 |
iax2_format format; |
| 41 |
char *codec_prefs; |
| 42 |
char *language; |
| 43 |
int version; |
| 44 |
unsigned short adsicpe; |
| 45 |
char *dnid; |
| 46 |
char *rdnis; |
| 47 |
unsigned int authmethods; |
| 48 |
unsigned int encmethods; |
| 49 |
char *challenge; |
| 50 |
char *md5_result; |
| 51 |
char *rsa_result; |
| 52 |
struct ast_sockaddr apparent_addr; |
| 53 |
unsigned short refresh; |
| 54 |
unsigned short dpstatus; |
| 55 |
unsigned short callno; |
| 56 |
char *cause; |
| 57 |
unsigned char causecode; |
| 58 |
unsigned char iax_unknown; |
| 59 |
int msgcount; |
| 60 |
int autoanswer; |
| 61 |
int musiconhold; |
| 62 |
unsigned int transferid; |
| 63 |
unsigned int datetime; |
| 64 |
char *devicetype; |
| 65 |
char *serviceident; |
| 66 |
int firmwarever; |
| 67 |
unsigned int fwdesc; |
| 68 |
unsigned char *fwdata; |
| 69 |
unsigned char fwdatalen; |
| 70 |
unsigned char *enckey; |
| 71 |
unsigned char enckeylen; |
| 72 |
unsigned int provver; |
| 73 |
unsigned short samprate; |
| 74 |
int provverpres; |
| 75 |
unsigned int rr_jitter; |
| 76 |
unsigned int rr_loss; |
| 77 |
unsigned int rr_pkts; |
| 78 |
unsigned short rr_delay; |
| 79 |
unsigned int rr_dropped; |
| 80 |
unsigned int rr_ooo; |
| 81 |
struct ast_variable *vars; |
| 82 |
char *osptokenblock[IAX_MAX_OSPBLOCK_NUM]; |
| 83 |
unsigned int ospblocklength[IAX_MAX_OSPBLOCK_NUM]; |
| 84 |
unsigned char calltoken; |
| 85 |
unsigned char *calltokendata; |
| 86 |
}; |
| 87 |
|
| 88 |
#define DIRECTION_INGRESS 1 |
| 89 |
#define DIRECTION_OUTGRESS 2 |
| 90 |
|
| 91 |
struct iax_frame { |
| 92 |
#ifdef LIBIAX |
| 93 |
struct iax_session *session; |
| 94 |
struct iax_event *event; |
| 95 |
#else |
| 96 |
int sockfd; |
| 97 |
#endif |
| 98 |
|
| 99 |
|
| 100 |
unsigned short callno; |
| 101 |
|
| 102 |
unsigned short dcallno; |
| 103 |
|
| 104 |
void *data; |
| 105 |
|
| 106 |
int datalen; |
| 107 |
|
| 108 |
int retries; |
| 109 |
|
| 110 |
unsigned int ts; |
| 111 |
|
| 112 |
int retrytime; |
| 113 |
|
| 114 |
unsigned int outoforder:1; |
| 115 |
|
| 116 |
unsigned int sentyet:1; |
| 117 |
|
| 118 |
unsigned int transfer:1; |
| 119 |
|
| 120 |
unsigned int final:1; |
| 121 |
|
| 122 |
unsigned int direction:2; |
| 123 |
|
| 124 |
unsigned int cacheable:1; |
| 125 |
|
| 126 |
int oseqno; |
| 127 |
|
| 128 |
int iseqno; |
| 129 |
|
| 130 |
int retrans; |
| 131 |
|
| 132 |
int encmethods; |
| 133 |
|
| 134 |
ast_aes_encrypt_key ecx; |
| 135 |
|
| 136 |
ast_aes_decrypt_key mydcx; |
| 137 |
|
| 138 |
unsigned char semirand[32]; |
| 139 |
|
| 140 |
AST_LIST_ENTRY(iax_frame) list; |
| 141 |
|
| 142 |
struct ast_frame af; |
| 143 |
|
| 144 |
size_t afdatalen; |
| 145 |
unsigned char unused[AST_FRIENDLY_OFFSET]; |
| 146 |
unsigned char afdata[0]; |
| 147 |
}; |
| 148 |
|
| 149 |
struct iax_ie_data { |
| 150 |
unsigned char buf[1024]; |
| 151 |
int pos; |
| 152 |
}; |
| 153 |
|
| 154 |
|
| 155 |
void iax_set_output(void (*output)(const char *data)); |
| 156 |
|
| 157 |
void iax_set_error(void (*output)(const char *data)); |
| 158 |
void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct ast_sockaddr *addr, int datalen); |
| 159 |
void iax_frame_subclass2str(enum iax_frame_subclass subclass, char *str, size_t len); |
| 160 |
|
| 161 |
const char *iax_ie2str(int ie); |
| 162 |
|
| 163 |
int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen); |
| 164 |
int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct ast_sockaddr *addr); |
| 165 |
int iax_ie_append_versioned_uint64(struct iax_ie_data *ied, unsigned char ie, unsigned char version, uint64_t value); |
| 166 |
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value); |
| 167 |
int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value); |
| 168 |
int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str); |
| 169 |
int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat); |
| 170 |
int iax_ie_append(struct iax_ie_data *ied, unsigned char ie); |
| 171 |
int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen); |
| 172 |
|
| 173 |
int iax_get_frames(void); |
| 174 |
int iax_get_iframes(void); |
| 175 |
int iax_get_oframes(void); |
| 176 |
|
| 177 |
void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f); |
| 178 |
struct iax_frame *iax_frame_new(int direction, int datalen, unsigned int cacheable); |
| 179 |
void iax_frame_free(struct iax_frame *fr); |
| 180 |
#endif |