summaryrefslogtreecommitdiff
path: root/cp/station/inc/station_data.h
blob: 862d13441a3e7a459e21f0c7e07a8322d42eaf99 (plain)
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
397
398
399
400
401
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cp/station/inc/station_data.h
 * \brief   the data stored 
 * \ingroup cp_station
 */
#ifndef STATION_DATA_H_
#define STATION_DATA_H_

#include <string.h>
#include "mac/common/store.h"
#include "cp/cp_types.h"
#include "cp/station/inc/station_types.h"
#include "cp/station/inc/station_ctx.h"
#include "cl/cl.h"
#include "SEMTypes.h"

typedef enum process_usta_result_t 
{
    BECOME_CCO, 
    USTA_MATCHING_NID, 
    CHECK_EXISTING_OTHER_AVLN 
} process_usta_result_t;

/*
cl_t *
station_get_cl_ctx(void);

mac_store_t *
station_get_mac_store_ctx(void);
*/

cp_sta_t *my_cp_sta_ctx;
/**
 * \brief       return the nid of the station
 * \param       ctx  pointer to station context.
 * \return      the nid !
 */
nid_t 
cp_station_get_nid(cp_sta_t *ctx);

/**
 * \brief       return the snid of the station
 * \param       
 * \return      the snid !
 */
snid_t 
cp_station_get_snid(void);

/**
 * \brief       return the cco capability of the station
 * \param       
 * \return      guess what ? the cco capa !
 *              ie : 0 : cco level 0
 *                   1 : level 1
 *                   ...
 */
u8 
cp_station_get_cco_capa(void);

/**
 * \brief       return true if the station is cco
 * \param       
 * \return      
 */
bool 
cp_station_get_is_cco(void);

/**
 * \brief       return true if the station is pcco capable
 * \param       
 * \return      
 */
bool
cp_station_get_pcco_capa(void);

/**
 * \brief       return true if the station is can be backup cco
 * \param       
 * \return      
 */
bool
cp_station_get_backup_cco_capa(void);


/**
 * \brief       return the number of associated station of the avln
 * \param       
 * \return      the number
 */
u8
cp_station_get_number_of_assoc(void);

/**
 * \brief       set the new tei of the station
 * \param       new_tei : the new tei
 * \param       lease_time : liease time of this tei
 * \return      
 */
void
cp_station_set_tei(const tei_t new_tei, const u16 lease_time);

/**
 * \brief       get the new tei of the station
 * \return      the tei of the station      
 */
tei_t
cp_station_get_tei(void *v);

/**
 * \brief       set the mac address of the station
 * \param       ctx  pointer to station context.
 * \param       mac_address : the mac address
 * \return      
 */
void
cp_station_set_mac_address(cp_sta_t *ctx, mac_address_t mac_address);

/**
 * \brief       return the mac address of the station
 * \param       ctx  pointer to station context.
 * \return      
 */
void
cp_station_get_mac_address(cp_sta_t *ctx, mac_address_t *mac_address);

/**
 * \brief       clear the associated sta list
 * \return      
 */
void 
cp_station_clear_assoc_sta_list(void);

/**
 * \brief       init the storage class
 * \param       
 * \return         
 */
void 
cp_station_data_init(mac_store_t *mac_store_ctx, cl_t *interf_cl_ctx, pbproc_t *pbproc_ctx);


/**
 * \brief       in the POND state, this function will record the cm_unassociated_sta.ind
 *              received.
 * \param       mac_address : the osa of the message
 * \param       cco_capa : the cco_capa field of the message
 * \param       nid : the nid field of the message
 * \return         
 */
void 
cp_station_add_usta(const mac_address_t mac_address, const u8 cco_capa, const nid_t nid);

/**
 * \brief       this will process the previously recorded messages, to know if
 *              in which state the station should go.
 * \return         process_usta_result_t
 */
process_usta_result_t
cp_station_process_recorded_usta(void);

/**
 * \brief       this will compare the field of a received cm_unssociated_sta.ind
 *              with the station's parameters
 * \param       mac_address : the osa of the message
 * \param       cco_capa : the cco_capa field of the message
 * \param       nid : the nid field of the message
 * \return         
 */
process_usta_result_t
cp_station_process_usta(const mac_address_t mac_address, const u8 cco_capa, const nid_t nid);

/**
 * \brief       this will add an avln to the discovered avln list of the station
 * \param       nid : the nid of the new avln
 * \param       snid : the snid of the new avln
 * \return         
 */
void 
cp_station_add_avln(const nid_t nid, const snid_t snid);

/**
 * \brief       associate a new station. call this function when cco
 *              (the station has no TEI)
 * \param       sta : information about the new station
 * \return      TEI of the newly associated station, or 0 if failed         
 */
