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>
|
2020-05-18 09:35:35 +00:00
|
|
|
|
Introduce NACC support
A new nacc_fsm is introduced per MS object, with its partner priv
structure struct nacc_fsm_ctx, which exists and is available in the MS
object only during the duration of the NACC procedure.
The NACC context is created on an MS whenever a Pkt Cell Change
Notification is received on Uplink RLCMAC, which asks for neighbor
information of a given ARFCN+BSIC.
First, the target ARFCN+BSIC needs to be translated into a CGI-PS
(RAC+CI) address. That's done by asking the BSC through the Neighbour
Resolution Service available in osmo-bsc using the CTRL interface.
Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO
request against the SGSN (which will route the request as needed), and
wait for a response containing the SI bits from the target cell.
After the SI are received, the scheduler is instructed to eventually
poll a TBF for the MS originating the CCN, so that we can send the SI
encapsulated into multiple Packet Neighbor Cell Data messages on the
downlink.
One all the SI bits are sent, the scheduler is instructed to send a
Packet Cell Change Continue message.
Once the message above has been sent, the FSM autodestroys itself.
Caches are also introduced in this patch which allows for re-using
recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO
respectively.
Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-21 17:46:13 +00:00
|
|
|
#ifdef __cplusplus
|
2016-09-02 11:20:43 +00:00
|
|
|
extern "C" {
|
Introduce NACC support
A new nacc_fsm is introduced per MS object, with its partner priv
structure struct nacc_fsm_ctx, which exists and is available in the MS
object only during the duration of the NACC procedure.
The NACC context is created on an MS whenever a Pkt Cell Change
Notification is received on Uplink RLCMAC, which asks for neighbor
information of a given ARFCN+BSIC.
First, the target ARFCN+BSIC needs to be translated into a CGI-PS
(RAC+CI) address. That's done by asking the BSC through the Neighbour
Resolution Service available in osmo-bsc using the CTRL interface.
Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO
request against the SGSN (which will route the request as needed), and
wait for a response containing the SI bits from the target cell.
After the SI are received, the scheduler is instructed to eventually
poll a TBF for the MS originating the CCN, so that we can send the SI
encapsulated into multiple Packet Neighbor Cell Data messages on the
downlink.
One all the SI bits are sent, the scheduler is instructed to send a
Packet Cell Change Continue message.
Once the message above has been sent, the FSM autodestroys itself.
Caches are also introduced in this patch which allows for re-using
recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO
respectively.
Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-21 17:46:13 +00:00
|
|
|
#endif
|
2016-09-02 11:20:43 +00:00
|
|
|
#include <osmocom/gsm/l1sap.h>
|
2020-05-18 09:35:35 +00:00
|
|
|
#include "coding_scheme.h"
|
2020-03-26 14:14:01 +00:00
|
|
|
#include "gsm_rlcmac.h"
|
Introduce NACC support
A new nacc_fsm is introduced per MS object, with its partner priv
structure struct nacc_fsm_ctx, which exists and is available in the MS
object only during the duration of the NACC procedure.
The NACC context is created on an MS whenever a Pkt Cell Change
Notification is received on Uplink RLCMAC, which asks for neighbor
information of a given ARFCN+BSIC.
First, the target ARFCN+BSIC needs to be translated into a CGI-PS
(RAC+CI) address. That's done by asking the BSC through the Neighbour
Resolution Service available in osmo-bsc using the CTRL interface.
Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO
request against the SGSN (which will route the request as needed), and
wait for a response containing the SI bits from the target cell.
After the SI are received, the scheduler is instructed to eventually
poll a TBF for the MS originating the CCN, so that we can send the SI
encapsulated into multiple Packet Neighbor Cell Data messages on the
downlink.
One all the SI bits are sent, the scheduler is instructed to send a
Packet Cell Change Continue message.
Once the message above has been sent, the FSM autodestroys itself.
Caches are also introduced in this patch which allows for re-using
recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO
respectively.
Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-21 17:46:13 +00:00
|
|
|
#ifdef __cplusplus
|
2016-09-02 11:20:43 +00:00
|
|
|
}
|
Introduce NACC support
A new nacc_fsm is introduced per MS object, with its partner priv
structure struct nacc_fsm_ctx, which exists and is available in the MS
object only during the duration of the NACC procedure.
The NACC context is created on an MS whenever a Pkt Cell Change
Notification is received on Uplink RLCMAC, which asks for neighbor
information of a given ARFCN+BSIC.
First, the target ARFCN+BSIC needs to be translated into a CGI-PS
(RAC+CI) address. That's done by asking the BSC through the Neighbour
Resolution Service available in osmo-bsc using the CTRL interface.
Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO
request against the SGSN (which will route the request as needed), and
wait for a response containing the SI bits from the target cell.
After the SI are received, the scheduler is instructed to eventually
poll a TBF for the MS originating the CCN, so that we can send the SI
encapsulated into multiple Packet Neighbor Cell Data messages on the
downlink.
One all the SI bits are sent, the scheduler is instructed to send a
Packet Cell Change Continue message.
Once the message above has been sent, the FSM autodestroys itself.
Caches are also introduced in this patch which allows for re-using
recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO
respectively.
Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-21 17:46:13 +00:00
|
|
|
#endif
|
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
|
|
|
|
Introduce NACC support
A new nacc_fsm is introduced per MS object, with its partner priv
structure struct nacc_fsm_ctx, which exists and is available in the MS
object only during the duration of the NACC procedure.
The NACC context is created on an MS whenever a Pkt Cell Change
Notification is received on Uplink RLCMAC, which asks for neighbor
information of a given ARFCN+BSIC.
First, the target ARFCN+BSIC needs to be translated into a CGI-PS
(RAC+CI) address. That's done by asking the BSC through the Neighbour
Resolution Service available in osmo-bsc using the CTRL interface.
Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO
request against the SGSN (which will route the request as needed), and
wait for a response containing the SI bits from the target cell.
After the SI are received, the scheduler is instructed to eventually
poll a TBF for the MS originating the CCN, so that we can send the SI
encapsulated into multiple Packet Neighbor Cell Data messages on the
downlink.
One all the SI bits are sent, the scheduler is instructed to send a
Packet Cell Change Continue message.
Once the message above has been sent, the FSM autodestroys itself.
Caches are also introduced in this patch which allows for re-using
recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO
respectively.
Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-21 17:46:13 +00:00
|
|
|
#ifdef __cplusplus
|
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(
|
2020-07-18 16:34:17 +00:00
|
|
|
const struct gprs_rlcmac_pdch *pdch,
|
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,
|
2020-07-18 16:34:17 +00:00
|
|
|
uint32_t ref_fn, uint8_t ta,
|
|
|
|
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(
|
encoding: use CSN.1 codec to generate Packet Uplink Assignment
It's quite odd to see that in write_packet_downlink_assignment()
we initialize an 'RlcMacDownlink_t', so then the caller can use
the power of CSN.1 codec to generate the final sequence of bytes
to be transmitted, while in write_packet_uplink_assignment() we
already compose the final RLC/MAC message straight away using
the low-level bitvec API (like bitvec_write_field()).
I guess the reason is that at the time of writing this code, the
CSN.1 codec was not stable enough, so it was safer to generate
the message 'by hand'. This would also explain why we *decode*
the final RLC/MAC message in create_ul_ass() right after encoding.
Rewrite write_packet_uplink_assignment(), so now it initializes
a caller-provided 'RlcMacDownlink_t' structure. Given that it's
allocated on heap using talloc_zero(), do not initialize presence
indicators of fields that are not present in the message.
This would facilitate handling of frequency hopping parameters
in the upcoming changes, in particular we can now introduce a
function that would compose Frequency Parameters IE for both
write_packet_{downlink,uplink}_assignment().
Tested manually by running a GPRS-enabled network, as well as by
running test cases from ttcn3-pcu-test => no regressions observed.
Change-Id: I2850b91e0043cdca8ae7498a5fc727eeedd029b6
Related: SYS#4868, OS#4547
2020-08-21 19:05:28 +00:00
|
|
|
RlcMacDownlink_t * block, uint8_t old_tfi,
|
2016-01-26 20:46:26 +00:00
|
|
|
uint8_t old_downlink, uint32_t tlli, uint8_t use_tlli,
|
2020-08-20 09:49:34 +00:00
|
|
|
const struct gprs_rlcmac_ul_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,
|
2020-08-21 17:12:30 +00:00
|
|
|
bool 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,
|
2020-08-20 09:49:34 +00:00
|
|
|
const 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
|
|
|
|
paging: pass struct osmo_mobile_identity, not encoded IE bytes
In get_paging_mi(), before this, an encoded buffer of Mobile Identity bytes is
returned. Code paths following this repeatedly decode the Mobile Identity
bytes, e.g. for logging. Also, in get_paging_mi(), since the TMSI is read in
from a different encoding than a typical Mobile Identity IE, the TMSI was
manually encoded into a typical Mobile Identity IE. This is essentially a code
dup of osmo_mobile_identity_encode(). Stop this madness.
Instead, in get_paging_mi(), return a decoded struct osmo_mobile_identity. Code
paths after this use the struct osmo_mobile_identity directly without repeated
decoding.
At the point of finally needing an encoded Mobile Identity IE (in
Encoding::write_paging_request()), do a proper osmo_mobile_identity_encode().
Since this may return errors, add an rc check for the caller of
write_paging_request(), gprs_rlcmac_paging_request().
A side effect is stricter validation of the Mobile Identity passing through the
Paging code path. Before, invalid MI might have passed through unnoticed.
Change-Id: Iad845acb0096b75dc453105c9c16b2252879b4ca
2020-08-21 14:21:23 +00:00
|
|
|
static int write_paging_request(bitvec * dest, const struct osmo_mobile_identity *mi);
|
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(
|
2020-05-18 09:35:35 +00:00
|
|
|
struct gprs_rlc_data_block_info *rdbi, enum CodingScheme 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);
|
2020-11-27 13:51:27 +00:00
|
|
|
static void rlc_data_to_dl_append_egprs_li_padding(
|
|
|
|
const struct gprs_rlc_data_block_info *rdbi,
|
|
|
|
int *offset, int *num_chunks, uint8_t *data_block);
|
2013-10-19 17:04:03 +00:00
|
|
|
};
|
Introduce NACC support
A new nacc_fsm is introduced per MS object, with its partner priv
structure struct nacc_fsm_ctx, which exists and is available in the MS
object only during the duration of the NACC procedure.
The NACC context is created on an MS whenever a Pkt Cell Change
Notification is received on Uplink RLCMAC, which asks for neighbor
information of a given ARFCN+BSIC.
First, the target ARFCN+BSIC needs to be translated into a CGI-PS
(RAC+CI) address. That's done by asking the BSC through the Neighbour
Resolution Service available in osmo-bsc using the CTRL interface.
Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO
request against the SGSN (which will route the request as needed), and
wait for a response containing the SI bits from the target cell.
After the SI are received, the scheduler is instructed to eventually
poll a TBF for the MS originating the CCN, so that we can send the SI
encapsulated into multiple Packet Neighbor Cell Data messages on the
downlink.
One all the SI bits are sent, the scheduler is instructed to send a
Packet Cell Change Continue message.
Once the message above has been sent, the FSM autodestroys itself.
Caches are also introduced in this patch which allows for re-using
recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO
respectively.
Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-21 17:46:13 +00:00
|
|
|
|
|
|
|
#endif /* ifdef __cplusplus */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void write_packet_neighbour_cell_data(RlcMacDownlink_t *block,
|
|
|
|
bool tfi_is_dl, uint8_t tfi, uint8_t container_id,
|
|
|
|
uint8_t container_idx, PNCDContainer_t *container);
|
|
|
|
|
|
|
|
void write_packet_cell_change_continue(RlcMacDownlink_t *block,
|
|
|
|
bool tfi_is_dl, uint8_t tfi, bool exist_id,
|
|
|
|
uint16_t arfcn, uint8_t bsic, uint8_t container_id);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|