summaryrefslogtreecommitdiff
path: root/mac/sar/src/sar.c
blob: f24bbee1df5da43156a4bc6259c2a138f11f630a (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
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    mac/sar/src/sar.c
 * \brief   common function for the reassembly and the segmentation part
 * \ingroup mac_sar
 */

#include "common/std.h"
#include "mac/sar/sar.h"

/**
 * Sar procedure
 * Launch the SAR.
 */
void sar_launch (cyg_addrword_t address)
{
    sar_work_message_t *work;
    sar_msdu_t *msdu;
    sar_mpdu_t *mpdu;
    //int iter;

    //TODO uncomment this part of the code.
    //while (true)
    //{
    work = sar_work_get ();

    if (work != NULL)
    {
        switch (work->type)
        {
            case SEG :
                msdu = &work->msg.msdu;
                segmentation_run (msdu);
                break;
            case REA :
                mpdu = &work->msg.mpdu;
                reassembly_run (mpdu);
                break;
            case ADD_BUFFER:
                buffer_address_list_add (work->ctx, work->msg.buffer_addr);
                upper_layer_transmit_data (work->ctx);
                break;
            case BRIDGE :
                bridge_dma_free_head (&sar_ctx.bridge_dma_jobs);
        }

        blk_release ((blk_t *) work);
    }
    else
    {
        mfs_manage_expiration ();
    }
    //}
}