mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
2.8 KiB
C
118 lines
2.8 KiB
C
4 years ago
|
/**
|
||
5 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
5 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2020 Software Radio Systems Limited
|
||
5 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
5 years ago
|
*
|
||
|
*/
|
||
|
|
||
4 years ago
|
#ifndef SRSLTE_MAC_SCH_PDU_NR_H
|
||
|
#define SRSLTE_MAC_SCH_PDU_NR_H
|
||
5 years ago
|
|
||
|
#include "srslte/common/common.h"
|
||
4 years ago
|
#include "srslte/common/logmap.h"
|
||
4 years ago
|
#include "srslte/config.h"
|
||
5 years ago
|
#include <memory>
|
||
|
#include <stdint.h>
|
||
|
#include <vector>
|
||
|
|
||
|
namespace srslte {
|
||
|
|
||
4 years ago
|
class mac_sch_pdu_nr;
|
||
5 years ago
|
|
||
4 years ago
|
class mac_sch_subpdu_nr
|
||
5 years ago
|
{
|
||
|
public:
|
||
|
// 3GPP 38.321 v15.3.0 Combined Tables 6.2.1-1, 6.2.1-2
|
||
|
typedef enum {
|
||
|
// Values for DL-SCH
|
||
5 years ago
|
CCCH = 0b000000,
|
||
5 years ago
|
DRX_CMD = 0b111100,
|
||
|
TA_CMD = 0b111101,
|
||
|
CON_RES_ID = 0b111110,
|
||
|
|
||
|
// Values for UL-SCH
|
||
|
CRNTI = 0b111010,
|
||
|
SHORT_TRUNC_BSR = 0b111011,
|
||
|
LONG_TRUNC_BSR = 0b111100,
|
||
5 years ago
|
CCCH_SIZE_48 = 0b110100,
|
||
|
CCCH_SIZE_64 = 0b000000,
|
||
5 years ago
|
|
||
|
SHORT_BSR = 0b111101,
|
||
|
LONG_BSR = 0b111110,
|
||
|
|
||
|
// Common
|
||
|
PADDING = 0b111111,
|
||
|
} nr_lcid_sch_t;
|
||
|
|
||
4 years ago
|
mac_sch_subpdu_nr(mac_sch_pdu_nr* parent_);
|
||
5 years ago
|
|
||
|
nr_lcid_sch_t get_type();
|
||
|
bool is_sdu();
|
||
5 years ago
|
bool is_valid_lcid();
|
||
5 years ago
|
bool is_var_len_ce();
|
||
5 years ago
|
bool is_ul_ccch();
|
||
5 years ago
|
|
||
5 years ago
|
int32_t read_subheader(const uint8_t* ptr);
|
||
5 years ago
|
uint32_t get_total_length();
|
||
|
uint32_t get_sdu_length();
|
||
|
uint32_t get_lcid();
|
||
|
uint8_t* get_sdu();
|
||
|
|
||
|
void set_sdu(const uint32_t lcid_, const uint8_t* payload_, const uint32_t len_);
|
||
|
|
||
|
void set_padding(const uint32_t len_);
|
||
|
|
||
|
uint32_t write_subpdu(const uint8_t* start_);
|
||
|
|
||
|
private:
|
||
|
uint32_t sizeof_ce(uint32_t lcid, bool is_ul);
|
||
|
|
||
|
// protected:
|
||
|
uint32_t lcid = 0;
|
||
|
int header_length = 0;
|
||
|
int sdu_length = 0;
|
||
|
bool F_bit = false;
|
||
|
uint8_t* sdu = nullptr;
|
||
|
|
||
4 years ago
|
mac_sch_pdu_nr* parent = nullptr;
|
||
4 years ago
|
srslte::log_ref log_h;
|
||
5 years ago
|
};
|
||
|
|
||
4 years ago
|
class mac_sch_pdu_nr
|
||
5 years ago
|
{
|
||
|
public:
|
||
4 years ago
|
mac_sch_pdu_nr(bool ulsch_ = false) : ulsch(ulsch_) {}
|
||
5 years ago
|
|
||
5 years ago
|
void pack();
|
||
|
void unpack(const uint8_t* payload, const uint32_t& len);
|
||
|
uint32_t get_num_subpdus();
|
||
4 years ago
|
const mac_sch_subpdu_nr& get_subpdu(const uint32_t& index);
|
||
5 years ago
|
bool is_ulsch();
|
||
5 years ago
|
|
||
|
void init_tx(byte_buffer_t* buffer_, uint32_t pdu_len_, bool is_ulsch_ = false);
|
||
4 years ago
|
void init_rx(bool ulsch_ = false);
|
||
5 years ago
|
|
||
|
uint32_t add_sdu(const uint32_t lcid_, const uint8_t* payload_, const uint32_t len_);
|
||
|
|
||
|
uint32_t get_remaing_len();
|
||
|
|
||
|
private:
|
||
5 years ago
|
uint32_t size_header_sdu(const uint32_t lcid_, const uint32_t nbytes);
|
||
5 years ago
|
|
||
5 years ago
|
bool ulsch = false;
|
||
4 years ago
|
std::vector<mac_sch_subpdu_nr> subpdus;
|
||
5 years ago
|
|
||
|
byte_buffer_t* buffer = nullptr;
|
||
|
uint32_t pdu_len = 0;
|
||
|
uint32_t remaining_len = 0;
|
||
|
};
|
||
|
|
||
|
} // namespace srslte
|
||
|
|
||
4 years ago
|
#endif // SRSLTE_MAC_SCH_PDU_NR_H
|