This repository was archived by the owner on Feb 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmessage.hpp
More file actions
159 lines (142 loc) · 4.17 KB
/
message.hpp
File metadata and controls
159 lines (142 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author : Richard GAYRAUD - 04 Nov 2003
* Olivier Jacques
* From Hewlett Packard Company.
* Shriram Natarajan
* Peter Higginson
* Eric Miller
* Venkatesh
* Enrico Hartung
* Nasir Khan
* Lee Ballard
* Guillaume Teissier from FTR&D
* Wolfgang Beck
* Venkatesh
* Vlad Troyanker
* Charles P Wright from IBM Research
* Amit On from Followap
* Jan Andres from Freenet
* Ben Evans from Open Cloud
* Marc Van Diest from Belgacom
* Andy Aicken
*/
#ifndef __MESSAGE__
#define __MESSAGE__
#include <vector>
class scenario;
struct MessageComponent;
typedef enum {
E_Message_Literal,
E_Message_Remote_IP,
E_Message_Remote_Host,
E_Message_Remote_Port,
E_Message_Transport,
E_Message_Local_IP,
E_Message_Local_IP_Type,
E_Message_Local_Port,
E_Message_Server_IP,
E_Message_Media_IP,
E_Message_Auto_Media_Port,
E_Message_Media_Port,
E_Message_Media_IP_Type,
E_Message_Call_Number,
E_Message_DynamicId, // general usage, global, autoincrementing and wrapping counter
E_Message_Call_ID,
E_Message_CSEQ,
E_Message_PID,
E_Message_Service,
E_Message_Branch,
E_Message_Index,
E_Message_Next_Url,
E_Message_Len,
E_Message_Peer_Tag_Param,
E_Message_Routes,
E_Message_Variable,
E_Message_Fill,
E_Message_Injection,
E_Message_Last_Header,
E_Message_Last_Request_URI,
E_Message_Last_CSeq_Number,
E_Message_Last_Message,
E_Message_TDM_Map,
E_Message_Authentication,
E_Message_ClockTick,
E_Message_Users,
E_Message_UserID,
E_Message_Timestamp,
E_Message_SippVersion,
E_Message_File,
E_Message_Custom,
} MessageCompType;
class SendingMessage {
public:
SendingMessage(scenario *msg_scenario, char *msg, bool skip_sanity = false);
~SendingMessage();
struct MessageComponent *getComponent(int);
int numComponents();
char *getMethod();
int getCode();
bool isResponse();
bool isAck();
bool isCancel();
static void parseAuthenticationKeyword(scenario *msg_scenario, struct MessageComponent *dst, char *keyword);
static void freeMessageComponent(struct MessageComponent *comp);
private:
std::vector <struct MessageComponent *> messageComponents;
char *method;
int code;
bool ack;
bool cancel;
bool response;
scenario *msg_scenario;
// Get parameters from a [keyword]
static void getQuotedParam(char * dest, char * src, int * len);
static void getHexStringParam(char * dest, char * src, int * len);
static void getKeywordParam(char * src, char * param, char * output);
};
/* Custom Keyword Function Type. */
struct MessageComponent;
class call;
typedef int (*customKeyword)(call *, struct MessageComponent *, char *, int);
/* Custom Keyword Registration Function. */
int registerKeyword(char *keyword, customKeyword fxn);
struct MessageComponent {
MessageCompType type;
char *literal;
int literalLen;
int offset;
int varId;
union u {
/* Authentication Parameters. */
struct {
SendingMessage *auth_user;
SendingMessage *auth_pass;
SendingMessage *aka_OP;
SendingMessage *aka_AMF;
SendingMessage *aka_K;
} auth_param;
/* Field Substitution. */
struct {
char *filename;
int field;
SendingMessage *line;
} field_param;
SendingMessage *filename;
customKeyword fxn;
} comp_param;
};
#endif