summaryrefslogtreecommitdiff
path: root/cp2/sta/mgr/sta_mgr.h
blob: b874fcdd82dd97e7bf624c66d70bd65c0a501b35 (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
#ifndef cp2_sta_data_sta_mgr_h
#define cp2_sta_data_sta_mgr_h
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cp2/sta/data/sta_mgr.h
 * \brief   Station and AVLN manager. 
 * \ingroup cp_sta_data
 *
 * Manage the network list and its Stations. The station manager job it to
 * keep the integrity of the differents databases.
 */

#include "cp2/sta/data/net_list.h"
#include "cp2/sta/data/sta_data.h"

struct cp_sta_mgr_t
{
    u16 current_sta_avln;
};
typedef struct cp_sta_mgr_t cp_sta_mgr_t;

/** Initialise the sta manager.
 * \return  the sta manager context.
 */
cp_sta_mgr_t *
cp_sta_mgr_init(void);

/** Uninitialise the sta manager.
 * \param  ctx  the sta manager context.
 */
void
cp_sta_mgr_uninit(cp_sta_mgr_t *ctx);

/** Get an AVLN from the sta manager.
 * \param  ctx  the sta manager context.
 * \return  the avln identified by its snid.
 *
 * This function shall return an avln with the snid provided or NULL if the
 * avln does not exists.
 */
cp_net_list_t*
cp_sta_mgr_get_avln(cp_sta_mgr_t *ctx, u16 snid);

/** Get our AVLN.
 * \param  ctx  the sta manager context.
 * \return  Our AVLN.
 */
cp_net_list_t*
cp_sta_mgr_get_our_avln(cp_sta_mgr_t *ctx);

/** Add an AVLN.
 * \param  ctx  the sta manager context.
 * \param  snid  the new avln's snid.
 * \return  the new avln.
 */
cp_net_list_t*
cp_sta_mgr_add_avln(cp_sta_mgr_t *ctx, u16 snid);

/** Remove an AVLN from  the list and all the STAs associated in it.
 * \param  ctx  the sta manager context.
 * \param  snid  the avln snid.
 *
 * This function shall not remove our AVLN.
 */
void
cp_sta_mgr_remove_avln(u16 snid);

/** Add a station to a specified AVLN.
 * \param  ctx  the sta manager context.
 * \param  tei  the tei of the station
 * \param  mac_addr  the mac address
 * \param  added  true if the station was just create, flase otherwise.
 * \return  the station just created.
 *
 * This function shall return the station just created and fill the added
 * boolean parameters with true value if the station has just been created or
 * false if the station already exists.
 */
cp_sta_t*
cp_sta_mgr_add_sta(cp_sta_mgr_t *ctx, u16 snid, u8 tei, mac_t mac_addr,
                   bool added);

/** Remove a sta from the specified AVLN.
 * \param  ctx the sta manager context.
 * \param  snid  the AVLN's snid.
 * \param  tei  the station tei.
 */
void
cp_sta_mgr_remove_sta(cp_sta_mgr_t *ctx, u16 snid, u8 tei);

/** Add a STA to our AVLN.
 * \param  ctx  the sta manager context.
 * \param  tei  the station tei
 * \param  mac_address  the station mac address.
 * \param  added true if the station was just create, flase otherwise.
 * \return  the station just created.
 *
 * This function shall return the station just created and fill the added
 * boolean parameters with true value if the station has just been created or
 * false if the station already exists.
 */
cp_sta_t*
cp_sta_mgr_add_sta_our_avln(cp_sta_mgr_t *ctx, u8 tei, mac_t mac_address);

/** Remove a STA of our AVLN.
 * \param  ctx  the sta manager context.
 * \param  tei  the station tei.
 */
void 
cp_sta_mgr_remove_sta_our_avln(cp_sta_mgr_t *ctx, u8 tei);

/** Get a STA from an AVLN.
 * \param  ctx  the sta manager context.
 * \param  snid  the AVLN's snid.
 * \param  tei  the STA's tei.
 * \return  The station associated of NULL of no tei is associated.
 */
cp_sta_t*
cp_sta_mgr_get_sta(cp_sta_mgr_t *ctx, u16 snid, u8 tei);

/** Get the STA in our AVLN corresponding to the tei provided.
 * \param  ctx  the sta manager context.
 * \param  tei  the station's tei
 * \return  the station corresponding to the tei.
 */
cp_sta_t*
cp_sta_mgr_get_sta_in_avln(cp_sta_mgr_t *ctx, u8 tei);

/** Update the STA data in our AVLN.
 * \param  ctx  the sta manager context.
 * \param  sta  the station to update
 * \param  tei  the station's new tei
 * \param  mac address the station's new mac address.
 */
void
cp_sta_mgr_update_sta_in_avln(cp_sta_mgr_t *ctx, cp_sta_t *sta, 
                              u8 tei, mac_t mac_addr);

/** Update the STA data in any AVLN.
 * \param  ctx  the sta manager context.
 * \param  sta  the station to update the data.
 * \param  tei  the station new tei.
 * \param  mac_addr  the station's new mac address.
 */
void
cp_sta_mgr_update_sta(cp_sta_t sta, u8 tei, mac_t mac_addr);

#endif /* cp2_sta_data_sta_mgr_h */