blob: b0a5aed9ecb01d3ca265a56290664fef272f6acd [file] [log] [blame]
Holger Hans Peter Freytherd11290b2013-10-26 17:32:04 +02001/* 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.
Holger Hans Peter Freytherd11290b2013-10-26 17:32:04 +020015 */
16#pragma once
17
Pau Espin Pedrol8a35e642021-01-18 17:14:14 +010018#ifdef __cplusplus
Pau Espin Pedrolb2653fe2020-03-26 15:14:01 +010019extern "C" {
Pau Espin Pedrol8a35e642021-01-18 17:14:14 +010020#endif
Pau Espin Pedrolb2653fe2020-03-26 15:14:01 +010021
Pau Espin Pedrol8a35e642021-01-18 17:14:14 +010022#include "gsm_rlcmac.h"
23#include "coding_scheme.h"
24
25#ifdef __cplusplus
26}
27#endif
Holger Hans Peter Freytherfcbc7022013-10-26 17:38:37 +020028
Holger Hans Peter Freytherd11290b2013-10-26 17:32:04 +020029#include <stdint.h>
30
Jacob Erlbeckae9c5752016-01-13 13:55:44 +010031struct bitvec;
32
Pau Espin Pedrol8a35e642021-01-18 17:14:14 +010033#ifdef __cplusplus
34
Holger Hans Peter Freytherd11290b2013-10-26 17:32:04 +020035class Decoding {
36public:
Alexander Couzensb82bd922016-05-30 17:30:10 +020037 /* represents (parts) LLC PDUs within one RLC Data block */
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010038 struct RlcData {
39 uint8_t offset;
40 uint8_t length;
Alexander Couzensb82bd922016-05-30 17:30:10 +020041 bool is_complete; /* if this PDU ends in this block */
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010042 };
43
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010044 static int rlc_data_from_ul_data(
Jacob Erlbeckf2ba4cb2016-01-07 18:59:28 +010045 const struct gprs_rlc_data_block_info *rdbi,
Pau Espin Pedrol2ae83372020-05-18 11:35:35 +020046 enum CodingScheme cs, const uint8_t *data, RlcData *chunks,
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010047 unsigned int chunks_size, uint32_t *tlli);
Holger Hans Peter Freytherdf6b4f52013-11-24 17:05:48 +010048
Jacob Erlbeckf2f24b02016-02-05 13:16:24 +010049 static void extract_rbb(const struct bitvec *rbb, char *show_rbb);
Bhargava Abhyankare44383b2016-03-22 18:42:30 +053050 static int rlc_parse_ul_data_header_egprs_type_3(
51 struct gprs_rlc_data_info *rlc,
52 const uint8_t *data,
Pau Espin Pedrol2ae83372020-05-18 11:35:35 +020053 const enum CodingScheme &cs);
Aravind Sirsikar550a5412016-06-14 18:59:18 +053054 static int rlc_parse_ul_data_header_egprs_type_2(
55 struct gprs_rlc_data_info *rlc,
56 const uint8_t *data,
Pau Espin Pedrol2ae83372020-05-18 11:35:35 +020057 const enum CodingScheme &cs);
Aravind Sirsikar99ab0a82016-06-15 17:46:41 +053058 static int rlc_parse_ul_data_header_egprs_type_1(
59 struct gprs_rlc_data_info *rlc,
60 const uint8_t *data,
Pau Espin Pedrol2ae83372020-05-18 11:35:35 +020061 const enum CodingScheme &cs);
Bhargava Abhyankare44383b2016-03-22 18:42:30 +053062 static int rlc_parse_ul_data_header_gprs(
63 struct gprs_rlc_data_info *rlc,
64 const uint8_t *data,
Pau Espin Pedrol2ae83372020-05-18 11:35:35 +020065 const enum CodingScheme &cs);
Jacob Erlbeckf2ba4cb2016-01-07 18:59:28 +010066 static int rlc_parse_ul_data_header(struct gprs_rlc_data_info *rlc,
Pau Espin Pedrol2ae83372020-05-18 11:35:35 +020067 const uint8_t *data, enum CodingScheme cs);
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010068 static unsigned int rlc_copy_to_aligned_buffer(
Jacob Erlbeckf2ba4cb2016-01-07 18:59:28 +010069 const struct gprs_rlc_data_info *rlc,
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010070 unsigned int data_block_idx,
71 const uint8_t *src, uint8_t *buffer);
72 static const uint8_t *rlc_get_data_aligned(
Jacob Erlbeckf2ba4cb2016-01-07 18:59:28 +010073 const struct gprs_rlc_data_info *rlc,
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010074 unsigned int data_block_idx,
75 const uint8_t *src, uint8_t *buffer);
Jacob Erlbeckae9c5752016-01-13 13:55:44 +010076 static int decode_egprs_acknack_bits(
77 const EGPRS_AckNack_Desc_t *desc,
78 struct bitvec *bits, int *bsn_begin, int *bsn_end,
79 struct gprs_rlc_dl_window *window);
Jacob Erlbeck192bf332016-02-05 13:10:29 +010080 static int decode_gprs_acknack_bits(
81 const Ack_Nack_Description_t *desc,
82 bitvec *bits, int *bsn_begin, int *bsn_end,
83 gprs_rlc_dl_window *window);
Holger Hans Peter Freytherd11290b2013-10-26 17:32:04 +020084};
Pau Espin Pedrol8a35e642021-01-18 17:14:14 +010085
86#endif /* #ifdef __cplusplus */
87
88#ifdef __cplusplus
89extern "C" {
90#endif
91
92uint8_t get_ms_class_by_capability(MS_Radio_Access_capability_t *cap);
93uint8_t get_egprs_ms_class_by_capability(MS_Radio_Access_capability_t *cap);
94
95#ifdef __cplusplus
96}
97#endif