Commit 3a5912a0 authored by Melissa's avatar Melissa Committed by Michael Cook

Updated non-blocking PDCP socket

More accurately, we changed the do/while infinite
loop to be an infinite for loop for the read command of
the socket. The socket file descriptor choice is more clear now.
parent 181ae665
...@@ -18,9 +18,8 @@ ...@@ -18,9 +18,8 @@
#ifndef _PNF_H_ #ifndef _PNF_H_
#define _PNF_H_ #define _PNF_H_
#include "nfapi_pnf_interface.h" #include "nfapi/open-nFAPI/pnf/inc/pnf_p7.h"
#define NFAPI_MAX_PACKED_MESSAGE_SIZE 8192
typedef struct { typedef struct {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include "nfapi/open-nFAPI/pnf/inc/pnf_p7.h"
#include "pnf.h" #include "pnf.h"
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "nfapi/open-nFAPI/pnf/inc/pnf_p7.h"
nfapi_pnf_config_t* nfapi_pnf_config_create() nfapi_pnf_config_t* nfapi_pnf_config_create()
{ {
......
...@@ -115,11 +115,13 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) { ...@@ -115,11 +115,13 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) {
int pdcp_nb_sdu_sent = 0; int pdcp_nb_sdu_sent = 0;
int ret=0; int ret=0;
while ((sdu_p = list_get_head (&pdcp_sdu_list)) != NULL && ((pdcp_data_ind_header_t *)(sdu_p->data))->inst == ctxt_pP->module_id) { while ((sdu_p = list_get_head (&pdcp_sdu_list)) != NULL) {
((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0; pdcp_data_ind_header_t *hdr = (pdcp_data_ind_header_t *) sdu_p->data;
int rb_id = ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id; if (hdr->inst != ctxt_pP->module_id) {
int sizeToWrite= sizeof (pdcp_data_ind_header_t) + break;
((pdcp_data_ind_header_t *) sdu_p->data)->data_size; }
hdr->inst = 0;
int rb_id = hdr->rb_id;
if (rb_id == 10) { //hardcoded for PC5-Signaling if (rb_id == 10) { //hardcoded for PC5-Signaling
if( LOG_DEBUGFLAG(DEBUG_PDCP) ) { if( LOG_DEBUGFLAG(DEBUG_PDCP) ) {
...@@ -132,42 +134,38 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) { ...@@ -132,42 +134,38 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) {
} else if (UE_NAS_USE_TUN) { } else if (UE_NAS_USE_TUN) {
//ret = write(nas_sock_fd[ctxt_pP->module_id], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite ); //ret = write(nas_sock_fd[ctxt_pP->module_id], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite );
if(rb_id == mbms_rab_id){ if (rb_id == mbms_rab_id) {
ret = write(nas_sock_mbms_fd, &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite ); ret = write(nas_sock_mbms_fd, &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), hdr->data_size);
LOG_I(PDCP,"[PDCP_FIFOS] ret %d TRIED TO PUSH MBMS DATA TO rb_id %d handle %d sizeToWrite %d\n",ret,rb_id,nas_sock_fd[ctxt_pP->module_id],sizeToWrite); LOG_I(PDCP,"[PDCP_FIFOS] ret %d TRIED TO PUSH MBMS DATA TO rb_id %d handle %d hdr->data_size %d\n",
} ret,rb_id,nas_sock_fd[ctxt_pP->module_id], hdr->data_size);
else } else {
{
#if defined(ENABLE_PDCP_PAYLOAD_DEBUG) #if defined(ENABLE_PDCP_PAYLOAD_DEBUG)
LOG_I(PHY, "PDCP output to be sent to TUN interface: \n"); LOG_I(PHY, "PDCP output to be sent to TUN interface: \n");
for (int i = sizeof(pdcp_data_ind_header_t); i < sizeToWrite; i++) { for (int i = 0; i < hdr->data_size; i++) {
printf("%02x ",(unsigned char)sdu_p->data[i]); printf("%02x ",(unsigned char)sdu_p->data[i + sizeof(pdcp_data_ind_header_t)]);
} }
printf("\n"); printf("\n");
#endif #endif
if (ue_id_g == 0) if (ue_id_g == 0) {
{ ret = write(nas_sock_fd[ctxt_pP->module_id], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), hdr->data_size);
ret = write(nas_sock_fd[ctxt_pP->module_id], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite ); } else {
} ret = write(nas_sock_fd[ue_id_g], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), hdr->data_size);
else
{
ret = write(nas_sock_fd[ue_id_g], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite );
} }
//LOG_I(PDCP,"[PDCP_FIFOS] ret %d TRIED TO PUSH DATA TO rb_id %d handle %d sizeToWrite %d\n",ret,rb_id,nas_sock_fd[ctxt_pP->module_id],sizeToWrite); //LOG_I(PDCP,"[PDCP_FIFOS] ret %d TRIED TO PUSH DATA TO rb_id %d handle %d hdr->data_size %d\n",ret,rb_id,nas_sock_fd[ctxt_pP->module_id],hdr->data_size);
} }
} else if (ENB_NAS_USE_TUN) { } else if (ENB_NAS_USE_TUN) {
#if defined(ENABLE_PDCP_PAYLOAD_DEBUG) #if defined(ENABLE_PDCP_PAYLOAD_DEBUG)
LOG_I(PHY, "PDCP output to be sent to TUN interface: \n"); LOG_I(PHY, "PDCP output to be sent to TUN interface: \n");
for (int i = sizeof(pdcp_data_ind_header_t); i < sizeToWrite; i++) { for (int i = 0; i < hdr->data_size; i++) {
printf("%02x ",(unsigned char)sdu_p->data[i]); printf("%02x ",(unsigned char)sdu_p->data[i + sizeof(pdcp_data_ind_header_t)]);
} }
printf("\n"); printf("\n");
#endif #endif
ret = write(nas_sock_fd[0], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), sizeToWrite); ret = write(nas_sock_fd[0], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), hdr->data_size);
} else if (PDCP_USE_NETLINK) { } else if (PDCP_USE_NETLINK) {
memcpy(NLMSG_DATA(nas_nlh_tx), (uint8_t *) sdu_p->data, sizeToWrite); memcpy(NLMSG_DATA(nas_nlh_tx), (uint8_t *) sdu_p->data, sizeof (pdcp_data_ind_header_t) + hdr->data_size);
nas_nlh_tx->nlmsg_len = sizeToWrite; nas_nlh_tx->nlmsg_len = sizeof (pdcp_data_ind_header_t) + hdr->data_size;
ret = sendmsg(nas_sock_fd[0],&nas_msg_tx,0); ret = sendmsg(nas_sock_fd[0],&nas_msg_tx,0);
} // PDCP_USE_NETLINK } // PDCP_USE_NETLINK
...@@ -691,12 +689,11 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP) ...@@ -691,12 +689,11 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP)
memset(receive_buf, 0, BUFSIZE); memset(receive_buf, 0, BUFSIZE);
bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, MSG_TRUNC, bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, MSG_TRUNC,
(struct sockaddr *) &prose_pdcp_addr, (socklen_t *)&prose_addr_len); (struct sockaddr *) &prose_pdcp_addr, (socklen_t *)&prose_addr_len);
if (bytes_received == -1) {
if (bytes_received == -1){
LOG_E(PDCP, "%s(%d). recvfrom failed. %s\n", __FUNCTION__, __LINE__, strerror(errno)); LOG_E(PDCP, "%s(%d). recvfrom failed. %s\n", __FUNCTION__, __LINE__, strerror(errno));
return; return;
} }
if (bytes_received == 0){ if (bytes_received == 0) {
LOG_E(PDCP, "%s(%d). EOF pdcp_pc5_sockfd.\n", __FUNCTION__, __LINE__); LOG_E(PDCP, "%s(%d). EOF pdcp_pc5_sockfd.\n", __FUNCTION__, __LINE__);
} }
if (bytes_received > BUFSIZE) { if (bytes_received > BUFSIZE) {
......
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