Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG UE
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
Michael Black
OpenXG UE
Commits
32ce8222
Commit
32ce8222
authored
Aug 23, 2016
by
Frédéric Leroy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(conf2uedata): add networks_t for managing known_networks
parent
308baec0
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
116 additions
and
111 deletions
+116
-111
openair3/NAS/TOOLS/conf2uedata.c
openair3/NAS/TOOLS/conf2uedata.c
+58
-61
openair3/NAS/TOOLS/conf2uedata.h
openair3/NAS/TOOLS/conf2uedata.h
+16
-9
openair3/NAS/TOOLS/conf_emm.c
openair3/NAS/TOOLS/conf_emm.c
+17
-17
openair3/NAS/TOOLS/conf_emm.h
openair3/NAS/TOOLS/conf_emm.h
+2
-2
openair3/NAS/TOOLS/conf_usim.c
openair3/NAS/TOOLS/conf_usim.c
+22
-21
openair3/NAS/TOOLS/conf_usim.h
openair3/NAS/TOOLS/conf_usim.h
+1
-1
No files found.
openair3/NAS/TOOLS/conf2uedata.c
View file @
32ce8222
...
@@ -12,11 +12,6 @@
...
@@ -12,11 +12,6 @@
#include "conf_user_data.h"
#include "conf_user_data.h"
#include "conf_usim.h"
#include "conf_usim.h"
int
plmn_nb
=
0
;
plmn_conf_param_t
*
user_plmn_list
=
NULL
;
network_record_t
*
user_network_record_list
=
NULL
;
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
int
option
;
int
option
;
const
char
*
conf_file
=
NULL
;
const
char
*
conf_file
=
NULL
;
...
@@ -71,6 +66,8 @@ int parse_config_file(const char *output_dir, const char *conf_filename) {
...
@@ -71,6 +66,8 @@ int parse_config_file(const char *output_dir, const char *conf_filename) {
char
user
[
10
];
char
user
[
10
];
config_t
cfg
;
config_t
cfg
;
networks_t
networks
;;
ret
=
get_config_from_file
(
conf_filename
,
&
cfg
);
ret
=
get_config_from_file
(
conf_filename
,
&
cfg
);
if
(
ret
==
EXIT_FAILURE
)
{
if
(
ret
==
EXIT_FAILURE
)
{
exit
(
1
);
exit
(
1
);
...
@@ -85,11 +82,10 @@ int parse_config_file(const char *output_dir, const char *conf_filename) {
...
@@ -85,11 +82,10 @@ int parse_config_file(const char *output_dir, const char *conf_filename) {
return
(
EXIT_FAILURE
);
return
(
EXIT_FAILURE
);
}
}
rc
=
parse_plmns
(
all_plmn_setting
);
rc
=
parse_plmns
(
all_plmn_setting
,
&
networks
);
if
(
rc
==
EXIT_FAILURE
)
{
if
(
rc
==
EXIT_FAILURE
)
{
return
rc
;
return
rc
;
}
}
fill_network_record_list
();
for
(
int
i
=
0
;
i
<
ue_nb
;
i
++
)
{
for
(
int
i
=
0
;
i
<
ue_nb
;
i
++
)
{
emm_nvdata_t
emm_data
;
emm_nvdata_t
emm_data
;
...
@@ -110,7 +106,7 @@ int parse_config_file(const char *output_dir, const char *conf_filename) {
...
@@ -110,7 +106,7 @@ int parse_config_file(const char *output_dir, const char *conf_filename) {
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
rc
=
parse_user_plmns_conf
(
ue_setting
,
i
,
&
user_plmns
,
&
usim_data_conf
.
hplmn
);
rc
=
parse_user_plmns_conf
(
ue_setting
,
i
,
&
user_plmns
,
&
usim_data_conf
.
hplmn
,
networks
);
if
(
rc
!=
EXIT_SUCCESS
)
{
if
(
rc
!=
EXIT_SUCCESS
)
{
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
...
@@ -128,13 +124,16 @@ int parse_config_file(const char *output_dir, const char *conf_filename) {
...
@@ -128,13 +124,16 @@ int parse_config_file(const char *output_dir, const char *conf_filename) {
printf
(
"Problem in SIM section for UE%d. EXITING...
\n
"
,
i
);
printf
(
"Problem in SIM section for UE%d. EXITING...
\n
"
,
i
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
gen_usim_data
(
&
usim_data_conf
,
&
usim_data
,
&
user_plmns
);
gen_usim_data
(
&
usim_data_conf
,
&
usim_data
,
&
user_plmns
,
networks
);
write_usim_data
(
output_dir
,
i
,
&
usim_data
);
write_usim_data
(
output_dir
,
i
,
&
usim_data
);
gen_emm_data
(
&
emm_data
,
usim_data_conf
.
hplmn
,
usim_data_conf
.
msin
,
user_plmns
.
equivalents_home
.
size
);
gen_emm_data
(
&
emm_data
,
usim_data_conf
.
hplmn
,
usim_data_conf
.
msin
,
user_plmns
.
equivalents_home
.
size
,
networks
);
write_emm_data
(
output_dir
,
i
,
&
emm_data
);
write_emm_data
(
output_dir
,
i
,
&
emm_data
);
}
}
free
(
networks
.
items
);
networks
.
size
=
0
;
config_destroy
(
&
cfg
);
config_destroy
(
&
cfg
);
return
(
EXIT_SUCCESS
);
return
(
EXIT_SUCCESS
);
}
}
...
@@ -160,52 +159,52 @@ int get_config_from_file(const char *filename, config_t *config) {
...
@@ -160,52 +159,52 @@ int get_config_from_file(const char *filename, config_t *config) {
}
}
int
parse_plmn_param
(
config_setting_t
*
plmn_setting
,
int
index
)
{
int
parse_plmn_param
(
config_setting_t
*
plmn_setting
,
plmn_conf_param_t
*
conf
)
{
int
rc
=
0
;
int
rc
=
0
;
rc
=
config_setting_lookup_string
(
plmn_setting
,
rc
=
config_setting_lookup_string
(
plmn_setting
,
FULLNAME
,
&
conf
->
fullname
);
FULLNAME
,
&
user_plmn_list
[
index
].
fullname
);
if
(
rc
!=
1
)
{
if
(
rc
!=
1
)
{
printf
(
"
Check PLMN%d FULLNAME. Exiting
\n
"
,
index
);
printf
(
"
Error on FULLNAME
\n
"
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
rc
=
config_setting_lookup_string
(
plmn_setting
,
rc
=
config_setting_lookup_string
(
plmn_setting
,
SHORTNAME
,
&
conf
->
shortname
);
SHORTNAME
,
&
user_plmn_list
[
index
].
shortname
);
if
(
rc
!=
1
)
{
if
(
rc
!=
1
)
{
printf
(
"
Check PLMN%d SHORTNAME. Exiting
\n
"
,
index
);
printf
(
"
Error on SHORTNAME
\n
"
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
rc
=
config_setting_lookup_string
(
plmn_setting
,
rc
=
config_setting_lookup_string
(
plmn_setting
,
MNC
,
&
conf
->
mnc
);
MNC
,
&
user_plmn_list
[
index
].
mnc
);
if
(
rc
!=
1
||
strlen
(
conf
->
mnc
)
>
3
if
(
rc
!=
1
||
strlen
(
user_plmn_list
[
index
].
mnc
)
>
3
||
strlen
(
conf
->
mnc
)
<
2
)
{
||
strlen
(
user_plmn_list
[
index
].
mnc
)
<
2
)
{
printf
(
"Error ond MNC. Exiting
\n
"
);
printf
(
"Check PLMN%d MNC. Exiting
\n
"
,
index
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
rc
=
config_setting_lookup_string
(
plmn_setting
,
rc
=
config_setting_lookup_string
(
plmn_setting
,
MCC
,
&
conf
->
mcc
);
MCC
,
&
user_plmn_list
[
index
].
mcc
);
if
(
rc
!=
1
||
strlen
(
conf
->
mcc
)
!=
3
)
{
if
(
rc
!=
1
||
strlen
(
user_plmn_list
[
index
].
mcc
)
!=
3
)
{
printf
(
"Error on MCC
\n
"
);
printf
(
"Check PLMN%d MCC. Exiting
\n
"
,
index
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
int
parse_plmns
(
config_setting_t
*
all_plmn_setting
)
{
int
parse_plmns
(
config_setting_t
*
all_plmn_setting
,
networks_t
*
networks
)
{
config_setting_t
*
plmn_setting
=
NULL
;
config_setting_t
*
plmn_setting
=
NULL
;
char
plmn
[
10
];
char
plmn
[
10
];
int
rc
=
EXIT_SUCCESS
;
int
rc
=
EXIT_SUCCESS
;
plmn_nb
=
config_setting_length
(
all_plmn_setting
);
int
size
=
0
;
user_plmn_list
=
malloc
(
sizeof
(
plmn_conf_param_t
)
*
plmn_nb
);
user_network_record_list
=
malloc
(
sizeof
(
network_record_t
)
*
plmn_nb
);
size
=
config_setting_length
(
all_plmn_setting
);
for
(
int
i
=
0
;
i
<
plmn_nb
;
i
++
)
{
memset
(
&
user_network_record_list
[
i
],
0xff
,
sizeof
(
network_record_t
));
networks
->
size
=
size
;
memset
(
&
user_plmn_list
[
i
],
0xff
,
sizeof
(
plmn_conf_param_t
));
networks
->
items
=
malloc
(
sizeof
(
network_t
)
*
size
);
}
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
for
(
int
i
=
0
;
i
<
plmn_nb
;
i
++
)
{
memset
(
&
networks
->
items
[
i
].
record
,
0xff
,
sizeof
(
network_record_t
));
}
for
(
int
i
=
0
;
i
<
networks
->
size
;
i
++
)
{
network_t
*
network
=
&
networks
->
items
[
i
];
sprintf
(
plmn
,
"%s%d"
,
PLMN
,
i
);
sprintf
(
plmn
,
"%s%d"
,
PLMN
,
i
);
plmn_setting
=
config_setting_get_member
(
all_plmn_setting
,
plmn
);
plmn_setting
=
config_setting_get_member
(
all_plmn_setting
,
plmn
);
if
(
plmn_setting
!=
NULL
)
{
if
(
plmn_setting
!=
NULL
)
{
rc
=
parse_plmn_param
(
plmn_setting
,
i
);
rc
=
parse_plmn_param
(
plmn_setting
,
&
network
->
conf
);
if
(
rc
==
EXIT_FAILURE
)
{
if
(
rc
==
EXIT_FAILURE
)
{
return
rc
;
return
rc
;
}
}
...
@@ -213,12 +212,15 @@ int parse_plmns(config_setting_t *all_plmn_setting) {
...
@@ -213,12 +212,15 @@ int parse_plmns(config_setting_t *all_plmn_setting) {
printf
(
"Problem in PLMN%d. Exiting...
\n
"
,
i
);
printf
(
"Problem in PLMN%d. Exiting...
\n
"
,
i
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
gen_network_record_from_conf
(
&
network
->
conf
,
&
network
->
record
);
network
->
plmn
=
network
->
record
.
plmn
;
}
}
return
rc
;
return
rc
;
}
}
int
parse_user_plmns_conf
(
config_setting_t
*
ue_setting
,
int
user_id
,
int
parse_user_plmns_conf
(
config_setting_t
*
ue_setting
,
int
user_id
,
user_plmns_t
*
user_plmns
,
const
char
**
h
)
{
user_plmns_t
*
user_plmns
,
const
char
**
h
,
const
networks_t
networks
)
{
int
nb_errors
=
0
;
int
nb_errors
=
0
;
const
char
*
hplmn
;
const
char
*
hplmn
;
...
@@ -227,21 +229,21 @@ int parse_user_plmns_conf(config_setting_t *ue_setting, int user_id,
...
@@ -227,21 +229,21 @@ int parse_user_plmns_conf(config_setting_t *ue_setting, int user_id,
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
hplmn
=
*
h
;
hplmn
=
*
h
;
if
(
get_plmn_index
(
hplmn
)
==
-
1
)
{
if
(
get_plmn_index
(
hplmn
,
networks
)
==
-
1
)
{
printf
(
"HPLMN for UE%d is not defined in PLMN section. Exiting
\n
"
,
printf
(
"HPLMN for UE%d is not defined in PLMN section. Exiting
\n
"
,
user_id
);
user_id
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
if
(
parse_Xplmn
(
ue_setting
,
UCPLMN
,
user_id
,
&
user_plmns
->
users_controlled
)
==
EXIT_FAILURE
)
if
(
parse_Xplmn
(
ue_setting
,
UCPLMN
,
user_id
,
&
user_plmns
->
users_controlled
,
networks
)
==
EXIT_FAILURE
)
nb_errors
++
;
nb_errors
++
;
if
(
parse_Xplmn
(
ue_setting
,
OPLMN
,
user_id
,
&
user_plmns
->
operators
)
==
EXIT_FAILURE
)
if
(
parse_Xplmn
(
ue_setting
,
OPLMN
,
user_id
,
&
user_plmns
->
operators
,
networks
)
==
EXIT_FAILURE
)
nb_errors
++
;
nb_errors
++
;
if
(
parse_Xplmn
(
ue_setting
,
OCPLMN
,
user_id
,
&
user_plmns
->
operators_controlled
)
==
EXIT_FAILURE
)
if
(
parse_Xplmn
(
ue_setting
,
OCPLMN
,
user_id
,
&
user_plmns
->
operators_controlled
,
networks
)
==
EXIT_FAILURE
)
nb_errors
++
;
nb_errors
++
;
if
(
parse_Xplmn
(
ue_setting
,
FPLMN
,
user_id
,
&
user_plmns
->
forbiddens
)
==
EXIT_FAILURE
)
if
(
parse_Xplmn
(
ue_setting
,
FPLMN
,
user_id
,
&
user_plmns
->
forbiddens
,
networks
)
==
EXIT_FAILURE
)
nb_errors
++
;
nb_errors
++
;
if
(
parse_Xplmn
(
ue_setting
,
EHPLMN
,
user_id
,
&
user_plmns
->
equivalents_home
)
==
EXIT_FAILURE
)
if
(
parse_Xplmn
(
ue_setting
,
EHPLMN
,
user_id
,
&
user_plmns
->
equivalents_home
,
networks
)
==
EXIT_FAILURE
)
nb_errors
++
;
nb_errors
++
;
if
(
nb_errors
>
0
)
if
(
nb_errors
>
0
)
...
@@ -250,7 +252,7 @@ int parse_user_plmns_conf(config_setting_t *ue_setting, int user_id,
...
@@ -250,7 +252,7 @@ int parse_user_plmns_conf(config_setting_t *ue_setting, int user_id,
}
}
int
parse_Xplmn
(
config_setting_t
*
ue_setting
,
const
char
*
section
,
int
parse_Xplmn
(
config_setting_t
*
ue_setting
,
const
char
*
section
,
int
user_id
,
plmns_list
*
plmns
)
{
int
user_id
,
plmns_list
*
plmns
,
const
networks_t
networks
)
{
int
rc
;
int
rc
;
int
item_count
;
int
item_count
;
config_setting_t
*
setting
;
config_setting_t
*
setting
;
...
@@ -269,7 +271,7 @@ int parse_Xplmn(config_setting_t *ue_setting, const char *section,
...
@@ -269,7 +271,7 @@ int parse_Xplmn(config_setting_t *ue_setting, const char *section,
printf
(
"Check %s section for UE%d. Exiting
\n
"
,
section
,
user_id
);
printf
(
"Check %s section for UE%d. Exiting
\n
"
,
section
,
user_id
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
rc
=
get_plmn_index
(
mccmnc
);
rc
=
get_plmn_index
(
mccmnc
,
networks
);
if
(
rc
==
-
1
)
{
if
(
rc
==
-
1
)
{
printf
(
"The PLMN %s is not defined in PLMN section. Exiting...
\n
"
,
printf
(
"The PLMN %s is not defined in PLMN section. Exiting...
\n
"
,
mccmnc
);
mccmnc
);
...
@@ -283,16 +285,16 @@ int parse_Xplmn(config_setting_t *ue_setting, const char *section,
...
@@ -283,16 +285,16 @@ int parse_Xplmn(config_setting_t *ue_setting, const char *section,
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
int
get_plmn_index
(
const
char
*
mccmnc
)
{
int
get_plmn_index
(
const
char
*
mccmnc
,
const
networks_t
networks
)
{
char
mcc
[
4
];
char
mcc
[
4
];
char
mnc
[
strlen
(
mccmnc
)
-
2
];
char
mnc
[
strlen
(
mccmnc
)
-
2
];
strncpy
(
mcc
,
mccmnc
,
3
);
strncpy
(
mcc
,
mccmnc
,
3
);
mcc
[
3
]
=
'\0'
;
mcc
[
3
]
=
'\0'
;
strncpy
(
mnc
,
mccmnc
+
3
,
3
);
strncpy
(
mnc
,
mccmnc
+
3
,
3
);
mnc
[
strlen
(
mccmnc
)
-
3
]
=
'\0'
;
mnc
[
strlen
(
mccmnc
)
-
3
]
=
'\0'
;
for
(
int
i
=
0
;
i
<
plmn_nb
;
i
++
)
{
for
(
int
i
=
0
;
i
<
networks
.
size
;
i
++
)
{
if
(
strcmp
(
user_plmn_list
[
i
]
.
mcc
,
mcc
)
==
0
)
{
if
(
strcmp
(
networks
.
items
[
i
].
conf
.
mcc
,
mcc
)
==
0
)
{
if
(
strcmp
(
user_plmn_list
[
i
]
.
mnc
,
mnc
)
==
0
)
{
if
(
strcmp
(
networks
.
items
[
i
].
conf
.
mnc
,
mnc
)
==
0
)
{
return
i
;
return
i
;
}
}
}
}
...
@@ -300,7 +302,6 @@ int get_plmn_index(const char * mccmnc) {
...
@@ -300,7 +302,6 @@ int get_plmn_index(const char * mccmnc) {
return
-
1
;
return
-
1
;
}
}
plmn_t
make_plmn_from_conf
(
const
plmn_conf_param_t
*
plmn_conf
)
{
plmn_t
make_plmn_from_conf
(
const
plmn_conf_param_t
*
plmn_conf
)
{
plmn_t
plmn
;
plmn_t
plmn
;
char
num
[
6
];
char
num
[
6
];
...
@@ -320,21 +321,17 @@ plmn_t make_plmn_from_conf(const plmn_conf_param_t *plmn_conf) {
...
@@ -320,21 +321,17 @@ plmn_t make_plmn_from_conf(const plmn_conf_param_t *plmn_conf) {
return
plmn
;
return
plmn
;
}
}
void
fill_network_record_list
()
{
void
gen_network_record_from_conf
(
const
plmn_conf_param_t
*
conf
,
network_record_t
*
record
)
{
for
(
int
i
=
0
;
i
<
plmn_nb
;
i
++
)
{
strcpy
(
record
->
fullname
,
conf
->
fullname
);
strcpy
(
user_network_record_list
[
i
].
fullname
,
strcpy
(
record
->
shortname
,
conf
->
shortname
);
user_plmn_list
[
i
].
fullname
);
strcpy
(
user_network_record_list
[
i
].
shortname
,
user_plmn_list
[
i
].
shortname
);
char
num
[
6
];
char
num
[
6
];
sprintf
(
num
,
"%s%s"
,
user_plmn_list
[
i
].
mcc
,
user_plmn_list
[
i
].
mnc
);
sprintf
(
num
,
"%s%s"
,
conf
->
mcc
,
conf
->
mnc
);
user_network_record_list
[
i
].
num
=
atoi
(
num
);
record
->
num
=
atoi
(
num
);
user_network_record_list
[
i
].
plmn
=
make_plmn_from_conf
(
&
user_plmn_list
[
i
]);
record
->
plmn
=
make_plmn_from_conf
(
conf
);
user_network_record_list
[
i
].
tac_end
=
0xfffd
;
record
->
tac_end
=
0xfffd
;
user_network_record_list
[
i
].
tac_start
=
0x0001
;
record
->
tac_start
=
0x0001
;
}
}
}
/*
/*
...
...
openair3/NAS/TOOLS/conf2uedata.h
View file @
32ce8222
...
@@ -56,24 +56,31 @@ typedef struct {
...
@@ -56,24 +56,31 @@ typedef struct {
plmns_list
equivalents_home
;
plmns_list
equivalents_home
;
}
user_plmns_t
;
}
user_plmns_t
;
extern
int
plmn_nb
;
typedef
struct
{
plmn_conf_param_t
conf
;
network_record_t
record
;
plmn_t
plmn
;
}
network_t
;
extern
plmn_conf_param_t
*
user_plmn_list
;
typedef
struct
{
extern
network_record_t
*
user_network_record_list
;
int
size
;
network_t
*
items
;
}
networks_t
;
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
*
output_dir
,
const
char
*
filename
);
int
parse_config_file
(
const
char
*
output_dir
,
const
char
*
filename
);
void
_display_usage
(
void
);
void
_display_usage
(
void
);
void
fill_network_record_list
(
voi
d
);
void
gen_network_record_from_conf
(
const
plmn_conf_param_t
*
conf
,
network_record_t
*
recor
d
);
int
parse_plmn_param
(
config_setting_t
*
plmn_setting
,
int
index
);
int
parse_plmn_param
(
config_setting_t
*
plmn_setting
,
plmn_conf_param_t
*
conf
);
int
parse_plmns
(
config_setting_t
*
all_plmn_setting
);
int
parse_plmns
(
config_setting_t
*
all_plmn_setting
,
networks_t
*
plmns
);
int
get_plmn_index
(
const
char
*
mccmnc
);
int
get_plmn_index
(
const
char
*
mccmnc
,
const
networks_t
networks
);
int
parse_user_plmns_conf
(
config_setting_t
*
ue_setting
,
int
user_id
,
int
parse_user_plmns_conf
(
config_setting_t
*
ue_setting
,
int
user_id
,
user_plmns_t
*
user_plmns
,
const
char
**
h
);
user_plmns_t
*
user_plmns
,
const
char
**
h
,
const
networks_t
networks
);
int
parse_Xplmn
(
config_setting_t
*
ue_setting
,
const
char
*
section
,
int
parse_Xplmn
(
config_setting_t
*
ue_setting
,
const
char
*
section
,
int
user_id
,
plmns_list
*
plmns
);
int
user_id
,
plmns_list
*
plmns
,
const
networks_t
networks
);
#endif // _CONF2UEDATA_H
#endif // _CONF2UEDATA_H
openair3/NAS/TOOLS/conf_emm.c
View file @
32ce8222
#include <string.h>
#include <string.h>
#include "conf2uedata.h"
#include "memory.h"
#include "memory.h"
#include "conf_emm.h"
#include "conf_emm.h"
#include "fs.h"
#include "fs.h"
void
gen_emm_data
(
emm_nvdata_t
*
emm_data
,
const
char
*
hplmn
,
const
char
*
msin
,
int
ehplmn_count
)
{
void
gen_emm_data
(
emm_nvdata_t
*
emm_data
,
const
char
*
hplmn
,
const
char
*
msin
,
int
ehplmn_count
,
const
networks_t
networks
)
{
memset
(
emm_data
,
0
,
sizeof
(
emm_nvdata_t
));
memset
(
emm_data
,
0
,
sizeof
(
emm_nvdata_t
));
int
hplmn_index
=
get_plmn_index
(
hplmn
);
int
hplmn_index
=
get_plmn_index
(
hplmn
,
networks
);
plmn_conf_param_t
*
conf
=
&
networks
.
items
[
hplmn_index
].
conf
;
emm_data
->
imsi
.
length
=
8
;
emm_data
->
imsi
.
length
=
8
;
emm_data
->
imsi
.
u
.
num
.
parity
=
get_msin_parity
(
msin
,
user_plmn_list
[
hplmn_index
].
mcc
,
user_plmn_list
[
hplmn_index
].
mnc
);
emm_data
->
imsi
.
u
.
num
.
parity
=
get_msin_parity
(
msin
,
conf
->
mcc
,
conf
->
mnc
);
emm_data
->
imsi
.
u
.
num
.
digit1
=
user_plmn_list
[
hplmn_index
].
mcc
[
0
];
emm_data
->
imsi
.
u
.
num
.
digit1
=
conf
->
mcc
[
0
];
emm_data
->
imsi
.
u
.
num
.
digit2
=
user_plmn_list
[
hplmn_index
].
mcc
[
1
];
emm_data
->
imsi
.
u
.
num
.
digit2
=
conf
->
mcc
[
1
];
emm_data
->
imsi
.
u
.
num
.
digit3
=
user_plmn_list
[
hplmn_index
].
mcc
[
2
];
emm_data
->
imsi
.
u
.
num
.
digit3
=
conf
->
mcc
[
2
];
emm_data
->
imsi
.
u
.
num
.
digit4
=
user_plmn_list
[
hplmn_index
].
mnc
[
0
];
emm_data
->
imsi
.
u
.
num
.
digit4
=
conf
->
mnc
[
0
];
emm_data
->
imsi
.
u
.
num
.
digit5
=
user_plmn_list
[
hplmn_index
].
mnc
[
1
];
emm_data
->
imsi
.
u
.
num
.
digit5
=
conf
->
mnc
[
1
];
if
(
strlen
(
user_plmn_list
[
hplmn_index
].
mnc
)
==
3
)
{
if
(
strlen
(
conf
->
mnc
)
==
3
)
{
emm_data
->
rplmn
.
MNCdigit3
=
user_plmn_list
[
hplmn_index
].
mnc
[
2
];
emm_data
->
rplmn
.
MNCdigit3
=
conf
->
mnc
[
2
];
emm_data
->
imsi
.
u
.
num
.
digit6
=
user_plmn_list
[
hplmn_index
].
mnc
[
2
];
emm_data
->
imsi
.
u
.
num
.
digit6
=
conf
->
mnc
[
2
];
emm_data
->
imsi
.
u
.
num
.
digit7
=
msin
[
0
];
emm_data
->
imsi
.
u
.
num
.
digit7
=
msin
[
0
];
emm_data
->
imsi
.
u
.
num
.
digit8
=
msin
[
1
];
emm_data
->
imsi
.
u
.
num
.
digit8
=
msin
[
1
];
emm_data
->
imsi
.
u
.
num
.
digit9
=
msin
[
2
];
emm_data
->
imsi
.
u
.
num
.
digit9
=
msin
[
2
];
...
@@ -47,11 +47,11 @@ void gen_emm_data(emm_nvdata_t *emm_data, const char *hplmn, const char *msin, i
...
@@ -47,11 +47,11 @@ void gen_emm_data(emm_nvdata_t *emm_data, const char *hplmn, const char *msin, i
}
}
emm_data
->
rplmn
.
MCCdigit1
=
user_plmn_list
[
hplmn_index
].
mcc
[
0
];
emm_data
->
rplmn
.
MCCdigit1
=
conf
->
mcc
[
0
];
emm_data
->
rplmn
.
MCCdigit2
=
user_plmn_list
[
hplmn_index
].
mcc
[
1
];
emm_data
->
rplmn
.
MCCdigit2
=
conf
->
mcc
[
1
];
emm_data
->
rplmn
.
MCCdigit3
=
user_plmn_list
[
hplmn_index
].
mcc
[
2
];
emm_data
->
rplmn
.
MCCdigit3
=
conf
->
mcc
[
2
];
emm_data
->
rplmn
.
MNCdigit1
=
user_plmn_list
[
hplmn_index
].
mnc
[
0
];
emm_data
->
rplmn
.
MNCdigit1
=
conf
->
mnc
[
0
];
emm_data
->
rplmn
.
MNCdigit2
=
user_plmn_list
[
hplmn_index
].
mnc
[
1
];
emm_data
->
rplmn
.
MNCdigit2
=
conf
->
mnc
[
1
];
emm_data
->
eplmn
.
n_plmns
=
ehplmn_count
;
emm_data
->
eplmn
.
n_plmns
=
ehplmn_count
;
}
}
...
...
openair3/NAS/TOOLS/conf_emm.h
View file @
32ce8222
#ifndef _CONF_EMM_H
#ifndef _CONF_EMM_H
#define _CONF_EMM_H
#define _CONF_EMM_H
#include "conf2uedata.h"
#include "emmData.h"
#include "emmData.h"
void
gen_emm_data
(
emm_nvdata_t
*
emm_data
,
const
char
*
hplmn
,
const
char
*
msin
,
void
gen_emm_data
(
emm_nvdata_t
*
emm_data
,
const
char
*
hplmn
,
const
char
*
msin
,
int
ehplmn_count
,
const
networks_t
networks
);
int
ehplmn_count
);
int
write_emm_data
(
const
char
*
directory
,
int
user_id
,
emm_nvdata_t
*
emm_data
);
int
write_emm_data
(
const
char
*
directory
,
int
user_id
,
emm_nvdata_t
*
emm_data
);
int
get_msin_parity
(
const
char
*
msin
,
const
char
*
mcc
,
const
char
*
mnc
);
int
get_msin_parity
(
const
char
*
msin
,
const
char
*
mcc
,
const
char
*
mnc
);
...
...
openair3/NAS/TOOLS/conf_usim.c
View file @
32ce8222
...
@@ -41,22 +41,23 @@ int parse_ue_sim_param(config_setting_t *ue_setting, int user_id, usim_data_conf
...
@@ -41,22 +41,23 @@ int parse_ue_sim_param(config_setting_t *ue_setting, int user_id, usim_data_conf
}
}
void
gen_usim_data
(
usim_data_conf_t
*
u
,
usim_data_t
*
usim_data
,
void
gen_usim_data
(
usim_data_conf_t
*
u
,
usim_data_t
*
usim_data
,
const
user_plmns_t
*
user_plmns
)
{
const
user_plmns_t
*
user_plmns
,
const
networks_t
networks
)
{
int
hplmn_index
=
get_plmn_index
(
u
->
hplmn
);
int
hplmn_index
=
get_plmn_index
(
u
->
hplmn
,
networks
);
const
plmn_conf_param_t
*
conf
=
&
networks
.
items
[
hplmn_index
].
conf
;
memset
(
usim_data
,
0
,
sizeof
(
usim_data_t
));
memset
(
usim_data
,
0
,
sizeof
(
usim_data_t
));
usim_data
->
imsi
.
length
=
8
;
usim_data
->
imsi
.
length
=
8
;
usim_data
->
imsi
.
u
.
num
.
parity
=
get_msin_parity
(
u
->
msin
,
usim_data
->
imsi
.
u
.
num
.
parity
=
get_msin_parity
(
u
->
msin
,
user_plmn_list
[
hplmn_index
].
mcc
,
conf
->
mcc
,
user_plmn_list
[
hplmn_index
].
mnc
);
conf
->
mnc
);
usim_data
->
imsi
.
u
.
num
.
digit1
=
user_plmn_list
[
hplmn_index
].
mcc
[
0
];
usim_data
->
imsi
.
u
.
num
.
digit1
=
conf
->
mcc
[
0
];
usim_data
->
imsi
.
u
.
num
.
digit2
=
user_plmn_list
[
hplmn_index
].
mcc
[
1
];
usim_data
->
imsi
.
u
.
num
.
digit2
=
conf
->
mcc
[
1
];
usim_data
->
imsi
.
u
.
num
.
digit3
=
user_plmn_list
[
hplmn_index
].
mcc
[
2
];
usim_data
->
imsi
.
u
.
num
.
digit3
=
conf
->
mcc
[
2
];
usim_data
->
imsi
.
u
.
num
.
digit4
=
user_plmn_list
[
hplmn_index
].
mnc
[
0
];
usim_data
->
imsi
.
u
.
num
.
digit4
=
conf
->
mnc
[
0
];
usim_data
->
imsi
.
u
.
num
.
digit5
=
user_plmn_list
[
hplmn_index
].
mnc
[
1
];
usim_data
->
imsi
.
u
.
num
.
digit5
=
conf
->
mnc
[
1
];
if
(
strlen
(
user_plmn_list
[
hplmn_index
].
mnc
)
==
2
)
{
if
(
strlen
(
conf
->
mnc
)
==
2
)
{
usim_data
->
imsi
.
u
.
num
.
digit6
=
u
->
msin
[
0
];
usim_data
->
imsi
.
u
.
num
.
digit6
=
u
->
msin
[
0
];
usim_data
->
imsi
.
u
.
num
.
digit7
=
u
->
msin
[
1
];
usim_data
->
imsi
.
u
.
num
.
digit7
=
u
->
msin
[
1
];
usim_data
->
imsi
.
u
.
num
.
digit8
=
u
->
msin
[
2
];
usim_data
->
imsi
.
u
.
num
.
digit8
=
u
->
msin
[
2
];
...
@@ -68,7 +69,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
...
@@ -68,7 +69,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
usim_data
->
imsi
.
u
.
num
.
digit14
=
u
->
msin
[
8
];
usim_data
->
imsi
.
u
.
num
.
digit14
=
u
->
msin
[
8
];
usim_data
->
imsi
.
u
.
num
.
digit15
=
u
->
msin
[
9
];
usim_data
->
imsi
.
u
.
num
.
digit15
=
u
->
msin
[
9
];
}
else
{
}
else
{
usim_data
->
imsi
.
u
.
num
.
digit6
=
user_plmn_list
[
hplmn_index
].
mnc
[
2
];
usim_data
->
imsi
.
u
.
num
.
digit6
=
conf
->
mnc
[
2
];
usim_data
->
imsi
.
u
.
num
.
digit7
=
u
->
msin
[
0
];
usim_data
->
imsi
.
u
.
num
.
digit7
=
u
->
msin
[
0
];
usim_data
->
imsi
.
u
.
num
.
digit8
=
u
->
msin
[
1
];
usim_data
->
imsi
.
u
.
num
.
digit8
=
u
->
msin
[
1
];
usim_data
->
imsi
.
u
.
num
.
digit9
=
u
->
msin
[
2
];
usim_data
->
imsi
.
u
.
num
.
digit9
=
u
->
msin
[
2
];
...
@@ -99,7 +100,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
...
@@ -99,7 +100,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
}
}
if
(
user_plmns
->
forbiddens
.
size
>
0
)
{
if
(
user_plmns
->
forbiddens
.
size
>
0
)
{
for
(
int
i
=
0
;
i
<
user_plmns
->
forbiddens
.
size
;
i
++
)
{
for
(
int
i
=
0
;
i
<
user_plmns
->
forbiddens
.
size
;
i
++
)
{
usim_data
->
fplmn
[
i
]
=
user_network_record_list
[
user_plmns
->
forbiddens
.
items
[
i
]].
plmn
;
usim_data
->
fplmn
[
i
]
=
networks
.
items
[
user_plmns
->
forbiddens
.
items
[
i
]].
plmn
;
}
}
}
}
...
@@ -107,7 +108,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
...
@@ -107,7 +108,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
* Location Information
* Location Information
*/
*/
usim_data
->
loci
.
tmsi
=
DEFAULT_TMSI
;
usim_data
->
loci
.
tmsi
=
DEFAULT_TMSI
;
usim_data
->
loci
.
lai
.
plmn
=
user_network_record_list
[
hplmn_index
].
plmn
;
usim_data
->
loci
.
lai
.
plmn
=
networks
.
items
[
hplmn_index
].
plmn
;
usim_data
->
loci
.
lai
.
lac
=
DEFAULT_LAC
;
usim_data
->
loci
.
lai
.
lac
=
DEFAULT_LAC
;
usim_data
->
loci
.
status
=
USIM_LOCI_NOT_UPDATED
;
usim_data
->
loci
.
status
=
USIM_LOCI_NOT_UPDATED
;
/*
/*
...
@@ -117,7 +118,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
...
@@ -117,7 +118,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
usim_data
->
psloci
.
signature
[
0
]
=
0x01
;
usim_data
->
psloci
.
signature
[
0
]
=
0x01
;
usim_data
->
psloci
.
signature
[
1
]
=
0x02
;
usim_data
->
psloci
.
signature
[
1
]
=
0x02
;
usim_data
->
psloci
.
signature
[
2
]
=
0x03
;
usim_data
->
psloci
.
signature
[
2
]
=
0x03
;
usim_data
->
psloci
.
rai
.
plmn
=
user_network_record_list
[
hplmn_index
].
plmn
;
usim_data
->
psloci
.
rai
.
plmn
=
networks
.
items
[
hplmn_index
].
plmn
;
usim_data
->
psloci
.
rai
.
lac
=
DEFAULT_LAC
;
usim_data
->
psloci
.
rai
.
lac
=
DEFAULT_LAC
;
usim_data
->
psloci
.
rai
.
rac
=
DEFAULT_RAC
;
usim_data
->
psloci
.
rai
.
rac
=
DEFAULT_RAC
;
usim_data
->
psloci
.
status
=
USIM_PSLOCI_NOT_UPDATED
;
usim_data
->
psloci
.
status
=
USIM_PSLOCI_NOT_UPDATED
;
...
@@ -126,7 +127,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
...
@@ -126,7 +127,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
*/
*/
usim_data
->
ad
.
UE_Operation_Mode
=
USIM_NORMAL_MODE
;
usim_data
->
ad
.
UE_Operation_Mode
=
USIM_NORMAL_MODE
;
usim_data
->
ad
.
Additional_Info
=
0xffff
;
usim_data
->
ad
.
Additional_Info
=
0xffff
;
usim_data
->
ad
.
MNC_Length
=
strlen
(
user_plmn_list
[
hplmn_index
].
mnc
);
usim_data
->
ad
.
MNC_Length
=
strlen
(
conf
->
mnc
);
/*
/*
* EPS NAS security context
* EPS NAS security context
*/
*/
...
@@ -185,7 +186,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
...
@@ -185,7 +186,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
* PLMN Network Name and Operator PLMN List
* PLMN Network Name and Operator PLMN List
*/
*/
for
(
int
i
=
0
;
i
<
user_plmns
->
operators
.
size
;
i
++
)
{
for
(
int
i
=
0
;
i
<
user_plmns
->
operators
.
size
;
i
++
)
{
network_record_t
record
=
user_network_record_list
[
user_plmns
->
operators
.
items
[
i
]]
;
network_record_t
record
=
networks
.
items
[
user_plmns
->
operators
.
items
[
i
]].
record
;
usim_data
->
pnn
[
i
].
fullname
.
type
=
USIM_PNN_FULLNAME_TAG
;
usim_data
->
pnn
[
i
].
fullname
.
type
=
USIM_PNN_FULLNAME_TAG
;
usim_data
->
pnn
[
i
].
fullname
.
length
=
strlen
(
record
.
fullname
);
usim_data
->
pnn
[
i
].
fullname
.
length
=
strlen
(
record
.
fullname
);
strncpy
((
char
*
)
usim_data
->
pnn
[
i
].
fullname
.
value
,
record
.
fullname
,
strncpy
((
char
*
)
usim_data
->
pnn
[
i
].
fullname
.
value
,
record
.
fullname
,
...
@@ -209,7 +210,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
...
@@ -209,7 +210,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
* List of Equivalent HPLMNs
* List of Equivalent HPLMNs
*/
*/
for
(
int
i
=
0
;
i
<
user_plmns
->
equivalents_home
.
size
;
i
++
)
{
for
(
int
i
=
0
;
i
<
user_plmns
->
equivalents_home
.
size
;
i
++
)
{
usim_data
->
ehplmn
[
i
]
=
user_network_record_list
[
user_plmns
->
equivalents_home
.
items
[
i
]].
plmn
;
usim_data
->
ehplmn
[
i
]
=
networks
.
items
[
user_plmns
->
equivalents_home
.
items
[
i
]].
plmn
;
}
}
if
(
user_plmns
->
equivalents_home
.
size
<
USIM_EHPLMN_MAX
)
{
if
(
user_plmns
->
equivalents_home
.
size
<
USIM_EHPLMN_MAX
)
{
for
(
int
i
=
user_plmns
->
equivalents_home
.
size
;
i
<
USIM_EHPLMN_MAX
;
i
++
)
{
for
(
int
i
=
user_plmns
->
equivalents_home
.
size
;
i
<
USIM_EHPLMN_MAX
;
i
++
)
{
...
@@ -219,7 +220,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
...
@@ -219,7 +220,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
/*
/*
* Home PLMN Selector with Access Technology
* Home PLMN Selector with Access Technology
*/
*/
usim_data
->
hplmn
.
plmn
=
user_network_record_list
[
hplmn_index
].
plmn
;
usim_data
->
hplmn
.
plmn
=
networks
.
items
[
hplmn_index
].
plmn
;
usim_data
->
hplmn
.
AcT
=
(
USIM_ACT_GSM
|
USIM_ACT_UTRAN
|
USIM_ACT_EUTRAN
);
usim_data
->
hplmn
.
AcT
=
(
USIM_ACT_GSM
|
USIM_ACT_UTRAN
|
USIM_ACT_EUTRAN
);
/*
/*
...
@@ -230,7 +231,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
...
@@ -230,7 +231,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
}
}
if
(
user_plmns
->
users_controlled
.
size
>
0
)
{
if
(
user_plmns
->
users_controlled
.
size
>
0
)
{
for
(
int
i
=
0
;
i
<
user_plmns
->
users_controlled
.
size
;
i
++
)
{
for
(
int
i
=
0
;
i
<
user_plmns
->
users_controlled
.
size
;
i
++
)
{
usim_data
->
plmn
[
i
].
plmn
=
user_network_record_list
[
user_plmns
->
users_controlled
.
items
[
i
]].
plmn
;
usim_data
->
plmn
[
i
].
plmn
=
networks
.
items
[
user_plmns
->
users_controlled
.
items
[
i
]].
plmn
;
}
}
}
}
...
@@ -241,7 +242,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
...
@@ -241,7 +242,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
}
}
if
(
user_plmns
->
operators_controlled
.
size
>
0
)
{
if
(
user_plmns
->
operators_controlled
.
size
>
0
)
{
for
(
int
i
=
0
;
i
<
user_plmns
->
operators_controlled
.
size
;
i
++
)
{
for
(
int
i
=
0
;
i
<
user_plmns
->
operators_controlled
.
size
;
i
++
)
{
usim_data
->
oplmn
[
i
].
plmn
=
user_network_record_list
[
user_plmns
->
operators_controlled
.
items
[
i
]].
plmn
;
usim_data
->
oplmn
[
i
].
plmn
=
networks
.
items
[
user_plmns
->
operators_controlled
.
items
[
i
]].
plmn
;
usim_data
->
oplmn
[
i
].
AcT
=
(
USIM_ACT_GSM
|
USIM_ACT_UTRAN
usim_data
->
oplmn
[
i
].
AcT
=
(
USIM_ACT_GSM
|
USIM_ACT_UTRAN
|
USIM_ACT_EUTRAN
);
|
USIM_ACT_EUTRAN
);
}
}
...
@@ -250,7 +251,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
...
@@ -250,7 +251,7 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
* EPS Location Information
* EPS Location Information
*/
*/
usim_data
->
epsloci
.
guti
.
gummei
.
plmn
=
usim_data
->
epsloci
.
guti
.
gummei
.
plmn
=
user_network_record_list
[
hplmn_index
].
plmn
;
networks
.
items
[
hplmn_index
].
plmn
;
usim_data
->
epsloci
.
guti
.
gummei
.
MMEgid
=
DEFAULT_MME_ID
;
usim_data
->
epsloci
.
guti
.
gummei
.
MMEgid
=
DEFAULT_MME_ID
;
usim_data
->
epsloci
.
guti
.
gummei
.
MMEcode
=
DEFAULT_MME_CODE
;
usim_data
->
epsloci
.
guti
.
gummei
.
MMEcode
=
DEFAULT_MME_CODE
;
usim_data
->
epsloci
.
guti
.
m_tmsi
=
DEFAULT_M_TMSI
;
usim_data
->
epsloci
.
guti
.
m_tmsi
=
DEFAULT_M_TMSI
;
...
...
openair3/NAS/TOOLS/conf_usim.h
View file @
32ce8222
...
@@ -41,6 +41,6 @@ typedef struct {
...
@@ -41,6 +41,6 @@ typedef struct {
int
parse_ue_sim_param
(
config_setting_t
*
ue_setting
,
int
user_id
,
usim_data_conf_t
*
u
);
int
parse_ue_sim_param
(
config_setting_t
*
ue_setting
,
int
user_id
,
usim_data_conf_t
*
u
);
int
write_usim_data
(
const
char
*
directory
,
int
user_id
,
usim_data_t
*
usim_data
);
int
write_usim_data
(
const
char
*
directory
,
int
user_id
,
usim_data_t
*
usim_data
);
void
gen_usim_data
(
usim_data_conf_t
*
u
,
usim_data_t
*
usim_data
,
void
gen_usim_data
(
usim_data_conf_t
*
u
,
usim_data_t
*
usim_data
,
const
user_plmns_t
*
user_plmns
);
const
user_plmns_t
*
user_plmns
,
const
networks_t
networks
);
#endif
#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