summaryrefslogtreecommitdiff
path: root/cesar/cl/src/cl.c
blob: 3c00bd7dba38b2115378e79c83489926d124c07f (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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cl/src/cl.c
 * \brief   private function for the Covnergence Layer
 * \ingroup cl
 * 
 */

#include "common/std.h"
#include "common/defs/ethernet.h"
#include "lib/read_word.h"

#include "cl/cl.h"
#include "mac/sar/sar.h"
#include "mac/pbproc/pbproc.h"

#include "cl/inc/context.h"
#include "cl/inc/cl.h"
#include "cl/inc/trace.h"
#include "cl/inc/cl_mactotei.h"

#include "mac/common/ntb.h"

static struct 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.
 * \param  mac_config  the mac config.
 * \return  the convergence layer context.
 */
cl_t *cl_init (mac_store_t *mac_store, sar_t *sar, mac_config_t *mac_config)
{
    cl_t *ctx;

    dbg_assert (mac_store);
    dbg_assert (sar);
    dbg_assert (mac_config);

    ctx = &cl_global;

    cl_global.mac_store = mac_store;

    /* Initialize the SAR */
    cl_global.sar = sar;

    // MME part
    sar_init_mme_context (cl_global.sar, &cl_global);
    sar_init_segmentation_mme_cb (cl_global.sar,
            (sar_segmentation_done_cb_t) cl_mme_sar_send_done);
    sar_init_reassembly_mme_cb (cl_global.sar,(sar_reassembly_done_cb_t) cl_mme_recv);

    sar_mme_buffer_add (cl_global.sar, cl_global.mme_buffer);

    // Data TX part
    sar_init_data_context (cl_global.sar, &cl_global);
    sar_init_segmentation_data_cb (cl_global.sar, 
                                   (sar_segmentation_done_cb_t) cl_data_send_done);

    // DATA RX part
    sar_init_reassembly_data_cb (cl_global.sar, (sar_reassembly_done_cb_t)cl_data_recv);

    /* Initialize the random generator */
    lib_rnd_init (&cl_global.random_generator, mac_config->seed ^ 0x45972612);

    /* init the mme */
    cl_mme_init (&cl_global.mme);

    /* init the cl_mactotei table */
    cl_global.mactotei = NULL;

    /* init the cl mme buffer to null */
    cl_global.mme_ul_send.cb = NULL;
    cl_global.mme_ul_send.user = NULL;

    /* add the mac_config */
    cl_global.mac_config = mac_config;

    /* Initialize the trace system. */
    cl_trace_init (ctx);

    CL_TRACE (INIT, mac_ntb());

    return &cl_global;
}

/**
 * Init the MME module of the CL
 * 
 * \param  ctx  the mme context.
 */
void cl_mme_init (cl_mme_t *ctx)
{
    dbg_assert (ctx);

    ctx->ul_mme_recv_done = NULL;
    ctx->ul_mme_recv_done_user_data = NULL;
}

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

    CL_TRACE (UNINIT, mac_ntb());

    if (ctx->mactotei)
    {
        cl_mactotei_release_table (ctx);
    }

    cl_trace_uninit(ctx);
}

/**
 * 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;
}

/**
 * Init the function call when an MME is recived from the SAR or the HLE.
 * The CP registers its callback to allow the CL to call it each time a MME
 * is receved from the PLC or the HLE.
 * 
 * \param  ctx  the CL ctx
 * \param  mme_recv_cb
 * \param  user_data  the user data
 */
void cl_mme_recv_init (cl_t *ctx, cl_mme_recv_cb_t mme_recv_cb, void
*user_data)
{
    dbg_assert (ctx);
    dbg_assert (mme_recv_cb);

    ctx->mme.mme_recv_cb = mme_recv_cb;
    ctx->mme.mme_recv_user_data = user_data;
}

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

    ctx->mme_ul_send.cb = cb;
    ctx->mme_ul_send.user = user;
    ctx->mme_ul_send.mme_buffer = NULL;
}

