summaryrefslogtreecommitdiff
path: root/cesar/cp2/conn/src/link.c
blob: df515ce454ca84e7444c0ae3002eb7c46a0f9acd (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
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    link.c
 * \brief   link management
 * \ingroup cp2/conn
 *
 * « long description »
 */
#include "common/std.h"
#include "cp2/cp.h"
#include "cp2/inc/context.h"
#include "cp2/conn/conn.h"
#include "cp2/conn/inc/conn.h"
#include "cp2/conn/link.h"
#include "cp2/conn/inc/link.h"
#include "lib/blk.h"

/**
 * init a link
 * \param  table_ble  ble elements
 * \param  nb_ble  number of element in this table
 * \return  the link initialised
 *
 * init the memory
 * fill the elements concerning the link
 */
cp_link_t*
cp_link_init (void)
{
    cp_link_t *link;

    link = blk_alloc();
    list_init(&link->ble);
    
    return link;
}

/**
 * del a connection regarding to its CID.
 * \param  ctx  conn context.
 * \param  lid  Connection identifier
 *
 */
void
cp_link_uninit (cp_link_t *link)
{
    cp_link_release_ble (link);
}

/**
 * BLE memory allocation 
 * \param first first BLE of a link
 * \param new new element to add to the heap
 *
 * link the BLE 
 */
void
cp_link_push_ble(cp_link_t *link, u8 ble, u16 et_atu)
{

    cp_link_ble_interval_t *new;

    dbg_assert(link);
    
    new = blk_alloc();
    new->ble = ble;
    new->et_atu = et_atu;
    list_init_node(&new->node);
    
    list_push(&link->ble, &new->node);
}

void
cp_link_release_ble(cp_link_t *link)
{
    dbg_assert(link);
    
    while(!list_empty(&link->ble))
    {
        blk_release(PARENT_OF(cp_link_ble_interval_t,
                             node,list_begin(&link->ble)));

        list_remove(&link->ble, list_begin(&link->ble));
    }
}

u8
cp_link_get_lid(void)
{
    return 0;
}