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,
|
2021-04-26 11:36:16 +00:00
|
|
|
enum ph_burst_type burst_type,
|
|
|
|
uint8_t t3142
|
2016-11-09 10:57:00 +00:00
|
|
|
);
|
|
|
|
|
2021-07-28 19:48:26 +00:00
|
|
|
static void encode_rbb(const char *show_rbb, bitvec *rbb);
|
2013-12-11 13:35:29 +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
|
|
|
|
|
2021-07-27 10:27:08 +00:00
|
|
|
void write_packet_access_reject(struct bitvec *dest, uint32_t tlli, unsigned long t3172_ms);
|
|
|
|
void write_packet_uplink_assignment(RlcMacDownlink_t *block, uint8_t old_tfi,
|
|
|
|
uint8_t old_downlink, uint32_t tlli, uint8_t use_tlli,
|
|
|
|
const struct gprs_rlcmac_ul_tbf *tbf, uint8_t poll,
|
|
|
|
uint8_t rrbp, uint8_t alpha, uint8_t gamma, int8_t ta_idx,
|
|
|
|
bool use_egprs);
|
|
|
|
|
2021-07-27 15:33:07 +00:00
|
|
|
void write_packet_downlink_assignment(RlcMacDownlink_t * block, bool old_tfi_is_valid,
|
|
|
|
uint8_t old_tfi, uint8_t old_downlink,
|
|
|
|
const struct gprs_rlcmac_dl_tbf *tbf, uint8_t poll,
|
|
|
|
uint8_t rrbp, uint8_t alpha, uint8_t gamma,
|
|
|
|
int8_t ta_idx, uint8_t ta_ts, bool use_egprs,
|
|
|
|
uint8_t control_ack);
|
|
|
|
|
2021-07-29 16:39:16 +00:00
|
|
|
void write_packet_uplink_ack(struct bitvec *dest, struct gprs_rlcmac_ul_tbf *tbf,
|
|
|
|
bool is_final, uint8_t rrbp);
|
|
|
|
|
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
|
|
|
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);
|
|
|
|
|
2021-02-01 13:52:48 +00:00
|
|
|
void write_packet_cell_change_continue(RlcMacDownlink_t *block, uint8_t poll, uint8_t rrbp,
|
|
|
|
bool tfi_is_dl, uint8_t tfi, bool exist_id,
|
|
|
|
uint16_t arfcn, uint8_t bsic, uint8_t container_id);
|
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
|
|
|
|
}
|
|
|
|
#endif
|