36
45
#define SIP_TRANSACTION_TIMEOUT 32000
39
extern int createAuthHeader(char * user, char * password, char * method, char * uri, char * msgbody, char * auth, char * result);
48
extern int createAuthHeader(char * user, char * password, char * method, char * uri, char * msgbody, char * auth, char * aka_OP, char * aka_AMF, char * aka_K, char * result);
41
extern "C" { extern int createAuthHeader(char * user, char * password, char * method, char * uri, char * msgbody, char * auth, char * result); }
50
extern "C" { extern int createAuthHeader(char * user, char * password, char * method, char * uri, char * msgbody, char * auth, char * aka_OP, char * aka_AMF, char * aka_K, char * result); }
53
/* Forward declaration of call, so that we can define the call_list iterator
54
* that is referenced from call. */
57
typedef std::list<call *> call_list;
59
/* This arrangement of wheels lets us support up to 32 bit timers.
61
* If we were to put a minimum bound on timer_resol (or do some kind of dynamic
62
* allocation), then we could reduce the level one order by a factor of
64
#define LEVEL_ONE_ORDER 12
65
#define LEVEL_TWO_ORDER 10
66
#define LEVEL_THREE_ORDER 10
67
#define LEVEL_ONE_SLOTS (1 << LEVEL_ONE_ORDER)
68
#define LEVEL_TWO_SLOTS (1 << LEVEL_TWO_ORDER)
69
#define LEVEL_THREE_SLOTS (1 << LEVEL_THREE_ORDER)
71
/* A time wheel structure as defined in Varghese and Lauck's 1996 journal
72
* article (based on their 1987 SOSP paper). */
77
int expire_paused_calls();
78
/* Add a paused call and increment count. */
79
void add_paused_call(call *call, bool increment);
80
void remove_paused_call(call *call);
84
/* How many calls are in this wheel. */
87
unsigned int wheel_base;
89
/* The actual wheels. */
90
call_list wheel_one[LEVEL_ONE_SLOTS];
91
call_list wheel_two[LEVEL_TWO_SLOTS];
92
call_list wheel_three[LEVEL_THREE_SLOTS];
94
/* Calls that are paused indefinitely. */
95
call_list forever_list;
97
/* Turn a call into a list (based on wakeup). */
98
call_list *call2list(call *call);
48
104
unsigned int number;
105
unsigned int tdm_map_number;
50
unsigned int msg_index;
52
109
/* Last message sent from scenario step (retransmitions do not
53
110
* change this index. Only message sent from the scenario
54
111
* are kept in this index.) */
55
unsigned int last_send_index;
56
113
char * last_send_msg;
58
115
/* Last received message (expected, not optional, and not
59
116
* retransmitted) and the associated hash. Stills setted until a new
60
117
* scenario steps sends a message */
61
118
unsigned long last_recv_hash;
62
unsigned int last_recv_index;
63
120
char * last_recv_msg;
65
122
/* Recv message characteristics when we sent a valid message
150
208
/* rc == true means call not deleted by processing */
152
bool process_incomming(char * msg);
210
void formatNextReqUrl (char* next_req_url);
211
void computeRouteSetAndRemoteTargetUri (char* rrList, char* contact, bool bRequestIncoming);
212
bool matches_scenario(unsigned int index, int reply_code, char * request, char * responsecseqmethod);
213
bool process_incoming(char * msg);
154
215
T_ActionResult executeAction(char * msg, int scenarioIndex);
155
void extractSubMessage(char * msg, char * matchingString, char* result);
216
void extractSubMessage(char * msg, char * matchingString, char* result, bool case_indep,
217
int occurrence, bool headers);
156
218
bool rejectCall();
220
// Get parameters from a [keyword]
221
void getHexStringParam(char * dest, char * src, int * len);
222
char* getKeywordParam(char * src, char * param, char * output);
158
224
// P_index use for message index in scenario and ctrl of CRLF
159
225
// P_index = -2 No ctrl of CRLF
160
226
// P_index = -1 Add crlf to end of message
166
232
// received from the twin socket
167
233
// used for example to cancel the call
168
234
// of the third party
235
bool check_peer_src(char* msg,
236
int search_index); // 3pcc extended mode:check if
237
// the twin message received
238
// comes from the expected sender
169
239
int sendBuffer(char *buf); // send a message out of a scenario
171
241
int checkAutomaticResponseMode(char * P_recv);
172
void automaticResponseMode(int P_case, char* P_recv);
242
bool automaticResponseMode(int P_case, char* P_recv);
175
245
int sendCmdMessage(int index); // 3PCC
188
258
static void readInputFileContents(const char* fileName);
189
259
static void dumpFileContents(void);
261
static void getFieldFromInputFile(const char* fieldName, unsigned int lineNum, char*& dest);
262
static void getIpFieldFromInputFile(int fieldNr, int lineNum, char *dest);
263
static int m_counter; // used for sequential access
265
/* Is this call paused or running? */
267
/* If we are running, the iterator to remove us from the running list. */
268
call_list::iterator runit;
269
/* If we are paused, the iterator to remove us from the paused list. */
270
call_list::iterator pauseit;
192
273
/* rc == true means call not deleted by processing */
194
275
bool process_unexpected(char * msg);
276
void do_bookkeeping(int index);
196
278
void extract_cseq_method (char* responseCseq, char* msg);
200
282
void connect_socket_if_needed();
202
284
char * compute_cseq(char * src);
285
char * get_header_field_code(char * msg, char * code);
203
286
char * get_last_header(char * name);
204
287
char * get_header_content(char* message, char * name);
288
char * get_header(char* message, char * name, bool content);
206
290
static InputFileUsage m_usage;
207
static int m_counter; // used for sequential access
209
292
int m_localLineNumber;
213
static void getFieldFromInputFile(const char* fieldName, int lineNum, char*& dest);
296
void get_remote_media_addr(char * message);
215
298
#ifdef _USE_OPENSSL
216
299
SSL_CTX *m_ctx_ssl ;
222
304
/* Call contexts interface */
224
306
typedef std::map<std::string, call *> call_map;
225
307
call_map * get_calls();
308
call_list * get_running_calls();
228
call * add_call(char * call_id , int P_pollset_indx, bool ipv6 = false);
310
call * add_call(char * call_id , int P_pollset_indx, bool ipv6 = false);
231
312
call * add_call(char * call_id , bool ipv6 = false);
233
314
call * add_call(bool ipv6 = false);
234
315
call * get_call(char *);
235
316
void delete_call(char *);
317
void delete_calls(void);
319
void add_running_call(call *call);
320
bool remove_running_call(call *call);
321
int expire_paused_calls();
322
int paused_calls_count();
323
void remove_paused_call(call *call);