/**
 * Initialize the CP call back to get a buffer.
 * 
 * \param  cl  the cl context
 * \param  cb  the call back function
 * \param  user_data  the user data.
 */
void cl_mme_init_buffer_add_cb (cl_t *cl, cl_mme_buffer_add_cb_t cb,
        void *user_data)
{
    dbg_assert (cl);
    dbg_assert (cb);
    
    cl->mme.mme_buffer_add_cb = cb;
    cl->mme.mme_buffer_add_user_data = user_data;
}

/**
 * Send an MME from the CP to the PLC via the SAR MME way.
 * 
 * \param  ctx  the CL context
 * \param  buffer  the buffer containing the MME
 * \param  length  the length of the MME
 * \param  mfs  the MFS use for the SAR if the MME should be send over the PLC
 */
void cl_mme_send_as_mme (cl_t *ctx, u8 *buffer, uint length, mfs_tx_t *mfs)
{
    dbg_assert (ctx);
    dbg_assert (buffer);
    dbg_assert (length >= ETH_PACKET_MIN_SIZE && length <= ETH_PACKET_MAX_SIZE);
    dbg_assert (mfs);
    dbg_assert (ctx->sar);
    dbg_assert (mfs->common.mme);

    CL_TRACE (MME_SEND_AS_MME, mac_ntb(), length, buffer, mfs->common.tei);

    sar_msdu_add (ctx->sar, buffer, length,
            lib_rnd32 (&ctx->random_generator), mfs);
}

/**
 * Send an MME as a data packet from the CP to the PLC or to the upper layer.
 * 
 * \param  ctx  the CL context
 * \param  buffer  the buffer containing the MME
 * \param  length  the length of the MME
 */
void cl_mme_send_as_data (cl_t *ctx, u8 *buffer, uint length)
{
    mac_t mac;
    uint tei;

    dbg_assert (ctx);
    dbg_assert (buffer);
    dbg_assert (length >= ETH_PACKET_MIN_SIZE && length <= ETH_PACKET_MAX_SIZE);

    CL_TRACE (MME_SEND_AS_DATA, mac_ntb(), length, buffer);

    ctx->mme_ul_send.mme_buffer = buffer;

    /* If a mac to tei table does not exist send to the hle. */
    if (ctx->mactotei == NULL)
    {
        CL_TRACE (DATA_SEND, mac_ntb(), buffer, length, 0, 0, 0);
        dbg_assert (ctx->mme_ul_send.cb);
        (*ctx->mme_ul_send.cb) (ctx->mme_ul_send.user, buffer, length);
    }
    else
    {
        mac = read_u48_from_word (buffer);

        /* Get the TEI from the mactotei table. */
        tei = cl_mactotei_table_find_tei_from_mac (ctx, mac & 0x0000FFFFFFFFFFFFull);

        if (tei == 0 || tei == ctx->mac_config->tei)
        {
            CL_TRACE (DATA_SEND, mac_ntb(), buffer, length, 0, 0, 0);
            dbg_assert (ctx->mme_ul_send.cb);
            (*ctx->mme_ul_send.cb) (ctx->mme_ul_send.user, buffer, length);
        }
        else
        {
            cl_data_send_with_tei(ctx, buffer, length, tei);
        }
    }
}

/**
 * Callback called by the sar when a MME as been sent over the PWL.
 * 
 * \param  ctx  the cl context.
 * \param  buffer  the buffer used. 
 */
void cl_mme_sar_send_done (cl_t *ctx, u8 *buffer)
{
    dbg_assert (ctx);
    dbg_assert (buffer);

    CL_TRACE (MME_BUFFER_ADD, mac_ntb(), buffer);
    cl_mme_buffer_add (ctx, buffer);
}

