summaryrefslogtreecommitdiff
path: root/cesar/cp2/sta/mgr/test/src/cl_stub.c
blob: 6c24a2ba02bc4bff9989fb734cb342f3e4066a6c (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
/* 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
 * 
 */ 
#include "common/std.h"
#include "cl/cl_mactotei.h"

#include "lib/bitstream.h"

/**
 * 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)
{
    u8 *my_data;

    my_data = blk_alloc ();
    my_data[0] = 0;
    return (cl_mactotei_blk_t *) my_data;
}

/**
 * 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)
{
    bitstream_t bitstream;
    u8 *data;
    uint pos;

    dbg_assert (table);
    dbg_assert (tei);

    data = (u8 *) table;
    pos = 8 * data[0] + 1;

    bitstream_init (&bitstream, &data[pos],
                    8, BITSTREAM_WRITE);
    bitstream_access (&bitstream, &tag, 8);
    bitstream_access (&bitstream, &tei, 8);
    bitstream_access (&bitstream, &mac_addr, 48);
    bitstream_finalise (&bitstream);

    data[0] ++;
}

/**
 * Request the CL to copy all the data corresponding to the tag.
 * 
 * \param  ctx  the cl context.
 * \param  table  the mactotei new table to fill
 * \param  tag  the tag to copy
 */
void 
cl_mactotei_copy_tag (cl_t *ctx,
        cl_mactotei_blk_t *table, u8 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)
{
}

/**
 * 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)
{
    dbg_assert (ctx);
    dbg_assert (table);

    bitstream_memcpy ((u8 *) ctx, (u8 *)table, 512) ;

    blk_release (table);
}

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