Asterisk - The Open Source Telephony Project GIT-master-f36a736
parser.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Implementation of Inter-Asterisk eXchange
5 *
6 * Copyright (C) 2003, Digium
7 *
8 * Mark Spencer <markster@digium.com>
9 *
10 * This program is free software, distributed under the terms of
11 * the GNU General Public License
12 */
13
14/*!\file
15 * \brief Implementation of the IAX2 protocol
16 */
17
18#ifndef _IAX2_PARSER_H
19#define _IAX2_PARSER_H
20
21#include "asterisk/frame.h"
23#include "asterisk/crypto.h"
24#include "asterisk/netsock2.h"
25#include "iax2.h"
26
27struct iax_ies {
37 char *username;
38 char *password;
42 char *language;
44 unsigned short adsicpe;
45 char *dnid;
46 char *rdnis;
47 unsigned int authmethods;
48 unsigned int encmethods;
49 char *challenge;
53 unsigned short refresh;
54 unsigned short dpstatus;
55 unsigned short callno;
56 char *cause;
57 unsigned char causecode;
58 unsigned char iax_unknown;
62 unsigned int transferid;
63 unsigned int datetime;
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;
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;
84 unsigned char calltoken;
85 unsigned char *calltokendata;
86};
87
88#define DIRECTION_INGRESS 1
89#define DIRECTION_OUTGRESS 2
90
91struct iax_frame {
92#ifdef LIBIAX
93 struct iax_session *session;
94 struct iax_event *event;
95#else
96 int sockfd;
97#endif
98
99 /*! /Our/ call number */
100 unsigned short callno;
101 /*! /Their/ call number */
102 unsigned short dcallno;
103 /*! Start of raw frame (outgoing only) */
104 void *data;
105 /*! Length of frame (outgoing only) */
107 /*! How many retries so far? */
109 /*! Outgoing relative timestamp (ms) */
110 unsigned int ts;
111 /*! How long to wait before retrying */
113 /*! Are we received out of order? */
114 unsigned int outoforder:1;
115 /*! Have we been sent at all yet? */
116 unsigned int sentyet:1;
117 /*! Non-zero if should be sent to transfer peer */
118 unsigned int transfer:1;
119 /*! Non-zero if this is the final message */
120 unsigned int final:1;
121 /*! Ingress or outgres */
122 unsigned int direction:2;
123 /*! Can this frame be cached? */
124 unsigned int cacheable:1;
125 /*! Outgoing Packet sequence number */
127 /*! Next expected incoming packet sequence number */
129 /*! Retransmission ID */
131 /*! is this packet encrypted or not. if set this varible holds encryption methods*/
133 /*! store encrypt key */
135 /*! store decrypt key which corresponds to ecx */
137 /*! random data for encryption pad */
138 unsigned char semirand[32];
139 /*! Easy linking */
141 /*! Actual, isolated frame header */
142 struct ast_frame af;
143 /*! Amount of space _allocated_ for data */
144 size_t afdatalen;
146 unsigned char afdata[0]; /* Data for frame */
147};
148
150 unsigned char buf[1024];
151 int pos;
152};
153
154/* Choose a different function for output */
155void iax_set_output(void (*output)(const char *data));
156/* Choose a different function for errors */
157void iax_set_error(void (*output)(const char *data));
158void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct ast_sockaddr *addr, int datalen);
159void iax_frame_subclass2str(enum iax_frame_subclass subclass, char *str, size_t len);
160
161const char *iax_ie2str(int ie);
162
163int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen);
164int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct ast_sockaddr *addr);
165int iax_ie_append_versioned_uint64(struct iax_ie_data *ied, unsigned char ie, unsigned char version, uint64_t value);
166int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value);
167int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value);
168int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str);
169int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat);
170int iax_ie_append(struct iax_ie_data *ied, unsigned char ie);
171int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen);
172
173int iax_get_frames(void);
174int iax_get_iframes(void);
175int iax_get_oframes(void);
176
177void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f);
178struct iax_frame *iax_frame_new(int direction, int datalen, unsigned int cacheable);
179void iax_frame_free(struct iax_frame *fr);
180#endif
const char * str
Definition: app_jack.c:147
static struct ast_mansession session
static char version[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:391
Provide cryptographic signature routines.
direction
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Implementation of Inter-Asterisk eXchange, version 2 parser.c parser.h chan_iax2.c.
iax_frame_subclass
Definition: iax2.h:51
int64_t iax2_format
Definition: iax2.h:224
#define IAX_MAX_OSPBLOCK_NUM
Definition: iax2.h:193
Asterisk internal frame definitions.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
A set of macros to manage forward-linked lists.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
Definition: linkedlists.h:410
Network socket handling.
int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
Definition: parser.c:795
int iax_get_iframes(void)
Definition: parser.c:1350
int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct ast_sockaddr *addr)
Definition: parser.c:741
void iax_frame_subclass2str(enum iax_frame_subclass subclass, char *str, size_t len)
Definition: parser.c:463
int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat)
Definition: parser.c:775
void iax_frame_free(struct iax_frame *fr)
Definition: parser.c:1295
int iax_ie_append(struct iax_ie_data *ied, unsigned char ie)
Definition: parser.c:780
int iax_ie_append_versioned_uint64(struct iax_ie_data *ied, unsigned char ie, unsigned char version, uint64_t value)
Definition: parser.c:746
struct iax_frame * iax_frame_new(int direction, int datalen, unsigned int cacheable)
Definition: parser.c:1228
int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen)
Definition: parser.c:726
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value)
Definition: parser.c:756
void iax_set_output(void(*output)(const char *data))
int iax_get_oframes(void)
Definition: parser.c:1351
void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f)
Definition: parser.c:1195
int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value)
Definition: parser.c:763
void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct ast_sockaddr *addr, int datalen)
Definition: parser.c:595
int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str)
Definition: parser.c:770
int iax_get_frames(void)
Definition: parser.c:1349
const char * iax_ie2str(int ie)
Definition: parser.c:353
void iax_set_error(void(*output)(const char *data))
Definition: crypto.h:39
Data structure associated with a single frame of data.
Socket address structure.
Definition: netsock2.h:97
Structure for variables, used for configurations and for channel variables.
Definition: astman.c:222
unsigned char semirand[32]
Definition: parser.h:138
unsigned short dcallno
Definition: parser.h:102
struct iax_frame::@139 list
unsigned int sentyet
Definition: parser.h:116
int retrans
Definition: parser.h:130
unsigned int ts
Definition: parser.h:110
unsigned char afdata[0]
Definition: parser.h:146
unsigned int outoforder
Definition: parser.h:114
void * data
Definition: parser.h:104
unsigned short callno
Definition: parser.h:100
int retries
Definition: parser.h:108
unsigned char unused[AST_FRIENDLY_OFFSET]
Definition: parser.h:145
int encmethods
Definition: parser.h:132
int iseqno
Definition: parser.h:128
size_t afdatalen
Definition: parser.h:144
unsigned int direction
Definition: parser.h:122
ast_aes_decrypt_key mydcx
Definition: parser.h:136
int sockfd
Definition: parser.h:96
int datalen
Definition: parser.h:106
int retrytime
Definition: parser.h:112
unsigned int transfer
Definition: parser.h:118
ast_aes_encrypt_key ecx
Definition: parser.h:134
struct ast_frame af
Definition: parser.h:142
unsigned int cacheable
Definition: parser.h:124
int oseqno
Definition: parser.h:126
int pos
Definition: parser.h:151
unsigned char buf[1024]
Definition: parser.h:150
Definition: parser.h:27
struct ast_sockaddr apparent_addr
Definition: parser.h:52
unsigned short adsicpe
Definition: parser.h:44
unsigned int rr_jitter
Definition: parser.h:75
unsigned int provver
Definition: parser.h:72
unsigned char * calltokendata
Definition: parser.h:85
unsigned int rr_pkts
Definition: parser.h:77
struct ast_variable * vars
Definition: parser.h:81
unsigned char calltoken
Definition: parser.h:84
unsigned char iax_unknown
Definition: parser.h:58
int calling_ani2
Definition: parser.h:35
unsigned int rr_loss
Definition: parser.h:76
unsigned int authmethods
Definition: parser.h:47
char * challenge
Definition: parser.h:49
char * dnid
Definition: parser.h:45
char * calling_name
Definition: parser.h:31
iax2_format capability
Definition: parser.h:39
char * called_context
Definition: parser.h:36
unsigned char * enckey
Definition: parser.h:70
char * calling_number
Definition: parser.h:29
unsigned int fwdesc
Definition: parser.h:67
char * calling_ani
Definition: parser.h:30
int calling_ton
Definition: parser.h:32
char * password
Definition: parser.h:38
unsigned int transferid
Definition: parser.h:62
unsigned int datetime
Definition: parser.h:63
unsigned int rr_dropped
Definition: parser.h:79
unsigned char causecode
Definition: parser.h:57
int firmwarever
Definition: parser.h:66
unsigned int ospblocklength[IAX_MAX_OSPBLOCK_NUM]
Definition: parser.h:83
int msgcount
Definition: parser.h:59
int calling_tns
Definition: parser.h:33
char * called_number
Definition: parser.h:28
unsigned short callno
Definition: parser.h:55
char * md5_result
Definition: parser.h:50
int provverpres
Definition: parser.h:74
char * language
Definition: parser.h:42
char * codec_prefs
Definition: parser.h:41
iax2_format format
Definition: parser.h:40
unsigned int encmethods
Definition: parser.h:48
unsigned char * fwdata
Definition: parser.h:68
unsigned short dpstatus
Definition: parser.h:54
char * username
Definition: parser.h:37
char * rsa_result
Definition: parser.h:51
int calling_pres
Definition: parser.h:34
int autoanswer
Definition: parser.h:60
unsigned short samprate
Definition: parser.h:73
int version
Definition: parser.h:43
unsigned char fwdatalen
Definition: parser.h:69
char * cause
Definition: parser.h:56
int musiconhold
Definition: parser.h:61
unsigned short refresh
Definition: parser.h:53
char * serviceident
Definition: parser.h:65
unsigned int rr_ooo
Definition: parser.h:80
char * devicetype
Definition: parser.h:64
char * rdnis
Definition: parser.h:46
unsigned short rr_delay
Definition: parser.h:78
unsigned char enckeylen
Definition: parser.h:71
char * osptokenblock[IAX_MAX_OSPBLOCK_NUM]
Definition: parser.h:82
int value
Definition: syslog.c:37