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

#include "cp2/cp.h"
#include "cp2/mme.h"
#include "cp2/beacon/forward.h"
#include "cp2/sta/mgr/sta.h"

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

/**
 * 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.
 * \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 responsability.
 * \param  ctx  the module context.
 */
void
cp_cco_action_garbage (cp_t *ctx);

/**
 * generate a new NEK value.
 * \param  ctx  the module context.
 * \param  sl  security level
 *
 *   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, u8 sl);

/**
 * manage association of a station.
 * \param  ctx  the module context.
 * \param  assoc_req  CM_ASSOC.REQ MME msg having being received
 *
 *   1) if CC_ASSOC.REQ ReqType field value is "join", call create_tei_lease()
 *     to create a default TEI lease (select a TEI value and set 15 minutes
 * of lease date by default, Table 11-212)  2) else if CC_ASSOC.REQ ReqType
 * field value is "renew", update (renew) the TEI lease     (lease = 15
 * minutes if STA still not authenticated, 48 Hours if STA is     authenticated
 * ? Table 11-212)  3) prepare CM_ASSOC.CNF MME to be sent back to the
 * STA that sent the assoc request  4) send CM_ASSOC.CNF MME back to the
 * STA that sent the assoc request  5) if the CM_ASSOC.CNF was a positive
 * confirmation, put a STA_JOINED event in the FSM
 */
void
cp_cco_action_manage_sta_assoc (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
 *
 *   1) prepare CM_SET_KEY.REQ MME to be sent back to the STA that sent
 * the auth (get key) request  2) encrypt and encapsulate the CM_SET_KEY.REQ
 * MME into a CM_ENCRYPTED_PAYLOAD.IND MME  3) send CM_ENCRYPTED_PAYLOAD.IND(CM_SET_KEY.REQ)
 * back to the STA that sent the auth (get key) request
 */
void
cp_cco_action_manage_sta_auth (cp_t *ctx, cp_mme_rx_t * get_key_req);

/**
 * manage explicit leave request of a station.
 * \param  ctx  the module context.
 * \param  leave_req  The MME leave req message.
 * \param  sta  provided by the garbage function to send a CC_LEAVE_IND.
 *
 *   Remove the station from the station manager
 */
void
cp_cco_action_manage_sta_leave (cp_t *ctx, cp_mme_rx_t * leave_req,
                                cp_sta_t *sta);

/**
 * manage explicit leave request of a station.
 * \param  ctx  the module context.
 * \param  leave_req  The MME leave req message.
 *
 *   Remove the station from the station manager
 */
extern inline void
cp_cco_action_manage_sta_leave_req (cp_t *ctx, cp_mme_rx_t * leave_req)
{
    dbg_assert (ctx);
    dbg_assert (leave_req);

    cp_cco_action_manage_sta_leave (ctx, leave_req, NULL);
}


#endif /* cp2_cco_action_h */