summaryrefslogtreecommitdiff
path: root/cesar/cl/bridge_table.h
blob: 3e969a3cff60a91ef0c51dbcefc0a26b28883018 (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
#ifndef cl_bridge_table_h
#define cl_bridge_table_h
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cl/bridge_table.h
 * \brief   Local Bridge Destination Address Table (LBDAT) public header.
 * \ingroup cl
 *
 * The bridge table module is used by a STA when it is acting as a bridge (if
 * you need more information on this behavior, have a look at the HomePlug AV
 * specification, section 5.3).
 *
 * Basically, you can:
 *  - initialize the bridge table (required to use this module),
 *  - de-initialize the bridge table (when you have finished using this
 *  module),
 *  - add new source MAC address to the bridge table (when receiving a packet
 *  coming from the bridged networks),
 *  - get the content of the whole bridge table (when you want to transmit it
 *  to other STA),
 *  - update the content of the bridge table (to remove expired entries).
 *
 * You must initialize and update this module every one second.
 */

#include "cl/cl.h"      // cl_t

BEGIN_DECLS

/**
 * Initialize the local bridge table module.
 * \param  ctx  the CL context structure.
 */
void
bridge_table_init (cl_t *ctx);

/**
 * De-initialize the local bridge table module.
 * \param  ctx  the CL context structure.
 */
void
bridge_table_deinit (cl_t *ctx);

/**
 * Add a source MAC address to the local bridge table.
 * \param  ctx  the CL context structure.
 * \param  src_mac  the source MAC address received from the bridged network.
 */
void
bridge_table_add (cl_t *ctx, mac_t src_mac);

/**
 * Update the local bridge table.
 * \param  ctx  the CL context structure.
 * \return
 *  - true if the bridge table has been modified,
 *  - false is the bridge table has not been modified (no expired entry or no
 *  new entry to add).
 *
 * \attention You must call this function every one second.
 *
 * This function will update the local bridge table by removing entries which
 * are expired and add the new one (because the add function only copy them to
 * a temporary table).
 */
bool
bridge_table_update (cl_t *ctx);

/**
 * Get the number of MAC addresses in the local bridge table.
 * \param  ctx  the CL context structure.
 * \return the number of MAC addresses in the local bridge table.
 */
uint
bridge_table_size (cl_t *ctx);

/**
 * Get a MAC address at a specific position in the table.
 * \param  ctx  the CL context structure.
 * \param  position  the position of the MAC address to get in the table.
 * \return the MAC address located at the \p position of the \p table.
 */
mac_t
bridge_table_get_entry (cl_t *ctx, uint position);

END_DECLS

#endif /* cl_bridge_table_h */