blob: 040ea623fc90acc78c8938fd728cb9f40aee5c79 [file] [log] [blame]
Holger Hans Peter Freytherbe570812013-11-07 08:01:49 +01001/*
2 * Copyright (C) 2013 by Holger Hans Peter Freyther
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#pragma once
20
21#include <stdint.h>
Holger Hans Peter Freytheracb54272013-11-07 08:15:58 +010022#include <string.h>
Holger Hans Peter Freytherbe570812013-11-07 08:01:49 +010023
24#define LLC_MAX_LEN 1543
25
26/**
27 * I represent the LLC data to a MS
28 */
29struct gprs_llc {
30 void init();
31 void reset();
32 void reset_frame_space();
33
34 void enqueue(struct msgb *llc_msg);
35 struct msgb *dequeue();
36
Holger Hans Peter Freytherbe570812013-11-07 08:01:49 +010037 void put_frame(const uint8_t *data, size_t len);
Holger Hans Peter Freytheracb54272013-11-07 08:15:58 +010038 void consume(uint8_t *data, size_t len);
Holger Hans Peter Freytherbe570812013-11-07 08:01:49 +010039 void clear(BTS *bts);
40
Holger Hans Peter Freytheracb54272013-11-07 08:15:58 +010041 uint16_t chunk_size() const;
42
Holger Hans Peter Freytherbe570812013-11-07 08:01:49 +010043 uint8_t frame[LLC_MAX_LEN]; /* current DL or UL frame */
44 uint16_t index; /* current write/read position of frame */
45 uint16_t length; /* len of current DL LLC_frame, 0 == no frame */
46 struct llist_head queue; /* queued LLC DL data */
47};
48
Holger Hans Peter Freytheracb54272013-11-07 08:15:58 +010049inline uint16_t gprs_llc::chunk_size() const
50{
51 return length - index;
52}
53
54inline void gprs_llc::consume(uint8_t *data, size_t len)
55{
56 /* copy and increment index */
57 memcpy(data, frame + index, len);
58 index += len;
59}