mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
RFsimulator C++ conversion
Convert rfsimulator C source code to C++ to access to STL.
This commit is contained in:
@@ -213,7 +213,7 @@ int config_check_unknown_cmdlineopt(configmodule_interface_t *cfg, char *prefix)
|
||||
return unknowndetected;
|
||||
} /* config_check_unknown_cmdlineopt */
|
||||
|
||||
int config_process_cmdline(configmodule_interface_t *cfg, paramdef_t *cfgoptions, int numoptions, char *prefix)
|
||||
int config_process_cmdline(configmodule_interface_t *cfg, paramdef_t *cfgoptions, int numoptions, const char *prefix)
|
||||
{
|
||||
int c = cfg->argc;
|
||||
int i,j;
|
||||
|
||||
@@ -118,7 +118,7 @@ void *config_allocate_new(configmodule_interface_t *cfg, int sz, bool autoFree)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
int config_setdefault_int(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *prefix)
|
||||
int config_setdefault_int(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *prefix)
|
||||
{
|
||||
int status = 0;
|
||||
config_check_valptr(cfg, cfgoptions, sizeof(*cfgoptions->iptr), 1);
|
||||
@@ -132,7 +132,7 @@ int config_setdefault_int(configmodule_interface_t *cfg, paramdef_t *cfgoptions,
|
||||
return status;
|
||||
}
|
||||
|
||||
int config_setdefault_int64(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *prefix)
|
||||
int config_setdefault_int64(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *prefix)
|
||||
{
|
||||
int status = 0;
|
||||
config_check_valptr(cfg, cfgoptions, sizeof(*cfgoptions->i64ptr), 1);
|
||||
@@ -150,7 +150,7 @@ int config_setdefault_int64(configmodule_interface_t *cfg, paramdef_t *cfgoption
|
||||
return status;
|
||||
}
|
||||
|
||||
int config_setdefault_intlist(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *prefix)
|
||||
int config_setdefault_intlist(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *prefix)
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
@@ -167,7 +167,7 @@ int config_setdefault_intlist(configmodule_interface_t *cfg, paramdef_t *cfgopti
|
||||
return status;
|
||||
}
|
||||
|
||||
int config_setdefault_string(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *prefix)
|
||||
int config_setdefault_string(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *prefix)
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
@@ -190,7 +190,7 @@ int config_setdefault_string(configmodule_interface_t *cfg, paramdef_t *cfgoptio
|
||||
return status;
|
||||
}
|
||||
|
||||
int config_setdefault_stringlist(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *prefix)
|
||||
int config_setdefault_stringlist(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *prefix)
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
@@ -210,7 +210,7 @@ int config_setdefault_stringlist(configmodule_interface_t *cfg, paramdef_t *cfgo
|
||||
return status;
|
||||
}
|
||||
|
||||
int config_setdefault_double(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *prefix)
|
||||
int config_setdefault_double(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *prefix)
|
||||
{
|
||||
int status = 0;
|
||||
config_check_valptr(cfg, cfgoptions, sizeof(*cfgoptions->dblptr), 1);
|
||||
@@ -224,7 +224,7 @@ int config_setdefault_double(configmodule_interface_t *cfg, paramdef_t *cfgoptio
|
||||
return status;
|
||||
}
|
||||
|
||||
int config_assign_ipv4addr(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *ipv4addr)
|
||||
int config_assign_ipv4addr(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *ipv4addr)
|
||||
{
|
||||
config_check_valptr(cfg, cfgoptions, sizeof(*cfgoptions->uptr), 1);
|
||||
int rst=inet_pton(AF_INET, ipv4addr,cfgoptions->uptr );
|
||||
@@ -246,7 +246,7 @@ int config_assign_ipv4addr(configmodule_interface_t *cfg, paramdef_t *cfgoptions
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_setdefault_ipv4addr(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *prefix)
|
||||
int config_setdefault_ipv4addr(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *prefix)
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
@@ -322,7 +322,7 @@ void config_assign_int(configmodule_interface_t *cfg, paramdef_t *cfgoptions, ch
|
||||
* @param[in] prefix Optional prefix for the parameter name (can be NULL).
|
||||
* @return 1 if the default value was set, 0 if ignored, or -1 on error/unsupported type.
|
||||
*/
|
||||
int config_common_getdefault(configmodule_interface_t *cfg, paramdef_t *cfgoption, char *prefix)
|
||||
int config_common_getdefault(configmodule_interface_t *cfg, paramdef_t *cfgoption, const char *prefix)
|
||||
{
|
||||
if( (cfgoption->paramflags & PARAMFLAG_DONOTREAD) != 0) {
|
||||
return 0;
|
||||
|
||||
@@ -41,16 +41,16 @@ extern "C"
|
||||
#endif
|
||||
void config_check_valptr(configmodule_interface_t *cfg, paramdef_t *cfgoptions, int elt_sz, int nb_elt);
|
||||
/* functions to set a parameter to its default value */
|
||||
int config_setdefault_int(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *prefix);
|
||||
int config_setdefault_int64(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *prefix);
|
||||
int config_setdefault_intlist(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *prefix);
|
||||
int config_setdefault_string(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *prefix);
|
||||
int config_setdefault_stringlist(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *prefix);
|
||||
int config_setdefault_double(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *prefix);
|
||||
int config_setdefault_ipv4addr(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *prefix);
|
||||
int config_setdefault_int(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *prefix);
|
||||
int config_setdefault_int64(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *prefix);
|
||||
int config_setdefault_intlist(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *prefix);
|
||||
int config_setdefault_string(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *prefix);
|
||||
int config_setdefault_stringlist(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *prefix);
|
||||
int config_setdefault_double(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *prefix);
|
||||
int config_setdefault_ipv4addr(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *prefix);
|
||||
void *config_allocate_new(configmodule_interface_t *cfg, int sz, bool autoFree);
|
||||
void config_assign_int(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *fullname, int val);
|
||||
int config_common_getdefault(configmodule_interface_t *cfg, paramdef_t *cfgoption, char *prefix);
|
||||
int config_common_getdefault(configmodule_interface_t *cfg, paramdef_t *cfgoption, const char *prefix);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ int config_cmdlineonly_getlist(configmodule_interface_t *cfg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_cmdlineonly_get(configmodule_interface_t *cfg, paramdef_t *cfgoptions, int numoptions, char *prefix)
|
||||
int config_cmdlineonly_get(configmodule_interface_t *cfg, paramdef_t *cfgoptions, int numoptions, const char *prefix)
|
||||
{
|
||||
int defval;
|
||||
int fatalerror=0;
|
||||
|
||||
@@ -59,10 +59,10 @@
|
||||
#define CONFIG_ABORT (1<<21) // config failed,abort execution
|
||||
#define CONFIG_NOOOPT (1<<22) // no -O option found when parsing command line
|
||||
struct configmodule_interface;
|
||||
typedef int (*configmodule_getfunc_t)(struct configmodule_interface *, paramdef_t *, int numparams, char *prefix);
|
||||
typedef int (*configmodule_getfunc_t)(struct configmodule_interface *, paramdef_t *, int numparams, const char *prefix);
|
||||
typedef int (
|
||||
*configmodule_getlistfunc_t)(struct configmodule_interface *, paramlist_def_t *, paramdef_t *, int numparams, char *prefix);
|
||||
typedef int (*configmodule_setfunc_t)(paramdef_t *cfgoptions, int numoptions, char *prefix);
|
||||
typedef int (*configmodule_setfunc_t)(paramdef_t *cfgoptions, int numoptions, const char *prefix);
|
||||
typedef void (*configmodule_endfunc_t)(struct configmodule_interface *cfg);
|
||||
|
||||
typedef int (*configmodule_initfunc_t)(struct configmodule_interface *cfg);
|
||||
|
||||
@@ -105,7 +105,7 @@ typedef union checkedparam {
|
||||
#define DEFAULT_EXTRA_SZ 256
|
||||
typedef struct paramdef {
|
||||
char optname[MAX_OPTNAME_SIZE]; /* parameter name, can be used as long command line option */
|
||||
char *helpstr; /* help string */
|
||||
const char *helpstr; /* help string */
|
||||
unsigned int paramflags; /* value is a "ored" combination of above PARAMFLAG_XXXX values */
|
||||
union { /* pointer to the parameter value, completed by the config module */
|
||||
char **strptr;
|
||||
@@ -122,7 +122,7 @@ typedef struct paramdef {
|
||||
void *voidptr;
|
||||
} ;
|
||||
union { /* default parameter value, to be used when PARAMFLAG_MANDATORY is not specified */
|
||||
char *defstrval;
|
||||
const char *defstrval;
|
||||
char **defstrlistval;
|
||||
uint32_t defuintval;
|
||||
int defintval;
|
||||
|
||||
@@ -71,7 +71,7 @@ int config_get_processedint(configmodule_interface_t *cfg, paramdef_t *cfgoption
|
||||
|
||||
return ret;
|
||||
}
|
||||
void config_printhelp(paramdef_t *params,int numparams, char *prefix) {
|
||||
void config_printhelp(paramdef_t *params,int numparams, const char *prefix) {
|
||||
printf("\n-----Help for section %-26s: %03i entries------\n",(prefix==NULL)?"(root section)":prefix,numparams);
|
||||
|
||||
for (int i=0 ; i<numparams ; i++) {
|
||||
@@ -84,7 +84,7 @@ void config_printhelp(paramdef_t *params,int numparams, char *prefix) {
|
||||
printf("--------------------------------------------------------------------\n\n");
|
||||
}
|
||||
|
||||
int config_execcheck(configmodule_interface_t *cfg, paramdef_t *params, int numparams, char *prefix)
|
||||
int config_execcheck(configmodule_interface_t *cfg, paramdef_t *params, int numparams, const char *prefix)
|
||||
{
|
||||
int st=0;
|
||||
|
||||
@@ -105,7 +105,7 @@ int config_execcheck(configmodule_interface_t *cfg, paramdef_t *params, int nump
|
||||
return st;
|
||||
}
|
||||
|
||||
int config_paramidx_fromname(paramdef_t *params, int numparams, char *name) {
|
||||
int config_paramidx_fromname(paramdef_t *params, int numparams, const char *name) {
|
||||
for (int i=0; i<numparams ; i++) {
|
||||
if (strcmp(name,params[i].optname) == 0)
|
||||
return i;
|
||||
@@ -115,7 +115,7 @@ int config_paramidx_fromname(paramdef_t *params, int numparams, char *name) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int config_get(configmodule_interface_t *cfgif, paramdef_t *params, int numparams, char *prefix)
|
||||
int config_get(configmodule_interface_t *cfgif, paramdef_t *params, int numparams, const char *prefix)
|
||||
{
|
||||
int ret= -1;
|
||||
|
||||
|
||||
@@ -49,17 +49,17 @@ extern configmodule_interface_t *uniqCfg;
|
||||
#define CONFIG_SETRTFLAG(P) if (config_get_if()) { config_get_if()->rtflags |= P; }
|
||||
#define CONFIG_CLEARRTFLAG(P) if (config_get_if()) { config_get_if()->rtflags &= (~P); }
|
||||
#define CONFIG_ISPARAMFLAGSET(P,F) ( !!(P.paramflags & F))
|
||||
int config_paramidx_fromname(paramdef_t *params, int numparams, char *name);
|
||||
int config_paramidx_fromname(paramdef_t *params, int numparams, const char *name);
|
||||
|
||||
/* utility functions, to be used by configuration module and/or configuration libraries */
|
||||
void config_printhelp(paramdef_t *, int numparams, char *prefix);
|
||||
int config_process_cmdline(configmodule_interface_t *cfg, paramdef_t *params, int numparams, char *prefix);
|
||||
int config_assign_ipv4addr(configmodule_interface_t *cfg, paramdef_t *cfgoptions, char *ipv4addr);
|
||||
void config_printhelp(paramdef_t *, int numparams, const char *prefix);
|
||||
int config_process_cmdline(configmodule_interface_t *cfg, paramdef_t *params, int numparams, const char *prefix);
|
||||
int config_assign_ipv4addr(configmodule_interface_t *cfg, paramdef_t *cfgoptions, const char *ipv4addr);
|
||||
|
||||
/* apis to get/check parameters, to be used by oai modules, at configuration time */
|
||||
#define CONFIG_CHECKALLSECTIONS "ALLSECTIONS"
|
||||
int config_check_unknown_cmdlineopt(configmodule_interface_t *cfg, char *prefix);
|
||||
int config_get(configmodule_interface_t *cfg, paramdef_t *params, int numparams, char *prefix);
|
||||
int config_get(configmodule_interface_t *cfg, paramdef_t *params, int numparams, const char *prefix);
|
||||
int config_getlist(configmodule_interface_t *cfg, paramlist_def_t *ParamList, paramdef_t *params, int numparams, char *prefix);
|
||||
|
||||
/* apis to set some of the paramdef_t fields before using the get/getlist api's */
|
||||
|
||||
@@ -411,7 +411,7 @@ TEST(yaml_config, test_read_ipv4) {
|
||||
config_yaml_get(cfg, &p, 1, prefix);
|
||||
printf("%x\n", addr);
|
||||
|
||||
p.defstrval = strdup("10.0.0.1");
|
||||
p.defstrval = "10.0.0.1";
|
||||
strncpy(p.optname, "ipv4_3", sizeof(p.optname) - 1);
|
||||
config_yaml_get(cfg, &p, 1, prefix);
|
||||
printf("%x\n", addr);
|
||||
@@ -419,7 +419,6 @@ TEST(yaml_config, test_read_ipv4) {
|
||||
config_yaml_end(cfg);
|
||||
free(cfg->cfgP[0]);
|
||||
end_configmodule(cfg);
|
||||
free(p.defstrval);
|
||||
}
|
||||
|
||||
TEST(yaml_config, yaml_read_str_as_int) {
|
||||
|
||||
@@ -252,7 +252,7 @@ load_module_shlib_exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void * get_shlibmodule_fptr(char *modname, char *fname)
|
||||
void * get_shlibmodule_fptr(const char *modname, const char *fname)
|
||||
{
|
||||
for (int i=0; i<loader_data.numshlibs && loader_data.shlibs[i].name != NULL; i++) {
|
||||
if ( strcmp(loader_data.shlibs[i].name, modname) == 0) {
|
||||
|
||||
@@ -82,7 +82,7 @@ extern loader_data_t loader_data;
|
||||
// clang-format on
|
||||
|
||||
int load_module_version_shlib(char *modname, char *version, loader_shlibfunc_t *farray, int numf, void *initfunc_arg);
|
||||
void *get_shlibmodule_fptr(char *modname, char *fname);
|
||||
void *get_shlibmodule_fptr(const char *modname, const char *fname);
|
||||
#define load_module_shlib(M, F, N, I) load_module_version_shlib(M, NULL, F, N, I)
|
||||
void loader_reset();
|
||||
#endif
|
||||
|
||||
@@ -76,7 +76,7 @@ typedef struct webdatadef {
|
||||
typedef void(*telnet_printfunc_t)(const char* format, ...);
|
||||
typedef int(*cmdfunc_t)(char*, int, telnet_printfunc_t prnt);
|
||||
typedef int (*webfunc_t)(char *cmdbuff, int debug, telnet_printfunc_t prnt, ...);
|
||||
typedef int (*webfunc_getdata_t)(char *cmdbuff, int debug, void *data, telnet_printfunc_t prnt);
|
||||
typedef int (*webfunc_getdata_t)(const char *cmdbuff, int debug, void *data, telnet_printfunc_t prnt);
|
||||
typedef int(*qcmdfunc_t)(char*, int, telnet_printfunc_t prnt,void *arg);
|
||||
|
||||
#define TELNETSRV_CMDFLAG_PUSHINTPOOLQ (1 << 0) // ask the telnet server to push the command in a thread pool queue
|
||||
@@ -195,7 +195,7 @@ VT escape sequence definition, for smarter display....
|
||||
#define TELNET_ADDCMD_FNAME "add_telnetcmd"
|
||||
#define TELNET_POLLCMDQ_FNAME "poll_telnetcmdq"
|
||||
#define TELNET_PUSHCMD_FNAME "telnet_pushcmd"
|
||||
typedef int(*add_telnetcmd_func_t)(char *, telnetshell_vardef_t *, telnetshell_cmddef_t *);
|
||||
typedef int(*add_telnetcmd_func_t)(const char *, telnetshell_vardef_t *, telnetshell_cmddef_t *);
|
||||
typedef void(*poll_telnetcmdq_func_t)(void *qid,void *arg);
|
||||
typedef void (*push_telnetcmd_func_t)(telnetshell_cmddef_t *cmd, char *cmdbuff, telnet_printfunc_t prnt);
|
||||
#ifdef TELNETSERVERCODE
|
||||
|
||||
@@ -48,8 +48,8 @@ static int channelmod_show_cmd(char *buff, int debug, telnet_printfunc_t prnt);
|
||||
static int channelmod_modify_cmd(char *buff, int debug, telnet_printfunc_t prnt);
|
||||
static int channelmod_print_help(char *buff, int debug, telnet_printfunc_t prnt);
|
||||
int get_modchannel_index(char *buf, int debug, void *vdata, telnet_printfunc_t prnt);
|
||||
int get_channel_params(char *buf, int debug, void *tdata, telnet_printfunc_t prnt);
|
||||
int get_currentchannels_type(char *buf, int debug, void *vdata, telnet_printfunc_t prnt);
|
||||
int get_channel_params(const char *buf, int debug, void *tdata, telnet_printfunc_t prnt);
|
||||
int get_currentchannels_type(const char *buf, int debug, void *vdata, telnet_printfunc_t prnt);
|
||||
|
||||
#define HELP_WEBIF_MODIFCHAN_STRING "<channel index>"
|
||||
static telnetshell_cmddef_t channelmod_cmdarray[] = {
|
||||
@@ -1696,7 +1696,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
|
||||
return(chan_desc);
|
||||
} /* channel_desc_t *new_channel_desc_scm */
|
||||
|
||||
channel_desc_t *find_channel_desc_fromname( char *modelname ) {
|
||||
channel_desc_t *find_channel_desc_fromname(const char *modelname) {
|
||||
for(int i=0; i<max_chan; i++) {
|
||||
if (defined_channels[i] != NULL) {
|
||||
if (strcmp(defined_channels[i]->model_name,modelname) == 0)
|
||||
@@ -2029,7 +2029,7 @@ static int channelmod_print_help(char *buff, int debug, telnet_printfunc_t prnt
|
||||
|
||||
static char *pnames[] = {"riceanf", "aoa", "randaoa", "ploss", "noise_power_dB", "offset", "forgetf", NULL};
|
||||
static char *pformat[] = {"%lf", "%lf", "%i", "%lf", "%lf", "%i", "%lf", NULL};
|
||||
int get_channel_params(char *buf, int debug, void *vdata, telnet_printfunc_t prnt)
|
||||
int get_channel_params(const char *buf, int debug, void *vdata, telnet_printfunc_t prnt)
|
||||
{
|
||||
if (buf == NULL) {
|
||||
LOG_I(UTIL, "%s received NULL buffer\n", __FUNCTION__);
|
||||
@@ -2111,7 +2111,7 @@ static void display_channelmodel(channel_desc_t *cd,int debug, telnet_printfunc_
|
||||
}
|
||||
}
|
||||
|
||||
int get_currentchannels_type(char *buf, int debug, void *vdata, telnet_printfunc_t prnt)
|
||||
int get_currentchannels_type(const char *buf, int debug, void *vdata, telnet_printfunc_t prnt)
|
||||
{
|
||||
webdatadef_t *tdata;
|
||||
if (buf == NULL) {
|
||||
|
||||
@@ -347,7 +347,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
|
||||
double path_loss_dB,
|
||||
float noise_power_dB);
|
||||
|
||||
channel_desc_t *find_channel_desc_fromname( char *modelname );
|
||||
channel_desc_t *find_channel_desc_fromname(const char *modelname);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
add_library(rfsimulator MODULE
|
||||
simulator.c
|
||||
simulator.cpp
|
||||
apply_channelmod.c
|
||||
../../openair1/PHY/TOOLS/signal_energy.c
|
||||
)
|
||||
|
||||
@@ -42,12 +42,14 @@
|
||||
|
||||
#include <common/utils/assertions.h>
|
||||
#include <common/utils/LOG/log.h>
|
||||
#include <common/utils/load_module_shlib.h>
|
||||
#include <common/utils/telnetsrv/telnetsrv.h>
|
||||
#include <common/config/config_userapi.h>
|
||||
#include "common_lib.h"
|
||||
#define CHANNELMOD_DYNAMICLOAD
|
||||
extern "C" {
|
||||
#include <common/utils/load_module_shlib.h>
|
||||
#include <openair1/SIMULATION/TOOLS/sim.h>
|
||||
}
|
||||
#include "rfsimulator.h"
|
||||
|
||||
#define PORT 4043 // default TCP port for this simulator
|
||||
@@ -104,7 +106,7 @@ typedef enum { SIMU_ROLE_SERVER = 1, SIMU_ROLE_CLIENT } simuRole;
|
||||
};
|
||||
// clang-format on
|
||||
static void getset_currentchannels_type(char *buf, int debug, webdatadef_t *tdata, telnet_printfunc_t prnt);
|
||||
extern int get_currentchannels_type(char *buf, int debug, webdatadef_t *tdata, telnet_printfunc_t prnt); // in random_channel.c
|
||||
extern int get_currentchannels_type(const char *buf, int debug, webdatadef_t *tdata, telnet_printfunc_t prnt); // in random_channel.c
|
||||
static int rfsimu_setchanmod_cmd(char *buff, int debug, telnet_printfunc_t prnt, void *arg);
|
||||
static int rfsimu_setdistance_cmd(char *buff, int debug, telnet_printfunc_t prnt, void *arg);
|
||||
static int rfsimu_getdistance_cmd(char *buff, int debug, telnet_printfunc_t prnt, void *arg);
|
||||
@@ -172,7 +174,7 @@ static buffer_t *allocCirBuf(rfsimulator_state_t *bridge, int sock)
|
||||
uint64_t buff_index = bridge->next_buf++ % MAX_FD_RFSIMU;
|
||||
buffer_t *ptr = &bridge->buf[buff_index];
|
||||
bridge->nb_cnx++;
|
||||
ptr->circularBuf = calloc(1, sampleToByte(CirSize, 1));
|
||||
ptr->circularBuf = static_cast<sample_t *>(calloc(1, sampleToByte(CirSize, 1)));
|
||||
if (ptr->circularBuf == NULL) {
|
||||
LOG_E(HW, "malloc(%lu) failed\n", sampleToByte(CirSize, 1));
|
||||
return NULL;
|
||||
@@ -208,7 +210,7 @@ static buffer_t *allocCirBuf(rfsimulator_state_t *bridge, int sock)
|
||||
ptr->channel_model = find_channel_desc_fromname(modelname); // path_loss in dB
|
||||
if (!ptr->channel_model) {
|
||||
// Use legacy method to find channel model - this will use the same channel model for all clients
|
||||
char *legacy_model_name = (bridge->role == SIMU_ROLE_SERVER) ? "rfsimu_channel_ue0" : "rfsimu_channel_enB0";
|
||||
const char *legacy_model_name = (bridge->role == SIMU_ROLE_SERVER) ? "rfsimu_channel_ue0" : "rfsimu_channel_enB0";
|
||||
ptr->channel_model = find_channel_desc_fromname(legacy_model_name);
|
||||
if (!ptr->channel_model) {
|
||||
LOG_E(HW, "Channel model %s/%s not found, check config file\n", modelname, legacy_model_name);
|
||||
@@ -282,7 +284,7 @@ static void fullwrite(int fd, void *_buf, ssize_t count, rfsimulator_state_t *t)
|
||||
LOG_E(HW, "write() in save iq file failed (%d)\n", errno);
|
||||
}
|
||||
|
||||
char *buf = _buf;
|
||||
char *buf = static_cast<char *>(_buf);
|
||||
ssize_t l;
|
||||
|
||||
while (count) {
|
||||
@@ -384,7 +386,7 @@ static int rfsimu_setchanmod_cmd(char *buff, int debug, telnet_printfunc_t prnt,
|
||||
if (b->conn_sock >= 0 && (strcmp(b->channel_model->model_name, modelname) == 0)) {
|
||||
channel_desc_t *newmodel = new_channel_desc_scm(t->tx_num_channels,
|
||||
t->rx_num_channels,
|
||||
channelmod,
|
||||
static_cast<SCM_t>(channelmod),
|
||||
t->sample_rate,
|
||||
t->rx_freq,
|
||||
t->tx_bw,
|
||||
@@ -520,9 +522,9 @@ static int startServer(openair0_device *device)
|
||||
snprintf(port, sizeof(port), "%d", t->port);
|
||||
|
||||
struct addrinfo hints = {
|
||||
.ai_family = AF_INET6,
|
||||
.ai_socktype = SOCK_STREAM,
|
||||
.ai_flags = AI_PASSIVE,
|
||||
.ai_flags = AI_PASSIVE,
|
||||
.ai_family = AF_INET6,
|
||||
.ai_socktype = SOCK_STREAM,
|
||||
};
|
||||
|
||||
int s = getaddrinfo(NULL, port, &hints, &results);
|
||||
@@ -619,7 +621,7 @@ static int client_try_connect(const char *host, uint16_t port)
|
||||
|
||||
static int startClient(openair0_device *device)
|
||||
{
|
||||
rfsimulator_state_t *t = device->priv;
|
||||
rfsimulator_state_t *t = static_cast<rfsimulator_state_t *>(device->priv);
|
||||
t->role = SIMU_ROLE_CLIENT;
|
||||
int sock;
|
||||
|
||||
@@ -673,9 +675,9 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t,
|
||||
buffer_t *b = &t->buf[i];
|
||||
|
||||
if (b->conn_sock >= 0) {
|
||||
samplesBlockHeader_t header = {nsamps, nbAnt, timestamp};
|
||||
if (!nbAnt)
|
||||
LOG_E(HW, "rfsimulator sending 0 tx antennas\n");
|
||||
samplesBlockHeader_t header = {(uint32_t)nsamps, (uint32_t)nbAnt, (uint64_t)timestamp};
|
||||
fullwrite(b->conn_sock, &header, sizeof(header), t);
|
||||
if (nbAnt == 1) {
|
||||
fullwrite(b->conn_sock, samplesVoid[0], sampleToByte(nsamps, nbAnt), t);
|
||||
@@ -712,10 +714,10 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t,
|
||||
nsamps,
|
||||
timestamp,
|
||||
timestamp + nsamps,
|
||||
signal_energy(samplesVoid[0], nsamps));
|
||||
signal_energy(static_cast<int32_t *>(samplesVoid[0]), nsamps));
|
||||
|
||||
/* trace only first antenna */
|
||||
T(T_USRP_TX_ANT0, T_INT(timestamp), T_BUFFER(samplesVoid[0], sampleToByte(nsamps, 1)));
|
||||
T(T_USRP_TX_ANT0, T_INT(timestamp), T_BUFFER(samplesVoid[0], (int)sampleToByte(nsamps, 1)));
|
||||
|
||||
return nsamps;
|
||||
}
|
||||
@@ -728,7 +730,8 @@ static int rfsimulator_write(openair0_device *device,
|
||||
int flags)
|
||||
{
|
||||
timestamp -= device->openair0_cfg->command_line_sample_advance;
|
||||
return rfsimulator_write_internal(device->priv, timestamp, samplesVoid, nsamps, nbAnt, flags);
|
||||
rfsimulator_state_t *t = static_cast<rfsimulator_state_t *>(device->priv);
|
||||
return rfsimulator_write_internal(t, timestamp, samplesVoid, nsamps, nbAnt, flags);
|
||||
}
|
||||
|
||||
static bool add_client(rfsimulator_state_t *t)
|
||||
@@ -758,7 +761,7 @@ static bool add_client(rfsimulator_state_t *t)
|
||||
void *samplesVoid[t->tx_num_channels];
|
||||
for (int i = 0; i < t->tx_num_channels; i++)
|
||||
samplesVoid[i] = (void *)&v;
|
||||
samplesBlockHeader_t header = {1, t->tx_num_channels, t->lastWroteTS};
|
||||
samplesBlockHeader_t header = {(uint32_t)1, (uint32_t)t->tx_num_channels, (uint64_t)t->lastWroteTS};
|
||||
fullwrite(conn_sock, &header, sizeof(header), t);
|
||||
fullwrite(conn_sock, samplesVoid, sampleToByte(1, t->tx_num_channels), t);
|
||||
|
||||
@@ -780,7 +783,7 @@ static void process_recv_header(rfsimulator_state_t *t, buffer_t *b, bool first_
|
||||
b->lastReceivedTS = b->th.timestamp;
|
||||
b->trashingPacket = true;
|
||||
} else {
|
||||
if (b->lastReceivedTS < b->th.timestamp) {
|
||||
if (b->lastReceivedTS < (int64_t)b->th.timestamp) {
|
||||
// We have a transmission hole to fill, like TDD
|
||||
// we create no signal samples up to the beginning of this reception
|
||||
int nbAnt = b->th.nbAnt;
|
||||
@@ -798,7 +801,7 @@ static void process_recv_header(rfsimulator_state_t *t, buffer_t *b, bool first_
|
||||
memset(b->circularBuf, 0, sampleToByte(CirSize, 1));
|
||||
}
|
||||
b->lastReceivedTS = b->th.timestamp;
|
||||
} else if (b->lastReceivedTS > b->th.timestamp) {
|
||||
} else if (b->lastReceivedTS > (int64_t)b->th.timestamp) {
|
||||
LOG_W(HW, "Received data in past: current is %lu, new reception: %lu!\n", b->lastReceivedTS, b->th.timestamp);
|
||||
b->trashingPacket = true;
|
||||
}
|
||||
@@ -850,7 +853,7 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, bool first_time)
|
||||
}
|
||||
|
||||
for (int nbEv = 0; nbEv < nfds; ++nbEv) {
|
||||
buffer_t *b = events[nbEv].data.ptr;
|
||||
buffer_t *b = static_cast<buffer_t *>(events[nbEv].data.ptr);
|
||||
|
||||
if (events[nbEv].events & EPOLLIN && b == NULL) {
|
||||
bool ret = add_client(t);
|
||||
@@ -895,7 +898,7 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, bool first_time)
|
||||
|
||||
static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, void **samplesVoid, int nsamps, int nbAnt)
|
||||
{
|
||||
rfsimulator_state_t *t = device->priv;
|
||||
rfsimulator_state_t *t = static_cast<rfsimulator_state_t *>(device->priv);
|
||||
LOG_D(HW,
|
||||
"Enter rfsimulator_read, expect %d samples, will release at TS: %ld, nbAnt %d\n",
|
||||
nsamps,
|
||||
@@ -995,7 +998,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
|
||||
sample_t *out = (sample_t *)samplesVoid[a_rx];
|
||||
if (nbAnt_tx == 1 && t->nb_cnx == 1) { // optimized for 1 Tx and 1 UE
|
||||
sample_t *firstSample = (sample_t *)&(ptr->circularBuf[firstIndex]);
|
||||
if (firstIndex + nsamps > CirSize) {
|
||||
if ((uint64_t)firstIndex + (uint64_t)nsamps > CirSize) {
|
||||
int tailSz = CirSize - firstIndex;
|
||||
memcpy(out, firstSample, sampleToByte(tailSz, 1));
|
||||
memcpy(out + tailSz, &ptr->circularBuf[0], sampleToByte(nsamps - tailSz, 1));
|
||||
@@ -1060,10 +1063,10 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
|
||||
nsamps,
|
||||
*ptimestamp,
|
||||
t->nextRxTstamp,
|
||||
signal_energy(samplesVoid[0], nsamps));
|
||||
signal_energy(static_cast<int32_t *>(samplesVoid[0]), nsamps));
|
||||
|
||||
/* trace only first antenna */
|
||||
T(T_USRP_RX_ANT0, T_INT(t->nextRxTstamp), T_BUFFER(samplesVoid[0], sampleToByte(nsamps, 1)));
|
||||
T(T_USRP_RX_ANT0, T_INT(t->nextRxTstamp), T_BUFFER(samplesVoid[0], (int)sampleToByte(nsamps, 1)));
|
||||
|
||||
return nsamps;
|
||||
}
|
||||
@@ -1075,7 +1078,7 @@ static int rfsimulator_reset_stats(openair0_device *device) {
|
||||
return 0;
|
||||
}
|
||||
static void rfsimulator_end(openair0_device *device) {
|
||||
rfsimulator_state_t *s = device->priv;
|
||||
rfsimulator_state_t *s = static_cast<rfsimulator_state_t *>(device->priv);
|
||||
for (int i = 0; i < MAX_FD_RFSIMU; i++) {
|
||||
buffer_t *b = &s->buf[i];
|
||||
if (b->conn_sock >= 0)
|
||||
@@ -1096,7 +1099,7 @@ static int rfsimulator_stop(openair0_device *device) {
|
||||
return 0;
|
||||
}
|
||||
static int rfsimulator_set_freq(openair0_device *device, openair0_config_t *openair0_cfg) {
|
||||
rfsimulator_state_t *s = device->priv;
|
||||
rfsimulator_state_t *s = static_cast<rfsimulator_state_t *>(device->priv);
|
||||
s->rx_freq = openair0_cfg->rx_freq[0];
|
||||
return 0;
|
||||
}
|
||||
@@ -1107,11 +1110,11 @@ static int rfsimulator_write_init(openair0_device *device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((__visibility__("default")))
|
||||
extern "C" __attribute__((__visibility__("default")))
|
||||
int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
|
||||
// to change the log level, use this on command line
|
||||
// --log_config.hw_log_level debug
|
||||
rfsimulator_state_t *rfsimulator = calloc(sizeof(rfsimulator_state_t), 1);
|
||||
rfsimulator_state_t *rfsimulator = static_cast<rfsimulator_state_t *>(calloc(sizeof(rfsimulator_state_t), 1));
|
||||
// initialize channel simulation
|
||||
rfsimulator->tx_num_channels = openair0_cfg->tx_num_channels;
|
||||
rfsimulator->rx_num_channels = openair0_cfg->rx_num_channels;
|
||||
Reference in New Issue
Block a user