Commit 8461a56a authored by Frédéric Leroy's avatar Frédéric Leroy

refactor(conf2uedata): add fs.[h|c] and display.[c|h]

parent 8ae72d1c
...@@ -10,13 +10,15 @@ add_definitions(-std=gnu99) ...@@ -10,13 +10,15 @@ add_definitions(-std=gnu99)
ENABLE_LANGUAGE(C) ENABLE_LANGUAGE(C)
set(CMAKE_C_FLAGS set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} -Werror -Wall -Wstrict-prototypes -Wno-packed-bitfield-compat") "${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} -Werror -Wall -Wstrict-prototypes -Wno-packed-bitfield-compat -g")
set(OPENAIR_DIR $ENV{OPENAIR_DIR}) set(OPENAIR_DIR $ENV{OPENAIR_DIR})
set(OPENAIR3_DIR $ENV{OPENAIR_DIR}/openair3) set(OPENAIR3_DIR $ENV{OPENAIR_DIR}/openair3)
set(conf2uedata_SRC set(conf2uedata_SRC
${OPENAIR_DIR}/openair3/NAS/TOOLS/conf2uedata.c ${OPENAIR_DIR}/openair3/NAS/TOOLS/conf2uedata.c
${OPENAIR_DIR}/openair3/NAS/TOOLS/fs.c
${OPENAIR_DIR}/openair3/NAS/TOOLS/display.c
${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/usim_api.c ${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/usim_api.c
${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/aka_functions.c ${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/aka_functions.c
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/memory.c ${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/memory.c
......
This diff is collapsed.
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
#include <libconfig.h> #include <libconfig.h>
#include "emmData.h" #include "emmData.h"
#include "usim_api.h"
#include "userDef.h"
#include "memory.h"
#include "getopt.h"
#define USER "USER" #define USER "USER"
#define UE "UE" #define UE "UE"
...@@ -36,16 +32,6 @@ ...@@ -36,16 +32,6 @@
#define EHPLMN "EHPLMN_LIST" #define EHPLMN "EHPLMN_LIST"
#define KSI USIM_KSI_NOT_AVAILABLE #define KSI USIM_KSI_NOT_AVAILABLE
#define PRINT_PLMN_DIGIT(d) if ((d) != 0xf) printf("%u", (d))
#define PRINT_PLMN(plmn) \
PRINT_PLMN_DIGIT((plmn).MCCdigit1); \
PRINT_PLMN_DIGIT((plmn).MCCdigit2); \
PRINT_PLMN_DIGIT((plmn).MCCdigit3); \
PRINT_PLMN_DIGIT((plmn).MNCdigit1); \
PRINT_PLMN_DIGIT((plmn).MNCdigit2); \
PRINT_PLMN_DIGIT((plmn).MNCdigit3)
#define KSI_ASME USIM_KSI_NOT_AVAILABLE #define KSI_ASME USIM_KSI_NOT_AVAILABLE
#define INT_ALGO USIM_INT_EIA1 #define INT_ALGO USIM_INT_EIA1
...@@ -65,16 +51,6 @@ ...@@ -65,16 +51,6 @@
#define DEFAULT_MME_ID 0x0102 #define DEFAULT_MME_ID 0x0102
#define DEFAULT_MME_CODE 0x0F #define DEFAULT_MME_CODE 0x0F
#define PRINT_PLMN_DIGIT(d) if ((d) != 0xf) printf("%u", (d))
#define PRINT_PLMN(plmn) \
PRINT_PLMN_DIGIT((plmn).MCCdigit1); \
PRINT_PLMN_DIGIT((plmn).MCCdigit2); \
PRINT_PLMN_DIGIT((plmn).MCCdigit3); \
PRINT_PLMN_DIGIT((plmn).MNCdigit1); \
PRINT_PLMN_DIGIT((plmn).MNCdigit2); \
PRINT_PLMN_DIGIT((plmn).MNCdigit3)
/* /*
* PLMN network operator record * PLMN network operator record
*/ */
...@@ -122,7 +98,6 @@ extern network_record_t* user_network_record_list; ...@@ -122,7 +98,6 @@ extern network_record_t* user_network_record_list;
int get_config_from_file(const char *filename, config_t *config); int get_config_from_file(const char *filename, config_t *config);
int parse_config_file(const char *filename); int parse_config_file(const char *filename);
void _display_usage(void); void _display_usage(void);
void gen_emm_data(int user_id) ; void gen_emm_data(int user_id) ;
void gen_usim_data(int user_id); void gen_usim_data(int user_id);
...@@ -130,17 +105,6 @@ void fill_network_record_list(void); ...@@ -130,17 +105,6 @@ void fill_network_record_list(void);
int _luhn(const char* cc); int _luhn(const char* cc);
void display_data_from_directory(const char *directory);
void display_ue_data(const char *filename);
void display_emm_data(const char *filename);
void display_usim_data(const char *filename);
bool file_exist_and_is_readable(const char *filename);
char *get_ue_filename(const char *output_dir, int user_id);
char *get_emm_filename(const char *output_dir, int user_id);
char *get_usim_filename(const char *output_dir, int user_id);
char *make_filename(const char *output_dir, const char *filename, int ueid);
int parse_ue_user_param(config_setting_t *ue_setting, int user_id); int parse_ue_user_param(config_setting_t *ue_setting, int user_id);
int parse_ue_sim_param(config_setting_t *ue_setting, int user_id); int parse_ue_sim_param(config_setting_t *ue_setting, int user_id);
int parse_plmn_param(config_setting_t *plmn_setting, int index); int parse_plmn_param(config_setting_t *plmn_setting, int index);
......
This diff is collapsed.
#ifndef _DISPLAY_H
#define _DISPLAY_H
void display_data_from_directory(const char *directory);
void display_ue_data(const char *filename);
void display_emm_data(const char *filename);
void display_usim_data(const char *filename);
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fs.h"
#include "user_api.h"
#include "utils.h"
bool file_exist_and_is_readable(const char *filename) {
FILE *file ;
file = fopen(filename, "r");
if ( file == NULL )
return false;
fclose(file);
return true;
}
char *get_ue_filename(const char *output_dir, int user_id) {
return make_filename(output_dir, USER_NVRAM_FILENAME, user_id);
}
char *get_emm_filename(const char *output_dir, int user_id) {
return make_filename(output_dir, EMM_NVRAM_FILENAME, user_id);
}
char *get_usim_filename(const char *output_dir, int user_id) {
return make_filename(output_dir, USIM_API_NVRAM_FILENAME, user_id);
}
char *make_filename(const char *output_dir, const char *filename, int ueid) {
size_t size;
char *str_ueid, *str;
str_ueid = itoa(ueid);
if (str_ueid == NULL) {
perror("ERROR\t: itoa() failed");
exit(EXIT_FAILURE);
}
size = strlen(output_dir)+strlen(filename) + sizeof(ueid) + 1 + 1; // for \0 and for '/'
str = malloc(size);
if (str == NULL) {
perror("ERROR\t: make_filename() failed");
exit(EXIT_FAILURE);
}
snprintf(str, size, "%s/%s%s",output_dir, filename, str_ueid);
free(str_ueid);
return str;
}
#ifndef _FS_H
#define _FS_H
#include <stdbool.h>
bool file_exist_and_is_readable(const char *filename);
char *get_ue_filename(const char *output_dir, int user_id);
char *get_emm_filename(const char *output_dir, int user_id);
char *get_usim_filename(const char *output_dir, int user_id);
char *make_filename(const char *output_dir, const char *filename, int ueid);
#endif
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