From d6b038fa27408475d56a396ed82ebd396c24f7c4 Mon Sep 17 00:00:00 2001 From: Andrew Burger Date: Fri, 29 May 2020 15:57:43 -0700 Subject: [PATCH] Trying to read a single packet inside oai ue --- nfapi/oai_integration/nfapi.c | 2 +- nfapi/oai_integration/vendor_ext.h | 4 ++-- openair2/PHY_INTERFACE/phy_stub_UE.c | 33 +++++++++++++++++++++++----- openair2/PHY_INTERFACE/phy_stub_UE.h | 3 +++ targets/RT/USER/lte-uesoftmodem.c | 32 +++++++++++++++++++-------- 5 files changed, 57 insertions(+), 17 deletions(-) diff --git a/nfapi/oai_integration/nfapi.c b/nfapi/oai_integration/nfapi.c index 86d1ae3127..545eb0d5b7 100644 --- a/nfapi/oai_integration/nfapi.c +++ b/nfapi/oai_integration/nfapi.c @@ -23,7 +23,7 @@ #include #include "nfapi/oai_integration/vendor_ext.h" #include "common/utils/LOG/log.h" -static char nfapi_str_mode[6][24] = {"MONOLITHIC","PNF","VNF","UE_STUB_PNF","UE_STUB_OFFNET",""}; +static char nfapi_str_mode[6][24] = {"MONOLITHIC","PNF","VNF","UE_STUB_PNF","UE_STUB_OFFNET","STANDALONE_PNF",""}; typedef struct { nfapi_mode_t nfapi_mode; diff --git a/nfapi/oai_integration/vendor_ext.h b/nfapi/oai_integration/vendor_ext.h index cfc1699080..a1ca7e91bc 100644 --- a/nfapi/oai_integration/vendor_ext.h +++ b/nfapi/oai_integration/vendor_ext.h @@ -70,8 +70,8 @@ typedef enum { NFAPI_MODE_VNF, NFAPI_UE_STUB_PNF, NFAPI_UE_STUB_OFFNET, - NFAPI_MODE_UNKNOWN, - NFAPI_MODE_STANDALONE_PNF + NFAPI_MODE_STANDALONE_PNF, + NFAPI_MODE_UNKNOWN } nfapi_mode_t; char *nfapi_get_strmode(void); diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c index 7efd6c25d9..64dd0a30c5 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.c +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -882,7 +882,7 @@ void hi_dci0_req_UE_MAC(int sfn, // The following set of memcpy functions should be getting called as callback // functions from pnf_p7_subframe_ind. -int memcpy_dl_config_req(L1_rxtx_proc_t *proc, +int memcpy_dl_config_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_dl_config_request_t *req) { dl_config_req = (nfapi_dl_config_request_t *)malloc(sizeof(nfapi_dl_config_request_t)); @@ -959,8 +959,8 @@ int memcpy_tx_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) { return 0; } -int memcpy_hi_dci0_req (L1_rxtx_proc_t *proc, - nfapi_pnf_p7_config_t* pnf_p7, +int memcpy_hi_dci0_req (L1_rxtx_proc_t *proc, + nfapi_pnf_p7_config_t* pnf_p7, nfapi_hi_dci0_request_t* req) { hi_dci0_req = (nfapi_hi_dci0_request_t *)malloc(sizeof(nfapi_hi_dci0_request_t)); //if(req!=0){ @@ -1044,9 +1044,32 @@ void UE_config_stub_pnf(void) { } } -void UE_init_socket(void) { +int ue_init_standalone_socket(const char *addr, int port) +{ - // scpt socket creation and memcpy function calls here + struct sockaddr_in server_address; + int addr_len = sizeof(server_address); + memset(&server_address, 0, addr_len); + server_address.sin_family = AF_INET; + server_address.sin_port = htons(port); + + int sd = socket(address.sin_family, SOCK_STREAM, IPPROTO_SCTP); + if (sd < 0) { + LOG_E(MAC, "Socket creation error standalone PNF"); + return -1; + } + + if (inet_pton(server_address.sin_family, addr, &server_address.sin_addr) <= 0) { + LOG_E(MAC, "Invalid standalone PNF Address"); + return -1; + } + + if (connect(socket, (struct sockaddr *)&server_address, addr_len) < 0) { + LOG_E(MAC, "Connection to standalone PNF failed"); + return -1; + } + + return sd; } /* Dummy functions*/ diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.h b/openair2/PHY_INTERFACE/phy_stub_UE.h index 09356fc9f8..b8a1b56938 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.h +++ b/openair2/PHY_INTERFACE/phy_stub_UE.h @@ -131,6 +131,9 @@ int memcpy_hi_dci0_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t* pnf_p7, nfa void UE_config_stub_pnf(void); +// This function is used to open an SCTP socket with a standalone PNF module +int ue_init_standalone_socket(const char *addr, int port); + #endif /* PHY_STUB_UE_H_ */ diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index fd431ea770..1b7208533c 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -631,7 +631,7 @@ int main( int argc, char **argv ) { NB_INST=1; - if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { // || NFAPI_MODE_STANDALONE_PNF + if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE_STANDALONE_PNF) { // || NFAPI_MODE_STANDALONE_PNF PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE **)*NB_UE_INST); for (int i=0; i