tei_t
cp_station_associate_new(const station_t sta);

/**
 * \brief       renew the TEI of a station
 * \param       sta : information about the new station
 * \return      TEI of the newly associated station, or 0 if failed         
 */
tei_t
cp_station_renew(const station_t sta);

/**
 * \brief       add a station to the associated station list.
 *              (the station already had a TEI)
 * \param       tei : tei of the station       
 * \param       sta : information about the new station
 * \return               
 */
void
cp_station_associate_old(const tei_t tei, const station_t sta);

/**
 * \brief       remove a station from the associated station list.
 * \param       tei : tei of the station       
 * \return               
 */
void
cp_station_remove_associated(const tei_t tei);

/**
 * \brief       return the data of an associated sta
 * \param       sta : the returned data
 * \param       from_first : set to true if you want to search station from the begining of the list
 * \param       tei : if you already know the tei of the station, set it here
 * \return      TEI of the next station in the list, or 0 if none         
 */
tei_t
cp_station_get_associate_info(station_t *sta, const bool from_first, const tei_t tei);

/**
 * \brief       return the tei associated to this mac address
 * \param       mac : the mac address
 * \return      the tei         
 */
tei_t
cp_station_find_tei_from_mac(const mac_address_t mac_address);

/**
 * \brief       get the status of the station
 * \param       
 * \return      the current status of the station 
 */
cp_station_status_t
cp_station_get_status(void);

/**
 * \brief       set the association status of the station
 * \param       become_associated true to set station in associated station state 
 * \return      
 */
VS_VOID 
cp_station_set_assoc_status (VS_BOOL become_associated);

/**
 * Return the association status of the station
 *
 * \return  boolean informing if the sta is associated or not.
 */
VS_BOOL 
cp_station_get_assoc_status (void);

/**
 * Return the association status of the station
 *
 * \param  ctx  the station context.
 * \return  boolean informing if the sta is associated or not.
 */
VS_BOOL
cp_station_is_associated(cp_sta_t *ctx);

/**
 * \brief       set the cco status of the station
 * \param       is_cco true to set station in cco state
 * \return      
 */
VS_VOID
cp_station_set_cco_status (VS_BOOL is_cco);

/**
 * \brief       set the authentication status of the station
 * \param       become_authenticated true to set station in authenticated station state
 * \return      
 */
VS_VOID 
cp_station_set_auth_status (VS_BOOL become_authenticated);

/**
 * Return the authentication status of the station
 *
 * \return  boolean informing if the sta is authenticated or not.
 */
VS_BOOL 
cp_station_get_auth_status (void);

/**
 * Return the authentication status of the station
 *
 * \param  ctx  the station context.
 * \return  boolean informing if the sta is authenticated or not.
 */
VS_BOOL
cp_station_is_authenticated(cp_sta_t *ctx);

/**
 * \brief       return true if the station is pco
 * \param       
 * \return      
 */
bool 
cp_station_get_is_pco(void);

/**
 * \brief       return true if the station is backup cco
 * \param       
 * \return      
 */
bool 
cp_station_get_is_backup_cco(void);

/**
 * \brief       return the number of station recorded in the discovered sta list
 * \param       
 * \return      
 */
u16
cp_station_get_num_discovered_sta(void);

/**
 * \brief       return the number of discovered AVLN
 * \param       
 * \return      
 */
u16
cp_station_get_num_discovered_avln(void);

/**
 * \brief       return true if the station user appointed cco
 * \param       
 * \return      
 */
bool 
cp_station_get_is_user_appointed_cco(void);

/**
 * Get the Handover in progress status.
 *
 * \param  sta the station context
 * \return  the handover progress status.
 */
bool
cp_station_get_hoip (cp_sta_t *sta);

/**
 * Set the Handover in progress status.
 *
 * \param  sta  context.
 * \param  hoip  handover in progress.
 */
void
cp_station_set_hoip(cp_sta_t *sta, uint hoip);

/**
 * get the rstbf flag
 *
 * \param  sta  the sta context.
 */
bool
cp_station_get_rtsbf(cp_sta_t *sta);

/**
 * Set the sta rtsbf
 *
 * \param  sta  the station context
 * \param  rstbf  the flag
 */
void
cp_station_set_rtsbf (cp_sta_t *sta, bool rtsbf);

/**
 * Get the number of distant STAs
 *
 * \param  sta  the station context
 * \return  the number of distant stations
 */
u8
cp_station_get_num_dis_sta(cp_sta_t *sta);

/**
 * Get number of distant networks.
 *
 * \param  sta the sta context.
 * \return  the number of distant networks.
 */
u8
cp_station_get_num_dis_net(cp_sta_t *sta);


#endif /*STATION_DATA_H_*/