Renamed the reset() method of byte_buffer_t to clear()

master
Francisco Paisana 6 years ago committed by Andre Puschmann
parent 3bedc93ba5
commit 0e3baa0f2f

@ -198,7 +198,7 @@ public:
if(!b) { if(!b) {
return; return;
} }
b->reset(); b->clear();
if (!pool->deallocate(b)) { if (!pool->deallocate(b)) {
if (log) { if (log) {
#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED #ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED

@ -153,7 +153,7 @@ public:
memcpy(msg, buf.msg, N_bytes); memcpy(msg, buf.msg, N_bytes);
return *this; return *this;
} }
void reset() void clear()
{ {
msg = &buffer[SRSLTE_BUFFER_HEADER_OFFSET]; msg = &buffer[SRSLTE_BUFFER_HEADER_OFFSET];
N_bytes = 0; N_bytes = 0;
@ -229,7 +229,7 @@ struct bit_buffer_t{
memcpy(msg, buf.msg, N_bits); memcpy(msg, buf.msg, N_bits);
return *this; return *this;
} }
void reset() void clear()
{ {
msg = &buffer[SRSLTE_BUFFER_HEADER_OFFSET]; msg = &buffer[SRSLTE_BUFFER_HEADER_OFFSET];
N_bits = 0; N_bits = 0;

@ -683,7 +683,7 @@ void rlc_um::rlc_um_rx::reassemble_rx_sdus()
if(rx_window.end() == rx_window.find(vr_ur)) if(rx_window.end() == rx_window.find(vr_ur))
{ {
log->debug("SN=%d not in rx_window. Reset received SDU\n", vr_ur); log->debug("SN=%d not in rx_window. Reset received SDU\n", vr_ur);
rx_sdu->reset(); rx_sdu->clear();
}else{ }else{
// Handle any SDU segments // Handle any SDU segments
for(uint32_t i=0; i<rx_window[vr_ur].header.N_li; i++) for(uint32_t i=0; i<rx_window[vr_ur].header.N_li; i++)
@ -696,7 +696,7 @@ void rlc_um::rlc_um_rx::reassemble_rx_sdus()
// Advance data pointers and continue with next segment // Advance data pointers and continue with next segment
rx_window[vr_ur].buf->msg += len; rx_window[vr_ur].buf->msg += len;
rx_window[vr_ur].buf->N_bytes -= len; rx_window[vr_ur].buf->N_bytes -= len;
rx_sdu->reset(); rx_sdu->clear();
break; break;
} }
@ -706,7 +706,7 @@ void rlc_um::rlc_um_rx::reassemble_rx_sdus()
rx_window[vr_ur].buf->N_bytes -= len; rx_window[vr_ur].buf->N_bytes -= len;
if((pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) || (vr_ur != ((vr_ur_in_rx_sdu+1)%cfg.rx_mod))) { if((pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) || (vr_ur != ((vr_ur_in_rx_sdu+1)%cfg.rx_mod))) {
log->warning("Dropping remainder of lost PDU (lower edge middle segments, vr_ur=%d, vr_ur_in_rx_sdu=%d)\n", vr_ur, vr_ur_in_rx_sdu); log->warning("Dropping remainder of lost PDU (lower edge middle segments, vr_ur=%d, vr_ur_in_rx_sdu=%d)\n", vr_ur, vr_ur_in_rx_sdu);
rx_sdu->reset(); rx_sdu->clear();
} else { } else {
log->info_hex(rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d, i=%d (lower edge middle segments)", get_rb_name(), vr_ur, i); log->info_hex(rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d, i=%d (lower edge middle segments)", get_rb_name(), vr_ur, i);
rx_sdu->set_timestamp(); rx_sdu->set_timestamp();
@ -736,7 +736,7 @@ void rlc_um::rlc_um_rx::reassemble_rx_sdus()
{ {
if(pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) { if(pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) {
log->warning("Dropping remainder of lost PDU (lower edge last segments)\n"); log->warning("Dropping remainder of lost PDU (lower edge last segments)\n");
rx_sdu->reset(); rx_sdu->clear();
} else { } else {
log->info_hex(rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d (lower edge last segments)", get_rb_name(), vr_ur); log->info_hex(rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d (lower edge last segments)", get_rb_name(), vr_ur);
rx_sdu->set_timestamp(); rx_sdu->set_timestamp();
@ -769,7 +769,7 @@ void rlc_um::rlc_um_rx::reassemble_rx_sdus()
if (not pdu_belongs_to_rx_sdu()) { if (not pdu_belongs_to_rx_sdu()) {
log->warning("PDU SN=%d lost, stop reassambling SDU (vr_ur_in_rx_sdu=%d)\n", vr_ur_in_rx_sdu+1, vr_ur_in_rx_sdu); log->warning("PDU SN=%d lost, stop reassambling SDU (vr_ur_in_rx_sdu=%d)\n", vr_ur_in_rx_sdu+1, vr_ur_in_rx_sdu);
pdu_lost = false; // Reset flag to not prevent reassembling of further segments pdu_lost = false; // Reset flag to not prevent reassembling of further segments
rx_sdu->reset(); rx_sdu->clear();
} }
// Handle any SDU segments // Handle any SDU segments
@ -788,7 +788,7 @@ void rlc_um::rlc_um_rx::reassemble_rx_sdus()
// Advance data pointers and continue with next segment // Advance data pointers and continue with next segment
rx_window[vr_ur].buf->msg += len; rx_window[vr_ur].buf->msg += len;
rx_window[vr_ur].buf->N_bytes -= len; rx_window[vr_ur].buf->N_bytes -= len;
rx_sdu->reset(); rx_sdu->clear();
// Reset flag, it is safe to process all remaining segments of this PDU // Reset flag, it is safe to process all remaining segments of this PDU
pdu_lost = false; pdu_lost = false;
@ -798,7 +798,7 @@ void rlc_um::rlc_um_rx::reassemble_rx_sdus()
// Check available space in SDU // Check available space in SDU
if ((uint32_t)len > rx_sdu->get_tailroom()) { if ((uint32_t)len > rx_sdu->get_tailroom()) {
log->error("Dropping PDU %d due to buffer mis-alignment (current segment len %d B, received %d B)\n", vr_ur, rx_sdu->N_bytes, len); log->error("Dropping PDU %d due to buffer mis-alignment (current segment len %d B, received %d B)\n", vr_ur, rx_sdu->N_bytes, len);
rx_sdu->reset(); rx_sdu->clear();
goto clean_up_rx_window; goto clean_up_rx_window;
} }
@ -842,7 +842,7 @@ void rlc_um::rlc_um_rx::reassemble_rx_sdus()
// Handle last segment // Handle last segment
if (rx_sdu->N_bytes == 0 && rx_window[vr_ur].header.N_li == 0 && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) { if (rx_sdu->N_bytes == 0 && rx_window[vr_ur].header.N_li == 0 && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) {
log->warning("Dropping PDU %d due to lost start segment\n", vr_ur); log->warning("Dropping PDU %d due to lost start segment\n", vr_ur);
rx_sdu->reset(); rx_sdu->clear();
goto clean_up_rx_window; goto clean_up_rx_window;
} }
@ -862,7 +862,7 @@ void rlc_um::rlc_um_rx::reassemble_rx_sdus()
if(rlc_um_end_aligned(rx_window[vr_ur].header.fi)) { if(rlc_um_end_aligned(rx_window[vr_ur].header.fi)) {
if(pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) { if(pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) {
log->warning("Dropping remainder of lost PDU (update vr_ur last segments)\n"); log->warning("Dropping remainder of lost PDU (update vr_ur last segments)\n");
rx_sdu->reset(); rx_sdu->clear();
} else { } else {
log->info_hex(rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d (update vr_ur last segments)", get_rb_name(), vr_ur); log->info_hex(rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d (update vr_ur last segments)", get_rb_name(), vr_ur);
rx_sdu->set_timestamp(); rx_sdu->set_timestamp();
@ -945,7 +945,7 @@ void rlc_um::rlc_um_rx::timer_expired(uint32_t timeout_id)
pdu_lost = true; pdu_lost = true;
if (rx_sdu != NULL) { if (rx_sdu != NULL) {
rx_sdu->reset(); rx_sdu->clear();
} }
while(RX_MOD_BASE(vr_ur) < RX_MOD_BASE(vr_ux)) { while(RX_MOD_BASE(vr_ur) < RX_MOD_BASE(vr_ux)) {

@ -45,8 +45,8 @@ int main(int argc, char **argv) {
for(uint32_t i=0;i<b2.N_bytes;i++) for(uint32_t i=0;i<b2.N_bytes;i++)
assert(b2.msg[i] == b1.msg[i]); assert(b2.msg[i] == b1.msg[i]);
b1.reset(); b1.clear();
b2.reset(); b2.clear();
memcpy(b1.msg, &pdu2[0], PDU2_LEN); memcpy(b1.msg, &pdu2[0], PDU2_LEN);
b1.N_bytes = PDU2_LEN; b1.N_bytes = PDU2_LEN;

@ -48,8 +48,8 @@ int main(int argc, char **argv) {
for(uint32_t i=0;i<b2.N_bytes;i++) for(uint32_t i=0;i<b2.N_bytes;i++)
assert(b2.msg[i] == b1.msg[i]); assert(b2.msg[i] == b1.msg[i]);
b1.reset(); b1.clear();
b2.reset(); b2.clear();
memset(&h, 0, sizeof(srslte::rlc_umd_pdu_header_t)); memset(&h, 0, sizeof(srslte::rlc_umd_pdu_header_t));
memcpy(b1.msg, &pdu2[0], PDU2_LEN); memcpy(b1.msg, &pdu2[0], PDU2_LEN);

@ -206,7 +206,7 @@ void gtpu::run_thread()
running=true; running=true;
while(run_enable) { while(run_enable) {
pdu->reset(); pdu->clear();
gtpu_log->debug("Waiting for read...\n"); gtpu_log->debug("Waiting for read...\n");
int n = 0; int n = 0;
do{ do{
@ -389,7 +389,7 @@ void gtpu::mch_thread::run_thread()
while(run_enable) { while(run_enable) {
pdu->reset(); pdu->clear();
do{ do{
n = recvfrom(m1u_sd, pdu->msg, SRSENB_MAX_BUFFER_SIZE_BYTES - SRSENB_BUFFER_HEADER_OFFSET, 0, (struct sockaddr *) &src_addr, &addrlen); n = recvfrom(m1u_sd, pdu->msg, SRSENB_MAX_BUFFER_SIZE_BYTES - SRSENB_BUFFER_HEADER_OFFSET, 0, (struct sockaddr *) &src_addr, &addrlen);
} while (n == -1 && errno == EAGAIN); } while (n == -1 && errno == EAGAIN);

@ -263,7 +263,7 @@ void rrc::write_dl_info(uint16_t rnti, srslte::unique_byte_buffer_t sdu)
memcpy(msg_c1->dl_info_transfer().crit_exts.c1().dl_info_transfer_r8().ded_info_type.ded_info_nas().data(), memcpy(msg_c1->dl_info_transfer().crit_exts.c1().dl_info_transfer_r8().ded_info_type.ded_info_nas().data(),
sdu->msg, sdu->N_bytes); sdu->msg, sdu->N_bytes);
sdu->reset(); sdu->clear();
users[rnti].send_dl_dcch(&dl_dcch_msg, std::move(sdu)); users[rnti].send_dl_dcch(&dl_dcch_msg, std::move(sdu));
} else { } else {
@ -483,7 +483,7 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t *payload_len)
pthread_mutex_unlock(&paging_mutex); pthread_mutex_unlock(&paging_mutex);
if (paging_rec->paging_record_list.size() > 0) { if (paging_rec->paging_record_list.size() > 0) {
byte_buf_paging.reset(); byte_buf_paging.clear();
asn1::bit_ref bref(byte_buf_paging.msg, byte_buf_paging.get_tailroom()); asn1::bit_ref bref(byte_buf_paging.msg, byte_buf_paging.get_tailroom());
pcch_msg.pack(bref); pcch_msg.pack(bref);
byte_buf_paging.N_bytes = (uint32_t)bref.distance_bytes(); byte_buf_paging.N_bytes = (uint32_t)bref.distance_bytes();
@ -1047,7 +1047,7 @@ void rrc::ue::parse_ul_dcch(uint32_t lcid, srslte::unique_byte_buffer_t pdu)
parent->log_rrc_message(rb_id_text[lcid], Rx, pdu.get(), ul_dcch_msg); parent->log_rrc_message(rb_id_text[lcid], Rx, pdu.get(), ul_dcch_msg);
// reuse PDU // reuse PDU
pdu->reset(); // FIXME: name collision with byte_buffer reset pdu->clear(); // FIXME: name collision with byte_buffer reset
transaction_id = 0; transaction_id = 0;
@ -1642,7 +1642,7 @@ void rrc::ue::send_connection_reconf_upd(srslte::unique_byte_buffer_t pdu)
sr_get(&phy_cfg->sched_request_cfg.setup().sr_cfg_idx, &phy_cfg->sched_request_cfg.setup().sr_pucch_res_idx); sr_get(&phy_cfg->sched_request_cfg.setup().sr_cfg_idx, &phy_cfg->sched_request_cfg.setup().sr_pucch_res_idx);
pdu->reset(); pdu->clear();
send_dl_dcch(&dl_dcch_msg, std::move(pdu)); send_dl_dcch(&dl_dcch_msg, std::move(pdu));
@ -1776,7 +1776,7 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu)
} }
// Reuse same PDU // Reuse same PDU
pdu->reset(); pdu->clear();
send_dl_dcch(&dl_dcch_msg, std::move(pdu)); send_dl_dcch(&dl_dcch_msg, std::move(pdu));

@ -111,7 +111,7 @@ void s1ap::run_thread()
// S1AP rx loop // S1AP rx loop
while(running) { while(running) {
pdu->reset(); pdu->clear();
pdu->N_bytes = recv(socket_fd, pdu->msg, sz, 0); pdu->N_bytes = recv(socket_fd, pdu->msg, sz, 0);
if(pdu->N_bytes <= 0) { if(pdu->N_bytes <= 0) {

@ -263,7 +263,7 @@ mbms_gw::run_thread()
uint8_t seq = 0; uint8_t seq = 0;
while(m_running) while(m_running)
{ {
msg->reset(); msg->clear();
int n; int n;
do{ do{
n = read(m_sgi_mb_if, msg->msg, SRSLTE_MAX_BUFFER_SIZE_BYTES); n = read(m_sgi_mb_if, msg->msg, SRSLTE_MAX_BUFFER_SIZE_BYTES);

@ -124,7 +124,7 @@ void mme::run_thread()
int s11 = m_mme_gtpc->get_s11(); int s11 = m_mme_gtpc->get_s11();
while (m_running) { while (m_running) {
pdu->reset(); pdu->clear();
int max_fd = std::max(s1mme, s11); int max_fd = std::max(s1mme, s11);
FD_ZERO(&m_set); FD_ZERO(&m_set);

@ -131,8 +131,8 @@ void spgw::run_thread()
max_fd = std::max(max_fd, s11); max_fd = std::max(max_fd, s11);
while (m_running) { while (m_running) {
s1u_msg->reset(); s1u_msg->clear();
s11_msg->reset(); s11_msg->clear();
FD_ZERO(&set); FD_ZERO(&set);
FD_SET(s1u, &set); FD_SET(s1u, &set);

@ -836,7 +836,7 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu)
liblte_mme_pack_activate_default_eps_bearer_context_accept_msg(&act_def_eps_bearer_context_accept, liblte_mme_pack_activate_default_eps_bearer_context_accept_msg(&act_def_eps_bearer_context_accept,
&attach_complete.esm_msg); &attach_complete.esm_msg);
pdu->reset(); pdu->clear();
liblte_mme_pack_attach_complete_msg(&attach_complete, liblte_mme_pack_attach_complete_msg(&attach_complete,
LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED, LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED,
ctxt.tx_count, ctxt.tx_count,
@ -1044,7 +1044,7 @@ void nas::parse_security_mode_command(uint32_t lcid, unique_byte_buffer_t pdu)
} }
// Send response // Send response
pdu->reset(); pdu->clear();
liblte_mme_pack_security_mode_complete_msg( liblte_mme_pack_security_mode_complete_msg(
&sec_mode_comp, &sec_mode_comp,
LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED_WITH_NEW_EPS_SECURITY_CONTEXT, LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED_WITH_NEW_EPS_SECURITY_CONTEXT,

Loading…
Cancel
Save