Holger Hans Peter Freyther | be57081 | 2013-11-07 08:01:49 +0100 | [diff] [blame] | 1 | /* |
| 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 Freyther | acb5427 | 2013-11-07 08:15:58 +0100 | [diff] [blame] | 22 | #include <string.h> |
Holger Hans Peter Freyther | be57081 | 2013-11-07 08:01:49 +0100 | [diff] [blame] | 23 | |
| 24 | #define LLC_MAX_LEN 1543 |
| 25 | |
| 26 | /** |
| 27 | * I represent the LLC data to a MS |
| 28 | */ |
| 29 | struct 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 | |
| 37 | void update_frame(struct msgb *msg); |
| 38 | void put_frame(const uint8_t *data, size_t len); |
Holger Hans Peter Freyther | acb5427 | 2013-11-07 08:15:58 +0100 | [diff] [blame] | 39 | void consume(uint8_t *data, size_t len); |
Holger Hans Peter Freyther | be57081 | 2013-11-07 08:01:49 +0100 | [diff] [blame] | 40 | void clear(BTS *bts); |
| 41 | |
Holger Hans Peter Freyther | acb5427 | 2013-11-07 08:15:58 +0100 | [diff] [blame] | 42 | uint16_t chunk_size() const; |
| 43 | |
Holger Hans Peter Freyther | be57081 | 2013-11-07 08:01:49 +0100 | [diff] [blame] | 44 | uint8_t frame[LLC_MAX_LEN]; /* current DL or UL frame */ |
| 45 | uint16_t index; /* current write/read position of frame */ |
| 46 | uint16_t length; /* len of current DL LLC_frame, 0 == no frame */ |
| 47 | struct llist_head queue; /* queued LLC DL data */ |
| 48 | }; |
| 49 | |
Holger Hans Peter Freyther | acb5427 | 2013-11-07 08:15:58 +0100 | [diff] [blame] | 50 | inline uint16_t gprs_llc::chunk_size() const |
| 51 | { |
| 52 | return length - index; |
| 53 | } |
| 54 | |
| 55 | inline void gprs_llc::consume(uint8_t *data, size_t len) |
| 56 | { |
| 57 | /* copy and increment index */ |
| 58 | memcpy(data, frame + index, len); |
| 59 | index += len; |
| 60 | } |