/**
 * Receives an MME from the SAR or the upper layer.
 * This function is called each time the SAR or the HLE has an MME to send to 
 * the CP. It is used by the inline function.
 * When the MFS is NULL the MME received comes from the HLE. Otherwise the MME
 * comes from the SAR. 
 * 
 * \param  ctx  the cl context
 * \param  buffer  the MME buffer
 * \param  length  the MME length
 * \param  mfs  the MFS used in the reassembly process.
 * \param  encryption  if the mac frame comes from the SAR if returns the
 * state of the encryption.
 */
void cl_mme_recv (cl_t *ctx, u8 *buffer, uint length, mfs_rx_t *mfs, bool
                  encryption)
{
    dbg_assert (ctx);

    dbg_assert (ctx->mme.mme_recv_cb);
    dbg_assert (buffer);
    dbg_assert (length >= ETH_PACKET_MIN_SIZE && length <= ETH_PACKET_MAX_SIZE);

    ctx->mme.mme_recv.buffer = buffer;

    CL_TRACE (MME_RECV, mac_ntb(), length, buffer, ctx->mme.mme_recv.sar);

    if (mfs)
        ctx->mme.mme_recv.sar = true;
    else
        ctx->mme.mme_recv.sar = false;

    (*ctx->mme.mme_recv_cb) (ctx->mme.mme_recv_user_data, mfs, buffer, length,
            &ctx->mme.mme_recv, encryption);
}

/**
 * The CP inform the CL that the buffer contaning previously a receved MME can
 * be use again to store another MME if necessary.
 * 
 * \param  ctx  the CL context
 * \param  mme_recv  the data provided on the previous callback.
 */
