blob: ac66838d954881d598c935a80d1e8a892e397c6e [file] [log] [blame]
Holger Hans Peter Freyther63f29d62013-10-19 19:04:03 +02001/* encoding.cpp
2 *
3 * Copyright (C) 2012 Ivan Klyuchnikov
4 * Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu>
5 * Copyright (C) 2013 by Holger Hans Peter Freyther
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21#pragma once
22
23#include <stdint.h>
24#include <gsm_rlcmac.h>
25
26struct gprs_rlcmac_bts;
27struct gprs_rlcmac_tbf;
28struct bitvec;
29
30/**
31 * I help with encoding data into CSN1 messages.
32 * TODO: Nobody can remember a function signature like this. One should
33 * fill out a struct with the request parameters and then hand the struct
34 * to the code.
35 */
36class Encoding {
37public:
38 static int write_immediate_assignment(
39 struct gprs_rlcmac_bts *bts,
40 bitvec * dest, uint8_t downlink, uint8_t ra,
41 uint32_t ref_fn, uint8_t ta, uint16_t arfcn, uint8_t ts, uint8_t tsc,
42 uint8_t tfi, uint8_t usf, uint32_t tlli, uint8_t polling,
43 uint32_t fn, uint8_t single_block, uint8_t alpha, uint8_t gamma,
44 int8_t ta_idx);
45
46 static void write_packet_uplink_assignment(
47 struct gprs_rlcmac_bts *bts,
48 bitvec * dest, uint8_t old_tfi,
49 uint8_t old_downlink, uint32_t tlli, uint8_t use_tlli,
Daniel Willmannf55e58f2014-08-07 15:02:16 +020050 struct gprs_rlcmac_ul_tbf *tbf, uint8_t poll, uint8_t alpha,
Jacob Erlbeck76d767c2015-09-28 18:54:32 +020051 uint8_t gamma, int8_t ta_idx, int8_t use_egprs);
Holger Hans Peter Freyther63f29d62013-10-19 19:04:03 +020052
53 static void write_packet_downlink_assignment(RlcMacDownlink_t * block, uint8_t old_tfi,
54 uint8_t old_downlink, struct gprs_rlcmac_tbf *tbf, uint8_t poll,
55 uint8_t alpha, uint8_t gamma, int8_t ta_idx, uint8_t ta_ts);
56
Daniel Willmann5241c1a2013-12-11 14:35:29 +010057 static void encode_rbb(const char *show_rbb, uint8_t *rbb);
58
Daniel Willmannf55e58f2014-08-07 15:02:16 +020059 static void write_packet_uplink_ack(struct gprs_rlcmac_bts *bts, RlcMacDownlink_t * block, struct gprs_rlcmac_ul_tbf *tbf,
Holger Hans Peter Freyther63f29d62013-10-19 19:04:03 +020060 uint8_t final);
61
62 static int write_paging_request(bitvec * dest, uint8_t *ptmsi, uint16_t ptmsi_len);
63
64 static unsigned write_repeated_page_info(bitvec * dest, unsigned& wp, uint8_t len,
65 uint8_t *identity, uint8_t chan_needed);
66
67 static unsigned write_packet_paging_request(bitvec * dest);
68};