summaryrefslogtreecommitdiff
path: root/cesar/cp2/sta/action/poweron.h
blob: 5484aea3baf6e3942089ec802f1796aebd3080b1 (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
#ifndef cp2_sta_action_poweron_h
#define cp2_sta_action_poweron_h
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cp2/sta/action/poweron.h
 * \brief   STA action, power on procedure related definitions.
 * \ingroup cp2_sta_action
 *
 * Power-on procedure
 * ==================
 *
 * This part handle power-on procedure, neighbourhood discovery and
 * association decision.  A state machine is used to handle the different
 * states:
 *
 * \image html poweron.png "Power-on state machine"
 *
 * - (1) send CM_UNASSOCIATED_STA.IND
 * - (2) select an AVLN to track
 * - (3) clear beacon not received counter if our beacon
 *
 * Related: 7.1.
 */
#include "cp2/sta/mgr/net.h"

BEGIN_DECLS

/**
 * Start the power-on procedure.
 * \param  ctx  control plane context
 *
 * Initialise the data plane to receive beacons and CM_UNASSOCIATED_STA.IND
 * messages.
 *
 * Initialise the BTT and USTT timers.
 */
void
cp_sta_action_poweron_start (cp_t *ctx);

/**
 * Handle POWERON => USTT TIMEOUT.
 * \param  ctx  control plane context
 *
 * If there is at least one AVLN in the discovered list, send a
 * CM_UNASSOCIATED_STA.IND, then restart the USTT timer with a random value
 * (in the right range).
 */
void
cp_sta_action_poweron__poweron__ustt_timeout (cp_t *ctx);

/**
 * Handle POWERON => BTT TIMEOUT.
 * \param  ctx  control plane context
 *
 * No beacon has been received during the BTT timer.  Look in the discovered
 * STA list to see if there is a NID match.  If a NID match and the station
 * should become CCo, go to CCO state.
 *
 * In other cases, if there is at least one AVLN in the discovered list, go to
 * USTA state.  If there is no AVLN discovered, go to UCCO state.
 */
void
cp_sta_action_poweron__poweron__btt_timeout (cp_t *ctx);

/**
 * Handle POWERON => BEACON.
 * \param  ctx  control plane context
 * \param  net  STA net
 * \param  sta  STA emitting the beacon
 *
 * When a beacon is received, if NID matches, go to corresponding JOINING
 * states and start the association procedure.  In the other case, select an
 * AVLN to track in the list of discovered AVLN and continue searching.
 */
void
cp_sta_action_poweron__poweron__beacon (cp_t *ctx, cp_net_t *net,
                                        cp_sta_t *sta);

/**
 * Handle POWERON_JOINING => LEFT.
 * \param  ctx  control plane context
 *
 * Select an AVLN to track and continue searching.
 */
void
cp_sta_action_poweron__poweron_joining__left (cp_t *ctx);

/**
 * Handle USTA => USTT TIMEOUT.
 * \param  ctx  control plane context
 *
 * If there is at least one AVLN in the discovered list, send a
 * CM_UNASSOCIATED_STA.IND, then restart the USTT timer with a random value
 * (in the right range).
 */
void
cp_sta_action_poweron__usta__ustt_timeout (cp_t *ctx);

/**
 * Handle USTA => BEACON.
 * \param  ctx  control plane context
 * \param  net  STA net
 * \param  sta  STA emitting the beacon
 *
 * When a beacon is received, if NID matches, go to corresponding JOINING
 * states and start the association procedure.  In the other case, select an
 * AVLN to track in the list of discovered AVLN and continue searching.
 */
void
cp_sta_action_poweron__usta__beacon (cp_t *ctx, cp_net_t *net, cp_sta_t *sta);

/**
 * Handle USTA => USTA IND.
 * \param  ctx  control plane context
 * \param  net  STA net
 * \param  sta  STA emitting CM_UNASSOCIATED_STA.IND
 *
 * If the NID match and the station should become CCo go to CCO state.
 */
void
cp_sta_action_poweron__usta__usta_ind (cp_t *ctx, cp_net_t *net,
                                       cp_sta_t *sta);

/**
 * Handle USTA_JOINING => LEFT.
 * \param  ctx  control plane context
 *
 * Select an AVLN to track and continue searching.
 */
void
cp_sta_action_poweron__usta_joining__left (cp_t *ctx);

/**
 * Handle entering STA.
 * \param  ctx  control plane context
 */
void
cp_sta_action_poweron__sta__enter (cp_t *ctx);

/**
 * Handle STA => BEACON.
 * \param  ctx  control plane context
 * \param  net  STA net
 * \param  sta  STA emitting the beacon
 *
 * If the beacon is ours, reset the "beacon not received" counter.
 */
void
cp_sta_action_poweron__sta__beacon (cp_t *ctx, cp_net_t *net, cp_sta_t *sta);

/**
 * Handle STA => BEACON NOT RECEIVED.
 * \param  ctx  control plane context
 *
 * Increment the "beacon not received" counter.  If it reaches the limit,
 * restart the power-on procedure.
 *
 * Inform the assoc FSM.
 */
void
cp_sta_action_poweron__sta__beacon_not_received (cp_t *ctx);

/**
 * Handle CCO => JOIN TIMEOUT.
 * \param  ctx  control plane context
 *
 * If there is no associated STA, stop being a CCo. In this case, if there is
 * at least one discovered AVLN, go to USTA state.  Else, go to UCCO state.
 */
void
cp_sta_action_poweron__cco__join_timeout (cp_t *ctx);

/**
 * Handle CCO => ALL STA LEAVED.
 * \param  ctx  control plane context
 *
 * If there is at least one discovered AVLN, go to USTA state.  Else, go to
 * UCCO state.
 */
void
cp_sta_action_poweron__cco__all_sta_leaved (cp_t *ctx);

END_DECLS

#endif /* cp2_sta_action_poweron_h */