summaryrefslogtreecommitdiff
path: root/cesar/cp/beacon/inc/beacon.h
blob: 99d697bb8b48ca07258192fa5c031b07dc16b551 (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
#ifndef cp_beacon_inc_beacon_h
#define cp_beacon_inc_beacon_h
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    inc/cp_beacon_private.h
 * \brief   Beacon private data.
 * \ingroup cp_beacon
 *
 */
#include "lib/circular_buffer.h"

// Public ones.
#include "hal/timer/timer.h"
#include "cp/sta/mgr/net.h"
#include "cp/beacon/defs.h"
#include "bsu/beacon/defs.h"

/* Countdown on 5 beacon periods. */
#define CP_BEACON_COUNTDOWN_DEFAULT 5
#define CP_BEACON_COUNTDOWN_SNID CP_BEACON_COUNTDOWN_DEFAULT
#define CP_BEACON_COUNTDOWN_HM CP_BEACON_COUNTDOWN_DEFAULT
#define CP_BEACON_COUNTDOWN_HOIP CP_BEACON_COUNTDOWN_DEFAULT
#define CP_BEACON_COUNTDOWN_EKS CP_BEACON_COUNTDOWN_DEFAULT

struct cp_beacon_discover_info_t
{
    /* Discover info data. */
    BITFIELDS_WORD
    (
        /** Indicates that the content has been updated. */
        u32 updated:1;,
        /** Ability for the sta to act as cco. */
        u32 cco_cap:2;,
        /** Ability for the sta to act as a proxy. */
        u32 proxy_net_cap:1;,
        /** Ability for the sta to act as a backup cco. */
        u32 backup_cco_cap:1;,
        /** Indication if the sta is cco. */
        u32 cco_status:1;,
        /** Indication if the sta is pco. */
        u32 pco_status:1;,
        /** Indication if the sta is a backup cco. */
        u32 backup_cco_status:1;,
        /** Indicates the number of entries in the discovered sta list. */
        u32 num_dis_sta:8;,
        /** Indicates the number of entries in the discovered network list. */
        u32 num_dis_net:8;,
        /** Sta authentication status. */
        u32 authentication:1;,
        /** Sta's status as user appointed CCO. */
        u32 status_user_ap_cco:1;,
        /** Reserved bits. */
        u32 rsvd:6;
    )
};
typedef struct cp_beacon_discover_info_t cp_beacon_discover_info_t;

struct cp_beacon_snid_t
{
    /** The new SNID of the AVLN. */
    cp_snid_t snid;
    /** The snid countdown. */
    uint snidcd;
};

struct cp_beacon_hybrid_mode_t
{
    /** The Hybrid mode countdown. */
    uint hmcd;
    /** The new hybrid mode value. */
    mac_coexistence_mode_t hm;
};

struct cp_beacon_hoip_t
{
    /** The handover in progress countdown */
    uint hoipcd;
    /** The new CCo's TEI. */
    cp_tei_t cco;
    /** Hoip bit. */
    enum cp_beacon_hoip_e hoip_flag;
};

struct cp_beacon_eks_t
{
    /** Key Change Countdown. */
    uint kccd;
    /** Key being change. */
    enum bsu_beacon_eks_kbc_t kbc;
    /** New EKS. */
    u8 new_eks;
};

struct cp_beacon_discover_t
{
    /**
     * Last TEI request for a discover beacon.
     */
    cp_tei_t tei_last;
    /**
     * The discover interval between the one no discover beacon is requested.
     * pwl.bp_max_discover / num of station in the AVLN.
     */
    int discover_interval_bp;
    /**
     * The next discover beacon to request countdown. When 0, add a discover
     * bentry. If next TEI is 0. The CCo shall send a discover beacon.
     */
    int countdown_bp;
};
typedef struct cp_beacon_discover_t cp_beacon_discover_t;

struct cp_beacon_list_t
{
    /** List head. */
    pb_beacon_t *head;
    /** List tail. */
    pb_beacon_t *tail;
};
typedef struct cp_beacon_list_t cp_beacon_list_t;

/**
 * Beacon module. Use to generate and read a beacon.
 */
struct cp_beacon_t
{
    /** Received beacon list. */
    cp_beacon_list_t list;
    /**
     * The leon timer to be programmed and awake each beacon period.
     * Each time the timer expires, the function register by the beacon
     * shall post an event in the FSM.
     */
    hal_timer_instance_t leon_timer;

    /** Nek index. */
    uint nek_index;

    /**
     * Discover process use by the CCo. */
    cp_beacon_discover_t discover;
    cp_beacon_discover_info_t discover_info_last;

    /** Snid countdown structure. */
    struct cp_beacon_snid_t snids;

    /** Hybrid mode countdown structure. */
    struct cp_beacon_hybrid_mode_t hm;

    /** Handover in progress structure. */
    struct cp_beacon_hoip_t hoip;

    /** EKS change structure. */
    struct cp_beacon_eks_t eks;

    /** Shared memory. */
    bsu_beacon_t shared_mem[CP_SHARED_MEM_SLOT_NB];

    /** Shared memory slot id. */
    cp_shared_mem_slot_id_t shared_mem_slot_id;

    /** Countown limit date, this is the time after which the countown
     * counters must be decremented. */
    u32 countdown_limit_date;

    /** Last processed countdown date. */
    u32 last_countdown_date;
};

BEGIN_DECLS

/**
 * Store all beacon parameters necessary for bsu in the next memory storage.
 * \param  ctx  the control plane context.
 * \return  the pointer to the memory storage where are the new data.
 */
bsu_beacon_t *
cp_beacon_fill_share_memory (cp_t *ctx);

END_DECLS

#endif /* cp_beacon_inc_beacon_h */