summaryrefslogtreecommitdiff
path: root/cesar/cp/beacon/beacon.h
blob: ccecfa00d66ac3ba95e1f0c0ab63cc4cfd749048 (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
#ifndef cp_beacon_beacon_h
#define cp_beacon_beacon_h
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cp/beacon/beacon.h
 * \brief   Beacon module public API.
 * \ingroup cp_beacon
 *
 * Beacon module. Use to generate and read a beacon.
 */

#include "cp/cp.h"
#include "cp/defs.h"
#include "cp/beacon/defs.h"

#include "cp/sta/mgr/net.h"
#include "bsu/beacon/beacon.h"

#define CP_BEACON_PERIOD_TIMER_OFFSET_TCK 10000
#define CP_BEACON_SIZE 136

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

BEGIN_DECLS

/**
 * Initialise the beacon module.
 * \param  ctx  the module context.
 */
void
cp_beacon_init (cp_t *ctx);

/**
 * Unitialise the beacon module.
 * \param  ctx  the module context.
 */
void
cp_beacon_uninit (cp_t *ctx);

/**
 * Generate beacon data when station acts as STA.
 * \param  ctx  the module context.
 */
void
cp_beacon_sta_update_beacon_data (cp_t *ctx);

/**
 * Generate beacon data when station acts as CCo.
 * \param  ctx  the module context.
 */
void
cp_beacon_cco_update_beacon_data (cp_t *ctx);

/**
 * Generate beacon data for poweron init
 * \param  ctx  the module context.
 */
void
cp_beacon_poweron_init (cp_t *ctx);

/**
 * Create default schedules and provide it to the Channel Access.
 * \param  ctx  the module context.
 */
void
cp_beacon_create_default_schedules (cp_t *ctx);

/**
 * Process the first beacon in the received list.
 * \param  ctx  the control plane context.
 */
void
cp_beacon_get_and_process_beacon (cp_t *ctx);

/**
 * Process a tracked network using the central beacon or the proxy beacon.
 * \param  ctx  the CP module context.
 * \param  beacon  the beacon received and tracked.
 * \param  net  the net of the STA emitting the beacon.
 */
void
cp_beacon_process_tracked_avln (cp_t *ctx, bsu_beacon_t *beacon,
                                cp_net_t *net);

/**
 * Reset tracking information.
 * \param  ctx  the CP module context.
 */
void
cp_beacon_process_untracked_avln (cp_t *ctx);

/**
 * Function to call once the beacon has not been received.
 * \param ctx  the module context.
 *
 * The beacon timer has expired and this function had been called by the FSM.
 */
void
cp_beacon_beacon_not_received (cp_t *ctx);

/**
 * Set the nek in the beacon module.
 * \param  ctx  the CP context.
 * \param  eks  the eks tu use.
 * \param  nek  the nek key.
 * \param  now  indicate if the nek shall be use right now.
 */
void
cp_beacon_change_nek (cp_t *ctx, uint eks, cp_key_t nek, bool now);

/**
 * Handover.
 * \param  ctx  the CP context.
 * \param  tei  the TEI of the new CCo on the AVLN.
 *
 * This function will set the handover in progress flag in the central beacon
 * and all beacon produce by this module.
 * It shall set the hccd bentry countdown to a finite value (in a define) to
 * change indicate to all the station in the AVLN, the CCo will change.
 */
void
cp_beacon_handover (cp_t *ctx, cp_tei_t tei);

/**
 * Handover in progress flag.
 * \param  ctx  the CP context.
 * \param  flag  the handover flag.
 */
void
cp_beacon_handover_hoipflag (cp_t *ctx, enum cp_beacon_hoip_e flag);

/**
 * Deactivate the Beacon module.
 * \param  ctx  the CP context.
 */
void
cp_beacon_deactivate (cp_t *ctx);

/**
 * Inform the module beacon the AVLN will change its SNID.
 * \param  ctx  the module context.
 * \param  snid  the new SNID.
 */
void
cp_beacon_change_snid (cp_t *ctx, cp_snid_t snid);

/**
 * Inform the module beacon the AVLN will change its hybrid mode.
 * \param  ctx  the module context.
 * \param  hybrid_mode  the new hybrid mode.
 */
void
cp_beacon_change_hm (cp_t *ctx, uint hybrid_mode);


/**
 * Inform the beacon module to start an handover.
 * \param  ctx  the module context.
 * \param  tei  the new CCo's TEI.
 */
void
cp_beacon_cco_handover (cp_t *ctx, cp_tei_t tei);

/**
 * Compute the new date for the beacon timer.
 * \param ctx  the module context.
 * \param cco  the cco status of the station.
 *
 * This function adjust the beacon timer for the station concerned by the
 * handover or when the CCo stops it activity of CCo for others reasons.
 */
void
cp_beacon_reconfigure_timer (cp_t *ctx, bool cco);

/**
 * Check if another countdown is currently active.
 * \param  ctx  the module context.
 * \return  true if another countdown is active, false otherwise.
 */
bool
cp_beacon_any_countdown_active (cp_t *ctx);

/**
 * Fill a beacon structure to provide it to the BSU.
 * \param  ctx  the module context.
 * \param  beacon  the bsu_beacon_t structure to fill.
 */
void
cp_beacon_fill (cp_t *ctx, bsu_beacon_t *beacon);

/**
 * Return the synchronisation status with an AVLN.
 * \param  ctx  the module context.
 * \return  true if synchronised.
 */
bool
cp_beacon_synchronised (cp_t *ctx);

END_DECLS

#endif /* cp_beacon_beacon_h */