-
Notifications
You must be signed in to change notification settings - Fork 84
/
CWAC.h
396 lines (338 loc) · 13.6 KB
/
CWAC.h
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
/************************************************************************************************
* Copyright (c) 2006-2009 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica *
* Universita' Campus BioMedico - Italy *
* *
* 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. *
*
* In addition, as a special exception, the copyright holders give permission to link the *
* code of portions of this program with the OpenSSL library under certain conditions as *
* described in each individual source file, and distribute linked combinations including *
* the two. You must obey the GNU General Public License in all respects for all of the *
* code used other than OpenSSL. If you modify file(s) with this exception, you may *
* extend this exception to your version of the file(s), but you are not obligated to do *
* so. If you do not wish to do so, delete this exception statement from your version. *
* If you delete this exception statement from all source files in the program, then also *
* delete it here. *
*
* -------------------------------------------------------------------------------------------- *
* Project: Capwap *
* *
* Authors : Ludovico Rossi ([email protected]) *
* Del Moro Andrea ([email protected]) *
* Giovannini Federica ([email protected]) *
* Massimo Vellucci ([email protected]) *
* Mauro Bisson ([email protected]) *
* Daniele De Sanctis ([email protected]) *
* Antonio Davoli ([email protected]) *
************************************************************************************************/
#ifndef __CAPWAP_CWAC_HEADER__
#define __CAPWAP_CWAC_HEADER__
/*_______________________________________________________*/
/* *******************___INCLUDE___******************* */
#include "CWCommon.h"
#include "ACMultiHomedSocket.h"
#include "ACProtocol.h"
#include "ACInterface.h"
#include "ACBinding.h"
#include <ctype.h>
#include <netinet/in.h>
#include <sys/un.h>
#include <sys/socket.h>
/*______________________________________________________*/
/* *******************___DEFINE___******************* */
#define CW_MAX_WTP 100
#define CW_CRITICAL_TIMER_EXPIRED_SIGNAL SIGUSR2
#define CW_SOFT_TIMER_EXPIRED_SIGNAL SIGUSR1
#define AC_LOG_FILE_NAME "/var/log/ac.log.txt"
#define MAC_ADDR_LEN 6
#define DEST_ADDR_START 4
#define SOURCE_ADDR_START 10
/*Definition of socket's path to send data stats */
#define SOCKET_PATH_AC "/tmp/af_unix_ac_client"
#define SOCKET_PATH_RECV_AGENT "/tmp/monitorclt"
/*********************************************************
* 2009 Updates: *
* Message Element Types for the CWAsseble- *
* ConfigurationUpdateRequest Function. *
*********************************************************/
#define CONFIG_UPDATE_REQ_QOS_ELEMENT_TYPE 0
#define CONFIG_UPDATE_REQ_OFDM_ELEMENT_TYPE 1
#define CONFIG_UPDATE_REQ_VENDOR_UCI_ELEMENT_TYPE 2
#define CONFIG_UPDATE_REQ_VENDOR_WUM_ELEMENT_TYPE 3
/********************************************************
* 2009 Updates: *
* For manage the applications connected to AC we use *
* an array of socket. Through this array we can set *
* easily the correct answer socket. *
* isFree and numSocketFree are used for management. *
* The mutex array is used for serialize the correct *
* write operation by the different wtp thread on the *
* relative application socket. *
********************************************************/
#define MAX_APPS_CONNECTED_TO_AC 4
typedef struct {
CWSocket appSocket[MAX_APPS_CONNECTED_TO_AC];
CWBool isFree[MAX_APPS_CONNECTED_TO_AC];
CWThreadMutex socketMutex[MAX_APPS_CONNECTED_TO_AC];
int numSocketFree;
CWThreadMutex numSocketFreeMutex;
} applicationsManager;
applicationsManager appsManager;
/*_____________________________________________________*/
/* *******************___TYPES___******************* */
/*
* Struct that describes a WTP from the AC's point of view
*/
typedef struct {
CWNetworkLev4Address address;
CWNetworkLev4Address dataaddress;
CWThread thread;
CWSecuritySession session;
/*
* Elena Agostini - 03/2014
* DTLS Data Session AC
*/
CWSecuritySession sessionData;
CWBool isNotFree;
CWBool isRequestClose;
CWStateTransition currentState;
int interfaceIndex;
CWSocket socket;
char buf[CW_BUFFER_SIZE];
enum {
CW_DTLS_HANDSHAKE_IN_PROGRESS,
CW_WAITING_REQUEST,
CW_COMPLETED,
} subState;
CWSafeList packetReceiveList;
/*
* Elena Agostini - 03/2014: DTLS Data Channel
*/
CWSafeList packetReceiveDataList;
CWBool sessionDataActive;
/* depends on the current state: WaitJoin, NeighborDead */
CWTimerID currentTimer;
CWTimerID heartbeatTimer;
CWList fragmentsList;
int pathMTU;
/**** ACInterface ****/
int interfaceResult;
CWBool interfaceCommandProgress;
int interfaceCommand;
CWThreadMutex interfaceSingleton;
CWThreadMutex interfaceMutex;
CWThreadCondition interfaceWait;
CWThreadCondition interfaceComplete;
WTPQosValues* qosValues;
/********************************************************
* 2009 Updates: *
* - ofdmValues is a struct for setting the values of *
* a Configuration Update Request with message *
* elemente OFDM. *
* - applicationIndex is the index of application which *
* request the command to WTP *
* (it will used for selecting the correct socket) *
********************************************************/
OFDMControlValues* ofdmValues;
CWProtocolVendorSpecificValues* vendorValues;
int applicationIndex;
/**** ACInterface ****/
CWWTPProtocolManager WTPProtocolManager;
//Elena Agostini - 09/2014: WUM channel for WLAN Iface operations
WUMWLANCmdParameters * cmdWLAN;
/* Retransmission */
CWProtocolMessage *messages;
int messagesCount;
int retransmissionCount;
CWTimerID currentPacketTimer;
CWBool isRetransmitting;
/* expected response */
int responseType;
int responseSeqNum;
/* //Unrecognized message type value
* int unrecognizedMsgType;
*/
// TAP interface name
char tap_name[IFNAMSIZ];
int tap_fd;
// IEEE 802.11
char RadioInformationABGN;
char SuppRates[8];
char MultiDomCapa[6];
char RadioMAC[6];
} CWWTPManager;
//Elena Agostini - 07/2014: max num contemporary threads of generic DTLS data session
#define WTP_MAX_TMP_THREAD_DTLS_DATA 30
/* Elena Agostini - 04/2014: DTLS Data Channel Generic Thread */
typedef struct genericHandshakeThread {
CWThread thread_GenericDataChannelHandshake;
CWSocket dataSock;
CWNetworkLev4Address addressWTPPtr;
CWSafeList packetDataList;
CWThreadMutex interfaceMutex;
CWThreadCondition interfaceWait;
struct genericHandshakeThread * next;
} genericHandshakeThread;
typedef genericHandshakeThread * genericHandshakeThreadPtr;
/* Start list generic threads DTLS Data Channel Handshake*/
extern genericHandshakeThreadPtr listGenericThreadDTLSData[WTP_MAX_TMP_THREAD_DTLS_DATA];
/*________________________________________________________________*/
/* *******************___EXTERN VARIABLES___******************* */
extern CWWTPManager gWTPs[CW_MAX_WTP];
//Elena Agostini: Unique TAP interface
extern int ACTap_FD;
extern char * ACTap_name;
extern CWThreadMutex gWTPsMutex;
extern CWSecurityContext gACSecurityContext;
extern int gACHWVersion;
extern int gACSWVersion;
extern int gActiveStations;
extern int gActiveWTPs;
extern CWThreadMutex gActiveWTPsMutex;
extern int gLimit;
extern int gMaxWTPs;
extern CWAuthSecurity gACDescriptorSecurity;
extern int gRMACField;
extern int gWirelessField;
extern int gDTLSPolicy;
extern CWThreadSpecific gIndexSpecific;
extern char *gACName;
extern int gDiscoveryTimer;
extern int gEchoRequestTimer;
extern int gIdleTimeout;
extern CWProtocolNetworkInterface *gInterfaces;
extern int gInterfacesCount;
extern char **gMulticastGroups;
extern int gMulticastGroupsCount;
extern CWMultiHomedSocket gACSocket;
extern WTPQosValues* gDefaultQosValues;
extern int gHostapd_port;
extern char* gHostapd_unix_path;
extern unsigned char WTPRadioInformationType;
/*
* Elena Agostini - 02/2014
*
* ECN Support Msg Elem MUST be included in Join Request/Response Messages
*/
extern int gACECNSupport;
/*
* Elena Agostini - 02/2014
* OpenSSL params variables
*/
extern char *gACCertificate;
extern char *gACKeyfile;
extern char *gACPassword;
/*
* Elena Agostini - 03/2014: DTLS Data Channel
*/
extern CWBool ACSessionDataActive;
/*________________________________________________________________*/
/* *******************___GLOBAL VARIABLES FOR ATH_MONITOR TEST___******************* */
typedef struct {
struct sockaddr_un servaddr;/* address of Receive Agent */
struct sockaddr_un clntaddr;/* address on AC-side */
int data_stats_sock;
} UNIX_SOCKS_INFO;
UNIX_SOCKS_INFO UnixSocksArray[CW_MAX_WTP];
/*__________________________________________________________*/
/* *******************___PROTOTYPES___******************* */
/* in AC.c */
void CWACInit(void);
void CWACEnterMainLoop(void);
CWBool CWACSendAcknowledgedPacket(int WTPIndex, int msgType, int seqNum);
CWBool CWACResendAcknowledgedPacket(int WTPIndex);
void CWACStopRetransmission(int WTPIndex);
void CWACDestroy(void);
/* in ACTest.h */
CWBool ACQosTest(int WTPIndex);
/* in ACRunState.c */
CWBool CWSaveChangeStateEventRequestMessage(CWProtocolChangeStateEventRequestValues *valuesPtr,
CWWTPProtocolManager *WTPProtocolManager);
CW_THREAD_RETURN_TYPE CWACipc_with_ac_hostapd(void *arg);
/*
* Elena Agostini - 03/2014: DTLS Data Channel Receive Packet
*/
CW_THREAD_RETURN_TYPE CWACReceiveDataChannel(void *arg);
//send_data_to_hostapd(unsigned char *, int);
/****************************************************************
* 2009 Updates: *
* msgElement is used for differentiation between *
* all message elements *
****************************************************************/
CWBool CWAssembleConfigurationUpdateRequest(CWProtocolMessage **messagesPtr,
int *fragmentsNumPtr,
int PMTU,
int seqNum,
int msgElement);
CWBool CWAssembleStationConfigurationRequest(CWProtocolMessage **messagesPtr, int *fragmentsNumPtr, int PMTU, int seqNum, CWFrameAssociationResponse associationResponse, int WTPIndex, int Operation);
CWBool CWAssembleClearConfigurationRequest(CWProtocolMessage **messagesPtr,
int *fragmentsNumPtr, int PMTU,
int seqNum);
/* in ACDiscoveryState.c */
CWBool CWAssembleDiscoveryResponse(CWProtocolMessage **messagesPtr, int seqNum, WTPglobalPhyInfo * tmp);
CWBool CWParseDiscoveryRequestMessage(char *msg,
int len,
int *seqNumPtr,
CWDiscoveryRequestValues *valuesPtr);
/* in ACRetransmission.c */
CWBool CWACSendFragments(int WTPIndex);
/* in ACRunStateCheck.c */
CWBool CWACCheckForConfigurationUpdateRequest(int WTPIndex);
/* in ACProtocol_User.c */
CWBool CWACGetVendorInfos(CWACVendorInfos *valPtr);
int CWACGetRMACField();
int CWACGetWirelessField();
int CWACGetDTLSPolicy();
void CWACDestroyVendorInfos(CWACVendorInfos *valPtr);
/* in ACMainLoop.c */
void CWACManageIncomingPacket(CWSocket sock,
char *buf,
int len,
int incomingInterfaceIndex,
CWNetworkLev4Address *addrPtr,
CWBool dataFlag );
void *CWManageWTP(void *arg);
void CWCloseThread();
CW_THREAD_RETURN_TYPE CWGenericWTPDataHandshake(void *arg);
/* in CWSecurity.c */
CWBool CWSecurityInitSessionServer(CWWTPManager* pWtp,
CWSocket sock,
CWSecurityContext ctx,
CWSecuritySession *sessionPtr,
int *PMTUPtr);
CWBool ACEnterJoin(int WTPIndex, CWProtocolMessage *msgPtr);
CWBool ACEnterConfigure(int WTPIndex, CWProtocolMessage *msgPtr);
CWBool ACEnterDataCheck(int WTPIndex, CWProtocolMessage *msgPtr);
CWBool ACEnterRun(int WTPIndex, CWProtocolMessage *msgPtr, CWBool dataFlag);
//Elena Agostini: 09/2014. IEEE Binding
/* ACIEEEConfigurationState.c */
CWBool CWParseIEEEConfigurationResponseMessage(CWProtocolMessage *msgPtr, int len, int WTPIndex);
CWBool CWAssembleIEEEConfigurationRequest(CWProtocolMessage **messagesPtr,
int *fragmentsNumPtr,
int PMTU,
int seqNum,
int operation,
int radioID,
int wlanNum,
int WTPIndex);
CWBool ACUpdateInfoWlanInterface(WTPInterfaceInfo * interfaceInfo, int wlanID, char * SSID, int tunnelMode);
CWBool CWSecurityInitSessionServerDataChannel(CWWTPManager* pWtp,
CWNetworkLev4Address * address,
CWSocket sock,
CWSecurityContext ctx,
CWSecuritySession *sessionPtr,
int *PMTUPtr);
CW_THREAD_RETURN_TYPE CWInterface(void* arg);
/* void CWTimerExpiredHandler(int arg); */
#endif