blob: 524814cf3545b51d5e784f35b93f51cdf07ee4c0 [file] [log] [blame]
Holger Hans Peter Freyther096f6f92013-11-07 07:21:06 +01001/* Copied from tbf.cpp
2 *
3 * Copyright (C) 2012 Ivan Klyuchnikov
4 * Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu>
5 * Copyright (C) 2013 by Holger Hans Peter Freyther
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#include <tbf.h>
23#include <bts.h>
24
Holger Hans Peter Freyther857281f2013-11-13 14:56:55 +010025#include <stdio.h>
26
Holger Hans Peter Freyther096f6f92013-11-07 07:21:06 +010027extern "C" {
28#include <osmocom/core/msgb.h>
29}
30
31/* reset LLC frame */
32void gprs_llc::reset()
33{
34 index = 0;
35 length = 0;
36}
37
38void gprs_llc::reset_frame_space()
39{
40 index = 0;
41}
42
43void gprs_llc::enqueue(struct msgb *llc_msg)
44{
45 msgb_enqueue(&queue, llc_msg);
46}
47
48void gprs_llc::put_frame(const uint8_t *data, size_t len)
49{
Holger Hans Peter Freyther857281f2013-11-13 14:56:55 +010050 /* only put frames when we are empty */
51 OSMO_ASSERT(index == 0 && length == 0);
52
53 /* TODO: bounds check */
Holger Hans Peter Freyther096f6f92013-11-07 07:21:06 +010054 memcpy(frame, data, len);
55 length = len;
56}
57
58void gprs_llc::clear(BTS *bts)
59{
60 struct msgb *msg;
61
62 while ((msg = msgb_dequeue(&queue))) {
63 bts->dropped_frame();
64 msgb_free(msg);
65 }
66}
67
68void gprs_llc::init()
69{
70 INIT_LLIST_HEAD(&queue);
71}
72
73struct msgb *gprs_llc::dequeue()
74{
75 return msgb_dequeue(&queue);
76}