[GITLAB] - UPGRADE TO v12 on Wednesday the 18th of December at 11.30AM

Commit 57d7c10f authored by nikaeinn's avatar nikaeinn

* apply patches

* test pre-ci passed


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6498 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 0e7d1371
......@@ -688,7 +688,7 @@ int32_t generate_prach(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe,
memcpy((void*)prach,(void*)(prach+36864),Ncp<<2);
prach_len = 18432+Ncp;
if (prach_fmt>1) {
memcpy((void*)(prach2+36834),(void*)prach2,73728);
memmove(prach2+36834,prach2,73728);
prach_len = 2*18432+Ncp;
}
}
......
......@@ -100,68 +100,69 @@ multicast_link_init(void)
// struct ifreq ifr;
for (group = 0; group < MULTICAST_LINK_NUM_GROUPS; group++) {
strcpy (group_list[group].host_addr, multicast_group_list[group]);
group_list[group].port = 46014 + group;
group_list[group].socket = make_socket_inet(
SOCK_DGRAM,
&group_list[group].port, &sin);
LOG_D(EMU, "multicast_link_init(): Created socket %d for group %d, port %d\n",
group_list[group].socket,group,group_list[group].port);
//strcpy (group_list[group].host_addr, multicast_group_list[group]);
strncpy (group_list[group].host_addr, multicast_group_list[group], sizeof(group_list[group].host_addr));
group_list[group].host_addr[sizeof(group_list[group].host_addr) - 1] = 0; // terminate string
group_list[group].port = 46014 + group;
group_list[group].socket = make_socket_inet(
SOCK_DGRAM,
&group_list[group].port, &sin);
LOG_D(EMU, "multicast_link_init(): Created socket %d for group %d, port %d\n",
group_list[group].socket,group,group_list[group].port);
/* Used so we can re-bind to our port while a previous connection is still
* in TIME_WAIT state.
*/
if (setsockopt(group_list[group].socket, SOL_SOCKET, SO_REUSEADDR,
&reuse_addr, sizeof (reuse_addr)) < 0) {
LOG_E(EMU, "[MULTICAST] ERROR : setsockopt:SO_REUSEADDR, exiting ...");
exit (EXIT_FAILURE);
}
if (multicast_if != NULL) {
if (setsockopt(group_list[group].socket, SOL_SOCKET,SO_BINDTODEVICE,
multicast_if, 4) < 0) {
LOG_E(EMU,
"[MULTICAST] ERROR : setsockopt:SO_BINDTODEVICE on interface %s, exiting ...\n",
multicast_if);
LOG_E(EMU,
"[MULTICAST] make sure that you have a root privilage or run with sudo -E \n");
exit (EXIT_FAILURE);
}
}
if (setsockopt(group_list[group].socket, SOL_SOCKET, SO_REUSEADDR,
&reuse_addr, sizeof (reuse_addr)) < 0) {
LOG_E(EMU, "[MULTICAST] ERROR : setsockopt:SO_REUSEADDR, exiting ...");
exit (EXIT_FAILURE);
}
if (multicast_if != NULL) {
if (setsockopt(group_list[group].socket, SOL_SOCKET,SO_BINDTODEVICE,
multicast_if, 4) < 0) {
LOG_E(EMU,
"[MULTICAST] ERROR : setsockopt:SO_BINDTODEVICE on interface %s, exiting ...\n",
multicast_if);
LOG_E(EMU,
"[MULTICAST] make sure that you have a root privilage or run with sudo -E \n");
exit (EXIT_FAILURE);
}
}
#if !defined(ENABLE_NEW_MULTICAST)
/* Make the socket blocking */
socket_setnonblocking(group_list[group].socket);
/* Make the socket blocking */
socket_setnonblocking(group_list[group].socket);
#endif
multicast_loop = 0;
if (setsockopt (group_list[group].socket, IPPROTO_IP, IP_MULTICAST_LOOP,
&multicast_loop, sizeof (multicast_loop)) < 0) {
LOG_E(EMU,
"[MULTICAST] ERROR: %s line %d multicast_link_main_loop() IP_MULTICAST_LOOP %m",
__FILE__, __LINE__);
exit (EXIT_FAILURE);
}
// Join the broadcast group:
command.imr_multiaddr.s_addr = inet_addr (group_list[group].host_addr);
command.imr_interface.s_addr = htonl (INADDR_ANY);
if (command.imr_multiaddr.s_addr == -1) {
LOG_E(EMU, "[MULTICAST] ERROR: %s line %d NO MULTICAST", __FILE__, __LINE__);
exit (EXIT_FAILURE);
}
if (setsockopt (group_list[group].socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&command, sizeof (command)) < 0) {
LOG_E(EMU, "[MULTICAST] ERROR: %s line %d IP_ADD_MEMBERSHIP %m", __FILE__,
__LINE__);
exit (EXIT_FAILURE);
}
memset (&group_list[group].sock_remote_addr, 0, sizeof (struct sockaddr_in));
group_list[group].sock_remote_addr.sin_family = AF_INET;
group_list[group].sock_remote_addr.sin_addr.s_addr = inet_addr (
multicast_group_list[group]);
group_list[group].sock_remote_addr.sin_port = htons (group_list[group].port);
multicast_loop = 0;
if (setsockopt (group_list[group].socket, IPPROTO_IP, IP_MULTICAST_LOOP,
&multicast_loop, sizeof (multicast_loop)) < 0) {
LOG_E(EMU,
"[MULTICAST] ERROR: %s line %d multicast_link_main_loop() IP_MULTICAST_LOOP %m",
__FILE__, __LINE__);
exit (EXIT_FAILURE);
}
// Join the broadcast group:
command.imr_multiaddr.s_addr = inet_addr (group_list[group].host_addr);
command.imr_interface.s_addr = htonl (INADDR_ANY);
if (command.imr_multiaddr.s_addr == -1) {
LOG_E(EMU, "[MULTICAST] ERROR: %s line %d NO MULTICAST", __FILE__, __LINE__);
exit (EXIT_FAILURE);
}
if (setsockopt (group_list[group].socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&command, sizeof (command)) < 0) {
LOG_E(EMU, "[MULTICAST] ERROR: %s line %d IP_ADD_MEMBERSHIP %m", __FILE__,
__LINE__);
exit (EXIT_FAILURE);
}
memset (&group_list[group].sock_remote_addr, 0, sizeof (struct sockaddr_in));
group_list[group].sock_remote_addr.sin_family = AF_INET;
group_list[group].sock_remote_addr.sin_addr.s_addr = inet_addr (multicast_group_list[group]);
group_list[group].sock_remote_addr.sin_port = htons (group_list[group].port);
}
}
......
......@@ -189,6 +189,8 @@ double compute_sinr(channel_desc_t *desc,
struct complex S_i1;
struct complex S_i2;
DevAssert( nb_rb > 0 );
avg_sinr=0.0;
// printf("nb_rb %d\n",nb_rb);
for (f=0;f<2*nb_rb;f++) {
......
......@@ -471,7 +471,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
for (i = 0; i<chan_desc->nb_taps; i++)
chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex));
chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**));
chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex*));
for (i = 0; i<6; i++) {
chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
for (j = 0; j<nb_tx*nb_rx*nb_tx*nb_rx; j+=(nb_tx*nb_rx+1)) {
......
......@@ -877,7 +877,7 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) {
lib_config_file_name_pP, i, nb_antennas_rx);
enb_properties.properties[enb_properties_index]->tx_gain[j] = tx_gain;
if ((tx_gain <0) || (nb_antennas_tx > 127))
if ((tx_gain <0) || (tx_gain > 127))
AssertError (0, parse_errors ++,
"Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for tx_gain choice: 0..127 !\n",
lib_config_file_name_pP, i, tx_gain);
......@@ -1075,7 +1075,8 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) {
&& config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_SRS_MAXUPPTS, &srs_MaxUpPts)
))
AssertError(0, parse_errors++,"Failed to parse eNB configuration file %s, enb %d unknown values for srs_BandwidthConfig, srs_SubframeConfig, srs_ackNackST, srs_MaxUpPts\n",
lib_config_file_name_pP, i, srs_BandwidthConfig);
// lib_config_file_name_pP, i, srs_BandwidthConfig);
lib_config_file_name_pP, i);
enb_properties.properties[enb_properties_index]->srs_BandwidthConfig[j] = srs_BandwidthConfig;
if ((srs_BandwidthConfig < 0) || (srs_BandwidthConfig >7))
......@@ -1223,7 +1224,8 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) {
&& config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_RACH_MESSAGEPOWEROFFSETGROUPB, &rach_messagePowerOffsetGroupB)))
AssertError (0, parse_errors ++,
"Failed to parse eNB configuration file %s, enb %d rach_sizeOfRA_PreamblesGroupA, messageSizeGroupA,messagePowerOffsetGroupB!\n",
lib_config_file_name_pP, i, pucch_deltaF_Format2b);
// lib_config_file_name_pP, i, pucch_deltaF_Format2b);
lib_config_file_name_pP, i);
enb_properties.properties[enb_properties_index]->rach_sizeOfRA_PreamblesGroupA[j] = (rach_sizeOfRA_PreamblesGroupA/4)-1;
if ((rach_numberOfRA_Preambles <4) || (rach_numberOfRA_Preambles>60) || ((rach_numberOfRA_Preambles&3)!=0))
......
......@@ -236,7 +236,7 @@ uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_i
T=MGRP/10;
//check the measurement gap and sr prohibit timer
if ((subframe == gapOffset %10) && ((frameP %T) == (floor(gapOffset/10)))
&& (UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running =0)){
&& (UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running ==0)){
UE_mac_inst[module_idP].scheduling_info.SR_pending=1;
return(0);
}
......
......@@ -95,7 +95,7 @@ void rlc_am_pdu_polling (
rlc_pP->rb_id,
rlc_pP->poll_pdu);
}
if (rlc_pP->c_pdu_without_poll >= rlc_pP->poll_pdu) {
if (rlc_pP->c_byte_without_poll >= rlc_pP->poll_byte) {
LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][POLL] SET POLL BECAUSE TX NUM BYTES THRESHOLD %d HAS BEEN REACHED\n",
ctxt_pP->frame,
(ctxt_pP->enb_flag) ? "eNB" : "UE",
......
......@@ -967,7 +967,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
(*sib3)->intraFreqCellReselectionInfo.q_RxLevMin = -70;
(*sib3)->intraFreqCellReselectionInfo.p_Max = NULL;
(*sib3)->intraFreqCellReselectionInfo.s_IntraSearch = CALLOC(1,sizeof((*sib3)->intraFreqCellReselectionInfo.s_IntraSearch));
(*sib3)->intraFreqCellReselectionInfo.s_IntraSearch = CALLOC(1,sizeof(*(*sib3)->intraFreqCellReselectionInfo.s_IntraSearch));
*(*sib3)->intraFreqCellReselectionInfo.s_IntraSearch = 31;
(*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth=CALLOC(1,sizeof(*(*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth));
......@@ -1365,7 +1365,8 @@ uint8_t do_RRCConnectionSetup(uint8_t Mod_id,
// RRCConnectionSetup
// Configure SRB1
*SRB_configList = CALLOC(1,sizeof(*SRB_configList));
// *SRB_configList = CALLOC(1,sizeof(*SRB_configList));
*SRB_configList = CALLOC(1,sizeof(SRB_ToAddModList_t));
/// SRB1
SRB1_config = CALLOC(1,sizeof(*SRB1_config));
......@@ -2151,8 +2152,9 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_
memset(&measresult_cgi2->cellGlobalId.plmn_Identity,0,sizeof(measresult_cgi2->cellGlobalId.plmn_Identity));
measresult_cgi2->cellGlobalId.plmn_Identity.mcc=CALLOC(1,sizeof(measresult_cgi2->cellGlobalId.plmn_Identity.mcc));
// measresult_cgi2->cellGlobalId.plmn_Identity.mcc=CALLOC(1,sizeof(measresult_cgi2->cellGlobalId.plmn_Identity.mcc));
measresult_cgi2->cellGlobalId.plmn_Identity.mcc = CALLOC(1, sizeof(*measresult_cgi2->cellGlobalId.plmn_Identity.mcc));
asn_set_empty(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list);//.size=0;
MCC_MNC_Digit_t dummy;
......@@ -2312,8 +2314,7 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) {
UE_EUTRA_Capability_t *UE_EUTRA_Capability;
char UE_EUTRA_Capability_xer[8192];
size_t size;
FILE *f;
LOG_I(RRC,"Allocating %u bytes for UE_EUTRA_Capability\n",sizeof(*UE_EUTRA_Capability));
UE_EUTRA_Capability = CALLOC(1, sizeof(*UE_EUTRA_Capability));
......@@ -2406,11 +2407,13 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) {
else {
f = fopen(UE_EUTRA_Capability_xer_fname, "r");
FILE* f = fopen(UE_EUTRA_Capability_xer_fname, "r");
assert(f);
size = fread(UE_EUTRA_Capability_xer, 1, sizeof UE_EUTRA_Capability_xer, f);
fclose(f);
if (size == 0 || size == sizeof UE_EUTRA_Capability_xer) {
LOG_E(RRC,"UE Capabilities XER file %s is too large\n", UE_EUTRA_Capability_xer_fname);
free( UE_EUTRA_Capability);
return(NULL);
}
......@@ -2469,6 +2472,7 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) {
sprintf (&sdu[3 * i], "%02x.", UECapability.sdu[i]);
LOG_D(PHY, "[RRC]UE Capability encoded, %s\n", sdu);
free(sdu);
}
return(&UECapability);
......
......@@ -815,7 +815,8 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration(
ASN_SEQUENCE_ADD(&SRB_configList2->list, SRB2_config);
// Configure DRB
*DRB_configList = CALLOC(1, sizeof(*DRB_configList));
//*DRB_configList = CALLOC(1, sizeof(*DRB_configList));
*DRB_configList = CALLOC(1, sizeof(**DRB_configList));
/// DRB
DRB_config = CALLOC(1, sizeof(*DRB_config));
......@@ -1395,10 +1396,16 @@ void rrc_eNB_generate_HandoverPreparationInformation(
handoverInfo->as_config.antennaInfoCommon.antennaPortsCount = 0; //Not used 0- but check value
handoverInfo->as_config.sourceDl_CarrierFreq = 36090; //Verify!
memcpy((void *)&handoverInfo->as_config.sourceMasterInformationBlock,
(void *)&eNB_rrc_inst[enb_mod_idP].mib, sizeof(MasterInformationBlock_t));
memcpy((void *)&handoverInfo->as_config.sourceMeasConfig,
(void *)&eNB_rrc_inst[enb_mod_idP].measConfig[ue_mod_idP], sizeof(MeasConfig_t));
// FIXME handoverInfo not used...
free( handoverInfo );
handoverInfo = 0;
//to be configured
memset((void *)&eNB_rrc_inst[enb_mod_idP].handover_info[ue_mod_idP]->as_config.sourceSecurityAlgorithmConfig,
0, sizeof(SecurityAlgorithmConfig_t));
......
......@@ -77,7 +77,7 @@ char* getNetMask (){
}
void setBroadcastAddress (char* baseAddr){
strcpy(baseAddr, baseAddr);
strcpy(broadcastAddr, baseAddr);
}
char* getBroadcastAddress (){
......@@ -219,6 +219,7 @@ int bringInterfaceUp(char *interfaceName, int up)
}
// printf("UP/DOWN OK!\n");
close( sock_fd );
return 0;
}
// non blocking full configuration of the interface (address, net mask, and broadcast mask)
......@@ -283,14 +284,14 @@ int blocking_NAS_config(char *interfaceName, char *ipAddress, char *networkMask,
command[0]='\0';
strcat(command, "ifconfig ");
strcat(command, interfaceName);
strcat(command, " ");
strcat(command, ipAddress);
strcat(command, " networkMask ");
strcat(command, networkMask);
strcat(command, " broadcast ");
strcat(command, broadcastAddress);
strncat(command, interfaceName, sizeof(command) - strlen(command) - 1);
strncat(command, " ", sizeof(command) - strlen(command) - 1);
strncat(command, ipAddress, sizeof(command) - strlen(command) - 1);
strncat(command, " networkMask ", sizeof(command) - strlen(command) - 1);
strncat(command, networkMask, sizeof(command) - strlen(command) - 1);
strncat(command, " broadcast ", sizeof(command) - strlen(command) - 1);
strncat(command, broadcastAddress, sizeof(command) - strlen(command) - 1);
// ifconfig nasmesh0 10.0.1.1 networkMask 255.255.255.0 broadcast 10.0.1.255
int i = system (command);
......
......@@ -217,9 +217,13 @@ int OCG_main(char is_local_server[FILENAME_LENGTH_MAX]) {
case STATE_GENERATE_REPORT :
if (create_dir_OK != MODULE_OK) {
// a temp folder is required when the output folder could not be correctly generated
strcpy(output_dir, OPENAIR_TARGETS);
strcat(output_dir, "SIMU/EXAMPLES/OSD/");
strcat(output_dir, TEMP_OUTPUT_DIR);
//strcpy(output_dir, OPENAIR_TARGETS);
//strcat(output_dir, "SIMU/EXAMPLES/OSD/");
//strcat(output_dir, TEMP_OUTPUT_DIR);
strncpy(output_dir, OPENAIR_TARGETS, sizeof(output_dir));
output_dir[sizeof(output_dir) - 1] = 0; // terminate string
strncat(output_dir, "SIMU/EXAMPLES/OSD/", sizeof(output_dir) - strlen(output_dir) - 1);
strncat(output_dir, TEMP_OUTPUT_DIR, sizeof(output_dir) - strlen(output_dir) - 1);
struct stat st;
if(stat(output_dir, &st) != 0) { // if temp output directory does not exist, we create it here
mkdir(output_dir, S_IRWXU | S_IRWXG | S_IRWXO);
......
......@@ -52,21 +52,26 @@ int create_dir(char output_dir[DIR_LENGTH_MAX], char user_name[FILENAME_LENGTH_M
char directory[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX] = "";
mode_t process_mask = umask(0);
strcpy(directory, output_dir);
//strcpy(directory, output_dir);
strncpy(directory, output_dir, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX);
directory[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - 1] = 0; // terminate string
struct stat st;
if(stat(directory, &st) != 0) { // if output_dir does not exist, we create it here
mkdir(directory, S_IRWXU | S_IRWXG | S_IRWXO);
LOG_I(OCG, "output_dir %s is created", directory);
}
strcat(directory, user_name);
//strcat(directory, user_name);
strncat(directory, user_name, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(directory) - 1);
mkdir(directory, S_IRWXU | S_IRWXG | S_IRWXO);
strcat(directory, "/");
strcat(directory, file_date);
// strcat(directory, "/");
//strcat(directory, file_date);
strncat(directory, "/", FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(directory) - 1);
strncat(directory, file_date, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(directory) - 1);
mkdir(directory, S_IRWXU | S_IRWXG |S_IRWXO);
//char directory_extension[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX + 64] = "";
......
......@@ -92,8 +92,11 @@ int detect_file(char src_dir[DIR_LENGTH_MAX], char is_local_server[FILENAME_LENG
}
char check_src_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX];
strcpy(check_src_file, src_dir);
strcat(check_src_file, filename);
//strcpy(check_src_file, src_dir);
//strcat(check_src_file, filename);
strncpy(check_src_file, src_dir, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX);
check_src_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - 1] = 0; // terminate string
strncat(check_src_file, filename, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(check_src_file) - 1);
struct stat st;
if(stat(check_src_file, &st) != 0) {
LOG_E(OCG, "file %s does not exist\n", check_src_file);
......
......@@ -54,9 +54,11 @@ int generate_report(char dst_dir[DIR_LENGTH_MAX], char filename[FILENAME_LENGTH_
// for the xml writer, refer to http://xmlsoft.org/html/libxml-xmlwriter.html
char dst_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX] = "";
strcat(dst_file, dst_dir);
strcat(dst_file, filename);
//strcat(dst_file, dst_dir);
//strcat(dst_file, filename);
strncat(dst_file, dst_dir, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(dst_file) - 1);
strncat(dst_file, filename, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(dst_file) - 1);
xmlTextWriterPtr writer;
writer = xmlNewTextWriterFilename(dst_file, 0);
......
......@@ -1249,15 +1249,17 @@ void characters(void *user_data, const xmlChar *xmlch, int xmllen) { // called o
oai_emulation.info.opp_enabled = atoi(ch);
} else if (trace_file_) {
oai_emulation.info.opt_enabled = 1;
if (strcmp(strndup(ch, len), "wireshark") == 0) {
opt_type = OPT_WIRESHARK;
} else if (strcmp(strndup(ch, len), "pcap") == 0) {
opt_type = OPT_PCAP;
} else {
opt_type = OPT_NONE;
oai_emulation.info.opt_enabled = 0;
}
oai_emulation.info.opt_mode = opt_type;
// if (strcmp(strndup(ch, len), "wireshark") == 0) {
if (strncmp(ch, "wireshark", len) == 0) {
opt_type = OPT_WIRESHARK;
// } else if (strcmp(strndup(ch, len), "pcap") == 0) {
} else if (strncmp(ch, "pcap", len) == 0) {
opt_type = OPT_PCAP;
} else {
opt_type = OPT_NONE;
oai_emulation.info.opt_enabled = 0;
}
oai_emulation.info.opt_mode = opt_type;
} else if (background_stats_) {
oai_emulation.emulation_config.background_stats = strndup(ch, len);
}else if (performance_metrics_) {
......
......@@ -48,27 +48,34 @@
/*----------------------------------------------------------------------------*/
int parse_filename(char filename[FILENAME_LENGTH_MAX]) {
char *delim = "._";
//char *result;
char tmp_filename[FILENAME_LENGTH_MAX];
char *fd_tmp;
char *un_tmp;
char *ex_tmp;
//delim = "._";
strcpy(tmp_filename, filename);
un_tmp = strtok(tmp_filename, delim);
fd_tmp = strtok(NULL, delim);
ex_tmp = strtok(NULL, delim);
if ((ex_tmp == NULL) || ((strcmp(ex_tmp, "xml")) && (strcmp(ex_tmp, "XML")))) {
LOG_E(OCG, "Please use .xml file for configuration with the format \"user_name.file_date.xml\"\nfile_date = \"year month day hour minute second\" without space, \ne.g. 20100201193045 represents in the year 2010, February 1st, 19:30:45\n");
return MODULE_ERROR;
} else {
strcpy(file_date, fd_tmp);
strcpy(user_name, un_tmp);
LOG_I(OCG, "File name is parsed as user_name = %s, file_date = %s\n", user_name, file_date);
return MODULE_OK;
}
char *delim = "._";
//char *result;
char tmp_filename[FILENAME_LENGTH_MAX];
char *fd_tmp;
char *un_tmp;
char *ex_tmp;
//delim = "._";
// strcpy(tmp_filename, filename);
strncpy(tmp_filename, filename, FILENAME_LENGTH_MAX);
tmp_filename[FILENAME_LENGTH_MAX - 1] = 0; // terminate string
un_tmp = strtok(tmp_filename, delim);
fd_tmp = strtok(NULL, delim);
ex_tmp = strtok(NULL, delim);
if ((ex_tmp == NULL) || ((strcmp(ex_tmp, "xml")) && (strcmp(ex_tmp, "XML")))) {
LOG_E(OCG, "Please use .xml file for configuration with the format \"user_name.file_date.xml\"\nfile_date = \"year month day hour minute second\" without space, \ne.g. 20100201193045 represents in the year 2010, February 1st, 19:30:45\n");
return MODULE_ERROR;
} else {
//strcpy(file_date, fd_tmp);
//strcpy(user_name, un_tmp);
strncpy(file_date, fd_tmp, sizeof(file_date));
file_date[sizeof(file_date) - 1] = 0; // terminate string
strncpy(user_name, un_tmp, sizeof(user_name));
user_name[sizeof(user_name) - 1] = 0; // terminate string
LOG_I(OCG, "File name is parsed as user_name = %s, file_date = %s\n", user_name, file_date);
return MODULE_OK;
}
}
......@@ -49,32 +49,40 @@
//int save_XML(int copy_or_move, char src_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX], char dst_dir[DIR_LENGTH_MAX], char filename[FILENAME_LENGTH_MAX]) {
int save_XML(int copy_or_move, char *src_file, char *output_dir, char *filename) {
FILE *fs, *ft;
char ch;
char dst_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX + 32] = "";
char XML_saving_dir[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX + 32] = "";
strcpy(dst_file, output_dir);
//strcat(dst_file, "SCENARIO/XML/");
strcpy(XML_saving_dir, dst_file);
strcat(dst_file, filename);
fs = fopen(src_file, "r");
ft = fopen(dst_file, "w");
if ((ft !=NULL)&&(fs!=NULL)){
while(1) {
ch = getc(fs);
if(ch == EOF) {
break;
} else {
putc(ch, ft);
}
}
fclose(fs);
fclose(ft);
}
if (copy_or_move == 2) remove(src_file);
LOG_I(OCG, "The file is saved in directory \"%s\"\n", XML_saving_dir);
return MODULE_OK;
FILE *fs, *ft;
int ch;
char dst_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX + 32] = "";
char XML_saving_dir[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX + 32] = "";
//strcpy(dst_file, output_dir);
strncpy(dst_file, output_dir, sizeof(dst_file));
dst_file[sizeof(dst_file) - 1] = 0; // terminate string
//strcat(dst_file, "SCENARIO/XML/");
//strcpy(XML_saving_dir, dst_file);
//strcat(dst_file, filename);
strncpy(XML_saving_dir, dst_file, sizeof(XML_saving_dir));
XML_saving_dir[sizeof(XML_saving_dir) - 1] = 0; // terminate string
strncat(dst_file, filename, sizeof(dst_file) - strlen(dst_file) - 1);
fs = fopen(src_file, "r");
ft = fopen(dst_file, "w");
if ((ft !=NULL)&&(fs!=NULL)){
while(1) {
ch = getc(fs);
if(ch == EOF) {
break;
} else {
putc(ch, ft);
}
}
}
if (fs)
fclose(fs);
if (ft)
fclose(ft);
if (copy_or_move == 2) remove(src_file);
LOG_I(OCG, "The file is saved in directory \"%s\"\n", XML_saving_dir);
return MODULE_OK;
}
......@@ -164,6 +164,7 @@ void processSubscriptions() {
continue;
}
}
free( objID );
}
}
......@@ -211,7 +212,8 @@ int extractCommandStatus(storage *s, unsigned char commandId, char * description
description = readString();
// print description if needed
free( description );
description = 0;
//free actual message content
//depends on the message which is handled
......@@ -325,6 +327,8 @@ void commandGetVehicleVariable(char *vehID, int varID)// malloc for vehID and va
UNUSED_VARIABLE(rs);
UNUSED_VARIABLE(valueDataType);
UNUSED_VARIABLE(domID);
free( rs );
}
}
......
......@@ -118,6 +118,7 @@ void sendExact(int cmdLength){
buf +=n;
}
freeStorage(storageStart);
free(buf);
}
......@@ -147,6 +148,9 @@ storage * receiveExact(){
// create storage to access the content
tracker = writePacket(bufLength, 4);
free( bufLength );
bufLength = 0;
// store pointer to free the space later
// storage *freeTracker = tracker;
int s= readInt();
......@@ -184,7 +188,10 @@ storage * receiveExact(){
bytesRead += readThisTime;
}
return writePacket(buf, NN);
storage* temp = writePacket(buf, NN);
free( buf );
return temp;
//return writePacket(buf, NN);
}
......
......@@ -211,7 +211,8 @@ update_IDs (void)
if (tmp_departed->string != NULL)
{
char *tmp_string = malloc (sizeof (strlen (tmp_departed->string)));
// char *tmp_string = malloc (sizeof (strlen (tmp_departed->string)));
char *tmp_string = malloc( strlen(tmp_departed->string) + 1 );
strcpy (tmp_string, tmp_departed->string);
//printf("OMG - 2 head is not null and value is: %s\n",tmp_string);
int OAI_ID = get_oaiID_by_SUMO (tmp_string, id_manager);
......@@ -221,16 +222,19 @@ update_IDs (void)
{
// printf("Reached the Maximum of OAI nodes to be mapped to SUMO\n");
// LOG_I(OMG, "Reached the Maximum of OAI nodes to be mapped to SUMO\n");
free( tmp_string );
return; // stopping mapping as the maximum of OAI nodes has been reached;
}
}
free( tmp_string );
}
while (tmp_departed->next != NULL)
{
// printf("OMG - 2 main is not null \n");
//char tmp_string [strlen(tmp_departed->string)];
char *tmp_string = malloc (sizeof (strlen (tmp_departed->string)));
//char *tmp_string = malloc (sizeof (strlen (tmp_departed->string)));
char *tmp_string = malloc( strlen(tmp_departed->string) + 1 );
strcpy (tmp_string, tmp_departed->string);
//char *tmp_string = tmp_departed->string;
int OAI_ID = get_oaiID_by_SUMO (tmp_string, id_manager);
......@@ -240,9 +244,11 @@ update_IDs (void)
{
//printf("Reached the Maximum of OAI nodes to be mapped to SUMO\n");
//LOG_I(OMG, "Reached the Maximum of OAI nodes to be mapped to SUMO\n");
free( tmp_string );
return; // stopping mapping as the maximum of OAI nodes has been reached;
}
}
free( tmp_string );
tmp_departed = tmp_departed->next;
}
......@@ -324,8 +330,7 @@ activate_and_map (char *sumo_id)
LOG_I (OMG, "activating node %s \n", sumo_id);
#endif
// TODO: So far, only UE can be SUMO mobile, but could change
node_struct *active_node =
get_first_inactive_OAI_node (node_vector[SUMO], UE);
node_struct *active_node = get_first_inactive_OAI_node (node_vector[SUMO], UE);
if (active_node != NULL)
{ // found an inactive OAI node; will be mapped to SUMO
active_node->mobile = 1; // now node is active in SUMO
......@@ -333,7 +338,8 @@ activate_and_map (char *sumo_id)
active_nodes = add_entry (active_node, active_nodes);
map->oai_id = active_node->id;
map->sumo_id = malloc (sizeof ((int) strlen (sumo_id)));
// map->sumo_id = malloc (sizeof ((int) strlen (sumo_id)));
map->sumo_id = malloc( strlen(sumo_id) + 1 );
strcpy (map->sumo_id, sumo_id);
#ifdef STANDALONE
......@@ -345,6 +351,7 @@ activate_and_map (char *sumo_id)
#endif