void cl_mme_recv_done (cl_t *ctx, cl_mme_recv_t *mme_recv)
{
    dbg_assert (ctx);
    dbg_assert (mme_recv);
    dbg_assert (mme_recv->buffer);

    CL_TRACE (MME_RECV_DONE, mac_ntb(), mme_recv->buffer, mme_recv->sar);

    if (mme_recv->sar)
    {
        dbg_assert (ctx->sar);
        sar_mme_buffer_add (ctx->sar, mme_recv->buffer);
    }
    else
    {
        dbg_assert (ctx->mme.ul_mme_recv_done);

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

/**
 * Copy all the lines of the CL mactotei table to the table provided in 
 * paramter without all the lines which the tag corresponds to the parameter
 * tag.
 * 
 * Sample : cl_mactotei_copy_table_excluding_tag (cl, table, 2), will copy all 
 * the mac to tei lines of the CL table without those where the tag value is 2.
 * 
 * \param  ctx  the convergence layer context
 * \param  table  the mactotei new table to fill
 * \param  tag  the tag to exclude from the copy
 */
void cl_mactotei_copy_table_excluding_tag (cl_t *ctx,
        cl_mactotei_blk_t *table, u8 tag)
{
    dbg_assert (ctx);
    dbg_assert (ctx->mactotei);
    dbg_assert (table);

    CL_TRACE (MACTOTEI_COPY, mac_ntb(), table, tag);

    cl_mactotei_copy (ctx->mactotei, table, 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);

    CL_TRACE (MACTOTEI_USE, mac_ntb(), table);

    /** add the table to the CL context */
    cl_mactotei_switch_table (ctx, cl_mactotei_generate_table (table));
}

/**
 * Swith the old mactotei table with the new one.
 * 
 * \param  ctx  the convergence layer context
 * \param  table  the table to switch
 */
void cl_mactotei_switch_table (cl_t *ctx, cl_mactotei_table_t *table)
{
    dbg_assert (ctx);
    dbg_assert (table);

    if (ctx->mactotei)
    {
        CL_TRACE (MACTOTEI_RELEASE, mac_ntb(), ctx->mactotei);
        cl_mactotei_release_table_intern (ctx->mactotei);
    }
    ctx->mactotei = table;
}

/**
 * Release the complete table from the memory.
 * 
 * \param  ctx  the convergence layer context
 */
void cl_mactotei_release_table (cl_t *ctx)
{
    dbg_assert (ctx);
    dbg_assert (ctx->mactotei);

    CL_TRACE (MACTOTEI_RELEASE, mac_ntb(), ctx->mactotei);
    cl_mactotei_release_table_intern (ctx->mactotei);
    ctx->mactotei = NULL;
}

/**
 * Find a mac address in the table using a dichotomy search
 * 
 * \param  ctx  the convergence layer context.
 * \param  mac  the mac address to find
 * \return  the tei corresponding to the mac address if known otherwise it 
 * returns 0x0 if tei not found
 */
uint cl_mactotei_table_find_tei_from_mac (cl_t *ctx, mac_t mac)
{
    uint index;
    cl_mactotei_t mactotei;

    dbg_assert (ctx);
    dbg_assert (ctx->mactotei);

    DICHOTOMY_SEARCH (0, ctx->mactotei->nb_total, index, mac
            <= cl_mactotei_table_get_mac_at (ctx->mactotei, index));

    if (index < ctx->mactotei->nb_total)
    {
        mactotei = cl_mactotei_table_get_mactotei_at (ctx->mactotei, index);

        if (mactotei.mac != mac)
        {
            CL_TRACE (MACTOTEI_FIND_TEI, mac_ntb(), TRACE_U64(mac), false, 0x0);
            return 0x0;
        }
        else
        {
            CL_TRACE (MACTOTEI_FIND_TEI, mac_ntb(), TRACE_U64(mac), true, mactotei.tei);
            return mactotei.tei;
        }
    }

    CL_TRACE (MACTOTEI_FIND_TEI, mac_ntb(), TRACE_U64(mac), false, 0x0);
    return 0x0;
}

/**
 * Search for the lid in the classifier
 * 
 * \param  ctx  CL context
 * \param  tei  the tei found previously by the mactotei table.
 * \param  bcast  put true if the link is a bcast one, false otherwise.
 * \param  acs  put true if the link should be process by the acs
 * \param  drop put true if the data should be drop.
 */
uint cl_classifer_get_lid (cl_t *ctx, uint tei, bool *bcast, bool *acs,
        bool *drop)
{
    if (tei == 0xff)
    {
        *bcast = true;
    }
    else
    {
        *bcast = false;
    }

    *acs = false;
    *drop = false;

    CL_TRACE (CLASSIFIER, mac_ntb(), tei, *bcast, *acs, *drop, 1);

    /** TODO fill the clissifier */
    return 1;
}

/**
 * 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;
}

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

    dbg_assert (ctx);
    dbg_assert (buffer);
    dbg_assert (length >= ETH_PACKET_MIN_SIZE && length <= ETH_PACKET_MAX_SIZE);
    dbg_assert (ctx->mactotei);

    if (!ctx->mac_config->authenticated)
    {
       (*ctx->data_tx.cb) (ctx->data_tx.user, buffer);
       CL_TRACE (DATA_SEND_DROP, mac_ntb(), ctx->mac_config->authenticated, buffer,
                 length);
       return;
    }

    mac = read_u48_from_word (buffer);

    /* Get the TEI from the mactotei table. */
    tei = cl_mactotei_table_find_tei_from_mac (ctx, mac & 0x0000FFFFFFFFFFFFull);

    dbg_assert (tei != ctx->mac_config->tei);
    // if the TEI is not found the packet is send as broadcast.
    cl_data_send_with_tei (ctx, buffer, length, tei == 0 ? 0xFF : tei);
}

/**
 * Send a data once the TEI has been find.
 *
 * \param  ctx  the cl context.
 * \param  buffer  the buffer containing the data to send.
 * \param  length  the buffer data length.
 * \param  tei  the tei found from the cl_mactotei list.
 */
void
cl_data_send_with_tei (cl_t *ctx, u8 *buffer, uint length, uint tei)
{
    uint lid;
    bool bcast;
    bool acs;
    bool drop;
    mfs_tx_t *mfs;

    dbg_assert (ctx);
    dbg_assert (buffer);
    dbg_assert (length >= ETH_PACKET_MIN_SIZE && length <=
                ETH_PACKET_MAX_SIZE);
    dbg_assert (tei);

    /* Get some data from the classifier. */
    lid = cl_classifer_get_lid (ctx, tei, &bcast, &acs, &drop);

    /* try to get the mfs from the store. */
    mfs = mac_store_mfs_get_tx (ctx->mac_store, bcast, false, lid, tei);

    if (!drop && !acs && mfs)
    {
        CL_TRACE (DATA_SEND, mac_ntb(), buffer, length, mfs->common.tei, mfs->common.lid,
                  mfs->common.bcast);
        sar_msdu_add (ctx->sar, buffer, length, mac_ntb(), mfs);
        
        /* release the mfs */
        blk_release (mfs);

    }
    else
    {
        CL_TRACE (DATA_SEND_DROP, mac_ntb(), buffer, length);
        dbg_assert (ctx->data_tx.cb);
        (*ctx->data_tx.cb) (ctx->data_tx.user, buffer);
    }
}

/**
 * The SAR inform the CL that the data previously provided had been sent over
 * the PLC.
 * 
 * \param  ctx  the CL context.
 * \param  buffer  the buffer containing the MME
 */
void cl_data_send_done (cl_t *ctx, u8 *buffer)
{
    dbg_assert (ctx);
    dbg_assert (buffer);

    CL_TRACE (DATA_SEND_DONE, mac_ntb(), buffer);

    /* Compare the buffer address with the MME buffer address. */
    if (ctx->mme_ul_send.mme_buffer == buffer)
    {
        cl_mme_buffer_add(ctx, buffer);
        ctx->mme_ul_send.mme_buffer = NULL;
    }
    else
    {
        dbg_assert (ctx->data_tx.cb);
        (*ctx->data_tx.cb) (ctx->data_tx.user, buffer);
    }
}

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

    cl->data_rx.cb = cb;
    cl->data_rx.user = user;
}

