-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCWAC.h
332 lines (282 loc) · 11.1 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
/************************************************************************************************
* 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. *
* *
* -------------------------------------------------------------------------------------------- *
* 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_NO_DTLS
#define CW_MAX_WTP 3000
#define CW_CRITICAL_TIMER_EXPIRED_SIGNAL SIGUSR2
#define CW_SOFT_TIMER_EXPIRED_SIGNAL SIGUSR1
#define AC_LOG_FILE_NAME "./ac.log"
#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
#define CONFIG_UPDATE_REQ_VENDOR_CONFIG_ELEMENT_TYPE 10
#define CONFIG_UPDATE_REQ_VENDOR_STATE_ELEMENT_TYPE 11
#define CONFIG_UPDATE_REQ_VENDOR_PORTAL_ELEMENT_TYPE 12
#define CONFIG_UPDATE_REQ_VENDOR_ACTIVE_ELEMENT_TYPE 21
#define CONFIG_UPDATE_REQ_VENDOR_UNACTIVE_ELEMENT_TYPE 22
/********************************************************
* 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
// BE muilt config
#define MAX_APPS_CONNECTED_TO_AC 1000
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;
//add client
/*
CWSocket appClientSocket;
struct sockaddr_in appClientAddr;
CWThreadMutex appClientSocketMutex;
*/
} applicationsManager;
applicationsManager appsManager;
/*_____________________________________________________*/
/* *******************___TYPES___******************* */
/*
* Struct that describes a WTP from the AC's point of view
*/
typedef struct {
u_char MAC[MAC_ADDR_LEN];
CWNetworkLev4Address address;
CWThread thread;
CWSecuritySession session;
//CWBool isNotFree;
CWWTPState wtpState;
CWBool isRequestClose;
CWStateTransition currentState;
int interfaceIndex;
CWSocket socket;
//too large, malloc
//char buf[CW_BUFFER_SIZE];
char *buf;
enum {
CW_DTLS_HANDSHAKE_IN_PROGRESS,
CW_WAITING_REQUEST,
CW_COMPLETED,
} subState;
CWSafeList packetReceiveList;
/* 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 wtpMutex;
CWThreadCondition wtpWait;
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;
CWProtocolVendorPortalValues* vendorPortalValues;
int applicationIndex;
/**** ACInterface ****/
CWWTPProtocolManager WTPProtocolManager;
/* Retransmission */
CWProtocolMessage *messages;
int messagesCount;
int retransmissionCount;
CWTimerID currentPacketTimer;
CWBool isRetransmitting;
/* expected response */
int responseType;
int responseSeqNum;
//connectEvent
char isConnect;
/* //Unrecognized message type value
* int unrecognizedMsgType;
*/
} CWWTPManager;
/*________________________________________________________________*/
/* *******************___EXTERN VARIABLES___******************* */
extern CWWTPManager gWTPs[CW_MAX_WTP];
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;
//BE
extern char *gACBEServerAddr;
extern int gACBEServerPort;
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;
/*________________________________________________________________*/
/* *******************___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);
/* Debug in AC.c*/
void ShowApInfo(int apIndex);
void ShowRunApIndex();
/* in ACTest.h */
CWBool ACQosTest(int WTPIndex);
/* in ACRunState.c */
CWBool CWSaveChangeStateEventRequestMessage(CWProtocolChangeStateEventRequestValues *valuesPtr,
CWWTPProtocolManager *WTPProtocolManager);
/****************************************************************
* 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,
unsigned char* StationMacAddr);
CWBool CWAssembleClearConfigurationRequest(CWProtocolMessage **messagesPtr,
int *fragmentsNumPtr, int PMTU,
int seqNum);
CWBool CWAssembleResetRequest(CWProtocolMessage **messagesPtr,
int *fragmentsNumPtr, int PMTU,
int seqNum);
/* in ACDiscoveryState.c */
CWBool CWAssembleDiscoveryResponse(CWProtocolMessage **messagesPtr, int seqNum);
CWBool CWParseDiscoveryRequestMessage(char *msg,
int len,
int *seqNumPtr,
CWDiscoveryRequestValues *valuesPtr);
CWBool CWParseJoinReqMsgNotValue(char *msg,
int len);
/* 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);
void *CWManageWTP(void *arg);
void _CWCloseThread(int i);
void CWCloseThread();
/* 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);
CW_THREAD_RETURN_TYPE CWInterface(void* arg);
/* void CWTimerExpiredHandler(int arg); */
#endif