summaryrefslogtreecommitdiff
path: root/cesar/cp/cco/action/cco_action.h
blob: b1dcb9313e1dba0fbcc204263338211b2a948e10 (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
#ifndef cp_cco_action_h
#define cp_cco_action_h
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cp/cco/cco_action.h
 * \brief   CCo Public functions.
 * \ingroup cp_cco
 *
 */

#include "cp/cp.h"
#include "cp/mme.h"
#include "cp/beacon/beacon.h"
#include "cp/sta/mgr/sta.h"
#include "cp/cco/action/handover.h"

/** Forward declaration. */
typedef struct cp_cco_action_t cp_cco_action_t;

BEGIN_DECLS

/**
 * initialisation of CCo action module.
 * \param  ctx  the module context.
 *
 */
void
cp_cco_action_init (cp_t *ctx);

/**
 * Uninitialisation of CCo action module.
 * \param  ctx  the module context.
 *
 */
void
cp_cco_action_uninit (cp_t *ctx);

/**
 * Change the SNID using the beacon module.
 * \param  ctx  the module context.
 *
 *  It shall request the SNIDs in use from the station manager to choose
 * one randomly in the available SNIDs
 */
void
cp_cco_action_snid_change (cp_t *ctx);

/**
 * perform garbage actions of CCo's responsibility.
 * \param  ctx  the module context.
 */
void
cp_cco_action_garbage (cp_t *ctx);

/**
 * generate a new NEK value.
 * \param  ctx  the module context.
 *
 * NEK shall be used no more than 1 hour, so must be changed after 1
 * hour  for that purpose, NEK expiration date is checked at every occurrence
 * of  the global garbage collector timer and if current NEK expiration
 * date reached,  a new NEK value shall be generated by calling this function
 */
void
cp_cco_action_gen_nek (cp_t *ctx);

/**
 * Send the TEI map with the data corresponding to the station leaving.
 * \param  ctx  the CP context.
 * \param  sta  the station which leaves the AVLN.
 *
 * It will not add a reference on the station and will not release it.
 */
void
cp_cco_action__cco__sta_leave_send_tei_map (cp_t *ctx, cp_sta_t *sta);



/**
 * manage association of a station.
 * \param  ctx  the module context.
 * \param  assoc_req  CM_ASSOC.REQ MME msg having being received
 */
void
cp_cco_action__cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req);

/**
 * manage association of a station.
 * \param  ctx  the module context.
 * \param  assoc_req  CM_ASSOC.REQ MME msg having being received
 */
void
cp_cco_action__ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req);

/**
 * manage authentication of a station.
 * \param  ctx  the module context.
 * \param  get_key_req  CM_GET_KEY.REQ MME msg having being decrypted
 */
void
cp_cco_action__cco__cm_get_key_req_pid0 (cp_t *ctx, cp_mme_rx_t * get_key_req);

/**
 * manage explicit leave request of a station.
 * \param  ctx  the module context.
 * \param  sta  provided by the garbage function to send a CC_LEAVE_IND.
 *
 * Remove the station from the station manager.
 * \warn It does not release the reference of the station provided
 * in parameters.
 */
void
cp_cco_action__cco__tei_expired (cp_t *ctx, cp_sta_t *sta);

/**
 * Release a station.
 * \param  ctx  the CP context.
 * \param  mme  the MME received.
 */
void
cp_cco_action__cco__cc_leave (cp_t *ctx, cp_mme_rx_t *mme);

/**
 * Start to act as a CCo coming from the unassociated state..
 * \param  ctx  the module context.
 *
 * This function shall:
 *   - Choose a TEI for the station to authenticate it.
 *   - Choose a SNID for the AVLN.
 *   - Create and set our AVLN in the station manager.
 *   - Change the station CCo status.
 *   - Generate the NEK.
 *   - Program the NEK change timer.
 *   - Send a central beacon.
 */
void
cp_cco_action__unassoc__cco_start (cp_t *ctx);

/**
 * Start to act as a CCo coming from the unassociated state..
 * \param  ctx  the module context.
 *
 * This function shall:
 *   - Change the station CCo status.
 *   - Generate the NEK.
 *   - Program the NEK change timer (to change in few minutes).
 *   - Program the beacon timer to send a central beacon at the beginning of
 *   the next beacon period.
 */
void
cp_cco_action__assoc__cco_start (cp_t *ctx);

/**
 * Stop acting as a CCo and become a simple station.
 * \param  ctx  the module context.
 *
 * This function shall:
 *   - Change the station status.
 *   - Reprogram the beacon timer to expire a few time after the beacon period
 *   start date.
 *   - Stop the NEK generation.
 */
void
cp_cco_action__cco__assoc_stop (cp_t *ctx);

/**
 * Stop acting as a CCo and become a unassociated station.
 * \param  ctx  the module context.
 *
 * This function shall:
 *   - Change the station status.
 *   - Reprogram the beacon timer to expire a few time after the beacon period
 *   start date.
 *   - Stop the NEK generation.
 *   - Delete the AVLN.
 *   - Change the station authenticated status to not authenticated.
 */
