2013-10-19 17:04:03 +00:00
|
|
|
/* encoding.cpp
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Ivan Klyuchnikov
|
|
|
|
* Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu>
|
|
|
|
* Copyright (C) 2013 by Holger Hans Peter Freyther
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2016-01-13 09:51:25 +00:00
|
|
|
#include <gprs_coding_scheme.h>
|
2016-09-02 11:20:43 +00:00
|
|
|
extern "C" {
|
|
|
|
#include <osmocom/gsm/l1sap.h>
|
2020-03-26 14:14:01 +00:00
|
|
|
#include "gsm_rlcmac.h"
|
2016-09-02 11:20:43 +00:00
|
|
|
}
|
2013-10-19 17:04:03 +00:00
|
|
|
|
|
|
|
struct gprs_rlcmac_tbf;
|
|
|
|
struct bitvec;
|
2016-01-12 10:58:13 +00:00
|
|
|
struct gprs_llc;
|
|
|
|
struct gprs_rlc_data_block_info;
|
2013-10-19 17:04:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* I help with encoding data into CSN1 messages.
|
|
|
|
* TODO: Nobody can remember a function signature like this. One should
|
|
|
|
* fill out a struct with the request parameters and then hand the struct
|
|
|
|
* to the code.
|
|
|
|
*/
|
|
|
|
class Encoding {
|
|
|
|
public:
|
|
|
|
static int write_immediate_assignment(
|
2016-02-01 15:13:38 +00:00
|
|
|
struct gprs_rlcmac_tbf *tbf,
|
2019-02-18 17:52:38 +00:00
|
|
|
bitvec * dest, bool downlink, uint16_t ra,
|
2016-02-01 15:13:38 +00:00
|
|
|
uint32_t ref_fn, uint8_t ta, uint16_t arfcn, uint8_t ts,
|
2019-02-18 17:52:38 +00:00
|
|
|
uint8_t tsc, uint8_t usf, bool polling,
|
2016-02-01 15:13:38 +00:00
|
|
|
uint32_t fn, uint8_t alpha, uint8_t gamma,
|
2016-09-02 11:20:43 +00:00
|
|
|
int8_t ta_idx,
|
2019-02-18 17:52:38 +00:00
|
|
|
enum ph_burst_type burst_type);
|
2013-10-19 17:04:03 +00:00
|
|
|
|
2016-11-09 10:57:00 +00:00
|
|
|
static int write_immediate_assignment_reject(
|
|
|
|
bitvec *dest, uint16_t ra,
|
|
|
|
uint32_t ref_fn,
|
|
|
|
enum ph_burst_type burst_type
|
|
|
|
);
|
|
|
|
|
2013-10-19 17:04:03 +00:00
|
|
|
static void write_packet_uplink_assignment(
|
|
|
|
bitvec * dest, uint8_t old_tfi,
|
2016-01-26 20:46:26 +00:00
|
|
|
uint8_t old_downlink, uint32_t tlli, uint8_t use_tlli,
|
|
|
|
struct gprs_rlcmac_ul_tbf *tbf, uint8_t poll, uint8_t rrbp,
|
|
|
|
uint8_t alpha, uint8_t gamma, int8_t ta_idx,
|
|
|
|
int8_t use_egprs);
|
2013-10-19 17:04:03 +00:00
|
|
|
|
2016-01-07 15:04:29 +00:00
|
|
|
static void write_packet_downlink_assignment(RlcMacDownlink_t * block,
|
2016-01-29 15:39:21 +00:00
|
|
|
bool old_tfi_is_valid, uint8_t old_tfi, uint8_t old_downlink,
|
2017-12-15 10:21:57 +00:00
|
|
|
struct gprs_rlcmac_dl_tbf *tbf, uint8_t poll, uint8_t rrbp,
|
2016-01-26 20:46:26 +00:00
|
|
|
uint8_t alpha, uint8_t gamma,
|
|
|
|
int8_t ta_idx, uint8_t ta_ts, bool use_egprs);
|
2013-10-19 17:04:03 +00:00
|
|
|
|
2013-12-11 13:35:29 +00:00
|
|
|
static void encode_rbb(const char *show_rbb, uint8_t *rbb);
|
|
|
|
|
2016-11-11 11:45:10 +00:00
|
|
|
static void write_packet_access_reject(
|
|
|
|
bitvec * dest, uint32_t tlli);
|
|
|
|
|
2015-12-22 13:58:34 +00:00
|
|
|
static void write_packet_uplink_ack(
|
2019-06-16 13:25:30 +00:00
|
|
|
bitvec * dest, struct gprs_rlcmac_ul_tbf *tbf, bool is_final,
|
2016-01-26 20:46:26 +00:00
|
|
|
uint8_t rrbp);
|
2013-10-19 17:04:03 +00:00
|
|
|
|
2019-12-10 18:26:27 +00:00
|
|
|
static int write_paging_request(bitvec * dest, const uint8_t *mi, uint8_t mi_len);
|
2013-10-19 17:04:03 +00:00
|
|
|
|
|
|
|
static unsigned write_repeated_page_info(bitvec * dest, unsigned& wp, uint8_t len,
|
|
|
|
uint8_t *identity, uint8_t chan_needed);
|
|
|
|
|
|
|
|
static unsigned write_packet_paging_request(bitvec * dest);
|
2016-01-08 09:07:53 +00:00
|
|
|
|
|
|
|
static int rlc_write_dl_data_header(
|
|
|
|
const struct gprs_rlc_data_info *rlc,
|
|
|
|
uint8_t *data);
|
|
|
|
static unsigned int rlc_copy_from_aligned_buffer(
|
|
|
|
const struct gprs_rlc_data_info *rlc,
|
|
|
|
unsigned int data_block_idx,
|
|
|
|
uint8_t *dst, const uint8_t *buffer);
|
2016-01-12 10:58:13 +00:00
|
|
|
|
|
|
|
enum AppendResult {
|
|
|
|
AR_NEED_MORE_BLOCKS,
|
|
|
|
AR_COMPLETED_SPACE_LEFT,
|
|
|
|
AR_COMPLETED_BLOCK_FILLED,
|
|
|
|
};
|
|
|
|
|
|
|
|
static AppendResult rlc_data_to_dl_append(
|
2016-01-13 09:51:25 +00:00
|
|
|
struct gprs_rlc_data_block_info *rdbi, GprsCodingScheme cs,
|
2016-01-12 10:58:13 +00:00
|
|
|
gprs_llc *llc, int *offset, int *num_chunks,
|
2016-05-30 17:30:21 +00:00
|
|
|
uint8_t *data, bool is_final, int *count_payload);
|
2013-10-19 17:04:03 +00:00
|
|
|
};
|