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

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

/**
 * Function call back prototype.
 * \param  user data  the user data provided on the callback function
 * registration.
 * \param  cb  the function to call on the event.
 *
 * This will post an event in the FSM.
 */
typedef void
(*cp_beacon_event_cb_t) (void *user_data);

/**
 * 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);

/**
 * Initialise the function to call each time the beacon module needs to
 * post an event in the FSM.
 * \param  ctx  the module context.
 * \param  user_data  The user data to provide on function call.
 * \param  cb  Function call back.
 *
 * Those events are :  
 *    - beacon_timer, on this event the FSM shall call the following 
 * functions.  
 *    - CCo : send central beacon
 *    - UCo : send discover beacon
 *    - POND : create_default_schedules
 *    - Sta, Usta : beacon not receive.
 *    - beacon_received
 */
void
cp_beacon_init_event_callback (cp_t *ctx, void *user_data,
                               cp_beacon_event_cb_t cb);

/**
 * Generate and send a beacon when the station acts as a CCo or Unassociated
 * CCo.
 * \param  ctx  the module context.
 * \param  beacon_type  The beacon type to send (central, discover or proxy).
 *
 */
void
cp_beacon_cco_send_beacon (cp_t *ctx, uint beacon_type);

/**
 * Generate and send a discover beacon.
 * \param  ctx  the module context.
 *
 */
extern inline void
cp_beacon_cco_send_central_beacon (cp_t *ctx)
{
    cp_beacon_cco_send_beacon (ctx,
                               CP_BEACON_CENTRAL_BEACON);
}

/**
 * Generate and send a discover beacon.
 * \param  ctx  the module context.
 *
 */
extern inline void
cp_beacon_cco_send_discover_beacon (cp_t *ctx)
{
    cp_beacon_cco_send_beacon (ctx,
                               CP_BEACON_DISCOVER_BEACON);
}

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

/**
 * This function is only called when the station is acting as a CCo.
 * \param  ctx  the module context.
 * \param  snid  The new SNID.
 *
 *  It allows the beacon module to put the change SNID bentry in the central
 * beacon. Once the count down of the SNID reach 1, the SNID is inserted
 * in the station own data and in the mac config
 */
void
cp_beacon_change_snid (cp_t *ctx, u8 snid);

/**
 * 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.
 */
void
cp_beacon_process_tracked_avln (cp_t *ctx, cp_beacon_desc_t *beacon);

/**
 * 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);

#endif /* cp2_beacon_beacon_h */