blob: d1371d532e90553b084d1e7af590a3f2b5a0c76c [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.
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
Holger Hans Peter Freytherfcbc7022013-10-26 17:38:37 +020022#include <gsm_rlcmac.h>
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010023#include "rlc.h"
Holger Hans Peter Freytherfcbc7022013-10-26 17:38:37 +020024
Holger Hans Peter Freytherd11290b2013-10-26 17:32:04 +020025#include <stdint.h>
26
Jacob Erlbeckae9c5752016-01-13 13:55:44 +010027struct bitvec;
28
Holger Hans Peter Freytherd11290b2013-10-26 17:32:04 +020029class Decoding {
30public:
Alexander Couzensb82bd922016-05-30 17:30:10 +020031 /* represents (parts) LLC PDUs within one RLC Data block */
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010032 struct RlcData {
33 uint8_t offset;
34 uint8_t length;
Alexander Couzensb82bd922016-05-30 17:30:10 +020035 bool is_complete; /* if this PDU ends in this block */
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010036 };
37
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010038 static int rlc_data_from_ul_data(
Jacob Erlbeckf2ba4cb2016-01-07 18:59:28 +010039 const struct gprs_rlc_data_block_info *rdbi,
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010040 GprsCodingScheme cs, const uint8_t *data, RlcData *chunks,
41 unsigned int chunks_size, uint32_t *tlli);
Holger Hans Peter Freytherfcbc7022013-10-26 17:38:37 +020042 static uint8_t get_ms_class_by_capability(MS_Radio_Access_capability_t *cap);
Jacob Erlbeckc3c58042015-09-28 17:55:32 +020043 static uint8_t get_egprs_ms_class_by_capability(MS_Radio_Access_capability_t *cap);
Holger Hans Peter Freytherdf6b4f52013-11-24 17:05:48 +010044
45 static void extract_rbb(const uint8_t *rbb, char *extracted_rbb);
Jacob Erlbeckf2f24b02016-02-05 13:16:24 +010046 static void extract_rbb(const struct bitvec *rbb, char *show_rbb);
Bhargava Abhyankare44383b2016-03-22 18:42:30 +053047 static int rlc_parse_ul_data_header_egprs_type_3(
48 struct gprs_rlc_data_info *rlc,
49 const uint8_t *data,
50 const GprsCodingScheme &cs);
Aravind Sirsikar550a5412016-06-14 18:59:18 +053051 static int rlc_parse_ul_data_header_egprs_type_2(
52 struct gprs_rlc_data_info *rlc,
53 const uint8_t *data,
54 const GprsCodingScheme &cs);
Aravind Sirsikar99ab0a82016-06-15 17:46:41 +053055 static int rlc_parse_ul_data_header_egprs_type_1(
56 struct gprs_rlc_data_info *rlc,
57 const uint8_t *data,
58 const GprsCodingScheme &cs);
Bhargava Abhyankare44383b2016-03-22 18:42:30 +053059 static int rlc_parse_ul_data_header_gprs(
60 struct gprs_rlc_data_info *rlc,
61 const uint8_t *data,
62 const GprsCodingScheme &cs);
Jacob Erlbeckf2ba4cb2016-01-07 18:59:28 +010063 static int rlc_parse_ul_data_header(struct gprs_rlc_data_info *rlc,
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010064 const uint8_t *data, GprsCodingScheme cs);
65 static unsigned int rlc_copy_to_aligned_buffer(
Jacob Erlbeckf2ba4cb2016-01-07 18:59:28 +010066 const struct gprs_rlc_data_info *rlc,
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010067 unsigned int data_block_idx,
68 const uint8_t *src, uint8_t *buffer);
69 static const uint8_t *rlc_get_data_aligned(
Jacob Erlbeckf2ba4cb2016-01-07 18:59:28 +010070 const struct gprs_rlc_data_info *rlc,
Jacob Erlbeck4abc6862015-12-08 15:14:05 +010071 unsigned int data_block_idx,
72 const uint8_t *src, uint8_t *buffer);
Jacob Erlbeckae9c5752016-01-13 13:55:44 +010073 static int decode_egprs_acknack_bits(
74 const EGPRS_AckNack_Desc_t *desc,
75 struct bitvec *bits, int *bsn_begin, int *bsn_end,
76 struct gprs_rlc_dl_window *window);
Jacob Erlbeck192bf332016-02-05 13:10:29 +010077 static int decode_gprs_acknack_bits(
78 const Ack_Nack_Description_t *desc,
79 bitvec *bits, int *bsn_begin, int *bsn_end,
80 gprs_rlc_dl_window *window);
Holger Hans Peter Freytherd11290b2013-10-26 17:32:04 +020081};