summaryrefslogtreecommitdiff
path: root/cesar/cl/cl.h
blob: c4e604b97965565ea97cb08d6aa896494eed0024 (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
#ifndef CL_CL_H_
#define CL_CL_H_

/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cl/cl.h
 * \brief   Public functions
 * \ingroup cl
 *
 */
#include "common/defs/igmp.h"
#include "bufmgr/bufmgr.h"
#include "hal/ipmbox/ipmbox.h"
#include "mac/common/config.h"
#include "mac/common/store.h"
#include "mac/sar/sar.h"
#include "cl/mbx/mbx.h"

#if MODULE_INCLUDED (cl)
#  include "config/cl.h"
#else
#  define CONFIG_CL_DATA_RATE 0
#endif

/** forward declaration. */
typedef struct cl_t cl_t;

BEGIN_DECLS

/**
 * 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.
 * \param  ipmbox  context.
 * \param  bufmgr  context.
 * \return  the convergence layer context.
 */
cl_t *
cl_init (mac_store_t *mac_store, sar_t *sar, mac_config_t *mac_config,
         ipmbox_t *ipmbox, bufmgr_t *bufmgr);

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

/**
 * Clean data send link.
 * \param  ctx  CL context.
 */
void
cl_data_send_link_clear (cl_t *ctx);

/**
 * Get the access to the igmp data in the cl context.
 * \param  cl  the CL context.
  * \return the pointer to the igmp data.
 */
igmp_groups_t *
cl_get_igmp_groups (cl_t *cl);

/**
 * Update the igmp groups based on the mactotei table.
 * \param  cl  the CL context.
 */
void
cl_update_igmp_groups (cl_t *ctx);

/**
 * Send an MME from the CP to the PLC or to linux if TEI is foreign.
 * \param  ctx  the CL context
 * \param  buffer  the buffer containing the MME
 * \param  length  the length of the MME
 * \param  tei  the destination TEI (MAC_TEI_FOREIGN for linux)
 */
void
cl_mme_send (cl_t *ctx, u8 *buffer, uint length, uint tei);

/**
 * Compute the data rate on the station.
 * \param  ctx  the module context
 * \param  mfs  the mfs to use
 * \param  length  the payload length
 */
void
cl_compute_datarate_on_sta_ (cl_t *ctx, mfs_t *mfs, uint length);

extern inline void
cl_compute_datarate_on_sta (cl_t *ctx, mfs_t *mfs, uint length)
{
#if CONFIG_CL_DATA_RATE
    cl_compute_datarate_on_sta_ (ctx, mfs, length);
#endif
}

/**
 * For some users which needs mbx.
 * \param  ctx  the module context.
 * \return  cl_mbx context.
 */
cl_mbx_t*
cl_mbx_get (cl_t *ctx);

END_DECLS

#endif /* CL_CL_H_ */