summaryrefslogtreecommitdiff
path: root/cesar/cp2/sta/action/poweron.h
blob: 262964806fea4344a1b4b235716d82dcff4ac449 (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
#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
 * - (4) clear join timer
 *
 * 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, 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__poweron_usta__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, trigger a TO_CCO event.
 *
 * In other cases, if there is at least one AVLN in the discovered list,
 * trigger a TO_USTA event.  If there is no AVLN discovered, trigger a
 * TO_UCCO.
 */
void
cp_sta_action_poweron__poweron__btt_timeout (cp_t *ctx);

/**
 * Handle POWERON, 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, trigger a TO_JOIN event 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_usta__beacon (cp_t *ctx, cp_net_t *net,
                                             cp_sta_t *sta);

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

/**
 * 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 trigger a TO_CCO event.
 */
void
cp_sta_action_poweron__usta__usta_ind (cp_t *ctx, cp_net_t *net,
                                       cp_sta_t *sta);

/**
 * 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.
 */
void
cp_sta_action_poweron__sta__beacon_not_received (cp_t *ctx);

/**
 * Handle CCO => JOIN TIMEOUT.
 * \param  ctx  control plane context
 *
 * If there is at least one discovered AVLN, trigger a TO_USTA event.  Else,
 * trigger a TO_UCCO event.
 */
void
cp_sta_action_poweron__cco__join_timeout (cp_t *ctx);

/**
 * Handle CCO => STA JOINED.
 * \param  ctx  control plane context
 *
 * Reset the join timer.
 */
void
cp_sta_action_poweron__cco__sta_joined (cp_t *ctx);

/**
 * Handle CCO => ALL STA LEAVED.
 * \param  ctx  control plane context
 *
 * If there is at least one discovered AVLN, trigger a TO_USTA event.  Else,
 * trigger a TO_UCCO event.
 */
void
cp_sta_action_poweron__cco__all_sta_leaved (cp_t *ctx);

END_DECLS

#endif /* cp2_sta_action_poweron_h */