void
cp_cco_action__cco__unassoc_stop (cp_t *ctx);

/**
 * The Handover can not be done cause of a countdown in the central beacon.
 * \param  ctx  the module context.
 *
 * This function will be called on each beacon timer expiration to send a
 * central beacon and try to handover the CCo functionality to stop.
 */
void
cp_cco_action_drv_mac_stop_suspend (cp_t *ctx);

/**
 * Stop the station.
 * \param  ctx  the module context.
 *
 * This function should stop the station.
 *  - Stop the pbproc.
 *  - Stop the hle
 *  - deactivate the SAR
 *  - deactivate the beacon module.
 *  - cleanup the SAR.
 */
void
cp_cco_action_drv_mac_stop_ended (cp_t *ctx);

/**
 * Release a TEI.
 * \param  ctx  the module context.
 * \param  tei  The TEI value to release.
 *
 */
void
cp_cco_action_tei_release (cp_t *ctx, u8 tei);

/**
 * Set the TEI in use.
 * \param  ctx  the module context.
 * \param  tei  the TEI already in use.
 *
 * Use this function for the handover to disallow the new CCo to use a TEI
 * already in use.
 */
void
cp_cco_action_tei_in_use (cp_t *ctx, cp_tei_t tei);

/**
 * Clear the TEI compute mechanism.
 * \param  ctx  the module context.
 *
 * Use this function on the CCO stop.
 */
void
cp_cco_action_tei_clear (cp_t *ctx);

/**
 * CCo STOP on the DRV_MAC_STOP MME.
 * \param  ctx  the module context.
 *
 * This function shall produce a handover on the network to allow another
 * station to become the network CCo. So it shall inform the beacon module to
 * set the hoip flag in the central beacon and provide a handover in progress
 * bentry in the central beacon.
 *
 * \warn This function will not stop the CCo. This shall be done once the
 * handover has been done on the network.
 */
void
cp_cco_action_drv_mac_stop (cp_t *ctx);

/**
 * CCo selection for the drv mac stop request.
 * \param  ctx  the module context.
 * \param  sta  the station to add.
 */
void
cp_cco_action_cco_selection__mac_stop_sta_add (cp_t *ctx, cp_sta_t *sta);

/**
 * Clear the selection context.
 * \param  ctx  the module context.
 */
void
cp_cco_action_cco_selection__clear (cp_t *ctx);

/**
 * Add a station to the CCo selection procedure.
 * \param  ctx  the module context.
 * \param  net  the station's NET.
 * \param  sta  the station to add.
 *
 * This function shall add the station only if it can be a better CCo and if
 * out station is not CCo User appointed.
 */
void
cp_cco_action_cco_selection__sta_add (cp_t *ctx, cp_net_t *net, cp_sta_t *sta);

/**
 * Handle SC_CCO => CC_ASSOC_REQ.
 * \param  ctx  control plane context.
 * \param  mme  the handled MME.
 *
 * If it's the STA with which we are doing the SC assoc, reply with ok,
 * otherwise, reply with temporary failure.
 */
void
cp_cco_action_sc__sc_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t *mme);

/**
 * The handover is ended.
 * \param  ctx  control plane context.
 *
 * Allow the ASSOC FSM to go to the authenticated state
 */
void
cp_cco_action_handover_ended (cp_t *ctx);

/**
 * Start providing the NEK to the authenticated stations.
 * \param  ctx  control plane context.
 *
 * CCO_NEK_CHANGE_IDLE -> CCO_NEK_CHANGE_WAIT_STA_CNF.
 * This function should start a timer to check the timeout.
 */
void
cp_cco_action_nek_provide (cp_t *ctx);

/**
 * Timeout NEK exchange with a station.
 * \param  ctx  control plane context.
 *
 * This should try to provide the nek to another station if the peered station
 * was not the last of the AVLN, in the other case it should stop the FSM
 * going to the IDLE state.
 */
void
cp_cco_action_nek_change_timeout_wait (cp_t *ctx);

/**
 * Timeout NEK exchange with a station.
 * \param  ctx  control plane context.
 *
 * This should try to provide the nek to another station if the peered station
 * was not the last of the AVLN, in the other case it should stop the FSM
 * going to the IDLE state.
 */
void
cp_cco_action_nek_change_timeout_process (cp_t *ctx);

/**
 * Received the CM_SET_KEY.CNF from the station.
 * \param  ctx  control plane context.
 * \param  mme  the handled MME.
 *
 * CCO_NEK_CHANGE_WAIT_STA_CNF -> CCO_NEK_CHANGE_PROCESS_CM_SET_KEY_CNF
 * Check the security parameters and the prn.
 */
void
cp_cco_action_cm_set_key_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme);

/**
 * Call the beacon module to start inserting the EKS bentry in the central
 * beacon.
 * \param  ctx  control plane context.
 */
void
cp_cco_action_nek_change_prevent (cp_t *ctx);

END_DECLS

#endif /* cp_cco_action_h */