summaryrefslogtreecommitdiff
path: root/cesar/mac/common/src/sta.c
blob: 817a45edfb3214a678bc2556784f247a90653dba (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
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    mac/common/src/sta.c
 * \brief   Station functions
 * \ingroup mac_common
 */
#include "common/std.h"
#include "mac/common/sta.h"
#include "mac/common/defs.h"
#include "cl/data_rate.h"
#include "ce/rx/bitloading/intervals.h"

#include <string.h> //memset

void
sta_init (sta_t *sta, uint tei)
{
    dbg_assert (sta);
    dbg_assert (MAC_TEI_IS_STA (tei));
    sta->tei = tei;
    sta->authenticated = false;
    sta->nek = NULL;
    //todo : make eventually rx_tonemaps and tx_tonemaps in sta_t.
    sta->rx_tonemaps = tonemaps_alloc ();
    sta->tx_tonemaps = tonemaps_alloc ();
    sta->multi_unicast_receiver = true;
    ce_rx_bitloading_init (&sta->ce_rx_bt);
    sta->tx_data_rate.data_rate = CL_DATA_RATE_REQ_INIT;
    sta->rx_data_rate.data_rate = CL_DATA_RATE_REQ_INIT;
    sta->intervals = NULL;
}


void
sta_uninit (sta_t *sta)
{
    dbg_assert (sta);
    tonemaps_release (sta->rx_tonemaps);
    tonemaps_release (sta->tx_tonemaps);
    ce_rx_bitloading_uninit (&sta->ce_rx_bt);
    if (sta->intervals)
        ce_rx_bl_intervals_free (sta->intervals);
}