blob: f123cb6c4fab8708d1ac633dd11c008bf1a42486 [file] [log] [blame]
Harald Welte1f0b8c22011-06-27 10:51:37 +02001/* GSM LAPDm (TS 04.06) implementation */
2
3/* (C) 2010-2011 by Harald Welte <laforge@gnumonks.org>
rootaf48bed2011-09-26 11:23:06 +02004 * (C) 2010-2011 by Andreas Eversberg <jolly@eversberg.eu>
Harald Welte1f0b8c22011-06-27 10:51:37 +02005 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 */
23
Harald Welte6bdf0b12011-08-17 18:22:08 +020024/*! \addtogroup lapdm
25 * @{
26 */
27
28/*! \file lapdm.c */
29
Harald Welte1f0b8c22011-06-27 10:51:37 +020030#include <stdio.h>
31#include <stdint.h>
32#include <string.h>
33#include <errno.h>
34#include <arpa/inet.h>
35
36#include <osmocom/core/logging.h>
37#include <osmocom/core/timer.h>
38#include <osmocom/core/msgb.h>
39#include <osmocom/core/utils.h>
40
41#include <osmocom/gsm/tlv.h>
42#include <osmocom/gsm/rsl.h>
43#include <osmocom/gsm/prim.h>
44#include <osmocom/gsm/gsm_utils.h>
45#include <osmocom/gsm/lapdm.h>
46
47#include <osmocom/gsm/protocol/gsm_04_08.h>
48#include <osmocom/gsm/protocol/gsm_08_58.h>
49
50/* TS 04.06 Figure 4 / Section 3.2 */
51#define LAPDm_LPD_NORMAL 0
52#define LAPDm_LPD_SMSCB 1
53#define LAPDm_SAPI_NORMAL 0
54#define LAPDm_SAPI_SMS 3
55#define LAPDm_ADDR(lpd, sapi, cr) ((((lpd) & 0x3) << 5) | (((sapi) & 0x7) << 2) | (((cr) & 0x1) << 1) | 0x1)
56
rootaf48bed2011-09-26 11:23:06 +020057#define LAPDm_ADDR_LPD(addr) (((addr) >> 5) & 0x3)
Harald Welte1f0b8c22011-06-27 10:51:37 +020058#define LAPDm_ADDR_SAPI(addr) (((addr) >> 2) & 0x7)
59#define LAPDm_ADDR_CR(addr) (((addr) >> 1) & 0x1)
60#define LAPDm_ADDR_EA(addr) ((addr) & 0x1)
61
62/* TS 04.06 Table 3 / Section 3.4.3 */
63#define LAPDm_CTRL_I(nr, ns, p) ((((nr) & 0x7) << 5) | (((p) & 0x1) << 4) | (((ns) & 0x7) << 1))
64#define LAPDm_CTRL_S(nr, s, p) ((((nr) & 0x7) << 5) | (((p) & 0x1) << 4) | (((s) & 0x3) << 2) | 0x1)
65#define LAPDm_CTRL_U(u, p) ((((u) & 0x1c) << (5-2)) | (((p) & 0x1) << 4) | (((u) & 0x3) << 2) | 0x3)
66
67#define LAPDm_CTRL_is_I(ctrl) (((ctrl) & 0x1) == 0)
68#define LAPDm_CTRL_is_S(ctrl) (((ctrl) & 0x3) == 1)
69#define LAPDm_CTRL_is_U(ctrl) (((ctrl) & 0x3) == 3)
70
71#define LAPDm_CTRL_U_BITS(ctrl) ((((ctrl) & 0xC) >> 2) | ((ctrl) & 0xE0) >> 3)
72#define LAPDm_CTRL_PF_BIT(ctrl) (((ctrl) >> 4) & 0x1)
73
74#define LAPDm_CTRL_S_BITS(ctrl) (((ctrl) & 0xC) >> 2)
75
76#define LAPDm_CTRL_I_Ns(ctrl) (((ctrl) & 0xE) >> 1)
77#define LAPDm_CTRL_Nr(ctrl) (((ctrl) & 0xE0) >> 5)
78
Harald Welte1f0b8c22011-06-27 10:51:37 +020079#define LAPDm_LEN(len) ((len << 2) | 0x1)
80#define LAPDm_MORE 0x2
rootaf48bed2011-09-26 11:23:06 +020081#define LAPDm_EL 0x1
82
83#define LAPDm_U_UI 0x0
Harald Welte1f0b8c22011-06-27 10:51:37 +020084
85/* TS 04.06 Section 5.8.3 */
86#define N201_AB_SACCH 18
87#define N201_AB_SDCCH 20
88#define N201_AB_FACCH 20
89#define N201_Bbis 23
90#define N201_Bter_SACCH 21
91#define N201_Bter_SDCCH 23
92#define N201_Bter_FACCH 23
93#define N201_B4 19
94
95/* 5.8.2.1 N200 during establish and release */
96#define N200_EST_REL 5
97/* 5.8.2.1 N200 during timer recovery state */
98#define N200_TR_SACCH 5
99#define N200_TR_SDCCH 23
100#define N200_TR_FACCH_FR 34
101#define N200_TR_EFACCH_FR 48
102#define N200_TR_FACCH_HR 29
rootaf48bed2011-09-26 11:23:06 +0200103/* FIXME: set N200 depending on chan_nr */
104#define N200 N200_TR_SDCCH
Harald Welte1f0b8c22011-06-27 10:51:37 +0200105
106enum lapdm_format {
107 LAPDm_FMT_A,
108 LAPDm_FMT_B,
109 LAPDm_FMT_Bbis,
110 LAPDm_FMT_Bter,
111 LAPDm_FMT_B4,
112};
113
rootaf48bed2011-09-26 11:23:06 +0200114static int lapdm_send_ph_data_req(struct lapd_msg_ctx *lctx, struct msgb *msg);
115static int send_rslms_dlsap(struct osmo_dlsap_prim *dp,
116 struct lapd_msg_ctx *lctx);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200117
118static void lapdm_dl_init(struct lapdm_datalink *dl,
Andreas.Eversberg5ac44782011-11-06 20:35:48 +0100119 struct lapdm_entity *entity, int t200)
Harald Welte1f0b8c22011-06-27 10:51:37 +0200120{
121 memset(dl, 0, sizeof(*dl));
Harald Welte1f0b8c22011-06-27 10:51:37 +0200122 dl->entity = entity;
rootaf48bed2011-09-26 11:23:06 +0200123 lapd_dl_init(&dl->dl, 1, 8, 200);
124 dl->dl.reestablish = 0; /* GSM uses no reestablish */
125 dl->dl.send_ph_data_req = lapdm_send_ph_data_req;
126 dl->dl.send_dlsap = send_rslms_dlsap;
127 dl->dl.n200_est_rel = N200_EST_REL;
128 dl->dl.n200 = N200;
129 dl->dl.t203_sec = 0; dl->dl.t203_usec = 0;
Andreas.Eversberg5ac44782011-11-06 20:35:48 +0100130 dl->dl.t200_sec = t200; dl->dl.t200_usec = 0;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200131}
132
Harald Welte6bdf0b12011-08-17 18:22:08 +0200133/*! \brief initialize a LAPDm entity and all datalinks inside
134 * \param[in] le LAPDm entity
135 * \param[in] mode \ref lapdm_mode (BTS/MS)
136 */
Andreas.Eversberg5ac44782011-11-06 20:35:48 +0100137void lapdm_entity_init(struct lapdm_entity *le, enum lapdm_mode mode, int t200)
Harald Welte1f0b8c22011-06-27 10:51:37 +0200138{
139 unsigned int i;
140
141 for (i = 0; i < ARRAY_SIZE(le->datalink); i++)
Andreas.Eversberg5ac44782011-11-06 20:35:48 +0100142 lapdm_dl_init(&le->datalink[i], le, t200);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200143
144 lapdm_entity_set_mode(le, mode);
145}
146
Harald Welte6bdf0b12011-08-17 18:22:08 +0200147/*! \brief initialize a LAPDm channel and all its channels
148 * \param[in] lc \ref lapdm_channel to be initialized
149 * \param[in] mode \ref lapdm_mode (BTS/MS)
150 *
151 * This really is a convenience wrapper around calling \ref
152 * lapdm_entity_init twice.
153 */
Harald Welte1f0b8c22011-06-27 10:51:37 +0200154void lapdm_channel_init(struct lapdm_channel *lc, enum lapdm_mode mode)
155{
Andreas.Eversberg5ac44782011-11-06 20:35:48 +0100156 lapdm_entity_init(&lc->lapdm_acch, mode, 2);
rootaf48bed2011-09-26 11:23:06 +0200157 /* FIXME: this depends on chan type */
Andreas.Eversberg5ac44782011-11-06 20:35:48 +0100158 lapdm_entity_init(&lc->lapdm_dcch, mode, 1);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200159}
160
Harald Welte6bdf0b12011-08-17 18:22:08 +0200161/*! \brief flush and release all resoures in LAPDm entity */
Harald Welte1f0b8c22011-06-27 10:51:37 +0200162void lapdm_entity_exit(struct lapdm_entity *le)
163{
164 unsigned int i;
165 struct lapdm_datalink *dl;
166
167 for (i = 0; i < ARRAY_SIZE(le->datalink); i++) {
168 dl = &le->datalink[i];
rootaf48bed2011-09-26 11:23:06 +0200169 lapd_dl_exit(&dl->dl);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200170 }
171}
172
Harald Welte6bdf0b12011-08-17 18:22:08 +0200173/* \brief lfush and release all resources in LAPDm channel
174 *
175 * A convenience wrapper calling \ref lapdm_entity_exit on both
176 * entities inside the \ref lapdm_channel
177 */
Harald Welte1f0b8c22011-06-27 10:51:37 +0200178void lapdm_channel_exit(struct lapdm_channel *lc)
179{
180 lapdm_entity_exit(&lc->lapdm_acch);
181 lapdm_entity_exit(&lc->lapdm_dcch);
182}
183
Harald Welte1f0b8c22011-06-27 10:51:37 +0200184static struct lapdm_datalink *datalink_for_sapi(struct lapdm_entity *le, uint8_t sapi)
185{
186 switch (sapi) {
187 case LAPDm_SAPI_NORMAL:
188 return &le->datalink[0];
189 case LAPDm_SAPI_SMS:
190 return &le->datalink[1];
191 default:
192 return NULL;
193 }
194}
195
196/* remove the L2 header from a MSGB */
197static inline unsigned char *msgb_pull_l2h(struct msgb *msg)
198{
199 unsigned char *ret = msgb_pull(msg, msg->l3h - msg->l2h);
200 msg->l2h = NULL;
201 return ret;
202}
203
204/* Append padding (if required) */
205static void lapdm_pad_msgb(struct msgb *msg, uint8_t n201)
206{
207 int pad_len = n201 - msgb_l2len(msg);
208 uint8_t *data;
209
210 if (pad_len < 0) {
rootaf48bed2011-09-26 11:23:06 +0200211 LOGP(DLLAPD, LOGL_ERROR,
Harald Welte1f0b8c22011-06-27 10:51:37 +0200212 "cannot pad message that is already too big!\n");
213 return;
214 }
215
216 data = msgb_put(msg, pad_len);
217 memset(data, 0x2B, pad_len);
218}
219
220/* input function that L2 calls when sending messages up to L3 */
221static int rslms_sendmsg(struct msgb *msg, struct lapdm_entity *le)
222{
223 if (!le->l3_cb) {
224 msgb_free(msg);
225 return -EIO;
226 }
227
228 /* call the layer2 message handler that is registered */
229 return le->l3_cb(msg, le, le->l3_ctx);
230}
231
232/* write a frame into the tx queue */
233static int tx_ph_data_enqueue(struct lapdm_datalink *dl, struct msgb *msg,
rootaf48bed2011-09-26 11:23:06 +0200234 uint8_t chan_nr, uint8_t link_id, uint8_t pad)
Harald Welte1f0b8c22011-06-27 10:51:37 +0200235{
236 struct lapdm_entity *le = dl->entity;
237 struct osmo_phsap_prim pp;
238
239 /* if there is a pending message, queue it */
240 if (le->tx_pending || le->flags & LAPDM_ENT_F_POLLING_ONLY) {
rootaf48bed2011-09-26 11:23:06 +0200241 *msgb_push(msg, 1) = pad;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200242 *msgb_push(msg, 1) = link_id;
243 *msgb_push(msg, 1) = chan_nr;
rootaf48bed2011-09-26 11:23:06 +0200244 msgb_enqueue(&dl->dl.tx_queue, msg);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200245 return -EBUSY;
246 }
247
248 osmo_prim_init(&pp.oph, SAP_GSM_PH, PRIM_PH_DATA,
249 PRIM_OP_REQUEST, msg);
250 pp.u.data.chan_nr = chan_nr;
251 pp.u.data.link_id = link_id;
252
253 /* send the frame now */
254 le->tx_pending = 0; /* disabled flow control */
rootaf48bed2011-09-26 11:23:06 +0200255 lapdm_pad_msgb(msg, pad);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200256
257 return le->l1_prim_cb(&pp.oph, le->l1_ctx);
258}
259
260static struct msgb *tx_dequeue_msgb(struct lapdm_entity *le)
261{
262 struct lapdm_datalink *dl;
263 int last = le->last_tx_dequeue;
264 int i = last, n = ARRAY_SIZE(le->datalink);
265 struct msgb *msg = NULL;
266
267 /* round-robin dequeue */
268 do {
269 /* next */
270 i = (i + 1) % n;
271 dl = &le->datalink[i];
rootaf48bed2011-09-26 11:23:06 +0200272 if ((msg = msgb_dequeue(&dl->dl.tx_queue)))
Harald Welte1f0b8c22011-06-27 10:51:37 +0200273 break;
274 } while (i != last);
275
276 if (msg) {
277 /* Set last dequeue position */
278 le->last_tx_dequeue = i;
279 }
280
281 return msg;
282}
283
Harald Welte6bdf0b12011-08-17 18:22:08 +0200284/*! \brief dequeue a msg that's pending transmission via L1 and wrap it into
Harald Welte1f0b8c22011-06-27 10:51:37 +0200285 * a osmo_phsap_prim */
286int lapdm_phsap_dequeue_prim(struct lapdm_entity *le, struct osmo_phsap_prim *pp)
287{
288 struct msgb *msg;
rootaf48bed2011-09-26 11:23:06 +0200289 uint8_t pad;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200290
291 msg = tx_dequeue_msgb(le);
292 if (!msg)
293 return -ENODEV;
294
295 /* if we have a message, send PH-DATA.req */
296 osmo_prim_init(&pp->oph, SAP_GSM_PH, PRIM_PH_DATA,
297 PRIM_OP_REQUEST, msg);
298
299 /* Pull chan_nr and link_id */
300 pp->u.data.chan_nr = *msg->data;
301 msgb_pull(msg, 1);
302 pp->u.data.link_id = *msg->data;
303 msgb_pull(msg, 1);
rootaf48bed2011-09-26 11:23:06 +0200304 pad = *msg->data;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200305 msgb_pull(msg, 1);
306
307 /* Pad the frame, we can transmit now */
rootaf48bed2011-09-26 11:23:06 +0200308 lapdm_pad_msgb(msg, pad);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200309
310 return 0;
311}
312
313/* get next frame from the tx queue. because the ms has multiple datalinks,
314 * each datalink's queue is read round-robin.
315 */
316static int l2_ph_data_conf(struct msgb *msg, struct lapdm_entity *le)
317{
318 struct osmo_phsap_prim pp;
319
320 /* we may send again */
321 le->tx_pending = 0;
322
323 /* free confirm message */
324 if (msg)
325 msgb_free(msg);
326
327 if (lapdm_phsap_dequeue_prim(le, &pp) < 0) {
328 /* no message in all queues */
329
330 /* If user didn't request PH-EMPTY_FRAME.req, abort */
331 if (!(le->flags & LAPDM_ENT_F_EMPTY_FRAME))
332 return 0;
333
334 /* otherwise, send PH-EMPTY_FRAME.req */
335 osmo_prim_init(&pp.oph, SAP_GSM_PH,
336 PRIM_PH_EMPTY_FRAME,
337 PRIM_OP_REQUEST, NULL);
338 } else {
339 le->tx_pending = 1;
340 }
341
342 return le->l1_prim_cb(&pp.oph, le->l1_ctx);
343}
344
345/* Create RSLms various RSLms messages */
346static int send_rslms_rll_l3(uint8_t msg_type, struct lapdm_msg_ctx *mctx,
347 struct msgb *msg)
348{
349 /* Add the RSL + RLL header */
350 rsl_rll_push_l3(msg, msg_type, mctx->chan_nr, mctx->link_id, 1);
351
352 /* send off the RSLms message to L3 */
353 return rslms_sendmsg(msg, mctx->dl->entity);
354}
355
356/* Take a B4 format message from L1 and create RSLms UNIT DATA IND */
357static int send_rslms_rll_l3_ui(struct lapdm_msg_ctx *mctx, struct msgb *msg)
358{
359 uint8_t l3_len = msg->tail - (uint8_t *)msgb_l3(msg);
360 struct abis_rsl_rll_hdr *rllh;
361
362 /* Add the RSL + RLL header */
363 msgb_tv16_push(msg, RSL_IE_L3_INFO, l3_len);
364 msgb_push(msg, 2 + 2);
365 rsl_rll_push_hdr(msg, RSL_MT_UNIT_DATA_IND, mctx->chan_nr,
366 mctx->link_id, 1);
367 rllh = (struct abis_rsl_rll_hdr *)msgb_l2(msg);
368
369 rllh->data[0] = RSL_IE_TIMING_ADVANCE;
370 rllh->data[1] = mctx->ta_ind;
371
372 rllh->data[2] = RSL_IE_MS_POWER;
373 rllh->data[3] = mctx->tx_power_ind;
374
375 return rslms_sendmsg(msg, mctx->dl->entity);
376}
377
378static int send_rll_simple(uint8_t msg_type, struct lapdm_msg_ctx *mctx)
379{
380 struct msgb *msg;
381
382 msg = rsl_rll_simple(msg_type, mctx->chan_nr, mctx->link_id, 1);
383
384 /* send off the RSLms message to L3 */
385 return rslms_sendmsg(msg, mctx->dl->entity);
386}
387
388static int rsl_rll_error(uint8_t cause, struct lapdm_msg_ctx *mctx)
389{
390 struct msgb *msg;
391
rootaf48bed2011-09-26 11:23:06 +0200392 LOGP(DLLAPD, LOGL_NOTICE, "sending MDL-ERROR-IND %d\n", cause);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200393 msg = rsl_rll_simple(RSL_MT_ERROR_IND, mctx->chan_nr, mctx->link_id, 1);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200394 msgb_tlv_put(msg, RSL_IE_RLM_CAUSE, 1, &cause);
395 return rslms_sendmsg(msg, mctx->dl->entity);
396}
397
rootaf48bed2011-09-26 11:23:06 +0200398/* DLSAP L2 -> L3 (RSLms) */
399static int send_rslms_dlsap(struct osmo_dlsap_prim *dp,
400 struct lapd_msg_ctx *lctx)
Harald Welte1f0b8c22011-06-27 10:51:37 +0200401{
rootaf48bed2011-09-26 11:23:06 +0200402 struct lapd_datalink *dl = lctx->dl;
403 struct lapdm_datalink *mdl =
404 container_of(dl, struct lapdm_datalink, dl);
405 struct lapdm_msg_ctx *mctx = &mdl->mctx;
406 uint8_t rll_msg = 0;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200407
Andreas Eversberg78122ab2011-09-27 12:06:55 +0200408 switch (OSMO_PRIM_HDR(&dp->oph)) {
409 case OSMO_PRIM(PRIM_DL_EST, PRIM_OP_INDICATION):
410 rll_msg = RSL_MT_EST_IND;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200411 break;
Andreas Eversberg78122ab2011-09-27 12:06:55 +0200412 case OSMO_PRIM(PRIM_DL_EST, PRIM_OP_CONFIRM):
413 rll_msg = RSL_MT_EST_CONF;
rootaf48bed2011-09-26 11:23:06 +0200414 break;
Andreas Eversberg78122ab2011-09-27 12:06:55 +0200415 case OSMO_PRIM(PRIM_DL_DATA, PRIM_OP_INDICATION):
416 rll_msg = RSL_MT_DATA_IND;
rootaf48bed2011-09-26 11:23:06 +0200417 break;
Andreas Eversberg78122ab2011-09-27 12:06:55 +0200418 case OSMO_PRIM(PRIM_DL_UNIT_DATA, PRIM_OP_INDICATION):
419 return send_rslms_rll_l3_ui(mctx, dp->oph.msg);
420 case OSMO_PRIM(PRIM_DL_REL, PRIM_OP_INDICATION):
421 rll_msg = RSL_MT_REL_IND;
rootaf48bed2011-09-26 11:23:06 +0200422 break;
Andreas Eversberg78122ab2011-09-27 12:06:55 +0200423 case OSMO_PRIM(PRIM_DL_REL, PRIM_OP_CONFIRM):
424 rll_msg = RSL_MT_REL_CONF;
rootaf48bed2011-09-26 11:23:06 +0200425 break;
Andreas Eversberg78122ab2011-09-27 12:06:55 +0200426 case OSMO_PRIM(PRIM_DL_SUSP, PRIM_OP_CONFIRM):
427 rll_msg = RSL_MT_SUSP_CONF;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200428 break;
Andreas Eversberg78122ab2011-09-27 12:06:55 +0200429 case OSMO_PRIM(PRIM_MDL_ERROR, PRIM_OP_INDICATION):
430 rsl_rll_error(dp->u.error_ind.cause, mctx);
431 if (dp->oph.msg)
432 msgb_free(dp->oph.msg);
433 return 0;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200434 }
rootaf48bed2011-09-26 11:23:06 +0200435
436 if (!rll_msg) {
437 LOGP(DLLAPD, LOGL_ERROR, "Unsupported op %d, prim %d. Please "
438 "fix!\n", dp->oph.primitive, dp->oph.operation);
439 return -EINVAL;
440 }
441
442 if (!dp->oph.msg)
443 return send_rll_simple(rll_msg, mctx);
444
445 return send_rslms_rll_l3(rll_msg, mctx, dp->oph.msg);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200446}
447
rootaf48bed2011-09-26 11:23:06 +0200448/* send a data frame to layer 1 */
449static int lapdm_send_ph_data_req(struct lapd_msg_ctx *lctx, struct msgb *msg)
Harald Welte1f0b8c22011-06-27 10:51:37 +0200450{
rootaf48bed2011-09-26 11:23:06 +0200451 uint8_t l3_len = msg->tail - msg->data;
452 struct lapd_datalink *dl = lctx->dl;
453 struct lapdm_datalink *mdl =
454 container_of(dl, struct lapdm_datalink, dl);
455 struct lapdm_msg_ctx *mctx = &mdl->mctx;
456 int format = lctx->format;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200457
rootaf48bed2011-09-26 11:23:06 +0200458 /* prepend l2 header */
459 msg->l2h = msgb_push(msg, 3);
460 msg->l2h[0] = LAPDm_ADDR(lctx->lpd, lctx->sapi, lctx->cr);
461 /* EA is set here too */
462 switch (format) {
463 case LAPD_FORM_I:
464 msg->l2h[1] = LAPDm_CTRL_I(lctx->n_recv, lctx->n_send,
465 lctx->p_f);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200466 break;
rootaf48bed2011-09-26 11:23:06 +0200467 case LAPD_FORM_S:
468 msg->l2h[1] = LAPDm_CTRL_S(lctx->n_recv, lctx->s_u, lctx->p_f);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200469 break;
rootaf48bed2011-09-26 11:23:06 +0200470 case LAPD_FORM_U:
471 msg->l2h[1] = LAPDm_CTRL_U(lctx->s_u, lctx->p_f);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200472 break;
473 default:
Harald Welte1f0b8c22011-06-27 10:51:37 +0200474 msgb_free(msg);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200475 return -EINVAL;
476 }
rootaf48bed2011-09-26 11:23:06 +0200477 msg->l2h[2] = LAPDm_LEN(l3_len); /* EL is set here too */
478 if (lctx->more)
479 msg->l2h[2] |= LAPDm_MORE;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200480
Andreas.Eversbergf1f80de2011-11-06 20:45:29 +0100481 /* add ACCH header with last indicated tx-power and TA */
482 if ((mctx->link_id & 0x40)) {
483 struct lapdm_entity *le = mdl->entity;
484
485 msg->l2h = msgb_push(msg, 2);
486 msg->l2h[0] = le->tx_power;
487 msg->l2h[1] = le->ta;
488 }
489
rootaf48bed2011-09-26 11:23:06 +0200490 return tx_ph_data_enqueue(mctx->dl, msg, mctx->chan_nr, mctx->link_id,
491 23);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200492}
493
494/* input into layer2 (from layer 1) */
rootaf48bed2011-09-26 11:23:06 +0200495static int l2_ph_data_ind(struct msgb *msg, struct lapdm_entity *le,
496 uint8_t chan_nr, uint8_t link_id)
Harald Welte1f0b8c22011-06-27 10:51:37 +0200497{
498 uint8_t cbits = chan_nr >> 3;
Harald Welte64207742011-06-27 23:32:14 +0200499 uint8_t sapi; /* we cannot take SAPI from link_id, as L1 has no clue */
Harald Welte1f0b8c22011-06-27 10:51:37 +0200500 struct lapdm_msg_ctx mctx;
rootaf48bed2011-09-26 11:23:06 +0200501 struct lapd_msg_ctx lctx;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200502 int rc = 0;
rootaf48bed2011-09-26 11:23:06 +0200503 int n201;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200504
505 /* when we reach here, we have a msgb with l2h pointing to the raw
506 * 23byte mac block. The l1h has already been purged. */
507
rootaf48bed2011-09-26 11:23:06 +0200508 memset(&mctx, 0, sizeof(mctx));
Harald Welte1f0b8c22011-06-27 10:51:37 +0200509 mctx.chan_nr = chan_nr;
510 mctx.link_id = link_id;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200511
Harald Welte1f0b8c22011-06-27 10:51:37 +0200512 /* check for L1 chan_nr/link_id and determine LAPDm hdr format */
513 if (cbits == 0x10 || cbits == 0x12) {
514 /* Format Bbis is used on BCCH and CCCH(PCH, NCH and AGCH) */
515 mctx.lapdm_fmt = LAPDm_FMT_Bbis;
rootaf48bed2011-09-26 11:23:06 +0200516 n201 = N201_Bbis;
Harald Welte64207742011-06-27 23:32:14 +0200517 sapi = 0;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200518 } else {
519 if (mctx.link_id & 0x40) {
Harald Welte7ca604b2011-06-29 12:13:51 +0200520 /* It was received from network on SACCH */
521
Andreas.Eversberg816e1782011-11-06 20:46:30 +0100522 /* If UI on SACCH sent by BTS, lapdm_fmt must be B4 */
523 if (le->mode == LAPDM_MODE_MS
524 && LAPDm_CTRL_is_U(msg->l2h[3])
525 && LAPDm_CTRL_U_BITS(msg->l2h[3]) == 0) {
Harald Welte7ca604b2011-06-29 12:13:51 +0200526 mctx.lapdm_fmt = LAPDm_FMT_B4;
rootaf48bed2011-09-26 11:23:06 +0200527 n201 = N201_B4;
528 LOGP(DLLAPD, LOGL_INFO, "fmt=B4\n");
Harald Welte7ca604b2011-06-29 12:13:51 +0200529 } else {
530 mctx.lapdm_fmt = LAPDm_FMT_B;
rootaf48bed2011-09-26 11:23:06 +0200531 n201 = N201_AB_SACCH;
532 LOGP(DLLAPD, LOGL_INFO, "fmt=B\n");
Harald Welte7ca604b2011-06-29 12:13:51 +0200533 }
Harald Welte1f0b8c22011-06-27 10:51:37 +0200534 /* SACCH frames have a two-byte L1 header that
535 * OsmocomBB L1 doesn't strip */
536 mctx.tx_power_ind = msg->l2h[0] & 0x1f;
537 mctx.ta_ind = msg->l2h[1];
538 msgb_pull(msg, 2);
539 msg->l2h += 2;
Harald Welte64207742011-06-27 23:32:14 +0200540 sapi = (msg->l2h[0] >> 2) & 7;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200541 } else {
542 mctx.lapdm_fmt = LAPDm_FMT_B;
rootaf48bed2011-09-26 11:23:06 +0200543 LOGP(DLLAPD, LOGL_INFO, "fmt=B\n");
Andreas.Eversbergcbed3272011-11-06 20:43:08 +0100544 n201 = N201_AB_SDCCH;
Harald Welte64207742011-06-27 23:32:14 +0200545 sapi = (msg->l2h[0] >> 2) & 7;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200546 }
547 }
548
Harald Welte64207742011-06-27 23:32:14 +0200549 mctx.dl = datalink_for_sapi(le, sapi);
550 /* G.2.1 No action on frames containing an unallocated SAPI. */
551 if (!mctx.dl) {
rootaf48bed2011-09-26 11:23:06 +0200552 LOGP(DLLAPD, LOGL_NOTICE, "Received frame for unsupported "
Harald Welte64207742011-06-27 23:32:14 +0200553 "SAPI %d!\n", sapi);
Harald Welte64207742011-06-27 23:32:14 +0200554 msgb_free(msg);
555 return -EIO;
556 }
557
Harald Welte1f0b8c22011-06-27 10:51:37 +0200558 switch (mctx.lapdm_fmt) {
559 case LAPDm_FMT_A:
560 case LAPDm_FMT_B:
561 case LAPDm_FMT_B4:
rootaf48bed2011-09-26 11:23:06 +0200562 lctx.dl = &mctx.dl->dl;
563 /* obtain SAPI from address field */
564 mctx.link_id |= LAPDm_ADDR_SAPI(msg->l2h[0]);
565 /* G.2.3 EA bit set to "0" is not allowed in GSM */
566 if (!LAPDm_ADDR_EA(msg->l2h[0])) {
567 LOGP(DLLAPD, LOGL_NOTICE, "EA bit 0 is not allowed in "
568 "GSM\n");
Harald Welte1f0b8c22011-06-27 10:51:37 +0200569 msgb_free(msg);
rootaf48bed2011-09-26 11:23:06 +0200570 rsl_rll_error(RLL_CAUSE_FRM_UNIMPL, &mctx);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200571 return -EINVAL;
572 }
rootaf48bed2011-09-26 11:23:06 +0200573 /* adress field */
574 lctx.lpd = LAPDm_ADDR_LPD(msg->l2h[0]);
575 lctx.sapi = LAPDm_ADDR_SAPI(msg->l2h[0]);
576 lctx.cr = LAPDm_ADDR_CR(msg->l2h[0]);
577 /* command field */
578 if (LAPDm_CTRL_is_I(msg->l2h[1])) {
579 lctx.format = LAPD_FORM_I;
580 lctx.n_send = LAPDm_CTRL_I_Ns(msg->l2h[1]);
581 lctx.n_recv = LAPDm_CTRL_Nr(msg->l2h[1]);
582 } else if (LAPDm_CTRL_is_S(msg->l2h[1])) {
583 lctx.format = LAPD_FORM_S;
584 lctx.n_recv = LAPDm_CTRL_Nr(msg->l2h[1]);
585 lctx.s_u = LAPDm_CTRL_S_BITS(msg->l2h[1]);
586 } else if (LAPDm_CTRL_is_U(msg->l2h[1])) {
587 lctx.format = LAPD_FORM_U;
588 lctx.s_u = LAPDm_CTRL_U_BITS(msg->l2h[1]);
589 } else
590 lctx.format = LAPD_FORM_UKN;
591 lctx.p_f = LAPDm_CTRL_PF_BIT(msg->l2h[1]);
592 if (lctx.sapi != LAPDm_SAPI_NORMAL
593 && lctx.sapi != LAPDm_SAPI_SMS
594 && lctx.format == LAPD_FORM_U
595 && lctx.s_u == LAPDm_U_UI) {
596 /* 5.3.3 UI frames with invalid SAPI values shall be
597 * discarded
598 */
599 LOGP(DLLAPD, LOGL_INFO, "sapi=%u (discarding)\n",
600 lctx.sapi);
601 msgb_free(msg);
602 return 0;
603 }
604 if (mctx.lapdm_fmt == LAPDm_FMT_B4) {
605 lctx.n201 = n201;
606 lctx.length = n201;
607 lctx.more = 0;
608 msg->l3h = msg->l2h + 2;
609 msgb_pull_l2h(msg);
610 } else {
611 /* length field */
612 if (!(msg->l2h[2] & LAPDm_EL)) {
613 /* G.4.1 If the EL bit is set to "0", an
614 * MDL-ERROR-INDICATION primitive with cause
615 * "frame not implemented" is sent to the
616 * mobile management entity. */
617 LOGP(DLLAPD, LOGL_NOTICE, "we don't support "
618 "multi-octet length\n");
619 msgb_free(msg);
620 rsl_rll_error(RLL_CAUSE_FRM_UNIMPL, &mctx);
621 return -EINVAL;
622 }
623 lctx.n201 = n201;
624 lctx.length = msg->l2h[2] >> 2;
625 lctx.more = !!(msg->l2h[2] & LAPDm_MORE);
626 msg->l3h = msg->l2h + 3;
627 msgb_pull_l2h(msg);
628 }
629 /* store context for messages from lapd */
630 memcpy(&mctx.dl->mctx, &mctx, sizeof(mctx.dl->mctx));
631 /* send to LAPD */
632 rc = lapd_ph_data_ind(msg, &lctx);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200633 break;
634 case LAPDm_FMT_Bter:
635 /* FIXME */
636 msgb_free(msg);
637 break;
638 case LAPDm_FMT_Bbis:
639 /* directly pass up to layer3 */
rootaf48bed2011-09-26 11:23:06 +0200640 LOGP(DLLAPD, LOGL_INFO, "fmt=Bbis UI\n");
Harald Welte1f0b8c22011-06-27 10:51:37 +0200641 msg->l3h = msg->l2h;
642 msgb_pull_l2h(msg);
643 rc = send_rslms_rll_l3(RSL_MT_UNIT_DATA_IND, &mctx, msg);
644 break;
645 default:
646 msgb_free(msg);
647 }
648
649 return rc;
650}
651
652/* input into layer2 (from layer 1) */
653static int l2_ph_rach_ind(struct lapdm_entity *le, uint8_t ra, uint32_t fn, uint8_t acc_delay)
654{
655 struct abis_rsl_cchan_hdr *ch;
656 struct gsm48_req_ref req_ref;
657 struct gsm_time gt;
658 struct msgb *msg = msgb_alloc_headroom(512, 64, "RSL CHAN RQD");
659
660 msg->l2h = msgb_push(msg, sizeof(*ch));
661 ch = (struct abis_rsl_cchan_hdr *)msg->l2h;
662 rsl_init_cchan_hdr(ch, RSL_MT_CHAN_RQD);
663 ch->chan_nr = RSL_CHAN_RACH;
664
665 /* generate a RSL CHANNEL REQUIRED message */
666 gsm_fn2gsmtime(&gt, fn);
667 req_ref.ra = ra;
668 req_ref.t1 = gt.t1; /* FIXME: modulo? */
669 req_ref.t2 = gt.t2;
670 req_ref.t3_low = gt.t3 & 7;
671 req_ref.t3_high = gt.t3 >> 3;
672
673 msgb_tv_fixed_put(msg, RSL_IE_REQ_REFERENCE, 3, (uint8_t *) &req_ref);
674 msgb_tv_put(msg, RSL_IE_ACCESS_DELAY, acc_delay);
675
676 return rslms_sendmsg(msg, le);
677}
678
679static int l2_ph_chan_conf(struct msgb *msg, struct lapdm_entity *le, uint32_t frame_nr);
680
Harald Welte6bdf0b12011-08-17 18:22:08 +0200681/*! \brief Receive a PH-SAP primitive from L1 */
Harald Welte1f0b8c22011-06-27 10:51:37 +0200682int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le)
683{
684 struct osmo_phsap_prim *pp = (struct osmo_phsap_prim *) oph;
685 int rc = 0;
686
687 if (oph->sap != SAP_GSM_PH) {
rootaf48bed2011-09-26 11:23:06 +0200688 LOGP(DLLAPD, LOGL_ERROR, "primitive for unknown SAP %u\n",
Harald Welte1f0b8c22011-06-27 10:51:37 +0200689 oph->sap);
690 return -ENODEV;
691 }
692
693 switch (oph->primitive) {
694 case PRIM_PH_DATA:
695 if (oph->operation != PRIM_OP_INDICATION) {
rootaf48bed2011-09-26 11:23:06 +0200696 LOGP(DLLAPD, LOGL_ERROR, "PH_DATA is not INDICATION %u\n",
Harald Welte1f0b8c22011-06-27 10:51:37 +0200697 oph->operation);
698 return -ENODEV;
699 }
700 rc = l2_ph_data_ind(oph->msg, le, pp->u.data.chan_nr,
701 pp->u.data.link_id);
702 break;
703 case PRIM_PH_RTS:
704 if (oph->operation != PRIM_OP_INDICATION) {
rootaf48bed2011-09-26 11:23:06 +0200705 LOGP(DLLAPD, LOGL_ERROR, "PH_RTS is not INDICATION %u\n",
Harald Welte1f0b8c22011-06-27 10:51:37 +0200706 oph->operation);
707 return -ENODEV;
708 }
709 rc = l2_ph_data_conf(oph->msg, le);
710 break;
711 case PRIM_PH_RACH:
712 switch (oph->operation) {
713 case PRIM_OP_INDICATION:
714 rc = l2_ph_rach_ind(le, pp->u.rach_ind.ra, pp->u.rach_ind.fn,
715 pp->u.rach_ind.acc_delay);
716 break;
717 case PRIM_OP_CONFIRM:
718 rc = l2_ph_chan_conf(oph->msg, le, pp->u.rach_ind.fn);
719 break;
720 default:
721 return -EIO;
722 }
723 break;
724 }
725
726 return rc;
727}
728
729
730/* L3 -> L2 / RSLMS -> LAPDm */
731
rootaf48bed2011-09-26 11:23:06 +0200732/* Set LAPDm context for established connection */
733static int set_lapdm_context(struct lapdm_datalink *dl, uint8_t chan_nr,
734 uint8_t link_id, int n201, uint8_t sapi)
735{
736 memset(&dl->mctx, 0, sizeof(dl->mctx));
737 dl->mctx.dl = dl;
738 dl->mctx.chan_nr = chan_nr;
739 dl->mctx.link_id = link_id;
740 dl->dl.lctx.dl = &dl->dl;
741 dl->dl.lctx.n201 = n201;
742 dl->dl.lctx.sapi = sapi;
743
744 return 0;
745}
746
Harald Welte1f0b8c22011-06-27 10:51:37 +0200747/* L3 requests establishment of data link */
748static int rslms_rx_rll_est_req(struct msgb *msg, struct lapdm_datalink *dl)
749{
Harald Welte1f0b8c22011-06-27 10:51:37 +0200750 struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
751 uint8_t chan_nr = rllh->chan_nr;
752 uint8_t link_id = rllh->link_id;
753 uint8_t sapi = rllh->link_id & 7;
754 struct tlv_parsed tv;
755 uint8_t length;
Andreas.Eversbergcbed3272011-11-06 20:43:08 +0100756 uint8_t n201 = (rllh->link_id & 0x40) ? N201_AB_SACCH : N201_AB_SDCCH;
rootaf48bed2011-09-26 11:23:06 +0200757 struct osmo_dlsap_prim dp;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200758
rootaf48bed2011-09-26 11:23:06 +0200759 /* Set LAPDm context for established connection */
760 set_lapdm_context(dl, chan_nr, link_id, n201, sapi);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200761
rootaf48bed2011-09-26 11:23:06 +0200762 rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg) - sizeof(*rllh));
Harald Welte1f0b8c22011-06-27 10:51:37 +0200763 if (TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
rootaf48bed2011-09-26 11:23:06 +0200764 msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200765 /* contention resolution establishment procedure */
766 if (sapi != 0) {
767 /* According to clause 6, the contention resolution
768 * procedure is only permitted with SAPI value 0 */
rootaf48bed2011-09-26 11:23:06 +0200769 LOGP(DLLAPD, LOGL_ERROR, "SAPI != 0 but contention"
Harald Welte1f0b8c22011-06-27 10:51:37 +0200770 "resolution (discarding)\n");
771 msgb_free(msg);
772 return send_rll_simple(RSL_MT_REL_IND, &dl->mctx);
773 }
774 /* transmit a SABM command with the P bit set to "1". The SABM
775 * command shall contain the layer 3 message unit */
776 length = TLVP_LEN(&tv, RSL_IE_L3_INFO);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200777 } else {
778 /* normal establishment procedure */
rootaf48bed2011-09-26 11:23:06 +0200779 msg->l3h = msg->l2h + sizeof(*rllh);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200780 length = 0;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200781 }
782
783 /* check if the layer3 message length exceeds N201 */
Andreas.Eversbergcbed3272011-11-06 20:43:08 +0100784 if (length > n201) {
rootaf48bed2011-09-26 11:23:06 +0200785 LOGP(DLLAPD, LOGL_ERROR, "frame too large: %d > N201(%d) "
Andreas.Eversbergcbed3272011-11-06 20:43:08 +0100786 "(discarding)\n", length, n201);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200787 msgb_free(msg);
788 return send_rll_simple(RSL_MT_REL_IND, &dl->mctx);
789 }
790
rootaf48bed2011-09-26 11:23:06 +0200791 /* Remove RLL header from msgb and set length to L3-info */
Harald Welte1f0b8c22011-06-27 10:51:37 +0200792 msgb_pull_l2h(msg);
rootaf48bed2011-09-26 11:23:06 +0200793 msg->len = length;
Holger Hans Peter Freyther3a5f08c2012-01-12 23:12:28 +0100794 msg->tail = msg->l3h + length;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200795
rootaf48bed2011-09-26 11:23:06 +0200796 /* prepare prim */
797 osmo_prim_init(&dp.oph, 0, PRIM_DL_EST, PRIM_OP_REQUEST, msg);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200798
rootaf48bed2011-09-26 11:23:06 +0200799 /* send to L2 */
800 return lapd_recv_dlsap(&dp, &dl->dl.lctx);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200801}
802
803/* L3 requests transfer of unnumbered information */
804static int rslms_rx_rll_udata_req(struct msgb *msg, struct lapdm_datalink *dl)
805{
Andreas.Eversberg816e1782011-11-06 20:46:30 +0100806 struct lapdm_entity *le = dl->entity;
807 int ui_bts = (le->mode == LAPDM_MODE_BTS);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200808 struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
809 uint8_t chan_nr = rllh->chan_nr;
810 uint8_t link_id = rllh->link_id;
811 uint8_t sapi = link_id & 7;
812 struct tlv_parsed tv;
813 int length;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200814
815 /* check if the layer3 message length exceeds N201 */
816
817 rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
818
819 if (TLVP_PRESENT(&tv, RSL_IE_TIMING_ADVANCE)) {
Andreas.Eversbergf1f80de2011-11-06 20:45:29 +0100820 le->ta = *TLVP_VAL(&tv, RSL_IE_TIMING_ADVANCE);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200821 }
822 if (TLVP_PRESENT(&tv, RSL_IE_MS_POWER)) {
Andreas.Eversbergf1f80de2011-11-06 20:45:29 +0100823 le->tx_power = *TLVP_VAL(&tv, RSL_IE_MS_POWER);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200824 }
825 if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
rootaf48bed2011-09-26 11:23:06 +0200826 LOGP(DLLAPD, LOGL_ERROR, "unit data request without message "
Harald Welte1f0b8c22011-06-27 10:51:37 +0200827 "error\n");
828 msgb_free(msg);
829 return -EINVAL;
830 }
rootaf48bed2011-09-26 11:23:06 +0200831 msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200832 length = TLVP_LEN(&tv, RSL_IE_L3_INFO);
833 /* check if the layer3 message length exceeds N201 */
Andreas.Eversberg816e1782011-11-06 20:46:30 +0100834 if (length + 4 + !ui_bts > 23) {
rootaf48bed2011-09-26 11:23:06 +0200835 LOGP(DLLAPD, LOGL_ERROR, "frame too large: %d > N201(%d) "
Andreas.Eversberg816e1782011-11-06 20:46:30 +0100836 "(discarding)\n", length, 18 + ui_bts);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200837 msgb_free(msg);
838 return -EIO;
839 }
840
rootaf48bed2011-09-26 11:23:06 +0200841 LOGP(DLLAPD, LOGL_INFO, "sending unit data (tx_power=%d, ta=%d)\n",
Andreas.Eversbergf1f80de2011-11-06 20:45:29 +0100842 le->tx_power, le->ta);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200843
rootaf48bed2011-09-26 11:23:06 +0200844 /* Remove RLL header from msgb and set length to L3-info */
Harald Welte1f0b8c22011-06-27 10:51:37 +0200845 msgb_pull_l2h(msg);
rootaf48bed2011-09-26 11:23:06 +0200846 msg->len = length;
Holger Hans Peter Freyther3a5f08c2012-01-12 23:12:28 +0100847 msg->tail = msg->l3h + length;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200848
849 /* Push L1 + LAPDm header on msgb */
Andreas.Eversberg816e1782011-11-06 20:46:30 +0100850 msg->l2h = msgb_push(msg, 4 + !ui_bts);
Andreas.Eversbergf1f80de2011-11-06 20:45:29 +0100851 msg->l2h[0] = le->tx_power;
852 msg->l2h[1] = le->ta;
rootaf48bed2011-09-26 11:23:06 +0200853 msg->l2h[2] = LAPDm_ADDR(LAPDm_LPD_NORMAL, sapi, dl->dl.cr.loc2rem.cmd);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200854 msg->l2h[3] = LAPDm_CTRL_U(LAPDm_U_UI, 0);
Andreas.Eversberg816e1782011-11-06 20:46:30 +0100855 if (!ui_bts)
856 msg->l2h[4] = LAPDm_LEN(length);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200857
858 /* Tramsmit */
rootaf48bed2011-09-26 11:23:06 +0200859 return tx_ph_data_enqueue(dl, msg, chan_nr, link_id, 23);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200860}
861
862/* L3 requests transfer of acknowledged information */
863static int rslms_rx_rll_data_req(struct msgb *msg, struct lapdm_datalink *dl)
864{
865 struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
866 struct tlv_parsed tv;
rootaf48bed2011-09-26 11:23:06 +0200867 int length;
868 struct osmo_dlsap_prim dp;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200869
870 rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
871 if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
rootaf48bed2011-09-26 11:23:06 +0200872 LOGP(DLLAPD, LOGL_ERROR, "data request without message "
Harald Welte1f0b8c22011-06-27 10:51:37 +0200873 "error\n");
874 msgb_free(msg);
875 return -EINVAL;
876 }
rootaf48bed2011-09-26 11:23:06 +0200877 msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
878 length = TLVP_LEN(&tv, RSL_IE_L3_INFO);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200879
rootaf48bed2011-09-26 11:23:06 +0200880 /* Remove RLL header from msgb and set length to L3-info */
Harald Welte1f0b8c22011-06-27 10:51:37 +0200881 msgb_pull_l2h(msg);
rootaf48bed2011-09-26 11:23:06 +0200882 msg->len = length;
Holger Hans Peter Freyther3a5f08c2012-01-12 23:12:28 +0100883 msg->tail = msg->l3h + length;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200884
rootaf48bed2011-09-26 11:23:06 +0200885 /* prepare prim */
886 osmo_prim_init(&dp.oph, 0, PRIM_DL_DATA, PRIM_OP_REQUEST, msg);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200887
rootaf48bed2011-09-26 11:23:06 +0200888 /* send to L2 */
889 return lapd_recv_dlsap(&dp, &dl->dl.lctx);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200890}
891
892/* L3 requests suspension of data link */
893static int rslms_rx_rll_susp_req(struct msgb *msg, struct lapdm_datalink *dl)
894{
895 struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
896 uint8_t sapi = rllh->link_id & 7;
rootaf48bed2011-09-26 11:23:06 +0200897 struct osmo_dlsap_prim dp;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200898
899 if (sapi != 0) {
rootaf48bed2011-09-26 11:23:06 +0200900 LOGP(DLLAPD, LOGL_ERROR, "SAPI != 0 while suspending\n");
Harald Welte1f0b8c22011-06-27 10:51:37 +0200901 msgb_free(msg);
902 return -EINVAL;
903 }
904
rootaf48bed2011-09-26 11:23:06 +0200905 /* prepare prim */
906 osmo_prim_init(&dp.oph, 0, PRIM_DL_SUSP, PRIM_OP_REQUEST, msg);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200907
rootaf48bed2011-09-26 11:23:06 +0200908 /* send to L2 */
909 return lapd_recv_dlsap(&dp, &dl->dl.lctx);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200910}
911
912/* L3 requests resume of data link */
913static int rslms_rx_rll_res_req(struct msgb *msg, struct lapdm_datalink *dl)
914{
Harald Welte1f0b8c22011-06-27 10:51:37 +0200915 struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
rootaf48bed2011-09-26 11:23:06 +0200916 int msg_type = rllh->c.msg_type;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200917 uint8_t chan_nr = rllh->chan_nr;
918 uint8_t link_id = rllh->link_id;
919 uint8_t sapi = rllh->link_id & 7;
920 struct tlv_parsed tv;
921 uint8_t length;
Andreas.Eversbergcbed3272011-11-06 20:43:08 +0100922 uint8_t n201 = (rllh->link_id & 0x40) ? N201_AB_SACCH : N201_AB_SDCCH;
rootaf48bed2011-09-26 11:23:06 +0200923 struct osmo_dlsap_prim dp;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200924
rootaf48bed2011-09-26 11:23:06 +0200925 /* Set LAPDm context for established connection */
926 set_lapdm_context(dl, chan_nr, link_id, n201, sapi);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200927
928 rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
929 if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
rootaf48bed2011-09-26 11:23:06 +0200930 LOGP(DLLAPD, LOGL_ERROR, "resume without message error\n");
Harald Welte1f0b8c22011-06-27 10:51:37 +0200931 msgb_free(msg);
932 return send_rll_simple(RSL_MT_REL_IND, &dl->mctx);
933 }
rootaf48bed2011-09-26 11:23:06 +0200934 msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200935 length = TLVP_LEN(&tv, RSL_IE_L3_INFO);
936
rootaf48bed2011-09-26 11:23:06 +0200937 /* Remove RLL header from msgb and set length to L3-info */
938 msgb_pull_l2h(msg);
939 msg->len = length;
Holger Hans Peter Freyther3a5f08c2012-01-12 23:12:28 +0100940 msg->tail = msg->l3h + length;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200941
rootaf48bed2011-09-26 11:23:06 +0200942 /* prepare prim */
943 osmo_prim_init(&dp.oph, 0, (msg_type == RSL_MT_RES_REQ) ? PRIM_DL_RES
944 : PRIM_DL_RECON, PRIM_OP_REQUEST, msg);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200945
rootaf48bed2011-09-26 11:23:06 +0200946 /* send to L2 */
947 return lapd_recv_dlsap(&dp, &dl->dl.lctx);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200948}
949
950/* L3 requests release of data link */
951static int rslms_rx_rll_rel_req(struct msgb *msg, struct lapdm_datalink *dl)
952{
Harald Welte1f0b8c22011-06-27 10:51:37 +0200953 struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200954 uint8_t mode = 0;
rootaf48bed2011-09-26 11:23:06 +0200955 struct osmo_dlsap_prim dp;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200956
957 /* get release mode */
958 if (rllh->data[0] == RSL_IE_RELEASE_MODE)
959 mode = rllh->data[1] & 1;
960
Harald Welte1f0b8c22011-06-27 10:51:37 +0200961 /* Pull rllh */
962 msgb_pull(msg, msg->tail - msg->l2h);
963
rootaf48bed2011-09-26 11:23:06 +0200964 /* prepare prim */
965 osmo_prim_init(&dp.oph, 0, PRIM_DL_REL, PRIM_OP_REQUEST, msg);
966 dp.u.rel_req.mode = mode;
Harald Welte1f0b8c22011-06-27 10:51:37 +0200967
rootaf48bed2011-09-26 11:23:06 +0200968 /* send to L2 */
969 return lapd_recv_dlsap(&dp, &dl->dl.lctx);
Harald Welte1f0b8c22011-06-27 10:51:37 +0200970}
971
972/* L3 requests channel in idle state */
973static int rslms_rx_chan_rqd(struct lapdm_channel *lc, struct msgb *msg)
974{
975 struct abis_rsl_cchan_hdr *cch = msgb_l2(msg);
976 void *l1ctx = lc->lapdm_dcch.l1_ctx;
977 struct osmo_phsap_prim pp;
978
979 osmo_prim_init(&pp.oph, SAP_GSM_PH, PRIM_PH_RACH,
980 PRIM_OP_REQUEST, NULL);
981
982 if (msgb_l2len(msg) < sizeof(*cch) + 4 + 2 + 2) {
rootaf48bed2011-09-26 11:23:06 +0200983 LOGP(DLLAPD, LOGL_ERROR, "Message too short for CHAN RQD!\n");
Harald Welte1f0b8c22011-06-27 10:51:37 +0200984 return -EINVAL;
985 }
986 if (cch->data[0] != RSL_IE_REQ_REFERENCE) {
rootaf48bed2011-09-26 11:23:06 +0200987 LOGP(DLLAPD, LOGL_ERROR, "Missing REQ REFERENCE IE\n");
Harald Welte1f0b8c22011-06-27 10:51:37 +0200988 return -EINVAL;
989 }
990 pp.u.rach_req.ra = cch->data[1];
991 pp.u.rach_req.offset = ((cch->data[2] & 0x7f) << 8) | cch->data[3];
992 pp.u.rach_req.is_combined_ccch = cch->data[2] >> 7;
993
994 if (cch->data[4] != RSL_IE_ACCESS_DELAY) {
rootaf48bed2011-09-26 11:23:06 +0200995 LOGP(DLLAPD, LOGL_ERROR, "Missing ACCESS_DELAY IE\n");
Harald Welte1f0b8c22011-06-27 10:51:37 +0200996 return -EINVAL;
997 }
998 /* TA = 0 - delay */
999 pp.u.rach_req.ta = 0 - cch->data[5];
1000
1001 if (cch->data[6] != RSL_IE_MS_POWER) {
rootaf48bed2011-09-26 11:23:06 +02001002 LOGP(DLLAPD, LOGL_ERROR, "Missing MS POWER IE\n");
Harald Welte1f0b8c22011-06-27 10:51:37 +02001003 return -EINVAL;
1004 }
1005 pp.u.rach_req.tx_power = cch->data[7];
1006
1007 msgb_free(msg);
1008
1009 return lc->lapdm_dcch.l1_prim_cb(&pp.oph, l1ctx);
1010}
1011
1012/* L1 confirms channel request */
1013static int l2_ph_chan_conf(struct msgb *msg, struct lapdm_entity *le, uint32_t frame_nr)
1014{
1015 struct abis_rsl_cchan_hdr *ch;
1016 struct gsm_time tm;
1017 struct gsm48_req_ref *ref;
1018
1019 gsm_fn2gsmtime(&tm, frame_nr);
1020
1021 msgb_pull_l2h(msg);
1022 msg->l2h = msgb_push(msg, sizeof(*ch) + sizeof(*ref));
1023 ch = (struct abis_rsl_cchan_hdr *)msg->l2h;
1024 rsl_init_cchan_hdr(ch, RSL_MT_CHAN_CONF);
1025 ch->chan_nr = RSL_CHAN_RACH;
1026 ch->data[0] = RSL_IE_REQ_REFERENCE;
1027 ref = (struct gsm48_req_ref *) (ch->data + 1);
1028 ref->t1 = tm.t1;
1029 ref->t2 = tm.t2;
1030 ref->t3_low = tm.t3 & 0x7;
1031 ref->t3_high = tm.t3 >> 3;
1032
1033 return rslms_sendmsg(msg, le);
1034}
1035
Harald Welte1f0b8c22011-06-27 10:51:37 +02001036/* incoming RSLms RLL message from L3 */
1037static int rslms_rx_rll(struct msgb *msg, struct lapdm_channel *lc)
1038{
1039 struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
1040 int msg_type = rllh->c.msg_type;
1041 uint8_t sapi = rllh->link_id & 7;
1042 struct lapdm_entity *le;
1043 struct lapdm_datalink *dl;
Harald Welte1f0b8c22011-06-27 10:51:37 +02001044 int rc = 0;
1045
1046 if (msgb_l2len(msg) < sizeof(*rllh)) {
rootaf48bed2011-09-26 11:23:06 +02001047 LOGP(DLLAPD, LOGL_ERROR, "Message too short for RLL hdr!\n");
Andreas.Eversberga42b6992011-11-06 20:31:47 +01001048 msgb_free(msg);
Harald Welte1f0b8c22011-06-27 10:51:37 +02001049 return -EINVAL;
1050 }
1051
1052 if (rllh->link_id & 0x40)
1053 le = &lc->lapdm_acch;
1054 else
1055 le = &lc->lapdm_dcch;
1056
1057 /* G.2.1 No action schall be taken on frames containing an unallocated
1058 * SAPI.
1059 */
1060 dl = datalink_for_sapi(le, sapi);
1061 if (!dl) {
rootaf48bed2011-09-26 11:23:06 +02001062 LOGP(DLLAPD, LOGL_ERROR, "No instance for SAPI %d!\n", sapi);
Andreas.Eversberga42b6992011-11-06 20:31:47 +01001063 msgb_free(msg);
Harald Welte1f0b8c22011-06-27 10:51:37 +02001064 return -EINVAL;
1065 }
1066
Andreas.Eversberg153903c2011-11-06 20:47:00 +01001067 LOGP(DLLAPD, LOGL_INFO, "(%p) RLL Message '%s' received. (sapi %d)\n",
1068 lc->name, rsl_msg_name(msg_type), sapi);
Harald Welte1f0b8c22011-06-27 10:51:37 +02001069
rootaf48bed2011-09-26 11:23:06 +02001070 switch (msg_type) {
1071 case RSL_MT_UNIT_DATA_REQ:
1072 rc = rslms_rx_rll_udata_req(msg, dl);
1073 break;
1074 case RSL_MT_EST_REQ:
1075 rc = rslms_rx_rll_est_req(msg, dl);
1076 break;
1077 case RSL_MT_DATA_REQ:
1078 rc = rslms_rx_rll_data_req(msg, dl);
1079 break;
1080 case RSL_MT_SUSP_REQ:
1081 rc = rslms_rx_rll_susp_req(msg, dl);
1082 break;
1083 case RSL_MT_RES_REQ:
1084 rc = rslms_rx_rll_res_req(msg, dl);
1085 break;
1086 case RSL_MT_RECON_REQ:
1087 rc = rslms_rx_rll_res_req(msg, dl);
1088 break;
1089 case RSL_MT_REL_REQ:
1090 rc = rslms_rx_rll_rel_req(msg, dl);
1091 break;
1092 default:
1093 LOGP(DLLAPD, LOGL_NOTICE, "Message unsupported.\n");
Harald Welte1f0b8c22011-06-27 10:51:37 +02001094 msgb_free(msg);
rootaf48bed2011-09-26 11:23:06 +02001095 rc = -EINVAL;
Harald Welte1f0b8c22011-06-27 10:51:37 +02001096 }
Harald Welte1f0b8c22011-06-27 10:51:37 +02001097
1098 return rc;
1099}
1100
1101/* incoming RSLms COMMON CHANNEL message from L3 */
1102static int rslms_rx_com_chan(struct msgb *msg, struct lapdm_channel *lc)
1103{
1104 struct abis_rsl_cchan_hdr *cch = msgb_l2(msg);
1105 int msg_type = cch->c.msg_type;
1106 int rc = 0;
1107
1108 if (msgb_l2len(msg) < sizeof(*cch)) {
rootaf48bed2011-09-26 11:23:06 +02001109 LOGP(DLLAPD, LOGL_ERROR, "Message too short for COM CHAN hdr!\n");
Harald Welte1f0b8c22011-06-27 10:51:37 +02001110 return -EINVAL;
1111 }
1112
1113 switch (msg_type) {
1114 case RSL_MT_CHAN_RQD:
1115 /* create and send RACH request */
1116 rc = rslms_rx_chan_rqd(lc, msg);
1117 break;
1118 default:
rootaf48bed2011-09-26 11:23:06 +02001119 LOGP(DLLAPD, LOGL_NOTICE, "Unknown COMMON CHANNEL msg %d!\n",
Harald Welte1f0b8c22011-06-27 10:51:37 +02001120 msg_type);
1121 msgb_free(msg);
1122 return 0;
1123 }
1124
1125 return rc;
1126}
1127
Harald Welte6bdf0b12011-08-17 18:22:08 +02001128/*! \brief Receive a RSLms \ref msgb from Layer 3 */
Harald Welte1f0b8c22011-06-27 10:51:37 +02001129int lapdm_rslms_recvmsg(struct msgb *msg, struct lapdm_channel *lc)
1130{
1131 struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
1132 int rc = 0;
1133
1134 if (msgb_l2len(msg) < sizeof(*rslh)) {
rootaf48bed2011-09-26 11:23:06 +02001135 LOGP(DLLAPD, LOGL_ERROR, "Message too short RSL hdr!\n");
Harald Welte1f0b8c22011-06-27 10:51:37 +02001136 return -EINVAL;
1137 }
1138
1139 switch (rslh->msg_discr & 0xfe) {
1140 case ABIS_RSL_MDISC_RLL:
1141 rc = rslms_rx_rll(msg, lc);
1142 break;
1143 case ABIS_RSL_MDISC_COM_CHAN:
1144 rc = rslms_rx_com_chan(msg, lc);
1145 break;
1146 default:
rootaf48bed2011-09-26 11:23:06 +02001147 LOGP(DLLAPD, LOGL_ERROR, "unknown RSLms message "
Harald Welte1f0b8c22011-06-27 10:51:37 +02001148 "discriminator 0x%02x", rslh->msg_discr);
1149 msgb_free(msg);
1150 return -EINVAL;
1151 }
1152
1153 return rc;
1154}
1155
Harald Welte6bdf0b12011-08-17 18:22:08 +02001156/*! \brief Set the \ref lapdm_mode of a LAPDm entity */
Harald Welte1f0b8c22011-06-27 10:51:37 +02001157int lapdm_entity_set_mode(struct lapdm_entity *le, enum lapdm_mode mode)
1158{
rootaf48bed2011-09-26 11:23:06 +02001159 int i;
1160 enum lapd_mode lm;
1161
Harald Welte1f0b8c22011-06-27 10:51:37 +02001162 switch (mode) {
1163 case LAPDM_MODE_MS:
rootaf48bed2011-09-26 11:23:06 +02001164 lm = LAPD_MODE_USER;
Harald Welte1f0b8c22011-06-27 10:51:37 +02001165 break;
1166 case LAPDM_MODE_BTS:
rootaf48bed2011-09-26 11:23:06 +02001167 lm = LAPD_MODE_NETWORK;
Harald Welte1f0b8c22011-06-27 10:51:37 +02001168 break;
1169 default:
1170 return -EINVAL;
1171 }
1172
rootaf48bed2011-09-26 11:23:06 +02001173 for (i = 0; i < ARRAY_SIZE(le->datalink); i++) {
1174 lapd_set_mode(&le->datalink[i].dl, lm);
1175 }
1176
Harald Welte1f0b8c22011-06-27 10:51:37 +02001177 le->mode = mode;
1178
1179 return 0;
1180}
1181
Harald Welte6bdf0b12011-08-17 18:22:08 +02001182/*! \brief Set the \ref lapdm_mode of a LAPDm channel*/
Harald Welte1f0b8c22011-06-27 10:51:37 +02001183int lapdm_channel_set_mode(struct lapdm_channel *lc, enum lapdm_mode mode)
1184{
1185 int rc;
1186
1187 rc = lapdm_entity_set_mode(&lc->lapdm_dcch, mode);
1188 if (rc < 0)
1189 return rc;
1190
1191 return lapdm_entity_set_mode(&lc->lapdm_acch, mode);
1192}
1193
Harald Welte6bdf0b12011-08-17 18:22:08 +02001194/*! \brief Set the L1 callback and context of a LAPDm channel */
Harald Welte1f0b8c22011-06-27 10:51:37 +02001195void lapdm_channel_set_l1(struct lapdm_channel *lc, osmo_prim_cb cb, void *ctx)
1196{
1197 lc->lapdm_dcch.l1_prim_cb = cb;
1198 lc->lapdm_acch.l1_prim_cb = cb;
1199 lc->lapdm_dcch.l1_ctx = ctx;
1200 lc->lapdm_acch.l1_ctx = ctx;
1201}
1202
Harald Welte6bdf0b12011-08-17 18:22:08 +02001203/*! \brief Set the L3 callback and context of a LAPDm channel */
Harald Welte1f0b8c22011-06-27 10:51:37 +02001204void lapdm_channel_set_l3(struct lapdm_channel *lc, lapdm_cb_t cb, void *ctx)
1205{
1206 lc->lapdm_dcch.l3_cb = cb;
1207 lc->lapdm_acch.l3_cb = cb;
1208 lc->lapdm_dcch.l3_ctx = ctx;
1209 lc->lapdm_acch.l3_ctx = ctx;
1210}
1211
Harald Welte6bdf0b12011-08-17 18:22:08 +02001212/*! \brief Reset an entire LAPDm entity and all its datalinks */
Harald Welte1f0b8c22011-06-27 10:51:37 +02001213void lapdm_entity_reset(struct lapdm_entity *le)
1214{
1215 struct lapdm_datalink *dl;
1216 int i;
1217
1218 for (i = 0; i < ARRAY_SIZE(le->datalink); i++) {
1219 dl = &le->datalink[i];
rootaf48bed2011-09-26 11:23:06 +02001220 lapd_dl_reset(&dl->dl);
Harald Welte1f0b8c22011-06-27 10:51:37 +02001221 }
1222}
1223
Harald Welte6bdf0b12011-08-17 18:22:08 +02001224/*! \brief Reset a LAPDm channel with all its entities */
Harald Welte1f0b8c22011-06-27 10:51:37 +02001225void lapdm_channel_reset(struct lapdm_channel *lc)
1226{
1227 lapdm_entity_reset(&lc->lapdm_dcch);
1228 lapdm_entity_reset(&lc->lapdm_acch);
1229}
1230
Harald Welte6bdf0b12011-08-17 18:22:08 +02001231/*! \brief Set the flags of a LAPDm entity */
Harald Welte1f0b8c22011-06-27 10:51:37 +02001232void lapdm_entity_set_flags(struct lapdm_entity *le, unsigned int flags)
1233{
1234 le->flags = flags;
1235}
1236
Harald Welte6bdf0b12011-08-17 18:22:08 +02001237/*! \brief Set the flags of all LAPDm entities in a LAPDm channel */
Harald Welte1f0b8c22011-06-27 10:51:37 +02001238void lapdm_channel_set_flags(struct lapdm_channel *lc, unsigned int flags)
1239{
1240 lapdm_entity_set_flags(&lc->lapdm_dcch, flags);
1241 lapdm_entity_set_flags(&lc->lapdm_acch, flags);
1242}
Harald Welte6bdf0b12011-08-17 18:22:08 +02001243
Sylvain Munautdca7d2c2012-04-18 21:53:23 +02001244/*! @} */