summaryrefslogtreecommitdiff
path: root/cesar/cl/cl_mactotei.h
blob: 4edd6cac907f219a379fcec62baa6ecf58d7f5d1 (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
#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"
#include "lib/mac_lookup_table.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 (Mac address, TEI) to the MAC to TEI table.
 *
 * \param  table  the non-sorted MAC to TEI table.
 * \param  mac_addr  the mac addr to add.
 * \param  tei  the TEI corresponding to the MAC address.
 * \param  tag  a tag provided by the CP.
 */
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 entries from the actual MAC to TEI table
 * corresponding to a TEI and a tag to the new one.
 *
 * \param  ctx  the CL context.
 * \param  table  the new MAC to TEI table to fill.
 * \param  tei  the corresponding TEI entries to copy.
 * \param  tag  the corresponding tag entries to copy.
 */
void
cl_mactotei_copy_tei_and_tag (cl_t *ctx, cl_mactotei_blk_t *table,
                              uint tei, uint tag);

/**
 * Find a mac address in the table using a dichotomy search.
 *
 * \param  ctx  the CL context.
 * \param  mac  the mac address to look for.
 * \return  the TEI corresponding to the mac address if the entry exists.
 * Otherwise, it returns MAC_TEI_UNASSOCIATED.
 */
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 from the current MAC to TEI table except the ones with
 * a specific tag.
 * \param  ctx  the CL 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, uint tag);

/**
 * Cancel the creation of a table.
 * \param  table  the table to cancel.
 *
 * 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_*/