Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
常顺宇
OpenXG-RAN
Commits
f03e2dbc
Commit
f03e2dbc
authored
Aug 17, 2016
by
Frédéric Leroy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(conf2uedata): move user_data function in conf_user_data[c|h]
parent
eeb44860
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
115 additions
and
86 deletions
+115
-86
cmake_targets/nas_sim_tools/CMakeLists.txt
cmake_targets/nas_sim_tools/CMakeLists.txt
+1
-0
openair3/NAS/TOOLS/conf2uedata.c
openair3/NAS/TOOLS/conf2uedata.c
+4
-79
openair3/NAS/TOOLS/conf2uedata.h
openair3/NAS/TOOLS/conf2uedata.h
+0
-7
openair3/NAS/TOOLS/conf_user_data.c
openair3/NAS/TOOLS/conf_user_data.c
+84
-0
openair3/NAS/TOOLS/conf_user_data.h
openair3/NAS/TOOLS/conf_user_data.h
+26
-0
No files found.
cmake_targets/nas_sim_tools/CMakeLists.txt
View file @
f03e2dbc
...
...
@@ -18,6 +18,7 @@ set(OPENAIR3_DIR $ENV{OPENAIR_DIR}/openair3)
set
(
conf2uedata_SRC
${
OPENAIR_DIR
}
/openair3/NAS/TOOLS/conf2uedata.c
${
OPENAIR_DIR
}
/openair3/NAS/TOOLS/conf_emm.c
${
OPENAIR_DIR
}
/openair3/NAS/TOOLS/conf_user_data.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
...
...
openair3/NAS/TOOLS/conf2uedata.c
View file @
f03e2dbc
...
...
@@ -11,6 +11,7 @@
#include "display.h"
#include "fs.h"
#include "conf_emm.h"
#include "conf_user_data.h"
const
char
*
msin
=
NULL
;
const
char
*
usim_api_k
=
NULL
;
...
...
@@ -113,6 +114,7 @@ int parse_config_file(const char *output_dir, const char *conf_filename) {
emm_nvdata_t
emm_data
;
user_nvdata_t
user_data
;
usim_data_t
usim_data
;
user_data_conf_t
user_data_conf
;
sprintf
(
user
,
"%s%d"
,
UE
,
i
);
...
...
@@ -122,11 +124,12 @@ int parse_config_file(const char *output_dir, const char *conf_filename) {
return
EXIT_FAILURE
;
}
rc
=
parse_ue_user_
param
(
ue_setting
,
i
,
&
user_data
);
rc
=
parse_ue_user_
data
(
ue_setting
,
i
,
&
user_data_conf
);
if
(
rc
!=
EXIT_SUCCESS
)
{
printf
(
"Problem in USER section for UE%d. EXITING...
\n
"
,
i
);
return
EXIT_FAILURE
;
}
gen_user_data
(
&
user_data_conf
,
&
user_data
);
write_user_data
(
output_dir
,
i
,
&
user_data
);
rc
=
parse_ue_sim_param
(
ue_setting
,
i
);
...
...
@@ -582,69 +585,6 @@ int parse_ue_sim_param(config_setting_t *ue_setting, int user_id) {
return
EXIT_SUCCESS
;
}
int
parse_ue_user_param
(
config_setting_t
*
ue_setting
,
int
user_id
,
user_nvdata_t
*
user_data
)
{
config_setting_t
*
ue_param_setting
=
NULL
;
const
char
*
imei
=
NULL
;
const
char
*
manufacturer
=
NULL
;
const
char
*
model
=
NULL
;
const
char
*
pin
=
NULL
;
int
rc
=
EXIT_SUCCESS
;
ue_param_setting
=
config_setting_get_member
(
ue_setting
,
USER
);
if
(
ue_param_setting
==
NULL
)
{
printf
(
"Check USER section of UE%d. EXITING...
\n
"
,
user_id
);
return
EXIT_FAILURE
;
}
rc
=
config_setting_lookup_string
(
ue_param_setting
,
UE_IMEI
,
&
imei
);
if
(
rc
!=
1
)
{
printf
(
"Check USER IMEI section for UE%d. Exiting
\n
"
,
user_id
);
return
EXIT_FAILURE
;
}
rc
=
config_setting_lookup_string
(
ue_param_setting
,
MANUFACTURER
,
&
manufacturer
);
if
(
rc
!=
1
)
{
printf
(
"Check USER MANUFACTURER for UE%d FULLNAME. Exiting
\n
"
,
user_id
);
return
EXIT_FAILURE
;
}
rc
=
config_setting_lookup_string
(
ue_param_setting
,
MODEL
,
&
model
);
if
(
rc
!=
1
)
{
printf
(
"Check USER MODEL for UE%d FULLNAME. Exiting
\n
"
,
user_id
);
return
EXIT_FAILURE
;
}
rc
=
config_setting_lookup_string
(
ue_param_setting
,
PINCODE
,
&
pin
);
if
(
rc
!=
1
)
{
printf
(
"Check USER PIN for UE%d FULLNAME. Exiting
\n
"
,
user_id
);
return
EXIT_FAILURE
;
}
memset
(
user_data
,
0
,
sizeof
(
user_nvdata_t
));
snprintf
(
user_data
->
IMEI
,
USER_IMEI_SIZE
+
1
,
"%s%d"
,
imei
,
_luhn
(
imei
));
/*
* Manufacturer identifier
*/
strncpy
(
user_data
->
manufacturer
,
manufacturer
,
USER_MANUFACTURER_SIZE
);
/*
* Model identifier
*/
strncpy
(
user_data
->
model
,
model
,
USER_MODEL_SIZE
);
/*
* SIM Personal Identification Number
*/
strncpy
(
user_data
->
PIN
,
pin
,
USER_PIN_SIZE
);
return
EXIT_SUCCESS
;
}
void
write_user_data
(
const
char
*
directory
,
int
user_id
,
user_nvdata_t
*
data
)
{
int
rc
;
char
*
filename
=
make_filename
(
directory
,
USER_NVRAM_FILENAME
,
user_id
);
rc
=
memory_write
(
filename
,
data
,
sizeof
(
user_nvdata_t
));
free
(
filename
);
if
(
rc
!=
RETURNok
)
{
perror
(
"ERROR
\t
: memory_write() failed"
);
exit
(
EXIT_FAILURE
);
}
}
int
fill_ucplmn
(
config_setting_t
*
setting
,
int
user_id
)
{
int
rc
;
...
...
@@ -788,21 +728,6 @@ void fill_network_record_list() {
}
}
/*
* Computes the check digit using Luhn algorithm
*/
int
_luhn
(
const
char
*
cc
)
{
const
int
m
[]
=
{
0
,
2
,
4
,
6
,
8
,
1
,
3
,
5
,
7
,
9
};
int
odd
=
1
,
sum
=
0
;
for
(
int
i
=
strlen
(
cc
);
i
--
;
odd
=
!
odd
)
{
int
digit
=
cc
[
i
]
-
'0'
;
sum
+=
odd
?
m
[
digit
]
:
digit
;
}
return
10
-
(
sum
%
10
);
}
/*
* Displays command line usage
*/
...
...
openair3/NAS/TOOLS/conf2uedata.h
View file @
f03e2dbc
...
...
@@ -4,9 +4,7 @@
#include <libconfig.h>
#include "usim_api.h"
#include "userDef.h"
#define USER "USER"
#define UE "UE"
#define SIM "SIM"
#define PLMN "PLMN"
...
...
@@ -101,14 +99,9 @@ int parse_config_file(const char *output_dir, const char *filename);
void
_display_usage
(
void
);
void
fill_network_record_list
(
void
);
int
parse_ue_user_param
(
config_setting_t
*
ue_setting
,
int
user_id
,
user_nvdata_t
*
user_data
);
void
write_user_data
(
const
char
*
directory
,
int
user_id
,
user_nvdata_t
*
data
);
int
write_usim_data
(
const
char
*
directory
,
int
user_id
,
usim_data_t
*
usim_data
);
void
gen_usim_data
(
usim_data_t
*
usim_data
);
int
_luhn
(
const
char
*
cc
);
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_plmns
(
config_setting_t
*
all_plmn_setting
);
...
...
openair3/NAS/TOOLS/conf_user_data.c
0 → 100644
View file @
f03e2dbc
#include <string.h>
#include <stdlib.h>
#include "memory.h"
#include "fs.h"
#include "conf_user_data.h"
int
parse_ue_user_data
(
config_setting_t
*
ue_setting
,
int
user_id
,
user_data_conf_t
*
u
)
{
config_setting_t
*
ue_param_setting
=
NULL
;
int
rc
=
EXIT_SUCCESS
;
ue_param_setting
=
config_setting_get_member
(
ue_setting
,
USER
);
if
(
ue_param_setting
==
NULL
)
{
printf
(
"Check USER section of UE%d. EXITING...
\n
"
,
user_id
);
return
EXIT_FAILURE
;
}
rc
=
config_setting_lookup_string
(
ue_param_setting
,
UE_IMEI
,
&
u
->
imei
);
if
(
rc
!=
1
)
{
printf
(
"Check USER IMEI section for UE%d. Exiting
\n
"
,
user_id
);
return
EXIT_FAILURE
;
}
rc
=
config_setting_lookup_string
(
ue_param_setting
,
MANUFACTURER
,
&
u
->
manufacturer
);
if
(
rc
!=
1
)
{
printf
(
"Check USER MANUFACTURER for UE%d FULLNAME. Exiting
\n
"
,
user_id
);
return
EXIT_FAILURE
;
}
rc
=
config_setting_lookup_string
(
ue_param_setting
,
MODEL
,
&
u
->
model
);
if
(
rc
!=
1
)
{
printf
(
"Check USER MODEL for UE%d FULLNAME. Exiting
\n
"
,
user_id
);
return
EXIT_FAILURE
;
}
rc
=
config_setting_lookup_string
(
ue_param_setting
,
PINCODE
,
&
u
->
pin
);
if
(
rc
!=
1
)
{
printf
(
"Check USER PIN for UE%d FULLNAME. Exiting
\n
"
,
user_id
);
return
EXIT_FAILURE
;
}
return
EXIT_SUCCESS
;
}
void
gen_user_data
(
user_data_conf_t
*
u
,
user_nvdata_t
*
user_data
)
{
memset
(
user_data
,
0
,
sizeof
(
user_nvdata_t
));
snprintf
(
user_data
->
IMEI
,
USER_IMEI_SIZE
+
1
,
"%s%d"
,
u
->
imei
,
_luhn
(
u
->
imei
));
/*
* Manufacturer identifier
*/
strncpy
(
user_data
->
manufacturer
,
u
->
manufacturer
,
USER_MANUFACTURER_SIZE
);
/*
* Model identifier
*/
strncpy
(
user_data
->
model
,
u
->
model
,
USER_MODEL_SIZE
);
/*
* SIM Personal Identification Number
*/
strncpy
(
user_data
->
PIN
,
u
->
pin
,
USER_PIN_SIZE
);
}
void
write_user_data
(
const
char
*
directory
,
int
user_id
,
user_nvdata_t
*
data
)
{
int
rc
;
char
*
filename
=
make_filename
(
directory
,
USER_NVRAM_FILENAME
,
user_id
);
rc
=
memory_write
(
filename
,
data
,
sizeof
(
user_nvdata_t
));
free
(
filename
);
if
(
rc
!=
EXIT_SUCCESS
)
{
perror
(
"ERROR
\t
: memory_write() failed"
);
exit
(
EXIT_FAILURE
);
}
}
/*
* Computes the check digit using Luhn algorithm
*/
int
_luhn
(
const
char
*
cc
)
{
const
int
m
[]
=
{
0
,
2
,
4
,
6
,
8
,
1
,
3
,
5
,
7
,
9
};
int
odd
=
1
,
sum
=
0
;
for
(
int
i
=
strlen
(
cc
);
i
--
;
odd
=
!
odd
)
{
int
digit
=
cc
[
i
]
-
'0'
;
sum
+=
odd
?
m
[
digit
]
:
digit
;
}
return
10
-
(
sum
%
10
);
}
openair3/NAS/TOOLS/conf_user_data.h
0 → 100644
View file @
f03e2dbc
#ifndef _CONF_USER_DATA_H
#define _CONF_USER_DATA_H
#include <libconfig.h>
#include "userDef.h"
#define USER "USER"
#define MANUFACTURER "MANUFACTURER"
#define MODEL "MODEL"
#define UE_IMEI "IMEI"
#define PINCODE "PIN"
typedef
struct
{
const
char
*
imei
;
const
char
*
manufacturer
;
const
char
*
model
;
const
char
*
pin
;
}
user_data_conf_t
;
void
gen_user_data
(
user_data_conf_t
*
u
,
user_nvdata_t
*
user_data
);
void
write_user_data
(
const
char
*
directory
,
int
user_id
,
user_nvdata_t
*
data
);
int
parse_ue_user_data
(
config_setting_t
*
ue_setting
,
int
user_id
,
user_data_conf_t
*
u
);
int
_luhn
(
const
char
*
cc
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment