summaryrefslogtreecommitdiff
path: root/cesar/cp/sta/mgr/inc/net.h
blob: 410143822e88dfd7a8c378c8d3e267713b08665e (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
#ifndef cp_sta_mgr_inc_net
#define cp_sta_mgr_inc_net
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cp/sta/mgr/inc/net.h
 * \brief   Private Network data.
 * \ingroup cp_sta_mgr
 *
 * Get all the data about an AVLN.
 *
 * Context of a Network.
 */

#include "lib/set.h"
#include "lib/slab.h"

/** Enumerator for the mac to tei table in the CL. */
enum cp_mactotei_tags_t
{
    CP_MACTOTEI_TAGS_LIST,
    CP_MACTOTEI_TAGS_BRIDGE,
    CP_MACTOTEI_TAGS_MAX
};


struct cp_net_t
{
    /** Indicate if it is the station's AVLN. If not the commit to
     * dataplane will not have any effect. */
    bool station_avln;

    /** AVLN's SNID. */
    cp_snid_t snid;

    /** AVLN's NID. */
    cp_nid_t nid;

    /** The pointer to the CCo station. */
    cp_sta_t * cco;

    /** the pointer to the Pco station. */
    cp_sta_t * pco;

    /** The pointer to the UCCo station. */
    cp_sta_t *ucco;

    /**
     * The expiration date at the one this AVLN should be removed
     * from the list. This will be verified in the garbage function.
     */
    uint expiration_ms;

    /** The list of associated stations in the AVLN. */
    set_t associated_stas;

    /** Th list of unassociated stations in the AVLN. */
    set_t unassociated_stas;

    /** Present flag. */
    bool present;

    /** AVLN slot id. */
    u8 avln_slot_id;

    /**
     * Slot usage mask read in the AVLN central beacon.
     */
    u8 avln_slot_usage;

    /**
     * Number of station in the network.
     */
    u8 num_stas;

    /**
     * Number of visible stations in the AVLN, correspond to the station
     * visible or discovered by the station.
     */
    u8 num_visible_stas;

    /**
     * The network mode.
     */
    cp_net_network_mode_t network_mode;

    /**
     * Slab cache.
     */
    slab_cache_t *sta_slab_cache;
};


/**
 * Station Associated lesser.
 *
 * \param  left  left node station.
 * \param  right  right node station.
 * \return  true if left is lesser than right
 */
bool
cp_net_station_assoc_less (set_node_t *left, set_node_t *right);

/**
 * Station Unassociated lesser.
 *
 * \param  left  left node station.
 * \param  right  right node station.
 * \return  true if left is lesser than right
 */
bool
cp_net_station_unassoc_less (set_node_t *left, set_node_t *right);

/**
 * Garbage function for the unassociated station list and the associated
 * station list.
 *
 * \param  ctx  the module context.
 * \param  net  the network.
 * \param  date_ms  the current date in milliseconds.
 * \param  status  the station list to expire.
 */
void
cp_net_garbage_station_list (cp_t *ctx, cp_net_t *net, u32 date_ms,
                             enum cp_sta_state_t status);

#endif /* cp_sta_mgr_inc_net */