|
|
|
@ -19,20 +19,19 @@
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <strings.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <strings.h>
|
|
|
|
|
|
|
|
|
|
#include "srslte/common/pdu.h"
|
|
|
|
|
#include "srslte/srslte.h"
|
|
|
|
|
|
|
|
|
|
// Table 6.1.3.1-1 Buffer size levels for BSR
|
|
|
|
|
static uint32_t btable[64] = {
|
|
|
|
|
0, 1, 10, 12, 14, 17, 19, 22, 26, 31, 36, 42, 49, 57, 67, 78, 91, 107, 125, 146, 171, 200, 234, 274, 321, 376, 440, 515, 603, 706, 826, 967, 1132,
|
|
|
|
|
1326, 1552, 1817, 2127, 2490, 2915, 3413, 3995, 4667, 5476, 6411, 7505, 8787, 10287, 12043, 14099, 16507, 19325, 22624, 26487, 31009, 36304,
|
|
|
|
|
42502, 49759, 58255, 68201, 79846, 93479, 109439, 128125, 150000};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
0, 1, 10, 12, 14, 17, 19, 22, 26, 31, 36, 42, 49, 57, 67, 78,
|
|
|
|
|
91, 107, 125, 146, 171, 200, 234, 274, 321, 376, 440, 515, 603, 706, 826, 967,
|
|
|
|
|
1132, 1326, 1552, 1817, 2127, 2490, 2915, 3413, 3995, 4667, 5476, 6411, 7505, 8787, 10287, 12043,
|
|
|
|
|
14099, 16507, 19325, 22624, 26487, 31009, 36304, 42502, 49759, 58255, 68201, 79846, 93479, 109439, 128125, 150000};
|
|
|
|
|
|
|
|
|
|
namespace srslte {
|
|
|
|
|
|
|
|
|
@ -63,7 +62,8 @@ void sch_pdu::parse_packet(uint8_t *ptr)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t* sch_pdu::write_packet() {
|
|
|
|
|
uint8_t* sch_pdu::write_packet()
|
|
|
|
|
{
|
|
|
|
|
return write_packet(NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -108,7 +108,6 @@ uint8_t* sch_pdu::write_packet(srslte::log *log_h)
|
|
|
|
|
rem_len = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Determine the header size and CE payload size */
|
|
|
|
|
uint32_t header_sz = 0;
|
|
|
|
|
uint32_t ce_payload_sz = 0;
|
|
|
|
@ -174,13 +173,30 @@ uint8_t* sch_pdu::write_packet(srslte::log *log_h)
|
|
|
|
|
|
|
|
|
|
/* Sanity check and print if error */
|
|
|
|
|
if (log_h) {
|
|
|
|
|
log_h->debug("Wrote PDU: pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, sdu_len=%d, onepad=%d, multi=%d\n",
|
|
|
|
|
pdu_len, header_sz+ce_payload_sz, header_sz, ce_payload_sz,
|
|
|
|
|
nof_subheaders, last_sdu_idx, total_sdu_len, onetwo_padding, rem_len);
|
|
|
|
|
log_h->debug(
|
|
|
|
|
"Wrote PDU: pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, sdu_len=%d, onepad=%d, multi=%d\n",
|
|
|
|
|
pdu_len,
|
|
|
|
|
header_sz + ce_payload_sz,
|
|
|
|
|
header_sz,
|
|
|
|
|
ce_payload_sz,
|
|
|
|
|
nof_subheaders,
|
|
|
|
|
last_sdu_idx,
|
|
|
|
|
total_sdu_len,
|
|
|
|
|
onetwo_padding,
|
|
|
|
|
rem_len);
|
|
|
|
|
} else {
|
|
|
|
|
printf("Wrote PDU: pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, sdu_len=%d, onepad=%d, multi=%d, init_rem_len=%d\n",
|
|
|
|
|
pdu_len, header_sz+ce_payload_sz, header_sz, ce_payload_sz,
|
|
|
|
|
nof_subheaders, last_sdu_idx, total_sdu_len, onetwo_padding, rem_len, init_rem_len);
|
|
|
|
|
printf("Wrote PDU: pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, sdu_len=%d, onepad=%d, "
|
|
|
|
|
"multi=%d, init_rem_len=%d\n",
|
|
|
|
|
pdu_len,
|
|
|
|
|
header_sz + ce_payload_sz,
|
|
|
|
|
header_sz,
|
|
|
|
|
ce_payload_sz,
|
|
|
|
|
nof_subheaders,
|
|
|
|
|
last_sdu_idx,
|
|
|
|
|
total_sdu_len,
|
|
|
|
|
onetwo_padding,
|
|
|
|
|
rem_len,
|
|
|
|
|
init_rem_len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rem_len + header_sz + ce_payload_sz + total_sdu_len != pdu_len) {
|
|
|
|
@ -231,7 +247,8 @@ uint8_t* sch_pdu::write_packet(srslte::log *log_h)
|
|
|
|
|
return pdu_start_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int sch_pdu::rem_size() {
|
|
|
|
|
int sch_pdu::rem_size()
|
|
|
|
|
{
|
|
|
|
|
return rem_len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -328,11 +345,13 @@ sch_subh::cetype sch_subh::ce_type()
|
|
|
|
|
return (cetype)SDU;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sch_subh::set_payload_size(uint32_t size) {
|
|
|
|
|
void sch_subh::set_payload_size(uint32_t size)
|
|
|
|
|
{
|
|
|
|
|
nof_bytes = size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t sch_subh::size_plus_header() {
|
|
|
|
|
uint32_t sch_subh::size_plus_header()
|
|
|
|
|
{
|
|
|
|
|
if (is_sdu() || is_var_len_ce()) {
|
|
|
|
|
return sch_pdu::size_header_sdu(nof_bytes) + nof_bytes;
|
|
|
|
|
}
|
|
|
|
@ -406,11 +425,12 @@ uint16_t sch_subh::get_c_rnti()
|
|
|
|
|
uint64_t sch_subh::get_con_res_id()
|
|
|
|
|
{
|
|
|
|
|
if (payload) {
|
|
|
|
|
return ((uint64_t) payload[5]) | (((uint64_t) payload[4])<<8) | (((uint64_t) payload[3])<<16) | (((uint64_t) payload[2])<<24) |
|
|
|
|
|
(((uint64_t) payload[1])<<32) | (((uint64_t) payload[0])<<40);
|
|
|
|
|
return ((uint64_t)payload[5]) | (((uint64_t)payload[4]) << 8) | (((uint64_t)payload[3]) << 16) |
|
|
|
|
|
(((uint64_t)payload[2]) << 24) | (((uint64_t)payload[1]) << 32) | (((uint64_t)payload[0]) << 40);
|
|
|
|
|
} else {
|
|
|
|
|
return ((uint64_t) w_payload_ce[5]) | (((uint64_t) w_payload_ce[4])<<8) | (((uint64_t) w_payload_ce[3])<<16) | (((uint64_t) w_payload_ce[2])<<24) |
|
|
|
|
|
(((uint64_t) w_payload_ce[1])<<32) | (((uint64_t) w_payload_ce[0])<<40);
|
|
|
|
|
return ((uint64_t)w_payload_ce[5]) | (((uint64_t)w_payload_ce[4]) << 8) | (((uint64_t)w_payload_ce[3]) << 16) |
|
|
|
|
|
(((uint64_t)w_payload_ce[2]) << 24) | (((uint64_t)w_payload_ce[1]) << 32) |
|
|
|
|
|
(((uint64_t)w_payload_ce[0]) << 40);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -462,9 +482,7 @@ bool sch_subh::get_next_mch_sched_info(uint8_t *lcid_, uint16_t *mtch_stop)
|
|
|
|
|
mtch_stop_ce = ((uint16_t)(payload[cur_mch_sched_ce * 2] & 0x07)) << 8;
|
|
|
|
|
mtch_stop_ce += payload[cur_mch_sched_ce * 2 + 1];
|
|
|
|
|
cur_mch_sched_ce++;
|
|
|
|
|
*mtch_stop = (mtch_stop_ce == srslte::mch_subh::MTCH_STOP_EMPTY)
|
|
|
|
|
? (0)
|
|
|
|
|
: (mtch_stop_ce);
|
|
|
|
|
*mtch_stop = (mtch_stop_ce == srslte::mch_subh::MTCH_STOP_EMPTY) ? (0) : (mtch_stop_ce);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -495,14 +513,14 @@ uint32_t sch_subh::get_sdu_lcid()
|
|
|
|
|
return lcid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t sch_subh::get_payload_size()
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
return nof_bytes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t sch_subh::get_header_size(bool is_last) {
|
|
|
|
|
uint32_t sch_subh::get_header_size(bool is_last)
|
|
|
|
|
{
|
|
|
|
|
if (!is_last) {
|
|
|
|
|
if (is_sdu()) {
|
|
|
|
|
return sch_pdu::size_header_sdu(nof_bytes);
|
|
|
|
@ -617,10 +635,8 @@ bool sch_subh::set_ta_cmd(uint8_t ta_cmd)
|
|
|
|
|
bool sch_subh::set_next_mch_sched_info(uint8_t lcid_, uint16_t mtch_stop)
|
|
|
|
|
{
|
|
|
|
|
if (((sch_pdu*)parent)->has_space_ce(2, true)) {
|
|
|
|
|
uint16_t mtch_stop_ce =
|
|
|
|
|
(mtch_stop) ? (mtch_stop) : (srslte::mch_subh::MTCH_STOP_EMPTY);
|
|
|
|
|
w_payload_ce[nof_mch_sched_ce * 2] =
|
|
|
|
|
(lcid_ & 0x1F) << 3 | (uint8_t)((mtch_stop_ce & 0x0700) >> 8);
|
|
|
|
|
uint16_t mtch_stop_ce = (mtch_stop) ? (mtch_stop) : (srslte::mch_subh::MTCH_STOP_EMPTY);
|
|
|
|
|
w_payload_ce[nof_mch_sched_ce * 2] = (lcid_ & 0x1F) << 3 | (uint8_t)((mtch_stop_ce & 0x0700) >> 8);
|
|
|
|
|
w_payload_ce[nof_mch_sched_ce * 2 + 1] = (uint8_t)(mtch_stop_ce & 0xff);
|
|
|
|
|
nof_mch_sched_ce++;
|
|
|
|
|
lcid = MCH_SCHED_INFO;
|
|
|
|
@ -645,8 +661,7 @@ int sch_subh::set_sdu(uint32_t lcid_, uint32_t requested_bytes, read_pdu_interfa
|
|
|
|
|
}
|
|
|
|
|
if (sdu_sz == 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
// Save final number of written bytes
|
|
|
|
|
nof_bytes = sdu_sz;
|
|
|
|
|
|
|
|
|
@ -680,7 +695,6 @@ int sch_subh::set_sdu(uint32_t lcid_, uint32_t nof_bytes_, uint8_t *payload)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Section 6.2.1
|
|
|
|
|
void sch_subh::write_subheader(uint8_t** ptr, bool is_last)
|
|
|
|
|
{
|
|
|
|
@ -796,7 +810,8 @@ void sch_subh::fprint(FILE* stream)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t sch_subh::buff_size_table(uint32_t buffer_size) {
|
|
|
|
|
uint8_t sch_subh::buff_size_table(uint32_t buffer_size)
|
|
|
|
|
{
|
|
|
|
|
if (buffer_size == 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
} else if (buffer_size > 150000) {
|
|
|
|
@ -988,4 +1003,4 @@ bool rar_subh::read_subheader(uint8_t** ptr)
|
|
|
|
|
return e_bit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} // namespace srslte
|
|
|
|
|