/**
 * Called by the SAR each time it has a data to provide to the CL.
 *
 * \param  ctx  the CL context
 * \param  buffer  the buffer containing the data to send to the Upper layer.
 * \param  length  the data length in the buffer
 * \param  mfs  the mfs used to receive the data.
 */
void cl_data_recv (cl_t *ctx, u8 *buffer, uint length, mfs_rx_t *mfs)
{
    dbg_assert (ctx);
    dbg_assert (buffer);
    dbg_assert (length >= ETH_PACKET_MIN_SIZE && length <= ETH_PACKET_MAX_SIZE);
    dbg_assert (mfs);

    dbg_assert (ctx->data_rx.cb);

    CL_TRACE (DATA_RECV, mac_ntb(), buffer, length);

    (*ctx->data_rx.cb) (ctx->data_rx.user, buffer, length);
}

/**
 * Provides a buffer to the CP.
 * 
 * \param  ctx  the CL context
 * \param  buffer  the buffer to reassembly some datas
 */
void cl_mme_buffer_add (cl_t *ctx, u8 *buffer)
{
    dbg_assert (ctx);
    dbg_assert (buffer);
   
    CL_TRACE (MME_BUFFER_ADD, mac_ntb(), buffer); 
    dbg_assert (ctx->mme.mme_buffer_add_cb);
    (*ctx->mme.mme_buffer_add_cb) (ctx->mme.mme_buffer_add_user_data, buffer);
}

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

    CL_TRACE (DATA_BUFFER_ADD, mac_ntb(), buffer); 

    sar_data_buffer_add (ctx->sar, buffer);
}