summaryrefslogtreecommitdiff
path: root/cesar/cl/cl_mactotei.h
blob: b6f0c6e2270a9d0acd53babb4be73242f685be47 (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
#ifndef CL_MACTOTEI_H_
#define CL_MACTOTEI_H_

/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cl/cl_mactotei.h
 * \brief   MAC to TEI table interface between the CL and the CP
 * \ingroup cl
 *
 * The MAC to TEI table associate a MAC address to a TEI and a tag. The tag is
 * used to know if the entry is bridged entry or not (in case of a bridge
 * entry, the tag will correspond to the entry acting as a bridge for this MAC
 * address).
 */

#include "cl/cl.h"

/**
 * Sorted MAC to TEI table.
 * It is based on the indexed MAC lookup table.
 */
typedef struct mac_lookup_table_t cl_mactotei_table_t;

/**
 * Non-sorted MAC to TEI table.
 * It is based on the non-sorted MAC lookup table.
 */
typedef struct mac_lookup_block_header_t cl_mactotei_blk_t;

BEGIN_DECLS

/**
 * Create a new table to be filled by the CP.
 *
 * \return  a pointer to the new block to be fill with the mac to tei table
 * data
 */
cl_mactotei_blk_t *cl_mactotei_new (void);

/**
 * Add a new tupple of data to the table.
 *
 * \param  table  the table pointer to add a new mac to tei correspondance.
 * \param  mac_addr  the mac addr to add
 * \param  tei  the tei corresponding to the STA.
 * \param  tag  the CP tag provide to indentifier a network.
 */
void cl_mactotei_addr_add (cl_mactotei_blk_t *table, mac_t mac_addr,
        uint tei, uint tag);

/**
 * Request the CL to copy all the data corresponding to the tag and the tei.
 *
 * \param  ctx  the cl context.
 * \param  table  the mactotei new table to fill
 * \param  tei  the tei to copy.
 * \param  tag  the tag to copy
 */
void
cl_mactotei_copy_tei_and_tag (cl_t *ctx,
        cl_mactotei_blk_t *table, u8 tei, u8 tag);

/**
 * Find a mac address in the table using a dichotomy search
 *
 * \param  ctx  the convergence layer context.
 * \param  mac  the mac address to find
 * \return  the tei corresponding to the mac address if known otherwise it
 * returns 0x0 if tei not found
 */
uint
cl_mactotei_table_find_tei_from_mac (cl_t *ctx, mac_t mac);

/**
 * Request the CL to use the new table and remove the old one.
 *
 * \param  ctx  the CL context
 * \param  table  the new table to use.
 */
void
cl_mactotei_use_table (cl_t *ctx, cl_mactotei_blk_t *table);

/**
 * Release the complete table from the memory.
 *
 * \param  ctx  the convergence layer context
 */
void cl_mactotei_release_table (cl_t *ctx);

/**
 * Copy all the entries in the table except the ones with a specific tag.
 * \param  ctx  the convergence layer context
 * \param  table  the table where to add copied entries.
 * \param  tag  the matching tag.
 *
 * This function can be used when you want to replace bridged entries of the
 * MAC lookup table by removing all the "old" one.
 */
void
cl_mactotei_copy_except_tag (cl_t *ctx, cl_mactotei_blk_t *table, u8 tag);

/**
 * Cancel the creation of a table.
 * \param  table  the table to cancel the creation.
 *
 * This function is quite like \see cl_mactotei_release_table. The difference,
 * is that it takes a block as argument and not a table. You should use this
 * function when you create a new table and realise that you should cancel its
 * creation and keep the old one.
 */
void
cl_mactotei_cancel (cl_mactotei_blk_t *table);

END_DECLS

#endif /*CL_MACTOTEI_H_*/