summaryrefslogtreecommitdiff
path: root/cesar/hle/test/overide/cl/src/cl.c
blob: 573adcc7ed25237e656bdb4748f0be761a1e959e (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    src/cl.c
 * \brief   « brief description »
 * \ingroup « module »
 *
 * « long description »
 */
#include "common/std.h"

#include <stdlib.h>

#include "cl/cl.h"
#include "cl/inc/cl.h"

static cl_t cl_global;

/**
 * Init the Convergence Layer and return a pointer on the CL context.
 * 
 * \param  mac_store  the mac store.
 * \param  sar  the sar context.
 * \return  the convergence layer context.
 */
cl_t *cl_init (mac_store_t *mac_store, sar_t *sar)
{
    return &cl_global;
}

/**
 * Initialize the CL to call the Upper layer once the CP ends processing the
 * MME.
 * Used each time the CP needs to send an MME to the upper layer.
 * 
 * \param  ctx  the CL context
 * \param  cb  the upper layer callback to use to send an MME.
 * \param  user  the user data to provide with the callback
 */
void cl_mme_ul_init_send_done (cl_t *ctx, cl_mme_ul_recv_done_cb_t cb,
        void *user)
{
    dbg_assert (ctx);
    dbg_assert (cb);

    ctx->mme.ul_mme_recv_done = cb;
    ctx->mme.ul_mme_recv_done_user_data = user;
}

/**
 * Initialize the callback to receive the data from the PLC.
 * 
 * \param  cl  the CL context
 * \param  cb  the function callback to call
 * \param  user  the user data to provide on the callback.
 */
void cl_data_recv_init (cl_t *cl, cl_data_recv_cb_t cb, void *user)
{
    dbg_assert (cl);
    dbg_assert (cb);
}

/**
 * Initialize the callback to inform the upper layer when a data had been sent
 * over the PLC.
 * 
 * \param  cl  the CL context
 * \param  cb  the callback to call once the data had been sent
 * \param  user  the user data to provide with the callback call  
 */
void cl_data_send_done_init (cl_t *cl, cl_data_send_done_cb_t cb, void *user)
{
    dbg_assert (cl);
    dbg_assert (cb);
    
    cl->data_tx.cb = cb;
    cl->data_tx.user = user;
}

/**
 * Initialize the CL to send MMEs to the Upper layer considered as data.
 * Used each time the CP needs to send an MME to the upper layer.
 * 
 * \param  ctx  the CL context
 * \param  cb  the upper layer callback to use to send an MME.
 * \param  user  the user data to provide with the callback
 */
void cl_mme_init_ul_as_data (cl_t *ctx, cl_mme_ul_send_done_cb_t cb,
        void *user)
{

}

/**
 * Send a data from the upper layer to the SAR, this data should be sent over
 * the PLC.
 * 
 * \param  cl  the CL context.
 * \param  buffer  the buffer containing the data to send
 * \param  length  the data length
 */
void cl_data_send (cl_t *cl, u8 *buffer, uint length)
{
    dbg_assert (cl);
    dbg_assert (buffer);

    (*cl->data_tx.cb) (cl->data_tx.user, buffer);
}

/**
 * Provides a buffer to the SAR to reassembly data
 * 
 * \param  cl  the CL context
 * \param  buffer  the buffer to reassembly some datas
 */
void cl_data_buffer_add (cl_t *cl, u8 *buffer)
{

}

/**
 * Receives an MME from the Upper layer.
 * It will provide this MME to the Control Plane to be processed.
 * 
 * \param  ctx  the cl context
 * \param  buffer  the MME buffer
 * \param  length  the MME length
 */
void cl_mme_ul_send (cl_t *ctx, u8 *buffer, uint length)
{
    dbg_assert (ctx);
    dbg_assert (buffer);

    (*ctx->mme.ul_mme_recv_done) (ctx->mme.ul_mme_recv_done_user_data, buffer);
}

/**
 * Provides a buffer to the CP.
 * 
 * \param  cl  the CL context
 * \param  buffer  the buffer to reassembly some datas
 */
void cl_mme_buffer_add (cl_t *cl, u8 *buffer)
{

}

/**
 * Uninit the Convergence layer context.
 * 
 * \param  ctx  the convergence layer context
 */
void cl_uninit (cl_t *ctx)
{

}