Holger Hans Peter Freyther | d11290b | 2013-10-26 17:32:04 +0200 | [diff] [blame] | 1 | /* decoding |
| 2 | * |
| 3 | * Copyright (C) 2012 Ivan Klyuchnikov |
| 4 | * Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version 2 |
| 9 | * of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 | */ |
| 20 | #pragma once |
| 21 | |
Pau Espin Pedrol | 8a35e64 | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 22 | #ifdef __cplusplus |
Pau Espin Pedrol | b2653fe | 2020-03-26 15:14:01 +0100 | [diff] [blame] | 23 | extern "C" { |
Pau Espin Pedrol | 8a35e64 | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 24 | #endif |
Pau Espin Pedrol | b2653fe | 2020-03-26 15:14:01 +0100 | [diff] [blame] | 25 | |
Pau Espin Pedrol | 8a35e64 | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 26 | #include "gsm_rlcmac.h" |
| 27 | #include "coding_scheme.h" |
| 28 | |
| 29 | #ifdef __cplusplus |
| 30 | } |
| 31 | #endif |
Holger Hans Peter Freyther | fcbc702 | 2013-10-26 17:38:37 +0200 | [diff] [blame] | 32 | |
Holger Hans Peter Freyther | d11290b | 2013-10-26 17:32:04 +0200 | [diff] [blame] | 33 | #include <stdint.h> |
| 34 | |
Jacob Erlbeck | ae9c575 | 2016-01-13 13:55:44 +0100 | [diff] [blame] | 35 | struct bitvec; |
| 36 | |
Pau Espin Pedrol | 8a35e64 | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 37 | #ifdef __cplusplus |
| 38 | |
Holger Hans Peter Freyther | d11290b | 2013-10-26 17:32:04 +0200 | [diff] [blame] | 39 | class Decoding { |
| 40 | public: |
Alexander Couzens | b82bd92 | 2016-05-30 17:30:10 +0200 | [diff] [blame] | 41 | /* represents (parts) LLC PDUs within one RLC Data block */ |
Jacob Erlbeck | 4abc686 | 2015-12-08 15:14:05 +0100 | [diff] [blame] | 42 | struct RlcData { |
| 43 | uint8_t offset; |
| 44 | uint8_t length; |
Alexander Couzens | b82bd92 | 2016-05-30 17:30:10 +0200 | [diff] [blame] | 45 | bool is_complete; /* if this PDU ends in this block */ |
Jacob Erlbeck | 4abc686 | 2015-12-08 15:14:05 +0100 | [diff] [blame] | 46 | }; |
| 47 | |
Jacob Erlbeck | 4abc686 | 2015-12-08 15:14:05 +0100 | [diff] [blame] | 48 | static int rlc_data_from_ul_data( |
Jacob Erlbeck | f2ba4cb | 2016-01-07 18:59:28 +0100 | [diff] [blame] | 49 | const struct gprs_rlc_data_block_info *rdbi, |
Pau Espin Pedrol | 2ae8337 | 2020-05-18 11:35:35 +0200 | [diff] [blame] | 50 | enum CodingScheme cs, const uint8_t *data, RlcData *chunks, |
Jacob Erlbeck | 4abc686 | 2015-12-08 15:14:05 +0100 | [diff] [blame] | 51 | unsigned int chunks_size, uint32_t *tlli); |
Holger Hans Peter Freyther | df6b4f5 | 2013-11-24 17:05:48 +0100 | [diff] [blame] | 52 | |
Jacob Erlbeck | f2f24b0 | 2016-02-05 13:16:24 +0100 | [diff] [blame] | 53 | static void extract_rbb(const struct bitvec *rbb, char *show_rbb); |
Bhargava Abhyankar | e44383b | 2016-03-22 18:42:30 +0530 | [diff] [blame] | 54 | static int rlc_parse_ul_data_header_egprs_type_3( |
| 55 | struct gprs_rlc_data_info *rlc, |
| 56 | const uint8_t *data, |
Pau Espin Pedrol | 2ae8337 | 2020-05-18 11:35:35 +0200 | [diff] [blame] | 57 | const enum CodingScheme &cs); |
Aravind Sirsikar | 550a541 | 2016-06-14 18:59:18 +0530 | [diff] [blame] | 58 | static int rlc_parse_ul_data_header_egprs_type_2( |
| 59 | struct gprs_rlc_data_info *rlc, |
| 60 | const uint8_t *data, |
Pau Espin Pedrol | 2ae8337 | 2020-05-18 11:35:35 +0200 | [diff] [blame] | 61 | const enum CodingScheme &cs); |
Aravind Sirsikar | 99ab0a8 | 2016-06-15 17:46:41 +0530 | [diff] [blame] | 62 | static int rlc_parse_ul_data_header_egprs_type_1( |
| 63 | struct gprs_rlc_data_info *rlc, |
| 64 | const uint8_t *data, |
Pau Espin Pedrol | 2ae8337 | 2020-05-18 11:35:35 +0200 | [diff] [blame] | 65 | const enum CodingScheme &cs); |
Bhargava Abhyankar | e44383b | 2016-03-22 18:42:30 +0530 | [diff] [blame] | 66 | static int rlc_parse_ul_data_header_gprs( |
| 67 | struct gprs_rlc_data_info *rlc, |
| 68 | const uint8_t *data, |
Pau Espin Pedrol | 2ae8337 | 2020-05-18 11:35:35 +0200 | [diff] [blame] | 69 | const enum CodingScheme &cs); |
Jacob Erlbeck | f2ba4cb | 2016-01-07 18:59:28 +0100 | [diff] [blame] | 70 | static int rlc_parse_ul_data_header(struct gprs_rlc_data_info *rlc, |
Pau Espin Pedrol | 2ae8337 | 2020-05-18 11:35:35 +0200 | [diff] [blame] | 71 | const uint8_t *data, enum CodingScheme cs); |
Jacob Erlbeck | 4abc686 | 2015-12-08 15:14:05 +0100 | [diff] [blame] | 72 | static unsigned int rlc_copy_to_aligned_buffer( |
Jacob Erlbeck | f2ba4cb | 2016-01-07 18:59:28 +0100 | [diff] [blame] | 73 | const struct gprs_rlc_data_info *rlc, |
Jacob Erlbeck | 4abc686 | 2015-12-08 15:14:05 +0100 | [diff] [blame] | 74 | unsigned int data_block_idx, |
| 75 | const uint8_t *src, uint8_t *buffer); |
| 76 | static const uint8_t *rlc_get_data_aligned( |
Jacob Erlbeck | f2ba4cb | 2016-01-07 18:59:28 +0100 | [diff] [blame] | 77 | const struct gprs_rlc_data_info *rlc, |
Jacob Erlbeck | 4abc686 | 2015-12-08 15:14:05 +0100 | [diff] [blame] | 78 | unsigned int data_block_idx, |
| 79 | const uint8_t *src, uint8_t *buffer); |
Jacob Erlbeck | ae9c575 | 2016-01-13 13:55:44 +0100 | [diff] [blame] | 80 | static int decode_egprs_acknack_bits( |
| 81 | const EGPRS_AckNack_Desc_t *desc, |
| 82 | struct bitvec *bits, int *bsn_begin, int *bsn_end, |
| 83 | struct gprs_rlc_dl_window *window); |
Jacob Erlbeck | 192bf33 | 2016-02-05 13:10:29 +0100 | [diff] [blame] | 84 | static int decode_gprs_acknack_bits( |
| 85 | const Ack_Nack_Description_t *desc, |
| 86 | bitvec *bits, int *bsn_begin, int *bsn_end, |
| 87 | gprs_rlc_dl_window *window); |
Holger Hans Peter Freyther | d11290b | 2013-10-26 17:32:04 +0200 | [diff] [blame] | 88 | }; |
Pau Espin Pedrol | 8a35e64 | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 89 | |
| 90 | #endif /* #ifdef __cplusplus */ |
| 91 | |
| 92 | #ifdef __cplusplus |
| 93 | extern "C" { |
| 94 | #endif |
| 95 | |
| 96 | uint8_t get_ms_class_by_capability(MS_Radio_Access_capability_t *cap); |
| 97 | uint8_t get_egprs_ms_class_by_capability(MS_Radio_Access_capability_t *cap); |
| 98 | |
| 99 | #ifdef __cplusplus |
| 100 | } |
| 101 | #endif |