Commit 875bdaf2 authored by frtabu's avatar frtabu

cppcheck fixes (2)

parent 227a0640
...@@ -247,13 +247,13 @@ int dump_eNB_l2_stats(char *buffer, int length) { ...@@ -247,13 +247,13 @@ int dump_eNB_l2_stats(char *buffer, int length) {
&stat_timer_status_prohibit_timed_out); &stat_timer_status_prohibit_timed_out);
if (rlc_status == RLC_OP_STATUS_OK) { if (rlc_status == RLC_OP_STATUS_OK) {
len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_SDU_TO_TX = %d (bytes %d)\tNB_SDU_TO_TX_DISC %d (bytes %d)\n", len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_SDU_TO_TX = %u (bytes %u)\tNB_SDU_TO_TX_DISC %u (bytes %u)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_tx_pdcp_sdu, stat_tx_pdcp_sdu,
stat_tx_pdcp_bytes, stat_tx_pdcp_bytes,
stat_tx_pdcp_sdu_discarded, stat_tx_pdcp_sdu_discarded,
stat_tx_pdcp_bytes_discarded); stat_tx_pdcp_bytes_discarded);
len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_TX_DATA = %d (bytes %d)\tNB_TX_CONTROL %d (bytes %d)\tNB_TX_RETX %d (bytes %d)\tNB_TX_RETX_BY_STATUS = %d (bytes %d)\n", len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_TX_DATA = %u (bytes %u)\tNB_TX_CONTROL %u (bytes %u)\tNB_TX_RETX %u (bytes %u)\tNB_TX_RETX_BY_STATUS = %u (bytes %u)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_tx_data_pdu, stat_tx_data_pdu,
stat_tx_data_bytes, stat_tx_data_bytes,
...@@ -263,7 +263,7 @@ int dump_eNB_l2_stats(char *buffer, int length) { ...@@ -263,7 +263,7 @@ int dump_eNB_l2_stats(char *buffer, int length) {
stat_tx_retransmit_bytes, stat_tx_retransmit_bytes,
stat_tx_retransmit_pdu_by_status, stat_tx_retransmit_pdu_by_status,
stat_tx_retransmit_bytes_by_status); stat_tx_retransmit_bytes_by_status);
len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_RX_DATA = %d (bytes %d)\tNB_RX_CONTROL %d (bytes %d)\tNB_RX_DUPL %d (bytes %d)\tNB_RX_DROP = %d (bytes %d)\tNB_RX_OUT_OF_WINDOW = %d (bytes %d)\n", len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_RX_DATA = %u (bytes %u)\tNB_RX_CONTROL %u (bytes %u)\tNB_RX_DUPL %u (bytes %u)\tNB_RX_DROP = %u (bytes %u)\tNB_RX_OUT_OF_WINDOW = %u (bytes %u)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_rx_data_pdu, stat_rx_data_pdu,
stat_rx_data_bytes, stat_rx_data_bytes,
...@@ -275,12 +275,12 @@ int dump_eNB_l2_stats(char *buffer, int length) { ...@@ -275,12 +275,12 @@ int dump_eNB_l2_stats(char *buffer, int length) {
stat_rx_data_bytes_dropped, stat_rx_data_bytes_dropped,
stat_rx_data_pdu_out_of_window, stat_rx_data_pdu_out_of_window,
stat_rx_data_bytes_out_of_window); stat_rx_data_bytes_out_of_window);
len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, RX_REODERING_TIMEOUT = %d\tRX_POLL_RET_TIMEOUT %d\tRX_PROHIBIT_TIME_OUT %d\n", len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, RX_REODERING_TIMEOUT = %u\tRX_POLL_RET_TIMEOUT %u\tRX_PROHIBIT_TIME_OUT %u\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_timer_reordering_timed_out, stat_timer_reordering_timed_out,
stat_timer_poll_retransmit_timed_out, stat_timer_poll_retransmit_timed_out,
stat_timer_status_prohibit_timed_out); stat_timer_status_prohibit_timed_out);
len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_SDU_TO_RX = %d (bytes %d)\n", len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_SDU_TO_RX = %u (bytes %u)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_rx_pdcp_sdu, stat_rx_pdcp_sdu,
stat_rx_pdcp_bytes); stat_rx_pdcp_bytes);
...@@ -319,13 +319,13 @@ int dump_eNB_l2_stats(char *buffer, int length) { ...@@ -319,13 +319,13 @@ int dump_eNB_l2_stats(char *buffer, int length) {
&stat_timer_status_prohibit_timed_out); &stat_timer_status_prohibit_timed_out);
if (rlc_status == RLC_OP_STATUS_OK) { if (rlc_status == RLC_OP_STATUS_OK) {
len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_SDU_TO_TX = %d (bytes %d)\tNB_SDU_TO_TX_DISC %d (bytes %d)\n", len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_SDU_TO_TX = %u (bytes %u)\tNB_SDU_TO_TX_DISC %u (bytes %u)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_tx_pdcp_sdu, stat_tx_pdcp_sdu,
stat_tx_pdcp_bytes, stat_tx_pdcp_bytes,
stat_tx_pdcp_sdu_discarded, stat_tx_pdcp_sdu_discarded,
stat_tx_pdcp_bytes_discarded); stat_tx_pdcp_bytes_discarded);
len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_TX_DATA = %d (bytes %d)\tNB_TX_CONTROL %d (bytes %d)\tNB_TX_RETX %d (bytes %d)\tNB_TX_RETX_BY_STATUS = %d (bytes %d)\n", len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_TX_DATA = %u (bytes %u)\tNB_TX_CONTROL %u (bytes %u)\tNB_TX_RETX %u (bytes %u)\tNB_TX_RETX_BY_STATUS = %u (bytes %u)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_tx_data_pdu, stat_tx_data_pdu,
stat_tx_data_bytes, stat_tx_data_bytes,
...@@ -335,7 +335,7 @@ int dump_eNB_l2_stats(char *buffer, int length) { ...@@ -335,7 +335,7 @@ int dump_eNB_l2_stats(char *buffer, int length) {
stat_tx_retransmit_bytes, stat_tx_retransmit_bytes,
stat_tx_retransmit_pdu_by_status, stat_tx_retransmit_pdu_by_status,
stat_tx_retransmit_bytes_by_status); stat_tx_retransmit_bytes_by_status);
len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_RX_DATA = %d (bytes %d)\tNB_RX_CONTROL %d (bytes %d)\tNB_RX_DUPL %d (bytes %d)\tNB_RX_DROP = %d (bytes %d)\tNB_RX_OUT_OF_WINDOW = %d (bytes %d)\n", len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_RX_DATA = %u (bytes %u)\tNB_RX_CONTROL %u (bytes %u)\tNB_RX_DUPL %u (bytes %u)\tNB_RX_DROP = %u (bytes %u)\tNB_RX_OUT_OF_WINDOW = %u (bytes %u)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_rx_data_pdu, stat_rx_data_pdu,
stat_rx_data_bytes, stat_rx_data_bytes,
...@@ -347,12 +347,12 @@ int dump_eNB_l2_stats(char *buffer, int length) { ...@@ -347,12 +347,12 @@ int dump_eNB_l2_stats(char *buffer, int length) {
stat_rx_data_bytes_dropped, stat_rx_data_bytes_dropped,
stat_rx_data_pdu_out_of_window, stat_rx_data_pdu_out_of_window,
stat_rx_data_bytes_out_of_window); stat_rx_data_bytes_out_of_window);
len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, RX_REODERING_TIMEOUT = %d\tRX_POLL_RET_TIMEOUT %d\tRX_PROHIBIT_TIME_OUT %d\n", len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, RX_REODERING_TIMEOUT = %u\tRX_POLL_RET_TIMEOUT %u\tRX_PROHIBIT_TIME_OUT %u\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_timer_reordering_timed_out, stat_timer_reordering_timed_out,
stat_timer_poll_retransmit_timed_out, stat_timer_poll_retransmit_timed_out,
stat_timer_status_prohibit_timed_out); stat_timer_status_prohibit_timed_out);
len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_SDU_TO_RX = %d (bytes %d)\n", len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_SDU_TO_RX = %u (bytes %u)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_rx_pdcp_sdu, stat_rx_pdcp_sdu,
stat_rx_pdcp_bytes); stat_rx_pdcp_bytes);
...@@ -389,9 +389,9 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) { ...@@ -389,9 +389,9 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) {
for (CH_index = 0; CH_index<NB_CNX_UE; CH_index++) { for (CH_index = 0; CH_index<NB_CNX_UE; CH_index++) {
if (UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Active==1) { if (UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Active==1) {
len+=sprintf(&buffer[len],"CH %d: Wideband SINR %d dB---\n", len+=sprintf(&buffer[len],"CH %u: Wideband SINR %d dB---\n",
CH_index,UE_mac_inst[Mod_id].Def_meas[CH_index].Wideband_sinr); CH_index,UE_mac_inst[Mod_id].Def_meas[CH_index].Wideband_sinr);
len+=sprintf(&buffer[len],"CH %d: Subband SINR (dB) :", len+=sprintf(&buffer[len],"CH %u: Subband SINR (dB) :",
CH_index); CH_index);
for (fg=0; fg<NUMBER_OF_MEASUREMENT_SUBBANDS; fg++) { for (fg=0; fg<NUMBER_OF_MEASUREMENT_SUBBANDS; fg++) {
...@@ -452,21 +452,21 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) { ...@@ -452,21 +452,21 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) {
&rx_control_pdu) ; &rx_control_pdu) ;
if (status == RLC_OP_STATUS_OK) { if (status == RLC_OP_STATUS_OK) {
len+=sprintf(&buffer[len],"RLC LCHAN %d, NB_SDU_TO_TX = %d\tNB_SDU_DISC %d\tNB_RX_SDU %d\n", len+=sprintf(&buffer[len],"RLC LCHAN %d, NB_SDU_TO_TX = %u\tNB_SDU_DISC %u\tNB_RX_SDU %u\n",
UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index, UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index,
tx_pdcp_sdu, tx_pdcp_sdu,
tx_pdcp_sdu_discarded, tx_pdcp_sdu_discarded,
rx_sdu); rx_sdu);
len+=sprintf(&buffer[len],"RLC LCHAN %d, NB_TB_TX_DATA = %d\tNB_TB_TX_CONTROL %d\tNB_TX_TB_RETRANS %d", len+=sprintf(&buffer[len],"RLC LCHAN %d, NB_TB_TX_DATA = %u\tNB_TB_TX_CONTROL %u\tNB_TX_TB_RETRANS %u",
UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index, UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index,
tx_data_pdu, tx_data_pdu,
tx_control_pdu, tx_control_pdu,
tx_retransmit_pdu); tx_retransmit_pdu);
len+=sprintf(&buffer[len],"\tRLC LCHAN %d, NB_TX_TB_RETRANS_BY_STATUS = %d\tNB_TX_TB_RETRANS_PADD %d\n", len+=sprintf(&buffer[len],"\tRLC LCHAN %d, NB_TX_TB_RETRANS_BY_STATUS = %u\tNB_TX_TB_RETRANS_PADD %u\n",
UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index, UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index,
tx_retransmit_pdu_by_status, tx_retransmit_pdu_by_status,
tx_retransmit_pdu_unblock); tx_retransmit_pdu_unblock);
len+=sprintf(&buffer[len],"RLC LCHAN %d, NB_RX_DATA = %d\tNB_RX_TB_OUT_WIN %d\tNB_RX_TB_CORRUPT %d\n", len+=sprintf(&buffer[len],"RLC LCHAN %d, NB_RX_DATA = %u\tNB_RX_TB_OUT_WIN %u\tNB_RX_TB_CORRUPT %u\n",
UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index, UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index,
rx_data_pdu, rx_data_pdu,
rx_data_pdu_out_of_window, rx_data_pdu_out_of_window,
...@@ -508,7 +508,7 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) { ...@@ -508,7 +508,7 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) {
for(i=1; i<=NB_CNX_CH; i++) { for(i=1; i<=NB_CNX_CH; i++) {
if (CH_mac_inst[Mod_id].Dcch_lchan[i].Active==1) { if (CH_mac_inst[Mod_id].Dcch_lchan[i].Active==1) {
len+=sprintf(&buffer[len],"\nMR index %d: DL SINR (feedback) %d dB, CQI: %s\n\n", len+=sprintf(&buffer[len],"\nMR index %u: DL SINR (feedback) %d dB, CQI: %s\n\n",
i,//CH_rrc_inst[Mod_id].Info.UE_list[i].L2_id[0], i,//CH_rrc_inst[Mod_id].Info.UE_list[i].L2_id[0],
CH_mac_inst[Mod_id].Def_meas[i].Wideband_sinr, CH_mac_inst[Mod_id].Def_meas[i].Wideband_sinr,
print_cqi(CH_mac_inst[Mod_id].Def_meas[i].cqi)); print_cqi(CH_mac_inst[Mod_id].Def_meas[i].cqi));
...@@ -583,7 +583,7 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) { ...@@ -583,7 +583,7 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) {
} }
*/ */
len+=sprintf(&buffer[len], len+=sprintf(&buffer[len],
"[MAC]LCHAN %d (CNX %d,RAB %d), NB_TX_MAC= %d (%d bits/TTI, %d kbit/s), NB_RX_MAC= %d (errors %d, sacch_errors %d, sach_errors %d, sach_missing %d)\n", "[MAC]LCHAN %d (CNX %u,RAB %u), NB_TX_MAC= %d (%d bits/TTI, %d kbit/s), NB_RX_MAC= %d (errors %d, sacch_errors %d, sach_errors %d, sach_missing %d)\n",
CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Lchan_id.Index, CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Lchan_id.Index,
i,j, i,j,
CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_TX, CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_TX,
......
...@@ -574,7 +574,7 @@ static int _at_response_encode_cnum(char* buffer, const at_response_t* data) ...@@ -574,7 +574,7 @@ static int _at_response_encode_cnum(char* buffer, const at_response_t* data)
} }
offset += sprintf(buffer+offset, "+CNUM: ,%s,%u\r\n", offset += sprintf(buffer+offset, "+CNUM: ,%s,%u\r\n",
cnum->number, cnum->type); cnum->number, (unsigned int)cnum->type);
} }
LOG_FUNC_RETURN (offset); LOG_FUNC_RETURN (offset);
...@@ -939,7 +939,7 @@ static int _at_response_encode_cgdcont(char* buffer, const at_response_t* data) ...@@ -939,7 +939,7 @@ static int _at_response_encode_cgdcont(char* buffer, const at_response_t* data)
/* Display the list of defined PDN contexts */ /* Display the list of defined PDN contexts */
for (i = 0; i < cgdcont->n_pdns; i++) { for (i = 0; i < cgdcont->n_pdns; i++) {
offset += sprintf(buffer+offset, "+CGDCONT: %u", cgdcont->cid[i]); offset += sprintf(buffer+offset, "+CGDCONT: %u", (unsigned int)cgdcont->cid[i]);
if (cgdcont->PDP_type[i] == NET_PDN_TYPE_IPV4) { if (cgdcont->PDP_type[i] == NET_PDN_TYPE_IPV4) {
offset += sprintf(buffer+offset, ",IP"); offset += sprintf(buffer+offset, ",IP");
...@@ -952,7 +952,7 @@ static int _at_response_encode_cgdcont(char* buffer, const at_response_t* data) ...@@ -952,7 +952,7 @@ static int _at_response_encode_cgdcont(char* buffer, const at_response_t* data)
offset += sprintf(buffer+offset, ",%s", cgdcont->APN[i]); offset += sprintf(buffer+offset, ",%s", cgdcont->APN[i]);
/* No data/header compression */ /* No data/header compression */
offset += sprintf(buffer+offset, ",%u,%u\r\n", offset += sprintf(buffer+offset, ",%u,%u\r\n",
AT_CGDCONT_D_COMP_OFF, AT_CGDCONT_H_COMP_OFF); (unsigned int)(AT_CGDCONT_D_COMP_OFF), (unsigned int)(AT_CGDCONT_H_COMP_OFF));
} }
} else if (data->type == AT_COMMAND_TST) { } else if (data->type == AT_COMMAND_TST) {
const at_cgdcont_tst_t * cgdcont = &(data->response.cgdcont.tst); const at_cgdcont_tst_t * cgdcont = &(data->response.cgdcont.tst);
...@@ -963,19 +963,19 @@ static int _at_response_encode_cgdcont(char* buffer, const at_response_t* data) ...@@ -963,19 +963,19 @@ static int _at_response_encode_cgdcont(char* buffer, const at_response_t* data)
/* IPv4 PDN type */ /* IPv4 PDN type */
offset += sprintf(buffer+offset, "+CGDCONT: "); offset += sprintf(buffer+offset, "+CGDCONT: ");
offset += sprintf(buffer+offset, "(1-%u),IP,,,(%u-%u),(%u-%u)", offset += sprintf(buffer+offset, "(1-%d),IP,,,(%d-%d),(%d-%d)",
cgdcont->n_cid, cgdcont->n_cid,
AT_CGDCONT_D_COMP_MIN, AT_CGDCONT_D_COMP_MAX, AT_CGDCONT_D_COMP_MIN, AT_CGDCONT_D_COMP_MAX,
AT_CGDCONT_H_COMP_MIN, AT_CGDCONT_H_COMP_MAX); AT_CGDCONT_H_COMP_MIN, AT_CGDCONT_H_COMP_MAX);
/* IPv6 PDN type */ /* IPv6 PDN type */
offset += sprintf(buffer+offset, "\r\n+CGDCONT: "); offset += sprintf(buffer+offset, "\r\n+CGDCONT: ");
offset += sprintf(buffer+offset, "(1-%u),IPV6,,,(%u-%u),(%u-%u)", offset += sprintf(buffer+offset, "(1-%d),IPV6,,,(%d-%d),(%d-%d)",
cgdcont->n_cid, cgdcont->n_cid,
AT_CGDCONT_D_COMP_MIN, AT_CGDCONT_D_COMP_MAX, AT_CGDCONT_D_COMP_MIN, AT_CGDCONT_D_COMP_MAX,
AT_CGDCONT_H_COMP_MIN, AT_CGDCONT_H_COMP_MAX); AT_CGDCONT_H_COMP_MIN, AT_CGDCONT_H_COMP_MAX);
/* IPv4v6 PDN type */ /* IPv4v6 PDN type */
offset += sprintf(buffer+offset, "\r\n+CGDCONT: "); offset += sprintf(buffer+offset, "\r\n+CGDCONT: ");
offset += sprintf(buffer+offset, "(1-%u),IPV4V6,,,(%u-%u),(%u-%u)", offset += sprintf(buffer+offset, "(1-%d),IPV4V6,,,(%d-%d),(%d-%d)",
cgdcont->n_cid, cgdcont->n_cid,
AT_CGDCONT_D_COMP_MIN, AT_CGDCONT_D_COMP_MAX, AT_CGDCONT_D_COMP_MIN, AT_CGDCONT_D_COMP_MAX,
AT_CGDCONT_H_COMP_MIN, AT_CGDCONT_H_COMP_MAX); AT_CGDCONT_H_COMP_MIN, AT_CGDCONT_H_COMP_MAX);
...@@ -1018,7 +1018,7 @@ static int _at_response_encode_cgact(char* buffer, const at_response_t* data) ...@@ -1018,7 +1018,7 @@ static int _at_response_encode_cgact(char* buffer, const at_response_t* data)
/* Display the list of defined PDN status */ /* Display the list of defined PDN status */
for (i = 0; i < cgact->n_pdns; i++) { for (i = 0; i < cgact->n_pdns; i++) {
offset += sprintf(buffer+offset, "+CGACT: %u,%u\r\n", offset += sprintf(buffer+offset, "+CGACT: %u,%u\r\n",
cgact->cid[i], cgact->state[i]); (unsigned int)cgact->cid[i], (unsigned int)cgact->state[i]);
} }
} else if (data->type == AT_COMMAND_TST) { } else if (data->type == AT_COMMAND_TST) {
if (at_response_format_v1) { if (at_response_format_v1) {
...@@ -1063,33 +1063,36 @@ static int _at_response_encode_cgpaddr(char* buffer, const at_response_t* data) ...@@ -1063,33 +1063,36 @@ static int _at_response_encode_cgpaddr(char* buffer, const at_response_t* data)
/* Display the list of IP addresses assigned to each defined PDN /* Display the list of IP addresses assigned to each defined PDN
* connections */ * connections */
for (i = 0; i < cgpaddr->n_pdns; i++) { for (i = 0; i < cgpaddr->n_pdns; i++) {
offset += sprintf(buffer+offset, "+CGPADDR: %u", cgpaddr->cid[i]); offset += sprintf(buffer+offset, "+CGPADDR: %u", (unsigned int)cgpaddr->cid[i]);
if (cgpaddr->PDP_addr_1[i] != NULL) { if (cgpaddr->PDP_addr_1[i] != NULL) {
/* IPv4 address */ /* IPv4 address */
offset += sprintf(buffer+offset, ",%hhu.%hhu.%hhu.%hhu", offset += sprintf(buffer+offset, ",%hhu.%hhu.%hhu.%hhu",
cgpaddr->PDP_addr_1[i][0], (unsigned int)cgpaddr->PDP_addr_1[i][0],
cgpaddr->PDP_addr_1[i][1], (unsigned int)cgpaddr->PDP_addr_1[i][1],
cgpaddr->PDP_addr_1[i][2], (unsigned int)cgpaddr->PDP_addr_1[i][2],
cgpaddr->PDP_addr_1[i][3]); (unsigned int)cgpaddr->PDP_addr_1[i][3]);
} }
if (cgpaddr->PDP_addr_2[i] != NULL) { if (cgpaddr->PDP_addr_2[i] != NULL) {
/* IPv6 Link-local address prefixe */ /* IPv6 Link-local address prefixe */
offset += sprintf(buffer+offset, offset += sprintf(buffer+offset,
",%hhu.%hhu.%hhu.%hhu.%hhu.%hhu.%hhu.%hhu", ",%hhu.%hhu.%hhu.%hhu.%hhu.%hhu.%hhu.%hhu",
0xfe, 0x80, 0, 0, 0, 0, 0, 0); (unsigned int)0xfe, (unsigned int)0x80,
(unsigned int)0, (unsigned int)0,
(unsigned int)0, (unsigned int)0,
(unsigned int)0, (unsigned int)0);
/* IPv6 Link-local address */ /* IPv6 Link-local address */
offset += sprintf(buffer+offset, offset += sprintf(buffer+offset,
".%hhu.%hhu.%hhu.%hhu.%hhu.%hhu.%hhu.%hhu", ".%hhu.%hhu.%hhu.%hhu.%hhu.%hhu.%hhu.%hhu",
cgpaddr->PDP_addr_2[i][0], (unsigned int)cgpaddr->PDP_addr_2[i][0],
cgpaddr->PDP_addr_2[i][1], (unsigned int)cgpaddr->PDP_addr_2[i][1],
cgpaddr->PDP_addr_2[i][2], (unsigned int)cgpaddr->PDP_addr_2[i][2],
cgpaddr->PDP_addr_2[i][3], (unsigned int)cgpaddr->PDP_addr_2[i][3],
cgpaddr->PDP_addr_2[i][4], (unsigned int)cgpaddr->PDP_addr_2[i][4],
cgpaddr->PDP_addr_2[i][5], (unsigned int)cgpaddr->PDP_addr_2[i][5],
cgpaddr->PDP_addr_2[i][6], (unsigned int)cgpaddr->PDP_addr_2[i][6],
cgpaddr->PDP_addr_2[i][7]); (unsigned int)cgpaddr->PDP_addr_2[i][7]);
} }
offset += sprintf(buffer+offset, "\r\n"); offset += sprintf(buffer+offset, "\r\n");
...@@ -1101,10 +1104,10 @@ static int _at_response_encode_cgpaddr(char* buffer, const at_response_t* data) ...@@ -1101,10 +1104,10 @@ static int _at_response_encode_cgpaddr(char* buffer, const at_response_t* data)
offset += sprintf(buffer, "\r\n"); offset += sprintf(buffer, "\r\n");
} }
offset += sprintf(buffer+offset, "+CGPADDR: %u", cgpaddr->cid[0]); offset += sprintf(buffer+offset, "+CGPADDR: %u", (unsigned int)cgpaddr->cid[0]);
for (i = 1; i < cgpaddr->n_pdns; i++) { for (i = 1; i < cgpaddr->n_pdns; i++) {
offset += sprintf(buffer+offset, ",%u", cgpaddr->cid[i]); offset += sprintf(buffer+offset, ",%u", (unsigned int)cgpaddr->cid[i]);
} }
offset += sprintf(buffer+offset, "\r\n"); offset += sprintf(buffer+offset, "\r\n");
...@@ -1179,7 +1182,7 @@ static int _at_response_encode_cgev(char* buffer, const at_response_t* data) ...@@ -1179,7 +1182,7 @@ static int _at_response_encode_cgev(char* buffer, const at_response_t* data)
if (data->type == AT_COMMAND_GET) { if (data->type == AT_COMMAND_GET) {
const at_cgev_resp_t * cgev = &(data->response.cgev); const at_cgev_resp_t * cgev = &(data->response.cgev);
offset += sprintf(buffer+offset, "+CGEV: %s %u\r\n", offset += sprintf(buffer+offset, "+CGEV: %s %u\r\n",
_at_response_event_str[cgev->code], cgev->cid); _at_response_event_str[cgev->code], (unsigned int)cgev->cid);
} }
LOG_FUNC_RETURN (offset); LOG_FUNC_RETURN (offset);
......
...@@ -181,7 +181,7 @@ int esm_proc_pdn_connectivity(nas_user_t *user, int cid, int is_to_define, ...@@ -181,7 +181,7 @@ int esm_proc_pdn_connectivity(nas_user_t *user, int cid, int is_to_define,
LOG_TRACE(INFO,"ESM-PROC - Define new %s PDN connection to APN %s (cid=%d)", LOG_TRACE(INFO,"ESM-PROC - Define new %s PDN connection to APN %s (cid=%d)",
(pdn_type == ESM_PDN_TYPE_IPV4)? "IPv4" : (pdn_type == ESM_PDN_TYPE_IPV4)? "IPv4" :
(pdn_type == ESM_PDN_TYPE_IPV6)? "IPv6" : "IPv4v6", (pdn_type == ESM_PDN_TYPE_IPV6)? "IPv6" : "IPv4v6",
apn->value, cid); (apn!=NULL)?apn->value:0, cid);
if (is_emergency && esm_data->emergency) { if (is_emergency && esm_data->emergency) {
/* The UE shall not request additional PDN connection for /* The UE shall not request additional PDN connection for
......
...@@ -90,6 +90,7 @@ extern int asn1_xer_print; ...@@ -90,6 +90,7 @@ extern int asn1_xer_print;
# define S1AP_DEBUG(x, args...) do { fprintf(stdout, "[S1AP][D]"x, ##args); } while(0) # define S1AP_DEBUG(x, args...) do { fprintf(stdout, "[S1AP][D]"x, ##args); } while(0)
#endif #endif
#define S1AP_FIND_PROTOCOLIE_BY_ID(IE_TYPE, ie, container, IE_ID, mandatory) \ #define S1AP_FIND_PROTOCOLIE_BY_ID(IE_TYPE, ie, container, IE_ID, mandatory) \
do {\ do {\
IE_TYPE **ptr; \ IE_TYPE **ptr; \
...@@ -102,9 +103,11 @@ extern int asn1_xer_print; ...@@ -102,9 +103,11 @@ extern int asn1_xer_print;
break; \ break; \
} \ } \
} \ } \
if (mandatory) DevAssert(ie != NULL); \ if (ie == NULL ) { \
S1AP_ERROR("S1AP_FIND_PROTOCOLIE_BY_ID: %s %d: ie is NULL\n",__FILE__,__LINE__);\
if (mandatory) _Assert_Exit_ \
} \
} while(0) } while(0)
/** \brief Function callback prototype. /** \brief Function callback prototype.
**/ **/
typedef int (*s1ap_message_decoded_callback)( typedef int (*s1ap_message_decoded_callback)(
......
...@@ -260,15 +260,17 @@ int s1ap_eNB_handle_s1_setup_failure(uint32_t assoc_id, ...@@ -260,15 +260,17 @@ int s1ap_eNB_handle_s1_setup_failure(uint32_t assoc_id,
} }
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupFailureIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupFailureIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_Cause, true); S1AP_ProtocolIE_ID_id_Cause,true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
if ((ie->value.choice.Cause.present == S1AP_Cause_PR_misc) && if ((ie->value.choice.Cause.present == S1AP_Cause_PR_misc) &&
(ie->value.choice.Cause.choice.misc == S1AP_CauseMisc_unspecified)) { (ie->value.choice.Cause.choice.misc == S1AP_CauseMisc_unspecified)) {
S1AP_WARN("Received s1 setup failure for MME... MME is not ready\n"); S1AP_WARN("Received s1 setup failure for MME... MME is not ready\n");
} else { } else {
S1AP_ERROR("Received s1 setup failure for MME... please check your parameters\n"); S1AP_ERROR("Received s1 setup failure for MME... please check your parameters\n");
} }
} else {
return -1;
}
mme_desc_p->state = S1AP_ENB_STATE_WAITING; mme_desc_p->state = S1AP_ENB_STATE_WAITING;
s1ap_handle_s1_setup_message(mme_desc_p, 0); s1ap_handle_s1_setup_message(mme_desc_p, 0);
return 0; return 0;
...@@ -303,6 +305,7 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t assoc_id, ...@@ -303,6 +305,7 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t assoc_id,
/* The list of served gummei can contain at most 8 elements. /* The list of served gummei can contain at most 8 elements.
* LTE related gummei is the first element in the list, i.e with an id of 0. * LTE related gummei is the first element in the list, i.e with an id of 0.
*/ */
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
S1AP_DEBUG("servedGUMMEIs.list.count %d\n", ie->value.choice.ServedGUMMEIs.list.count); S1AP_DEBUG("servedGUMMEIs.list.count %d\n", ie->value.choice.ServedGUMMEIs.list.count);
DevAssert(ie->value.choice.ServedGUMMEIs.list.count > 0); DevAssert(ie->value.choice.ServedGUMMEIs.list.count > 0);
DevAssert(ie->value.choice.ServedGUMMEIs.list.count <= S1AP_maxnoofRATs); DevAssert(ie->value.choice.ServedGUMMEIs.list.count <= S1AP_maxnoofRATs);
...@@ -351,11 +354,17 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t assoc_id, ...@@ -351,11 +354,17 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t assoc_id,
STAILQ_INSERT_TAIL(&mme_desc_p->served_gummei, new_gummei_p, next); STAILQ_INSERT_TAIL(&mme_desc_p->served_gummei, new_gummei_p, next);
} }
} else {
return -1;
}
/* Set the capacity of this MME */ /* Set the capacity of this MME */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupResponseIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupResponseIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_RelativeMMECapacity, true); S1AP_ProtocolIE_ID_id_RelativeMMECapacity, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
mme_desc_p->relative_mme_capacity = ie->value.choice.RelativeMMECapacity; mme_desc_p->relative_mme_capacity = ie->value.choice.RelativeMMECapacity;
} else {
return -1;
}
/* Optionaly set the mme name */ /* Optionaly set the mme name */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupResponseIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupResponseIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_MMEname, false); S1AP_ProtocolIE_ID_id_MMEname, false);
...@@ -399,12 +408,11 @@ int s1ap_eNB_handle_error_indication(uint32_t assoc_id, ...@@ -399,12 +408,11 @@ int s1ap_eNB_handle_error_indication(uint32_t assoc_id,
"MME context\n", assoc_id); "MME context\n", assoc_id);
return -1; return -1;
} }
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_ErrorIndicationIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_ErrorIndicationIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, false); S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, false);
/* optional */ /* optional */
if (!ie) { if (ie != NULL) {
S1AP_WARN("Received S1 Error indication MME UE S1AP ID 0x%lx\n", ie->value.choice.MME_UE_S1AP_ID); S1AP_WARN("Received S1 Error indication MME UE S1AP ID 0x%lx\n", ie->value.choice.MME_UE_S1AP_ID);
} }
...@@ -412,7 +420,7 @@ int s1ap_eNB_handle_error_indication(uint32_t assoc_id, ...@@ -412,7 +420,7 @@ int s1ap_eNB_handle_error_indication(uint32_t assoc_id,
S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, false); S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, false);
/* optional */ /* optional */
if (!ie) { if (ie != NULL) {
S1AP_WARN("Received S1 Error indication eNB UE S1AP ID 0x%lx\n", ie->value.choice.ENB_UE_S1AP_ID); S1AP_WARN("Received S1 Error indication eNB UE S1AP ID 0x%lx\n", ie->value.choice.ENB_UE_S1AP_ID);
} }
...@@ -744,12 +752,16 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id, ...@@ -744,12 +752,16 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id,
/* id-MME-UE-S1AP-ID */ /* id-MME-UE-S1AP-ID */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true); S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID; mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID;
} else {
return -1;
}
/* id-eNB-UE-S1AP-ID */ /* id-eNB-UE-S1AP-ID */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true); S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID; enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID;
if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance, if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance,
enb_ue_s1ap_id)) == NULL) { enb_ue_s1ap_id)) == NULL) {
S1AP_ERROR("[SCTP %d] Received initial context setup request for non " S1AP_ERROR("[SCTP %d] Received initial context setup request for non "
...@@ -757,6 +769,9 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id, ...@@ -757,6 +769,9 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id,
enb_ue_s1ap_id); enb_ue_s1ap_id);
return -1; return -1;
} }
} else {
return -1;
}
/* Initial context request = UE-related procedure -> stream != 0 */ /* Initial context request = UE-related procedure -> stream != 0 */
if (stream == 0) { if (stream == 0) {
...@@ -774,13 +789,18 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id, ...@@ -774,13 +789,18 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id,
/* id-uEaggregateMaximumBitrate */ /* id-uEaggregateMaximumBitrate */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_uEaggregateMaximumBitrate, true); S1AP_ProtocolIE_ID_id_uEaggregateMaximumBitrate, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
asn_INTEGER2ulong(&(ie->value.choice.UEAggregateMaximumBitrate.uEaggregateMaximumBitRateUL), asn_INTEGER2ulong(&(ie->value.choice.UEAggregateMaximumBitrate.uEaggregateMaximumBitRateUL),
&(S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).ue_ambr.br_ul)); &(S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).ue_ambr.br_ul));
asn_INTEGER2ulong(&(ie->value.choice.UEAggregateMaximumBitrate.uEaggregateMaximumBitRateDL), asn_INTEGER2ulong(&(ie->value.choice.UEAggregateMaximumBitrate.uEaggregateMaximumBitRateDL),
&(S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).ue_ambr.br_dl)); &(S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).ue_ambr.br_dl));
/* id-E-RABToBeSetupListCtxtSUReq */ /* id-E-RABToBeSetupListCtxtSUReq */
} else {
return -1;
}
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_E_RABToBeSetupListCtxtSUReq, true); S1AP_ProtocolIE_ID_id_E_RABToBeSetupListCtxtSUReq, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).nb_of_e_rabs = S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).nb_of_e_rabs =
ie->value.choice.E_RABToBeSetupListCtxtSUReq.list.count; ie->value.choice.E_RABToBeSetupListCtxtSUReq.list.count;
...@@ -817,21 +837,31 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id, ...@@ -817,21 +837,31 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id,
item_p->e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionCapability; item_p->e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionCapability;
S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].qos.allocation_retention_priority.pre_emp_vulnerability = S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].qos.allocation_retention_priority.pre_emp_vulnerability =
item_p->e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionVulnerability; item_p->e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionVulnerability;
} /* for i... */
} else {/* ie != NULL */
return -1;
} }
/* id-UESecurityCapabilities */ /* id-UESecurityCapabilities */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_UESecurityCapabilities, true); S1AP_ProtocolIE_ID_id_UESecurityCapabilities, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).security_capabilities.encryption_algorithms = S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).security_capabilities.encryption_algorithms =
BIT_STRING_to_uint16(&ie->value.choice.UESecurityCapabilities.encryptionAlgorithms); BIT_STRING_to_uint16(&ie->value.choice.UESecurityCapabilities.encryptionAlgorithms);
S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).security_capabilities.integrity_algorithms = S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).security_capabilities.integrity_algorithms =
BIT_STRING_to_uint16(&ie->value.choice.UESecurityCapabilities.integrityProtectionAlgorithms); BIT_STRING_to_uint16(&ie->value.choice.UESecurityCapabilities.integrityProtectionAlgorithms);
/* id-SecurityKey : Copy the security key */ /* id-SecurityKey : Copy the security key */
} else {/* ie != NULL */
return -1;
}
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_SecurityKey, true); S1AP_ProtocolIE_ID_id_SecurityKey, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
memcpy(&S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).security_key, memcpy(&S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).security_key,
ie->value.choice.SecurityKey.buf, ie->value.choice.SecurityKey.size); ie->value.choice.SecurityKey.buf, ie->value.choice.SecurityKey.size);
itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p); itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p);
} else {/* ie != NULL */
return -1;
}
return 0; return 0;
} }
...@@ -858,7 +888,7 @@ int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id, ...@@ -858,7 +888,7 @@ int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id,
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_UEContextReleaseCommand_IEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_UEContextReleaseCommand_IEs_t, ie, container,
S1AP_ProtocolIE_ID_id_UE_S1AP_IDs, true); S1AP_ProtocolIE_ID_id_UE_S1AP_IDs, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
switch (ie->value.choice.UE_S1AP_IDs.present) { switch (ie->value.choice.UE_S1AP_IDs.present) {
case S1AP_UE_S1AP_IDs_PR_uE_S1AP_ID_pair: case S1AP_UE_S1AP_IDs_PR_uE_S1AP_ID_pair:
enb_ue_s1ap_id = ie->value.choice.UE_S1AP_IDs.choice.uE_S1AP_ID_pair.eNB_UE_S1AP_ID; enb_ue_s1ap_id = ie->value.choice.UE_S1AP_IDs.choice.uE_S1AP_ID_pair.eNB_UE_S1AP_ID;
...@@ -911,7 +941,9 @@ int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id, ...@@ -911,7 +941,9 @@ int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id,
S1AP_ERROR("S1AP_UE_CONTEXT_RELEASE_COMMAND not processed, missing info elements"); S1AP_ERROR("S1AP_UE_CONTEXT_RELEASE_COMMAND not processed, missing info elements");
return -1; return -1;
} }
} else {
return -1;
}
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_UEContextReleaseCommand_IEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_UEContextReleaseCommand_IEs_t, ie, container,
S1AP_ProtocolIE_ID_id_Cause, true); S1AP_ProtocolIE_ID_id_Cause, true);
/* TBD */ /* TBD */
...@@ -941,12 +973,19 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, ...@@ -941,12 +973,19 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id,
/* id-MME-UE-S1AP-ID */ /* id-MME-UE-S1AP-ID */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABSetupRequestIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABSetupRequestIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true); S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID; mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID;
} else {
return -1;
}
/* id-eNB-UE-S1AP-ID */ /* id-eNB-UE-S1AP-ID */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABSetupRequestIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABSetupRequestIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true); S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID; enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID;
} else {
return -1;
}
if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance, if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance,
enb_ue_s1ap_id)) == NULL) { enb_ue_s1ap_id)) == NULL) {
S1AP_ERROR("[SCTP %d] Received initial context setup request for non " S1AP_ERROR("[SCTP %d] Received initial context setup request for non "
...@@ -975,6 +1014,7 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, ...@@ -975,6 +1014,7 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id,
S1AP_E_RAB_SETUP_REQ(message_p).eNB_ue_s1ap_id = enb_ue_s1ap_id; S1AP_E_RAB_SETUP_REQ(message_p).eNB_ue_s1ap_id = enb_ue_s1ap_id;
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABSetupRequestIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABSetupRequestIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_E_RABToBeSetupListBearerSUReq, true); S1AP_ProtocolIE_ID_id_E_RABToBeSetupListBearerSUReq, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
S1AP_E_RAB_SETUP_REQ(message_p).nb_e_rabs_tosetup = S1AP_E_RAB_SETUP_REQ(message_p).nb_e_rabs_tosetup =
ie->value.choice.E_RABToBeSetupListBearerSUReq.list.count; ie->value.choice.E_RABToBeSetupListBearerSUReq.list.count;
...@@ -994,7 +1034,6 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, ...@@ -994,7 +1034,6 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id,
S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.length = 0; S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.length = 0;
S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.buffer = NULL; S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.buffer = NULL;
S1AP_WARN("NAS PDU is not provided, generate a E_RAB_SETUP Failure (TBD) back to MME \n"); S1AP_WARN("NAS PDU is not provided, generate a E_RAB_SETUP Failure (TBD) back to MME \n");
// return -1;
} }
/* Set the transport layer address */ /* Set the transport layer address */
...@@ -1017,9 +1056,11 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, ...@@ -1017,9 +1056,11 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id,
item_p->e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionCapability; item_p->e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionCapability;
S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].qos.allocation_retention_priority.pre_emp_vulnerability = S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].qos.allocation_retention_priority.pre_emp_vulnerability =
item_p->e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionVulnerability; item_p->e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionVulnerability;
} } /* for i... */
itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p); itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p);
} else {
return -1;
}
return 0; return 0;
} }
...@@ -1063,15 +1104,19 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id, ...@@ -1063,15 +1104,19 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id,
/* id-UEIdentityIndexValue : convert UE Identity Index value */ /* id-UEIdentityIndexValue : convert UE Identity Index value */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_UEIdentityIndexValue, true); S1AP_ProtocolIE_ID_id_UEIdentityIndexValue, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
S1AP_PAGING_IND(message_p).ue_index_value = BIT_STRING_to_uint32(&ie->value.choice.UEIdentityIndexValue); S1AP_PAGING_IND(message_p).ue_index_value = BIT_STRING_to_uint32(&ie->value.choice.UEIdentityIndexValue);
S1AP_DEBUG("[SCTP %d] Received Paging ue_index_value (%d)\n", S1AP_DEBUG("[SCTP %d] Received Paging ue_index_value (%d)\n",
assoc_id,(uint32_t)S1AP_PAGING_IND(message_p).ue_index_value); assoc_id,(uint32_t)S1AP_PAGING_IND(message_p).ue_index_value);
S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.mme_code = 0; S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.mme_code = 0;
S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.m_tmsi = 0; S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.m_tmsi = 0;
} else {
return -1;
}
/* id-UEPagingID */ /* id-UEPagingID */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_UEPagingID, true); S1AP_ProtocolIE_ID_id_UEPagingID, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
/* convert UE Paging Identity */ /* convert UE Paging Identity */
if (ie->value.choice.UEPagingID.present == S1AP_UEPagingID_PR_s_TMSI) { if (ie->value.choice.UEPagingID.present == S1AP_UEPagingID_PR_s_TMSI) {
S1AP_PAGING_IND(message_p).ue_paging_identity.presenceMask = UE_PAGING_IDENTITY_s_tmsi; S1AP_PAGING_IND(message_p).ue_paging_identity.presenceMask = UE_PAGING_IDENTITY_s_tmsi;
...@@ -1096,18 +1141,21 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id, ...@@ -1096,18 +1141,21 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id,
} else { } else {
S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length++; S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length++;
} }
} } /* for i... */
if (S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length >= S1AP_IMSI_LENGTH) { if (S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length >= S1AP_IMSI_LENGTH) {
/* invalid paging_p->uePagingID.choise.iMSI.size */ /* invalid paging_p->uePagingID.choise.iMSI.size */
S1AP_ERROR("[SCTP %d] Received Paging : uePagingID.choise.iMSI.size(%d) is over IMSI length(%d)\n", assoc_id, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length, S1AP_IMSI_LENGTH); S1AP_ERROR("[SCTP %d] Received Paging : uePagingID.choise.iMSI.size(%d) is over IMSI length(%d)\n", assoc_id, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length, S1AP_IMSI_LENGTH);
return -1; return -1;
} }
} else { } else { /* of if (ie->value.choice.UEPagingID.present == S1AP_UEPagingID_PR_iMSI) */
/* invalid paging_p->uePagingID.present */ /* invalid paging_p->uePagingID.present */
S1AP_ERROR("[SCTP %d] Received Paging : uePagingID.present(%d) is unknown\n", assoc_id, ie->value.choice.UEPagingID.present); S1AP_ERROR("[SCTP %d] Received Paging : uePagingID.present(%d) is unknown\n", assoc_id, ie->value.choice.UEPagingID.present);
return -1; return -1;
} }
} else { /* of ie != NULL */
return -1;
}
S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_256; S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_256;
/* id-pagingDRX */ /* id-pagingDRX */
...@@ -1124,7 +1172,7 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id, ...@@ -1124,7 +1172,7 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id,
/* */ /* */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_CNDomain, true); S1AP_ProtocolIE_ID_id_CNDomain, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
/* id-CNDomain : convert cnDomain */ /* id-CNDomain : convert cnDomain */
if (ie->value.choice.CNDomain == S1AP_CNDomain_ps) { if (ie->value.choice.CNDomain == S1AP_CNDomain_ps) {
S1AP_PAGING_IND(message_p).cn_domain = CN_DOMAIN_PS; S1AP_PAGING_IND(message_p).cn_domain = CN_DOMAIN_PS;
...@@ -1135,15 +1183,17 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id, ...@@ -1135,15 +1183,17 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id,
S1AP_ERROR("[SCTP %d] Received Paging : cnDomain(%ld) is unknown\n", assoc_id, ie->value.choice.CNDomain); S1AP_ERROR("[SCTP %d] Received Paging : cnDomain(%ld) is unknown\n", assoc_id, ie->value.choice.CNDomain);
return -1; return -1;
} }
} else {
return -1;
}
memset (&S1AP_PAGING_IND(message_p).plmn_identity[0], 0, sizeof(plmn_identity_t)*256); memset (&S1AP_PAGING_IND(message_p).plmn_identity[0], 0, sizeof(plmn_identity_t)*256);
memset (&S1AP_PAGING_IND(message_p).tac[0], 0, sizeof(int16_t)*256); memset (&S1AP_PAGING_IND(message_p).tac[0], 0, sizeof(int16_t)*256);
S1AP_PAGING_IND(message_p).tai_size = 0; S1AP_PAGING_IND(message_p).tai_size = 0;
/* id-TAIList */ /* id-TAIList */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_TAIList, true); S1AP_ProtocolIE_ID_id_TAIList, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
S1AP_INFO("[SCTP %d] Received Paging taiList: count %d\n", assoc_id, ie->value.choice.TAIList.list.count); S1AP_INFO("[SCTP %d] Received Paging taiList: count %d\n", assoc_id, ie->value.choice.TAIList.list.count);
for (int i = 0; i < ie->value.choice.TAIList.list.count; i++) { for (int i = 0; i < ie->value.choice.TAIList.list.count; i++) {
S1AP_TAIItem_t *item_p; S1AP_TAIItem_t *item_p;
item_p = &(((S1AP_TAIItemIEs_t *)ie->value.choice.TAIList.list.array[i])->value.choice.TAIItem); item_p = &(((S1AP_TAIItemIEs_t *)ie->value.choice.TAIList.list.array[i])->value.choice.TAIItem);
...@@ -1157,6 +1207,9 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id, ...@@ -1157,6 +1207,9 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id,
S1AP_PAGING_IND(message_p).plmn_identity[i].mnc, S1AP_PAGING_IND(message_p).plmn_identity[i].mnc,
S1AP_PAGING_IND(message_p).tac[i]); S1AP_PAGING_IND(message_p).tac[i]);
} }
} else {
return -1;
}
//paging parameter values //paging parameter values
S1AP_DEBUG("[SCTP %d] Received Paging parameters: ue_index_value %d cn_domain %d paging_drx %d paging_priority %d\n",assoc_id, S1AP_DEBUG("[SCTP %d] Received Paging parameters: ue_index_value %d cn_domain %d paging_drx %d paging_priority %d\n",assoc_id,
...@@ -1197,12 +1250,19 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, ...@@ -1197,12 +1250,19 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id,
/* id-MME-UE-S1AP-ID */ /* id-MME-UE-S1AP-ID */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true); S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID; mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID;
} else {
return -1;
}
/* id-eNB-UE-S1AP-ID */ /* id-eNB-UE-S1AP-ID */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true); S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID; enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID;
} else {
return -1;
}
if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance, if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance,
enb_ue_s1ap_id)) == NULL) { enb_ue_s1ap_id)) == NULL) {
S1AP_ERROR("[SCTP %d] Received E-RAB modify request for non " S1AP_ERROR("[SCTP %d] Received E-RAB modify request for non "
...@@ -1227,7 +1287,7 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, ...@@ -1227,7 +1287,7 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id,
S1AP_E_RAB_MODIFY_RESP (message_p).eNB_ue_s1ap_id = enb_ue_s1ap_id; S1AP_E_RAB_MODIFY_RESP (message_p).eNB_ue_s1ap_id = enb_ue_s1ap_id;
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_E_RABToBeModifiedListBearerModReq, true); S1AP_ProtocolIE_ID_id_E_RABToBeModifiedListBearerModReq, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
for(nb_of_e_rabs_failed = 0; nb_of_e_rabs_failed < ie->value.choice.E_RABToBeModifiedListBearerModReq.list.count; nb_of_e_rabs_failed++) { for(nb_of_e_rabs_failed = 0; nb_of_e_rabs_failed < ie->value.choice.E_RABToBeModifiedListBearerModReq.list.count; nb_of_e_rabs_failed++) {
S1AP_E_RABToBeModifiedItemBearerModReq_t *item_p; S1AP_E_RABToBeModifiedItemBearerModReq_t *item_p;
item_p = &(((S1AP_E_RABToBeModifiedItemBearerModReqIEs_t *) item_p = &(((S1AP_E_RABToBeModifiedItemBearerModReqIEs_t *)
...@@ -1236,7 +1296,9 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, ...@@ -1236,7 +1296,9 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id,
S1AP_E_RAB_MODIFY_RESP(message_p).e_rabs_failed[nb_of_e_rabs_failed].cause = S1AP_Cause_PR_radioNetwork; S1AP_E_RAB_MODIFY_RESP(message_p).e_rabs_failed[nb_of_e_rabs_failed].cause = S1AP_Cause_PR_radioNetwork;
S1AP_E_RAB_MODIFY_RESP(message_p).e_rabs_failed[nb_of_e_rabs_failed].cause_value = S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id; S1AP_E_RAB_MODIFY_RESP(message_p).e_rabs_failed[nb_of_e_rabs_failed].cause_value = S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id;
} }
} else {
return -1;
}
S1AP_E_RAB_MODIFY_RESP(message_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed; S1AP_E_RAB_MODIFY_RESP(message_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed;
s1ap_eNB_e_rab_modify_resp(mme_desc_p->s1ap_eNB_instance->instance, s1ap_eNB_e_rab_modify_resp(mme_desc_p->s1ap_eNB_instance->instance,
&S1AP_E_RAB_MODIFY_RESP(message_p)); &S1AP_E_RAB_MODIFY_RESP(message_p));
...@@ -1251,6 +1313,7 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, ...@@ -1251,6 +1313,7 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id,
/* id-E-RABToBeModifiedListBearerModReq */ /* id-E-RABToBeModifiedListBearerModReq */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_E_RABToBeModifiedListBearerModReq, true); S1AP_ProtocolIE_ID_id_E_RABToBeModifiedListBearerModReq, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
S1AP_E_RAB_MODIFY_REQ(message_p).nb_e_rabs_tomodify = S1AP_E_RAB_MODIFY_REQ(message_p).nb_e_rabs_tomodify =
ie->value.choice.E_RABToBeModifiedListBearerModReq.list.count; ie->value.choice.E_RABToBeModifiedListBearerModReq.list.count;
...@@ -1282,6 +1345,9 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, ...@@ -1282,6 +1345,9 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id,
} }
itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p); itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p);
} else { /* of if (ie != NULL)*/
return -1;
}
return 0; return 0;
} }
// handle e-rab release command and send it to rrc_end // handle e-rab release command and send it to rrc_end
...@@ -1308,12 +1374,19 @@ int s1ap_eNB_handle_e_rab_release_command(uint32_t assoc_id, ...@@ -1308,12 +1374,19 @@ int s1ap_eNB_handle_e_rab_release_command(uint32_t assoc_id,
/* id-MME-UE-S1AP-ID */ /* id-MME-UE-S1AP-ID */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABReleaseCommandIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABReleaseCommandIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true); S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID; mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID;
} else {
return -1;
}
/* id-eNB-UE-S1AP-ID */ /* id-eNB-UE-S1AP-ID */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABReleaseCommandIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABReleaseCommandIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true); S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID; enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID;
} else {
return -1;
}
if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance, if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance,
enb_ue_s1ap_id)) == NULL) { enb_ue_s1ap_id)) == NULL) {
S1AP_ERROR("[SCTP %d] Received E-RAB release command for non existing UE context 0x%06lx\n", assoc_id, S1AP_ERROR("[SCTP %d] Received E-RAB release command for non existing UE context 0x%06lx\n", assoc_id,
...@@ -1359,6 +1432,7 @@ int s1ap_eNB_handle_e_rab_release_command(uint32_t assoc_id, ...@@ -1359,6 +1432,7 @@ int s1ap_eNB_handle_e_rab_release_command(uint32_t assoc_id,
/* id-E-RABToBeReleasedList */ /* id-E-RABToBeReleasedList */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABReleaseCommandIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABReleaseCommandIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_E_RABToBeReleasedList, true); S1AP_ProtocolIE_ID_id_E_RABToBeReleasedList, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
S1AP_E_RAB_RELEASE_COMMAND(message_p).nb_e_rabs_torelease = ie->value.choice.E_RABList.list.count; S1AP_E_RAB_RELEASE_COMMAND(message_p).nb_e_rabs_torelease = ie->value.choice.E_RABList.list.count;
for (i = 0; i < ie->value.choice.E_RABList.list.count; i++) { for (i = 0; i < ie->value.choice.E_RABList.list.count; i++) {
...@@ -1367,7 +1441,9 @@ int s1ap_eNB_handle_e_rab_release_command(uint32_t assoc_id, ...@@ -1367,7 +1441,9 @@ int s1ap_eNB_handle_e_rab_release_command(uint32_t assoc_id,
S1AP_E_RAB_RELEASE_COMMAND(message_p).e_rab_release_params[i].e_rab_id = item_p->e_RAB_ID; S1AP_E_RAB_RELEASE_COMMAND(message_p).e_rab_release_params[i].e_rab_id = item_p->e_RAB_ID;
S1AP_DEBUG("[SCTP] Received E-RAB release command for e-rab id %ld\n", item_p->e_RAB_ID); S1AP_DEBUG("[SCTP] Received E-RAB release command for e-rab id %ld\n", item_p->e_RAB_ID);
} }
} else {
return -1;
}
itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p); itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p);
return 0; return 0;
} }
...@@ -177,7 +177,7 @@ int s1ap_eNB_handle_nas_first_req( ...@@ -177,7 +177,7 @@ int s1ap_eNB_handle_nas_first_req(
if ((collision_p = RB_INSERT(s1ap_ue_map, &instance_p->s1ap_ue_head, ue_desc_p)) if ((collision_p = RB_INSERT(s1ap_ue_map, &instance_p->s1ap_ue_head, ue_desc_p))
== NULL) { == NULL) {
S1AP_DEBUG("Found usable eNB_ue_s1ap_id: 0x%06x %d(10)\n", S1AP_DEBUG("Found usable eNB_ue_s1ap_id: 0x%06x %u(10)\n",
ue_desc_p->eNB_ue_s1ap_id, ue_desc_p->eNB_ue_s1ap_id,
ue_desc_p->eNB_ue_s1ap_id); ue_desc_p->eNB_ue_s1ap_id);
/* Break the loop as the id is not already used by another UE */ /* Break the loop as the id is not already used by another UE */
...@@ -501,11 +501,18 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id, ...@@ -501,11 +501,18 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id,
container = &pdu->choice.initiatingMessage.value.choice.DownlinkNASTransport; container = &pdu->choice.initiatingMessage.value.choice.DownlinkNASTransport;
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container,
S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true); S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true);
if (ie == NULL) { /* checked by macro, but cppcheck doesn't see it */
return -1;
} else {
mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID; mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID;
}
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container,
S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true); S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true);
if (ie == NULL) { /* checked by macro, but cppcheck doesn't see it */
return -1;
} else {
enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID; enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID;
}
if ((ue_desc_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance, if ((ue_desc_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance,
enb_ue_s1ap_id)) == NULL) { enb_ue_s1ap_id)) == NULL) {
MSC_LOG_RX_DISCARDED_MESSAGE( MSC_LOG_RX_DISCARDED_MESSAGE(
...@@ -555,14 +562,19 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id, ...@@ -555,14 +562,19 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id,
MSC_AS_TIME_FMT" downlinkNASTransport eNB_ue_s1ap_id %u mme_ue_s1ap_id %u", MSC_AS_TIME_FMT" downlinkNASTransport eNB_ue_s1ap_id %u mme_ue_s1ap_id %u",
assoc_id, assoc_id,
mme_ue_s1ap_id); mme_ue_s1ap_id);
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container,
S1AP_ProtocolIE_ID_id_NAS_PDU, true); S1AP_ProtocolIE_ID_id_NAS_PDU, true);
/* Forward the NAS PDU to RRC */ /* Forward the NAS PDU to RRC */
if (ie != NULL) { /* checked by macro, but cppcheck doesn't see it */
s1ap_eNB_itti_send_nas_downlink_ind(s1ap_eNB_instance->instance, s1ap_eNB_itti_send_nas_downlink_ind(s1ap_eNB_instance->instance,
ue_desc_p->ue_initial_id, ue_desc_p->ue_initial_id,
ue_desc_p->eNB_ue_s1ap_id, ue_desc_p->eNB_ue_s1ap_id,
ie->value.choice.NAS_PDU.buf, ie->value.choice.NAS_PDU.buf,
ie->value.choice.NAS_PDU.size); ie->value.choice.NAS_PDU.size);
} else {
return -1;
}
return 0; return 0;
} }
......
...@@ -57,11 +57,11 @@ int s1ap_eNB_handle_overload_start(uint32_t assoc_id, ...@@ -57,11 +57,11 @@ int s1ap_eNB_handle_overload_start(uint32_t assoc_id,
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_OverloadStartIEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_OverloadStartIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_OverloadResponse, true); S1AP_ProtocolIE_ID_id_OverloadResponse, true);
if (ie != NULL) {
DevCheck(ie->value.choice.OverloadResponse.present == DevCheck(ie->value.choice.OverloadResponse.present ==
S1AP_OverloadResponse_PR_overloadAction, S1AP_OverloadResponse_PR_overloadAction,
S1AP_OverloadResponse_PR_overloadAction, 0, 0); S1AP_OverloadResponse_PR_overloadAction, 0, 0);
}
/* Non UE-associated signalling -> stream 0 */ /* Non UE-associated signalling -> stream 0 */
DevCheck(stream == 0, stream, 0, 0); DevCheck(stream == 0, stream, 0, 0);
......
...@@ -119,8 +119,9 @@ int s1ap_eNB_handle_trace_start(uint32_t assoc_id, ...@@ -119,8 +119,9 @@ int s1ap_eNB_handle_trace_start(uint32_t assoc_id,
mme_ref_p = s1ap_eNB_get_MME(NULL, assoc_id, 0); mme_ref_p = s1ap_eNB_get_MME(NULL, assoc_id, 0);
DevAssert(mme_ref_p != NULL); DevAssert(mme_ref_p != NULL);
if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_ref_p->s1ap_eNB_instance, ue_desc_p = s1ap_eNB_get_ue_context(mme_ref_p->s1ap_eNB_instance,
ie->value.choice.ENB_UE_S1AP_ID)) == NULL) { ie->value.choice.ENB_UE_S1AP_ID);
if (ue_desc_p == NULL) {
/* Could not find context associated with this eNB_ue_s1ap_id -> generate /* Could not find context associated with this eNB_ue_s1ap_id -> generate
* trace failure indication. * trace failure indication.
*/ */
...@@ -130,7 +131,7 @@ int s1ap_eNB_handle_trace_start(uint32_t assoc_id, ...@@ -130,7 +131,7 @@ int s1ap_eNB_handle_trace_start(uint32_t assoc_id,
memset(&cause, 0, sizeof(S1AP_Cause_t)); memset(&cause, 0, sizeof(S1AP_Cause_t));
cause.present = S1AP_Cause_PR_radioNetwork; cause.present = S1AP_Cause_PR_radioNetwork;
cause.choice.radioNetwork = S1AP_CauseRadioNetwork_unknown_pair_ue_s1ap_id; cause.choice.radioNetwork = S1AP_CauseRadioNetwork_unknown_pair_ue_s1ap_id;
s1ap_eNB_generate_trace_failure(ue_desc_p, &trace_id, &cause); s1ap_eNB_generate_trace_failure(NULL, &trace_id, &cause);
} }
return 0; return 0;
......
...@@ -603,7 +603,7 @@ sctp_handle_new_association_req( ...@@ -603,7 +603,7 @@ sctp_handle_new_association_req(
sd, sctp_nb_cnx, assoc_id); sd, sctp_nb_cnx, assoc_id);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void sctp_send_data( void sctp_send_data(
instance_t instance, instance_t instance,
task_id_t task_id, task_id_t task_id,
...@@ -667,7 +667,7 @@ static int sctp_close_association( ...@@ -667,7 +667,7 @@ static int sctp_close_association(
close(sctp_cnx->sd); close(sctp_cnx->sd);
STAILQ_REMOVE(&sctp_cnx_list, sctp_cnx, sctp_cnx_list_elm_s, entries); STAILQ_REMOVE(&sctp_cnx_list, sctp_cnx, sctp_cnx_list_elm_s, entries);
SCTP_DEBUG("Removed assoc_id %u (closed socket %u)\n", SCTP_DEBUG("Removed assoc_id %u (closed socket %u)\n",
sctp_cnx->assoc_id, sctp_cnx->sd); sctp_cnx->assoc_id, (unsigned int)sctp_cnx->sd);
} }
return 0; return 0;
...@@ -741,12 +741,14 @@ static int sctp_create_new_listener( ...@@ -741,12 +741,14 @@ static int sctp_create_new_listener(
if (server_type) { if (server_type) {
if ((sd = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0) { if ((sd = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0) {
SCTP_ERROR("socket: %s:%d\n", strerror(errno), errno); SCTP_ERROR("socket: %s:%d\n", strerror(errno), errno);
free(addr);
return -1; return -1;
} }
} }
else { else {
if ((sd = socket(AF_INET6, SOCK_STREAM, IPPROTO_SCTP)) < 0) { if ((sd = socket(AF_INET6, SOCK_STREAM, IPPROTO_SCTP)) < 0) {
SCTP_ERROR("socket: %s:%d\n", strerror(errno), errno); SCTP_ERROR("socket: %s:%d\n", strerror(errno), errno);
free(addr);
return -1; return -1;
} }
} }
...@@ -756,6 +758,7 @@ static int sctp_create_new_listener( ...@@ -756,6 +758,7 @@ static int sctp_create_new_listener(
if (setsockopt(sd, IPPROTO_SCTP, SCTP_EVENTS, &event, if (setsockopt(sd, IPPROTO_SCTP, SCTP_EVENTS, &event,
sizeof(struct sctp_event_subscribe)) < 0) { sizeof(struct sctp_event_subscribe)) < 0) {
SCTP_ERROR("setsockopt: %s:%d\n", strerror(errno), errno); SCTP_ERROR("setsockopt: %s:%d\n", strerror(errno), errno);
free(addr);
return -1; return -1;
} }
......
...@@ -152,7 +152,7 @@ static int trx_brf_write(openair0_device *device,openair0_timestamp ptimestamp, ...@@ -152,7 +152,7 @@ static int trx_brf_write(openair0_device *device,openair0_timestamp ptimestamp,
//fprintf(stderr,"Failed to TX sample: %s\n", bladerf_strerror(status)); //fprintf(stderr,"Failed to TX sample: %s\n", bladerf_strerror(status));
brf->num_tx_errors++; brf->num_tx_errors++;
brf_error(status); brf_error(status);
} else if (brf->meta_tx.status & BLADERF_META_STATUS_UNDERRUN){ } else if (brf->meta_tx.status & BLADERF_META_STATUS_UNDERRUN) {
/* libbladeRF does not report this status. It is here for future use. */ /* libbladeRF does not report this status. It is here for future use. */
fprintf(stderr, "TX Underrun detected. %u valid samples were read.\n", brf->meta_tx.actual_count); fprintf(stderr, "TX Underrun detected. %u valid samples were read.\n", brf->meta_tx.actual_count);
brf->num_underflows++; brf->num_underflows++;
...@@ -282,13 +282,13 @@ int trx_brf_set_freq(openair0_device* device, openair0_config_t *openair0_cfg1,i ...@@ -282,13 +282,13 @@ int trx_brf_set_freq(openair0_device* device, openair0_config_t *openair0_cfg1,i
openair0_config_t *openair0_cfg = (openair0_config_t *)device->openair0_cfg; openair0_config_t *openair0_cfg = (openair0_config_t *)device->openair0_cfg;
if ((status=bladerf_set_frequency(brf->dev, BLADERF_MODULE_TX, (unsigned int) openair0_cfg->tx_freq[0])) != 0){ if ((status=bladerf_set_frequency(brf->dev, BLADERF_MODULE_TX, (unsigned int) openair0_cfg->tx_freq[0])) != 0) {
fprintf(stderr,"Failed to set TX frequency: %s\n",bladerf_strerror(status)); fprintf(stderr,"Failed to set TX frequency: %s\n",bladerf_strerror(status));
brf_error(status); brf_error(status);
}else } else
printf("[BRF] set TX Frequency to %u\n", (unsigned int) openair0_cfg->tx_freq[0]); printf("[BRF] set TX Frequency to %u\n", (unsigned int) openair0_cfg->tx_freq[0]);
if ((status=bladerf_set_frequency(brf->dev, BLADERF_MODULE_RX, (unsigned int) openair0_cfg->rx_freq[0])) != 0){ if ((status=bladerf_set_frequency(brf->dev, BLADERF_MODULE_RX, (unsigned int) openair0_cfg->rx_freq[0])) != 0) {
fprintf(stderr,"Failed to set RX frequency: %s\n",bladerf_strerror(status)); fprintf(stderr,"Failed to set RX frequency: %s\n",bladerf_strerror(status));
brf_error(status); brf_error(status);
} else } else
...@@ -320,7 +320,8 @@ rx_gain_calib_table_t calib_table_fx4[] = { ...@@ -320,7 +320,8 @@ rx_gain_calib_table_t calib_table_fx4[] = {
{2300000000.0,53.5}, {2300000000.0,53.5},
{1880000000.0,57.0}, {1880000000.0,57.0},
{816000000.0,73.0}, {816000000.0,73.0},
{-1,0}}; {-1,0}
};
/*! \brief set RX gain offset from calibration table /*! \brief set RX gain offset from calibration table
* \param openair0_cfg RF frontend parameters set by application * \param openair0_cfg RF frontend parameters set by application
...@@ -372,7 +373,7 @@ void calibrate_rf(openair0_device *device) { ...@@ -372,7 +373,7 @@ void calibrate_rf(openair0_device *device) {
// fill TX buffer with fs/8 complex sinusoid // fill TX buffer with fs/8 complex sinusoid
j=0; j=0;
for (i=0;i<RXDCLENGTH;i++) { for (i=0; i<RXDCLENGTH; i++) {
calib_tx_buff[j++] = cos_fsover8[i&7]; calib_tx_buff[j++] = cos_fsover8[i&7];
calib_tx_buff[j++] = cos_fsover8[(i+6)&7]; // sin calib_tx_buff[j++] = cos_fsover8[(i+6)&7]; // sin
} }
...@@ -383,10 +384,10 @@ void calibrate_rf(openair0_device *device) { ...@@ -383,10 +384,10 @@ void calibrate_rf(openair0_device *device) {
offIold=offQold=2048; offIold=offQold=2048;
bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_LMS_DCOFF_I,offIold); bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_LMS_DCOFF_I,offIold);
bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_LMS_DCOFF_Q,offQold); bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_LMS_DCOFF_Q,offQold);
for (i=0;i<10;i++) for (i=0; i<10; i++)
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
for (meanIold=meanQold=i=j=0;i<RXDCLENGTH;i++) { for (meanIold=meanQold=i=j=0; i<RXDCLENGTH; i++) {
meanIold+=calib_buff[j++]; meanIold+=calib_buff[j++];
meanQold+=calib_buff[j++]; meanQold+=calib_buff[j++];
} }
...@@ -397,10 +398,10 @@ void calibrate_rf(openair0_device *device) { ...@@ -397,10 +398,10 @@ void calibrate_rf(openair0_device *device) {
offI=offQ=-2048; offI=offQ=-2048;
bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_LMS_DCOFF_I,offI); bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_LMS_DCOFF_I,offI);
bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_LMS_DCOFF_Q,offQ); bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_LMS_DCOFF_Q,offQ);
for (i=0;i<10;i++) for (i=0; i<10; i++)
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
for (meanI=meanQ=i=j=0;i<RXDCLENGTH;i++) { for (meanI=meanQ=i=j=0; i<RXDCLENGTH; i++) {
meanI+=calib_buff[j++]; meanI+=calib_buff[j++];
meanQ+=calib_buff[j++]; meanQ+=calib_buff[j++];
} }
...@@ -428,10 +429,10 @@ void calibrate_rf(openair0_device *device) { ...@@ -428,10 +429,10 @@ void calibrate_rf(openair0_device *device) {
bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_LMS_DCOFF_I,offI); bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_LMS_DCOFF_I,offI);
bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_LMS_DCOFF_Q,offQ); bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_LMS_DCOFF_Q,offQ);
for (i=0;i<10;i++) for (i=0; i<10; i++)
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
for (meanI=meanQ=i=j=0;i<RXDCLENGTH;i++) { for (meanI=meanQ=i=j=0; i<RXDCLENGTH; i++) {
meanI+=calib_buff[j++]; meanI+=calib_buff[j++];
meanQ+=calib_buff[j++]; meanQ+=calib_buff[j++];
} }
...@@ -452,11 +453,11 @@ void calibrate_rf(openair0_device *device) { ...@@ -452,11 +453,11 @@ void calibrate_rf(openair0_device *device) {
offIold=2048; offIold=2048;
bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_LMS_DCOFF_I,offIold); bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_LMS_DCOFF_I,offIold);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
for (meanIold=meanQold=i=j=0;i<RXDCLENGTH;i++) { for (meanIold=meanQold=i=j=0; i<RXDCLENGTH; i++) {
switch (i&3) { switch (i&3) {
case 0: case 0:
meanIold+=calib_buff[j++]; meanIold+=calib_buff[j++];
...@@ -478,11 +479,11 @@ void calibrate_rf(openair0_device *device) { ...@@ -478,11 +479,11 @@ void calibrate_rf(openair0_device *device) {
offI=-2048; offI=-2048;
bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_LMS_DCOFF_I,offI); bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_LMS_DCOFF_I,offI);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
for (meanI=meanQ=i=j=0;i<RXDCLENGTH;i++) { for (meanI=meanQ=i=j=0; i<RXDCLENGTH; i++) {
switch (i&3) { switch (i&3) {
case 0: case 0:
meanI+=calib_buff[j++]; meanI+=calib_buff[j++];
...@@ -514,11 +515,11 @@ void calibrate_rf(openair0_device *device) { ...@@ -514,11 +515,11 @@ void calibrate_rf(openair0_device *device) {
offI = offInew; offI = offInew;
bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_LMS_DCOFF_I,offI); bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_LMS_DCOFF_I,offI);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
for (meanI=meanQ=i=j=0;i<RXDCLENGTH;i++) { for (meanI=meanQ=i=j=0; i<RXDCLENGTH; i++) {
switch (i&3) { switch (i&3) {
case 0: case 0:
meanI+=calib_buff[j++]; meanI+=calib_buff[j++];
...@@ -543,12 +544,12 @@ void calibrate_rf(openair0_device *device) { ...@@ -543,12 +544,12 @@ void calibrate_rf(openair0_device *device) {
offQold=2048; offQold=2048;
bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_LMS_DCOFF_Q,offQold); bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_LMS_DCOFF_Q,offQold);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
// project on fs/4 // project on fs/4
for (meanIold=meanQold=i=j=0;i<RXDCLENGTH;i++) { for (meanIold=meanQold=i=j=0; i<RXDCLENGTH; i++) {
switch (i&3) { switch (i&3) {
case 0: case 0:
meanIold+=calib_buff[j++]; meanIold+=calib_buff[j++];
...@@ -570,11 +571,11 @@ void calibrate_rf(openair0_device *device) { ...@@ -570,11 +571,11 @@ void calibrate_rf(openair0_device *device) {
offQ=-2048; offQ=-2048;
bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_LMS_DCOFF_Q,offQ); bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_LMS_DCOFF_Q,offQ);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
for (meanI=meanQ=i=j=0;i<RXDCLENGTH;i++) { for (meanI=meanQ=i=j=0; i<RXDCLENGTH; i++) {
switch (i&3) { switch (i&3) {
case 0: case 0:
meanI+=calib_buff[j++]; meanI+=calib_buff[j++];
...@@ -608,11 +609,11 @@ void calibrate_rf(openair0_device *device) { ...@@ -608,11 +609,11 @@ void calibrate_rf(openair0_device *device) {
offQ = offQnew; offQ = offQnew;
bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_LMS_DCOFF_Q,offQ); bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_LMS_DCOFF_Q,offQ);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
for (meanI=meanQ=i=j=0;i<RXDCLENGTH;i++) { for (meanI=meanQ=i=j=0; i<RXDCLENGTH; i++) {
switch (i&3) { switch (i&3) {
case 0: case 0:
meanI+=calib_buff[j++]; meanI+=calib_buff[j++];
...@@ -638,15 +639,15 @@ void calibrate_rf(openair0_device *device) { ...@@ -638,15 +639,15 @@ void calibrate_rf(openair0_device *device) {
bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_LMS_DCOFF_Q,offQold); bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_LMS_DCOFF_Q,offQold);
// TX IQ imbalance // TX IQ imbalance
for (loop=0;loop<2;loop++) { for (loop=0; loop<2; loop++) {
offphaseold=4096; offphaseold=4096;
bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_FPGA_PHASE,offphaseold); bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_FPGA_PHASE,offphaseold);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
// project on fs/8 (Image of TX signal in +ve frequencies) // project on fs/8 (Image of TX signal in +ve frequencies)
for (meanIold=meanQold=i=j=0;i<RXDCLENGTH;i++) { for (meanIold=meanQold=i=j=0; i<RXDCLENGTH; i++) {
meanIold+= (calib_buff[j]*cos_fsover8[i&7] - calib_buff[j+1]*cos_fsover8[(i+2)&7])>>11; meanIold+= (calib_buff[j]*cos_fsover8[i&7] - calib_buff[j+1]*cos_fsover8[(i+2)&7])>>11;
meanQold+= (calib_buff[j]*cos_fsover8[(i+2)&7] + calib_buff[j+1]*cos_fsover8[i&7])>>11; meanQold+= (calib_buff[j]*cos_fsover8[(i+2)&7] + calib_buff[j+1]*cos_fsover8[i&7])>>11;
j+=2; j+=2;
...@@ -658,12 +659,12 @@ void calibrate_rf(openair0_device *device) { ...@@ -658,12 +659,12 @@ void calibrate_rf(openair0_device *device) {
offphase=-4096; offphase=-4096;
bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_FPGA_PHASE,offphase); bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_FPGA_PHASE,offphase);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
// project on fs/8 (Image of TX signal in +ve frequencies) // project on fs/8 (Image of TX signal in +ve frequencies)
for (meanI=meanQ=i=j=0;i<RXDCLENGTH;i++) { for (meanI=meanQ=i=j=0; i<RXDCLENGTH; i++) {
meanI+= (calib_buff[j]*cos_fsover8[i&7] - calib_buff[j+1]*cos_fsover8[(i+2)&7])>>11; meanI+= (calib_buff[j]*cos_fsover8[i&7] - calib_buff[j+1]*cos_fsover8[(i+2)&7])>>11;
meanQ+= (calib_buff[j]*cos_fsover8[(i+2)&7] + calib_buff[j+1]*cos_fsover8[i&7])>>11; meanQ+= (calib_buff[j]*cos_fsover8[(i+2)&7] + calib_buff[j+1]*cos_fsover8[i&7])>>11;
j+=2; j+=2;
...@@ -688,12 +689,12 @@ void calibrate_rf(openair0_device *device) { ...@@ -688,12 +689,12 @@ void calibrate_rf(openair0_device *device) {
offphase = offphasenew; offphase = offphasenew;
bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_FPGA_PHASE,offphase); bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_FPGA_PHASE,offphase);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
// project on fs/8 (Image of TX signal in +ve frequencies) // project on fs/8 (Image of TX signal in +ve frequencies)
for (meanI=meanQ=i=j=0;i<RXDCLENGTH;i++) { for (meanI=meanQ=i=j=0; i<RXDCLENGTH; i++) {
meanI+= (calib_buff[j]*cos_fsover8[i&7] - calib_buff[j+1]*cos_fsover8[(i+2)&7])>>11; meanI+= (calib_buff[j]*cos_fsover8[i&7] - calib_buff[j+1]*cos_fsover8[(i+2)&7])>>11;
meanQ+= (calib_buff[j]*cos_fsover8[(i+2)&7] + calib_buff[j+1]*cos_fsover8[i&7])>>11; meanQ+= (calib_buff[j]*cos_fsover8[(i+2)&7] + calib_buff[j+1]*cos_fsover8[i&7])>>11;
j+=2; j+=2;
...@@ -710,12 +711,12 @@ void calibrate_rf(openair0_device *device) { ...@@ -710,12 +711,12 @@ void calibrate_rf(openair0_device *device) {
offgainold=4096; offgainold=4096;
bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_FPGA_GAIN,offgainold); bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_FPGA_GAIN,offgainold);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
// project on fs/8 (Image of TX signal in +ve frequencies) // project on fs/8 (Image of TX signal in +ve frequencies)
for (meanIold=meanQold=i=j=0;i<RXDCLENGTH;i++) { for (meanIold=meanQold=i=j=0; i<RXDCLENGTH; i++) {
meanIold+= (calib_buff[j]*cos_fsover8[i&7] - calib_buff[j+1]*cos_fsover8[(i+2)&7])>>11; meanIold+= (calib_buff[j]*cos_fsover8[i&7] - calib_buff[j+1]*cos_fsover8[(i+2)&7])>>11;
meanQold+= (calib_buff[j]*cos_fsover8[(i+2)&7] + calib_buff[j+1]*cos_fsover8[i&7])>>11; meanQold+= (calib_buff[j]*cos_fsover8[(i+2)&7] + calib_buff[j+1]*cos_fsover8[i&7])>>11;
j+=2; j+=2;
...@@ -727,12 +728,12 @@ void calibrate_rf(openair0_device *device) { ...@@ -727,12 +728,12 @@ void calibrate_rf(openair0_device *device) {
offgain=-4096; offgain=-4096;
bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_FPGA_GAIN,offgain); bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_FPGA_GAIN,offgain);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
// project on fs/8 (Image of TX signal in +ve frequencies) // project on fs/8 (Image of TX signal in +ve frequencies)
for (meanI=meanQ=i=j=0;i<RXDCLENGTH;i++) { for (meanI=meanQ=i=j=0; i<RXDCLENGTH; i++) {
meanI+= (calib_buff[j]*cos_fsover8[i&7] - calib_buff[j+1]*cos_fsover8[(i+2)&7])>>11; meanI+= (calib_buff[j]*cos_fsover8[i&7] - calib_buff[j+1]*cos_fsover8[(i+2)&7])>>11;
meanQ+= (calib_buff[j]*cos_fsover8[(i+2)&7] + calib_buff[j+1]*cos_fsover8[i&7])>>11; meanQ+= (calib_buff[j]*cos_fsover8[(i+2)&7] + calib_buff[j+1]*cos_fsover8[i&7])>>11;
j+=2; j+=2;
...@@ -756,12 +757,12 @@ void calibrate_rf(openair0_device *device) { ...@@ -756,12 +757,12 @@ void calibrate_rf(openair0_device *device) {
offgain = offgainnew; offgain = offgainnew;
bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_FPGA_GAIN,offgain); bladerf_set_correction(brf->dev,BLADERF_MODULE_TX,BLADERF_CORR_FPGA_GAIN,offgain);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
// project on fs/8 (Image of TX signal in +ve frequencies) // project on fs/8 (Image of TX signal in +ve frequencies)
for (meanI=meanQ=i=j=0;i<RXDCLENGTH;i++) { for (meanI=meanQ=i=j=0; i<RXDCLENGTH; i++) {
meanI+= (calib_buff[j]*cos_fsover8[i&7] - calib_buff[j+1]*cos_fsover8[(i+2)&7])>>11; meanI+= (calib_buff[j]*cos_fsover8[i&7] - calib_buff[j+1]*cos_fsover8[(i+2)&7])>>11;
meanQ+= (calib_buff[j]*cos_fsover8[(i+2)&7] + calib_buff[j+1]*cos_fsover8[i&7])>>11; meanQ+= (calib_buff[j]*cos_fsover8[(i+2)&7] + calib_buff[j+1]*cos_fsover8[i&7])>>11;
j+=2; j+=2;
...@@ -778,15 +779,15 @@ void calibrate_rf(openair0_device *device) { ...@@ -778,15 +779,15 @@ void calibrate_rf(openair0_device *device) {
} }
// RX IQ imbalance // RX IQ imbalance
for (loop=0;loop<2;loop++) { for (loop=0; loop<2; loop++) {
offphaseold=4096; offphaseold=4096;
bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_FPGA_PHASE,offphaseold); bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_FPGA_PHASE,offphaseold);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
// project on -3fs/8 (Image of TX signal in -ve frequencies) // project on -3fs/8 (Image of TX signal in -ve frequencies)
for (meanIold=meanQold=i=j=0;i<RXDCLENGTH;i++) { for (meanIold=meanQold=i=j=0; i<RXDCLENGTH; i++) {
meanIold+= (calib_buff[j]*cos_3fsover8[i&7] - calib_buff[j+1]*cos_3fsover8[(i+2)&7])>>11; meanIold+= (calib_buff[j]*cos_3fsover8[i&7] - calib_buff[j+1]*cos_3fsover8[(i+2)&7])>>11;
meanQold+= (calib_buff[j]*cos_3fsover8[(i+2)&7] + calib_buff[j+1]*cos_3fsover8[i&7])>>11; meanQold+= (calib_buff[j]*cos_3fsover8[(i+2)&7] + calib_buff[j+1]*cos_3fsover8[i&7])>>11;
j+=2; j+=2;
...@@ -798,12 +799,12 @@ void calibrate_rf(openair0_device *device) { ...@@ -798,12 +799,12 @@ void calibrate_rf(openair0_device *device) {
offphase=-4096; offphase=-4096;
bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_FPGA_PHASE,offphase); bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_FPGA_PHASE,offphase);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
// project on -3fs/8 (Image of TX signal in -ve frequencies) // project on -3fs/8 (Image of TX signal in -ve frequencies)
for (meanI=meanQ=i=j=0;i<RXDCLENGTH;i++) { for (meanI=meanQ=i=j=0; i<RXDCLENGTH; i++) {
meanI+= (calib_buff[j]*cos_3fsover8[i&7] - calib_buff[j+1]*cos_3fsover8[(i+2)&7])>>11; meanI+= (calib_buff[j]*cos_3fsover8[i&7] - calib_buff[j+1]*cos_3fsover8[(i+2)&7])>>11;
meanQ+= (calib_buff[j]*cos_3fsover8[(i+2)&7] + calib_buff[j+1]*cos_3fsover8[i&7])>>11; meanQ+= (calib_buff[j]*cos_3fsover8[(i+2)&7] + calib_buff[j+1]*cos_3fsover8[i&7])>>11;
j+=2; j+=2;
...@@ -828,12 +829,12 @@ void calibrate_rf(openair0_device *device) { ...@@ -828,12 +829,12 @@ void calibrate_rf(openair0_device *device) {
offphase = offphasenew; offphase = offphasenew;
bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_FPGA_PHASE,offphase); bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_FPGA_PHASE,offphase);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
// project on -3fs/8 (Image of TX signal in -ve frequencies) // project on -3fs/8 (Image of TX signal in -ve frequencies)
for (meanI=meanQ=i=j=0;i<RXDCLENGTH;i++) { for (meanI=meanQ=i=j=0; i<RXDCLENGTH; i++) {
meanI+= (calib_buff[j]*cos_3fsover8[i&7] - calib_buff[j+1]*cos_3fsover8[(i+2)&7])>>11; meanI+= (calib_buff[j]*cos_3fsover8[i&7] - calib_buff[j+1]*cos_3fsover8[(i+2)&7])>>11;
meanQ+= (calib_buff[j]*cos_3fsover8[(i+2)&7] + calib_buff[j+1]*cos_3fsover8[i&7])>>11; meanQ+= (calib_buff[j]*cos_3fsover8[(i+2)&7] + calib_buff[j+1]*cos_3fsover8[i&7])>>11;
j+=2; j+=2;
...@@ -850,12 +851,12 @@ void calibrate_rf(openair0_device *device) { ...@@ -850,12 +851,12 @@ void calibrate_rf(openair0_device *device) {
offgainold=4096; offgainold=4096;
bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_FPGA_GAIN,offgainold); bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_FPGA_GAIN,offgainold);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0,0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0,0);
} }
// project on -3fs/8 (Image of TX signal in +ve frequencies) // project on -3fs/8 (Image of TX signal in +ve frequencies)
for (meanIold=meanQold=i=j=0;i<RXDCLENGTH;i++) { for (meanIold=meanQold=i=j=0; i<RXDCLENGTH; i++) {
meanIold+= (calib_buff[j]*cos_3fsover8[i&7] - calib_buff[j+1]*cos_3fsover8[(i+2)&7])>>11; meanIold+= (calib_buff[j]*cos_3fsover8[i&7] - calib_buff[j+1]*cos_3fsover8[(i+2)&7])>>11;
meanQold+= (calib_buff[j]*cos_3fsover8[(i+2)&7] + calib_buff[j+1]*cos_3fsover8[i&7])>>11; meanQold+= (calib_buff[j]*cos_3fsover8[(i+2)&7] + calib_buff[j+1]*cos_3fsover8[i&7])>>11;
j+=2; j+=2;
...@@ -867,12 +868,12 @@ void calibrate_rf(openair0_device *device) { ...@@ -867,12 +868,12 @@ void calibrate_rf(openair0_device *device) {
offgain=-4096; offgain=-4096;
bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_FPGA_GAIN,offgain); bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_FPGA_GAIN,offgain);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
// project on 3fs/8 (Image of TX signal in -ve frequencies) // project on 3fs/8 (Image of TX signal in -ve frequencies)
for (meanI=meanQ=i=j=0;i<RXDCLENGTH;i++) { for (meanI=meanQ=i=j=0; i<RXDCLENGTH; i++) {
meanI+= (calib_buff[j]*cos_3fsover8[i&7] - calib_buff[j+1]*cos_3fsover8[(i+2)&7])>>11; meanI+= (calib_buff[j]*cos_3fsover8[i&7] - calib_buff[j+1]*cos_3fsover8[(i+2)&7])>>11;
meanQ+= (calib_buff[j]*cos_3fsover8[(i+2)&7] + calib_buff[j+1]*cos_3fsover8[i&7])>>11; meanQ+= (calib_buff[j]*cos_3fsover8[(i+2)&7] + calib_buff[j+1]*cos_3fsover8[i&7])>>11;
j+=2; j+=2;
...@@ -896,12 +897,12 @@ void calibrate_rf(openair0_device *device) { ...@@ -896,12 +897,12 @@ void calibrate_rf(openair0_device *device) {
offgain = offgainnew; offgain = offgainnew;
bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_FPGA_GAIN,offgain); bladerf_set_correction(brf->dev,BLADERF_MODULE_RX,BLADERF_CORR_FPGA_GAIN,offgain);
for (i=0;i<10;i++) { for (i=0; i<10; i++) {
trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0); trx_brf_read(device, &ptimestamp, (void **)&calib_buffp, RXDCLENGTH, 0);
trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0); trx_brf_write(device,ptimestamp+5*RXDCLENGTH, (void **)&calib_tx_buffp, RXDCLENGTH, 0, 0);
} }
// project on -3fs/8 (Image of TX signal in -ve frequencies) // project on -3fs/8 (Image of TX signal in -ve frequencies)
for (meanI=meanQ=i=j=0;i<RXDCLENGTH;i++) { for (meanI=meanQ=i=j=0; i<RXDCLENGTH; i++) {
meanI+= (calib_buff[j]*cos_3fsover8[i&7] - calib_buff[j+1]*cos_3fsover8[(i+2)&7])>>11; meanI+= (calib_buff[j]*cos_3fsover8[i&7] - calib_buff[j+1]*cos_3fsover8[(i+2)&7])>>11;
meanQ+= (calib_buff[j]*cos_3fsover8[(i+2)&7] + calib_buff[j+1]*cos_3fsover8[i&7])>>11; meanQ+= (calib_buff[j]*cos_3fsover8[(i+2)&7] + calib_buff[j+1]*cos_3fsover8[i&7])>>11;
j+=2; j+=2;
...@@ -978,7 +979,7 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { ...@@ -978,7 +979,7 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
memset(&brf->meta_rx, 0, sizeof(brf->meta_rx)); memset(&brf->meta_rx, 0, sizeof(brf->meta_rx));
memset(&brf->meta_tx, 0, sizeof(brf->meta_tx)); memset(&brf->meta_tx, 0, sizeof(brf->meta_tx));
printf("\n[BRF] sampling_rate %d, num_buffers %d, buffer_size %d, num transfer %d, timeout_ms (rx %d, tx %d)\n", printf("\n[BRF] sampling_rate %u, num_buffers %u, buffer_size %u, num transfer %u, timeout_ms (rx %u, tx %u)\n",
brf->sample_rate, brf->num_buffers, brf->buffer_size,brf->num_transfers, brf->rx_timeout_ms, brf->tx_timeout_ms); brf->sample_rate, brf->num_buffers, brf->buffer_size,brf->num_transfers, brf->rx_timeout_ms, brf->tx_timeout_ms);
if ((status=bladerf_open(&brf->dev, "")) != 0 ) { if ((status=bladerf_open(&brf->dev, "")) != 0 ) {
...@@ -986,7 +987,7 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { ...@@ -986,7 +987,7 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
brf_error(status); brf_error(status);
} }
printf("[BRF] init dev %p\n", brf->dev); printf("[BRF] init dev %p\n", brf->dev);
switch(bladerf_device_speed(brf->dev)){ switch(bladerf_device_speed(brf->dev)) {
case BLADERF_DEVICE_SPEED_SUPER: case BLADERF_DEVICE_SPEED_SUPER:
printf("[BRF] Device operates at max speed\n"); printf("[BRF] Device operates at max speed\n");
break; break;
...@@ -1003,7 +1004,7 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { ...@@ -1003,7 +1004,7 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
brf_error(status); brf_error(status);
} }
if ((status=bladerf_set_frequency(brf->dev, BLADERF_MODULE_RX, (unsigned int) openair0_cfg->rx_freq[0])) != 0){ if ((status=bladerf_set_frequency(brf->dev, BLADERF_MODULE_RX, (unsigned int) openair0_cfg->rx_freq[0])) != 0) {
fprintf(stderr,"Failed to set RX frequency: %s\n",bladerf_strerror(status)); fprintf(stderr,"Failed to set RX frequency: %s\n",bladerf_strerror(status));
brf_error(status); brf_error(status);
} else } else
...@@ -1012,17 +1013,17 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { ...@@ -1012,17 +1013,17 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
unsigned int actual_value=0; unsigned int actual_value=0;
if ((status=bladerf_set_sample_rate(brf->dev, BLADERF_MODULE_RX, (unsigned int) openair0_cfg->sample_rate, &actual_value)) != 0){ if ((status=bladerf_set_sample_rate(brf->dev, BLADERF_MODULE_RX, (unsigned int) openair0_cfg->sample_rate, &actual_value)) != 0) {
fprintf(stderr,"Failed to set RX sample rate: %s\n", bladerf_strerror(status)); fprintf(stderr,"Failed to set RX sample rate: %s\n", bladerf_strerror(status));
brf_error(status); brf_error(status);
}else } else
printf("[BRF] set RX sample rate to %u, %u\n", (unsigned int) openair0_cfg->sample_rate, actual_value); printf("[BRF] set RX sample rate to %u, %u\n", (unsigned int) openair0_cfg->sample_rate, actual_value);
if ((status=bladerf_set_bandwidth(brf->dev, BLADERF_MODULE_RX, (unsigned int) openair0_cfg->rx_bw*2, &actual_value)) != 0){ if ((status=bladerf_set_bandwidth(brf->dev, BLADERF_MODULE_RX, (unsigned int) openair0_cfg->rx_bw*2, &actual_value)) != 0) {
fprintf(stderr,"Failed to set RX bandwidth: %s\n", bladerf_strerror(status)); fprintf(stderr,"Failed to set RX bandwidth: %s\n", bladerf_strerror(status));
brf_error(status); brf_error(status);
}else } else
printf("[BRF] set RX bandwidth to %u, %u\n",(unsigned int)openair0_cfg->rx_bw*2, actual_value); printf("[BRF] set RX bandwidth to %u, %u\n",(unsigned int)openair0_cfg->rx_bw*2, actual_value);
set_rx_gain_offset(&openair0_cfg[0],0); set_rx_gain_offset(&openair0_cfg[0],0);
...@@ -1034,28 +1035,28 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { ...@@ -1034,28 +1035,28 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
// TX // TX
if ((status=bladerf_set_frequency(brf->dev, BLADERF_MODULE_TX, (unsigned int) openair0_cfg->tx_freq[0])) != 0){ if ((status=bladerf_set_frequency(brf->dev, BLADERF_MODULE_TX, (unsigned int) openair0_cfg->tx_freq[0])) != 0) {
fprintf(stderr,"Failed to set TX frequency: %s\n",bladerf_strerror(status)); fprintf(stderr,"Failed to set TX frequency: %s\n",bladerf_strerror(status));
brf_error(status); brf_error(status);
}else } else
printf("[BRF] set TX Frequency to %u\n", (unsigned int) openair0_cfg->tx_freq[0]); printf("[BRF] set TX Frequency to %u\n", (unsigned int) openair0_cfg->tx_freq[0]);
if ((status=bladerf_set_sample_rate(brf->dev, BLADERF_MODULE_TX, (unsigned int) openair0_cfg->sample_rate, NULL)) != 0){ if ((status=bladerf_set_sample_rate(brf->dev, BLADERF_MODULE_TX, (unsigned int) openair0_cfg->sample_rate, NULL)) != 0) {
fprintf(stderr,"Failed to set TX sample rate: %s\n", bladerf_strerror(status)); fprintf(stderr,"Failed to set TX sample rate: %s\n", bladerf_strerror(status));
brf_error(status); brf_error(status);
}else } else
printf("[BRF] set TX sampling rate to %u \n", (unsigned int) openair0_cfg->sample_rate); printf("[BRF] set TX sampling rate to %u \n", (unsigned int) openair0_cfg->sample_rate);
if ((status=bladerf_set_bandwidth(brf->dev, BLADERF_MODULE_TX,(unsigned int)openair0_cfg->tx_bw*2, NULL)) != 0){ if ((status=bladerf_set_bandwidth(brf->dev, BLADERF_MODULE_TX,(unsigned int)openair0_cfg->tx_bw*2, NULL)) != 0) {
fprintf(stderr, "Failed to set TX bandwidth: %s\n", bladerf_strerror(status)); fprintf(stderr, "Failed to set TX bandwidth: %s\n", bladerf_strerror(status));
brf_error(status); brf_error(status);
}else } else
printf("[BRF] set TX bandwidth to %u \n", (unsigned int) openair0_cfg->tx_bw*2); printf("[BRF] set TX bandwidth to %u \n", (unsigned int) openair0_cfg->tx_bw*2);
if ((status=bladerf_set_gain(brf->dev, BLADERF_MODULE_TX, (int) openair0_cfg->tx_gain[0])) != 0) { if ((status=bladerf_set_gain(brf->dev, BLADERF_MODULE_TX, (int) openair0_cfg->tx_gain[0])) != 0) {
fprintf(stderr,"Failed to set TX gain: %s\n",bladerf_strerror(status)); fprintf(stderr,"Failed to set TX gain: %s\n",bladerf_strerror(status));
brf_error(status); brf_error(status);
}else } else
printf("[BRF] set the TX gain to %d\n", (int)openair0_cfg->tx_gain[0]); printf("[BRF] set the TX gain to %d\n", (int)openair0_cfg->tx_gain[0]);
...@@ -1064,15 +1065,15 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { ...@@ -1064,15 +1065,15 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
if ((status=bladerf_sync_config(brf->dev, BLADERF_MODULE_TX,BLADERF_FORMAT_SC16_Q11_META,brf->num_buffers,brf->buffer_size,brf->num_transfers,brf->tx_timeout_ms)) != 0 ) { if ((status=bladerf_sync_config(brf->dev, BLADERF_MODULE_TX,BLADERF_FORMAT_SC16_Q11_META,brf->num_buffers,brf->buffer_size,brf->num_transfers,brf->tx_timeout_ms)) != 0 ) {
fprintf(stderr,"Failed to configure TX sync interface: %s\n", bladerf_strerror(status)); fprintf(stderr,"Failed to configure TX sync interface: %s\n", bladerf_strerror(status));
brf_error(status); brf_error(status);
}else } else
printf("[BRF] configured TX sync interface \n"); printf("[BRF] configured TX sync interface \n");
/* Configure the device's RX module for use with the sync interface. /* Configure the device's RX module for use with the sync interface.
* SC16 Q11 samples *with* metadata are used. */ * SC16 Q11 samples *with* metadata are used. */
if ((status=bladerf_sync_config(brf->dev, BLADERF_MODULE_RX, BLADERF_FORMAT_SC16_Q11_META,brf->num_buffers,brf->buffer_size,brf->num_transfers,brf->rx_timeout_ms)) != 0 ) { if ((status=bladerf_sync_config(brf->dev, BLADERF_MODULE_RX, BLADERF_FORMAT_SC16_Q11_META,brf->num_buffers,brf->buffer_size,brf->num_transfers,brf->rx_timeout_ms)) != 0 ) {
fprintf(stderr,"Failed to configure RX sync interface: %s\n", bladerf_strerror(status)); fprintf(stderr,"Failed to configure RX sync interface: %s\n", bladerf_strerror(status));
brf_error(status); brf_error(status);
}else } else
printf("[BRF] configured Rx sync interface \n"); printf("[BRF] configured Rx sync interface \n");
...@@ -1089,7 +1090,7 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { ...@@ -1089,7 +1090,7 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
if ((status=bladerf_enable_module(brf->dev, BLADERF_MODULE_RX, true)) != 0) { if ((status=bladerf_enable_module(brf->dev, BLADERF_MODULE_RX, true)) != 0) {
fprintf(stderr,"Failed to enable RX module: %s\n", bladerf_strerror(status)); fprintf(stderr,"Failed to enable RX module: %s\n", bladerf_strerror(status));
brf_error(status); brf_error(status);
}else } else
printf("[BRF] RX module enabled \n"); printf("[BRF] RX module enabled \n");
// calibrate // calibrate
...@@ -1182,7 +1183,7 @@ struct bladerf * open_bladerf_from_serial(const char *serial) { ...@@ -1182,7 +1183,7 @@ struct bladerf * open_bladerf_from_serial(const char *serial) {
* \param log_level log level * \param log_level log level
* \returns log level of BLADERF device * \returns log level of BLADERF device
*/ */
int get_brf_log_level(int log_level){ int get_brf_log_level(int log_level) {
int level=BLADERF_LOG_LEVEL_INFO; int level=BLADERF_LOG_LEVEL_INFO;
return BLADERF_LOG_LEVEL_INFO; return BLADERF_LOG_LEVEL_INFO;
......
...@@ -340,8 +340,8 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { ...@@ -340,8 +340,8 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
ret=sysctl(rname, namelen, NULL, 0, newval, newlen); ret=sysctl(rname, namelen, NULL, 0, newval, newlen);
if (ret) { if (ret) {
fprintf(stderr,"[ETHERNET] Error using sysctl():%s\n",strerror(errno)); fprintf(stderr,"[ETHERNET] Error using sysctl():%s\n",strerror(errno));
} else{ } else {
printf("[ETHERNET] Kernel network receive buffer max size is set to %u\n",newval[0]); printf("[ETHERNET] Kernel network receive buffer max size is set to %u\n",(unsigned int)newval[0]);
} }
break; break;
case KERNEL_SND_BUF_MAX_SIZE: case KERNEL_SND_BUF_MAX_SIZE:
...@@ -349,8 +349,8 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) { ...@@ -349,8 +349,8 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
ret=sysctl(wname, namelen, NULL, 0, newval, newlen); ret=sysctl(wname, namelen, NULL, 0, newval, newlen);
if (ret) { if (ret) {
fprintf(stderr,"[ETHERNET] Error using sysctl():%s\n",strerror(errno)); fprintf(stderr,"[ETHERNET] Error using sysctl():%s\n",strerror(errno));
} else{ } else {
printf("[ETHERNET] Kernel network send buffer max size is set to %u\n",newval[0]); printf("[ETHERNET] Kernel network send buffer max size is set to %u\n",(unsigned int)newval[0]);
} }
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment