Commit df213402 authored by Andrew Burger's avatar Andrew Burger

OAI UE receive dl_config_request and call memcpy additions

parent d3398332
...@@ -1056,25 +1056,80 @@ int ue_init_standalone_socket(const char *addr, int port) ...@@ -1056,25 +1056,80 @@ int ue_init_standalone_socket(const char *addr, int port)
int sd = socket(server_address.sin_family, SOCK_STREAM, IPPROTO_SCTP); int sd = socket(server_address.sin_family, SOCK_STREAM, IPPROTO_SCTP);
if (sd < 0) { if (sd < 0) {
LOG_E(MAC, "Socket creation error standalone PNF"); LOG_E(MAC, "Socket creation error standalone PNF\n");
return -1; return -1;
} }
if (inet_pton(server_address.sin_family, addr, &server_address.sin_addr) <= 0) { if (inet_pton(server_address.sin_family, addr, &server_address.sin_addr) <= 0) {
LOG_E(MAC, "Invalid standalone PNF Address"); LOG_E(MAC, "Invalid standalone PNF Address\n");
close(sd); close(sd);
return -1; return -1;
} }
if (connect(sd, (struct sockaddr *)&server_address, addr_len) < 0) { while (connect(sd, (struct sockaddr *)&server_address, addr_len) < 0) {
LOG_E(MAC, "Connection to standalone PNF failed"); LOG_E(MAC, "Connection to standalone PNF failed: %s\n", strerror(errno));
close(sd); sleep(1);
return -1;
} }
LOG_I(MAC, "Succeeded Now\n");
return sd; return sd;
} }
void *ue_standalone_pnf_task(void *context)
{
const char *standalone_addr = "127.0.0.1";
int standalone_port = 3289;
char buffer[1024];
int sd = ue_init_standalone_socket(standalone_addr, standalone_port);
while (true)
{
ssize_t len = read(sd, buffer, sizeof(buffer));
if (len == -1)
{
LOG_E(MAC, "reading from standalone pnf sctp socket failed \n");
continue;
}
nfapi_p7_message_header_t header;
if (nfapi_p7_message_header_unpack((void *)buffer, len, &header, sizeof(header), NULL) < 0)
{
LOG_E(MAC, "Header unpack failed for standalone pnf\n");
continue;
}
LOG_I(MAC, "Bruins header_t.message_id: %u\n", header.message_id);
switch (header.message_id)
{
case NFAPI_DL_CONFIG_REQUEST:
{
nfapi_dl_config_request_t dl_config_req;
if (nfapi_p7_message_unpack((void *)buffer, len, &dl_config_req,
sizeof(dl_config_req), NULL) < 0)
{
LOG_E(MAC, "Message dl_config_req failed to unpack\n");
}
else
{
LOG_I(MAC, "Sending dl_config_req to memcpy function\n");
memcpy_dl_config_req(NULL, NULL, &dl_config_req);
}
break;
}
case NFAPI_TX_REQUEST:
break;
case NFAPI_HI_DCI0_REQUEST:
break;
default:
LOG_E(MAC, "Case Statement has no corresponding nfapi message\n");
break;
}
}
}
/* Dummy functions*/ /* Dummy functions*/
void handle_nfapi_hi_dci0_dci_pdu( void handle_nfapi_hi_dci0_dci_pdu(
......
...@@ -134,6 +134,9 @@ void UE_config_stub_pnf(void); ...@@ -134,6 +134,9 @@ void UE_config_stub_pnf(void);
// This function is used to open an SCTP socket with a standalone PNF module // This function is used to open an SCTP socket with a standalone PNF module
int ue_init_standalone_socket(const char *addr, int port); int ue_init_standalone_socket(const char *addr, int port);
// This function is used to read from standalone pnf socket call corresponding memcpy functions
void *ue_standalone_pnf_task(void *context);
#endif /* PHY_STUB_UE_H_ */ #endif /* PHY_STUB_UE_H_ */
...@@ -206,6 +206,7 @@ extern int stop_L1L2(module_id_t enb_id); ...@@ -206,6 +206,7 @@ extern int stop_L1L2(module_id_t enb_id);
extern int restart_L1L2(module_id_t enb_id); extern int restart_L1L2(module_id_t enb_id);
extern void init_UE_stub_single_thread(int nb_inst, int eMBMS_active, int uecap_xer_in, char *emul_iface); extern void init_UE_stub_single_thread(int nb_inst, int eMBMS_active, int uecap_xer_in, char *emul_iface);
extern void init_UE_standalone_thread(void);
extern PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag); extern PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag);
......
...@@ -422,6 +422,13 @@ void init_UE_stub_single_thread(int nb_inst, ...@@ -422,6 +422,13 @@ void init_UE_stub_single_thread(int nb_inst,
multicast_link_start(ue_stub_rx_handler,0,emul_iface); multicast_link_start(ue_stub_rx_handler,0,emul_iface);
} }
void init_UE_standalone_thread()
{
pthread_t thread;
if (pthread_create(&thread, NULL, ue_standalone_pnf_task, NULL) != 0) {
LOG_E(MAC, "pthread_create failed for calling ue_standalone_pnf_task");
}
}
void init_UE_stub(int nb_inst, void init_UE_stub(int nb_inst,
int eMBMS_active, int eMBMS_active,
......
...@@ -711,26 +711,11 @@ int main( int argc, char **argv ) { ...@@ -711,26 +711,11 @@ int main( int argc, char **argv ) {
} }
// hard-coding address and port for now fix later // hard-coding address and port for now fix later
int sd = -1; // beggining of test
if (NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) { if (NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) {
const char *standalone_addr = "127.0.0.1"; init_UE_standalone_thread();
int standalone_port = 3289;
char buffy[1024];
sd = ue_init_standalone_socket(standalone_addr, standalone_port);
ssize_t len = read(sd, buffy, sizeof(buffy));
if (len == -1) {
printf("reading from standalone pnf sctp socket failed \n");
return EXIT_FAILURE;
}
nfapi_p7_message_header_t header_t;
if (nfapi_p7_message_header_unpack((void *)buffy, len, &header_t, sizeof(header_t), NULL) != 0) {
printf("unpacking p7 message failed from standalone pnf\n");
printf("Bruins header_t.message_id: %u", header_t.message_id);
} }
} // end of test
printf("ITTI tasks created\n"); printf("ITTI tasks created\n");
mlockall(MCL_CURRENT | MCL_FUTURE); mlockall(MCL_CURRENT | MCL_FUTURE);
rt_sleep_ns(10*100000000ULL); rt_sleep_ns(10*100000000ULL);
......
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