Debian Codegraph @

src/ITGRecv/ITGRecv.h

raw symbols SCIP
1 /*
2 * Component of the D-ITG 2.8.1 (r1023) platform (http://traffic.comics.unina.it/software/ITG)
3 *
4 * Copyright : (C) 2004-2013 by Alessio Botta, Walter de Donato, Alberto Dainotti,
5 * Stefano Avallone, Antonio Pescape' (PI)
6 * COMICS (COMputer for Interaction and CommunicationS) Group
7 * Department of Electrical Engineering and Information Technologies
8 * University of Napoli "Federico II".
9 * email : [email protected], [email protected], [email protected],
10 * [email protected], [email protected]
11 *
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 *
25 * For commercial use please refer to D-ITG Professional.
26 */
27
28
29
30
31
32 #define MSG_FT_OK 1
33 #define MSG_FT_ERR1 2
34 #define MSG_FT_ERR2 3
35 #define MSG_FT_ERR_SOCK 4
36
37
38
39
40
41 struct paramThread {
42 BYTE l7Proto;
43 struct addrinfo destHost;
44 int flowId;
45 char *iface;
46 info *addressInfos;
47 int count;
48 int socket;
49 int socketClose;
50 BYTE meter;
51 BYTE dsByte;
52 char *fileLog;
53 int logSock;
54 struct addrinfo *logHost;
55 char serial[DIM_NAME_SERIAL_INTERFACE];
56 #ifdef UNIX
57 int rPipe[2];
58 #endif
59 #ifdef WIN32
60 HANDLE rPipe[3];
61 #endif
62 int preambleSize;
63 int payloadLogType;
64
65 uint16_t portForPssv;
66 #ifdef MULTIPORT
67 uint16_t indexPort;
68 #endif
69 };
70
71
72 struct memChannel {
73 int flowId;
74 BYTE l4Proto;
75 };
76
77
78 struct manageLogFile{
79 ofstream out;
80 int num;
81 char logFile[DIM_LOG_FILE];
82 };
83
84 #ifdef MULTIPORT
85 typedef struct {
86 int socket;
87 short inUse;
88 # ifdef WIN32
89 HANDLE mutexSharedSockets;
90 # endif
91 # ifdef UNIX
92 pthread_mutex_t mutexSharedSockets;
93 # endif
94 } sharedSocketType;
95
96 extern sharedSocketType sharedTcpSockets[];
97 extern sharedSocketType sharedUdpSockets[];
98 #endif
99
100
101 extern const char DEFAULT_LOG_FILE[];
102
103
104 extern int flagTerm;
105
106
107 extern struct addrinfo *logHost;
108
109
110 extern int logCheck;
111
112
113 extern int logRemote;
114
115
116 extern BYTE l4ProtoLog;
117
118
119 extern ofstream out;
120
121
122 extern int sockSignaling;
123
124
125 extern char logFile[DIM_LOG_FILE];
126
127 extern addrinfo hint;
128
129 #ifdef WIN32
130
131 extern HANDLE mutexLog;
132
133 extern HANDLE mutexLogRem;
134
135 extern int userId;
136 #endif
137
138 #ifdef UNIX
139
140 extern pthread_mutex_t mutexLog;
141
142 extern pthread_mutex_t mutexLogRem;
143
144 extern uid_t userId;
145 #endif
146
147
148
149
150 void *signalManager(void *param);
151
152
153 void printHelpAndExit();
154
155
156
157 void terminate(int sign);
158
159
160 void reportErrorAndExit(const char *function, const char *program, const char *msg);
161
162
163 int sendAck(int signaling, BYTE typeMessage);
164
165
166 int sendAckFlow(int signaling,BYTE typeMessage,int flowId, uint16_t openedPort = 0);
167
168
169
170 void recvInit();
171
172
173
174 void parserRecv(int argc , char *argv[]);
175
176
177
178
179
180
181 #ifdef WIN32
182 int typeParser(BYTE type, int &numFlow, int newSockSignaling , memChannel flowIdNum[],
183 paramThread paraThread[], pthread_t hThr[], HANDLE rPipe[], char *fileLog, int logSock, int logSockSignaling,
184 struct addrinfo *logHost);
185 #endif
186
187 #ifdef UNIX
188 int typeParser(BYTE type, int &numFlow, int newSockSignaling , memChannel flowIdNum[],
189 paramThread paraThread[], pthread_t hThr[], int rPipe[], char *fileLog, int logSock, int logSockSignaling,
190 struct addrinfo *logHost);
191 #endif
192
193
194 #ifdef WIN32
195 void pipeParser(int newSockSignaling,int &numFlow, HANDLE rPipe[], memChannel flowIdNum[],
196 paramThread paraThread[], pthread_t hThr[]);
197 #endif
198
199 #ifdef UNIX
200 void pipeParser(int newSockSignaling,int &numFlow, int rPipe[], memChannel flowIdNum[],
201 paramThread paraThread[], pthread_t hThr[]);
202 #endif
203
204
205
206 void createRemoteLogFile(struct addrinfo &logHost, char logFile[DIM_LOG_FILE], BYTE protocolLog, int & logSockSignaling, int & logSock);
207
208
209
210 void createSignalingLogChannel(struct addrinfo logHost, char logFile[DIM_LOG_FILE], BYTE protocolLog, int & logSockSignaling);
211
212
213 void recvFlowLog(int newSockSignaling, struct addrinfo & logHost, BYTE &protocolLog, char logFile[]);
214
215
216
217
218
219 inline void flushBuffer(ofstream * pointerLog, struct info *infos, int &count)
220 {
221
222 if (MUTEX_THREAD_LOCK(mutexLog) < 0)
223 reportErrorAndExit("flushBuffer", "MUTEX_THREAD_LOCK", "Cannot lock mutex");
224
225 if ((*pointerLog).is_open()){
226
227 (*pointerLog).write((const char *) infos, count * sizeof(struct info));
228 (*pointerLog).flush();
229 count = 0;
230 }
231
232
233 if (MUTEX_THREAD_UNLOCK(mutexLog) < 0)
234 reportErrorAndExit("flusBuffer", "MUTEX_THREAD_UNLOCK", "Cannot unlock mutex");
235 }
236 void recvNameLog(char nameFile[DIM_LOG_FILE],int newSockSignaling);
237 void copia(const struct addrinfo* src, struct addrinfo & dst);
238