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
canghaiwuhen
OpenXG-RAN
Commits
ef2dee59
Commit
ef2dee59
authored
Aug 16, 2016
by
Frédéric Leroy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(conf2uedata): separate processing and writing of data
parent
8461a56a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
229 additions
and
206 deletions
+229
-206
openair3/NAS/TOOLS/conf2uedata.c
openair3/NAS/TOOLS/conf2uedata.c
+217
-200
openair3/NAS/TOOLS/conf2uedata.h
openair3/NAS/TOOLS/conf2uedata.h
+12
-6
No files found.
openair3/NAS/TOOLS/conf2uedata.c
View file @
ef2dee59
...
...
@@ -11,8 +11,6 @@
#include "display.h"
#include "fs.h"
const
char
*
output_dir
=
NULL
;
const
char
*
msin
=
NULL
;
const
char
*
usim_api_k
=
NULL
;
const
char
*
msisdn
=
NULL
;
...
...
@@ -39,6 +37,7 @@ network_record_t* user_network_record_list = NULL;
int
main
(
int
argc
,
char
**
argv
)
{
int
option
;
const
char
*
conf_file
=
NULL
;
const
char
*
output_dir
=
NULL
;
const
char
options
[]
=
"c:o:h"
;
while
((
option
=
getopt
(
argc
,
argv
,
options
))
!=
-
1
)
{
...
...
@@ -70,7 +69,7 @@ int main(int argc, char**argv) {
return
EXIT_FAILURE
;
}
if
(
parse_config_file
(
conf_file
)
==
EXIT_FAILURE
)
{
if
(
parse_config_file
(
output_dir
,
conf_file
)
==
EXIT_FAILURE
)
{
exit
(
EXIT_FAILURE
);
}
...
...
@@ -79,7 +78,7 @@ int main(int argc, char**argv) {
exit
(
EXIT_SUCCESS
);
}
int
parse_config_file
(
const
char
*
filename
)
{
int
parse_config_file
(
const
char
*
output_dir
,
const
char
*
conf_
filename
)
{
int
rc
=
EXIT_SUCCESS
;
int
ret
;
int
ue_nb
=
0
;
...
...
@@ -89,7 +88,7 @@ int parse_config_file(const char *filename) {
char
user
[
10
];
config_t
cfg
;
ret
=
get_config_from_file
(
filename
,
&
cfg
);
ret
=
get_config_from_file
(
conf_
filename
,
&
cfg
);
if
(
ret
==
EXIT_FAILURE
)
{
exit
(
1
);
}
...
...
@@ -110,6 +109,10 @@ int parse_config_file(const char *filename) {
fill_network_record_list
();
for
(
int
i
=
0
;
i
<
ue_nb
;
i
++
)
{
emm_nvdata_t
emm_data
;
user_nvdata_t
user_data
;
usim_data_t
usim_data
;
sprintf
(
user
,
"%s%d"
,
UE
,
i
);
ue_setting
=
config_setting_get_member
(
root_setting
,
user
);
...
...
@@ -118,11 +121,12 @@ int parse_config_file(const char *filename) {
return
EXIT_FAILURE
;
}
rc
=
parse_ue_user_param
(
ue_setting
,
i
);
rc
=
parse_ue_user_param
(
ue_setting
,
i
,
&
user_data
);
if
(
rc
!=
EXIT_SUCCESS
)
{
printf
(
"Problem in USER section for UE%d. EXITING...
\n
"
,
i
);
return
EXIT_FAILURE
;
}
write_user_data
(
output_dir
,
i
,
&
user_data
);
rc
=
parse_ue_sim_param
(
ue_setting
,
i
);
if
(
rc
!=
EXIT_SUCCESS
)
{
...
...
@@ -134,8 +138,11 @@ int parse_config_file(const char *filename) {
if
(
rc
!=
EXIT_SUCCESS
)
{
return
EXIT_FAILURE
;
}
gen_emm_data
(
i
);
gen_usim_data
(
i
);
gen_emm_data
(
i
,
&
emm_data
);
write_emm_data
(
output_dir
,
i
,
&
emm_data
);
gen_usim_data
(
&
usim_data
);
write_usim_data
(
output_dir
,
i
,
&
usim_data
);
}
config_destroy
(
&
cfg
);
return
(
EXIT_SUCCESS
);
...
...
@@ -161,142 +168,141 @@ int get_config_from_file(const char *filename, config_t *config) {
return
EXIT_SUCCESS
;
}
void
gen_usim_data
(
int
user_id
)
{
usim_data_t
usim_data
=
{
};
memset
(
&
usim_data
,
0
,
sizeof
(
usim_data_t
));
usim_data
.
imsi
.
length
=
8
;
usim_data
.
imsi
.
u
.
num
.
parity
=
get_msin_parity
(
msin
);
void
gen_usim_data
(
usim_data_t
*
usim_data
)
{
memset
(
usim_data
,
0
,
sizeof
(
usim_data_t
));
usim_data
->
imsi
.
length
=
8
;
usim_data
->
imsi
.
u
.
num
.
parity
=
get_msin_parity
(
msin
);
usim_data
.
imsi
.
u
.
num
.
digit1
=
user_plmn_list
[
hplmn_index
].
mcc
[
0
];
usim_data
.
imsi
.
u
.
num
.
digit2
=
user_plmn_list
[
hplmn_index
].
mcc
[
1
];
usim_data
.
imsi
.
u
.
num
.
digit3
=
user_plmn_list
[
hplmn_index
].
mcc
[
2
];
usim_data
->
imsi
.
u
.
num
.
digit1
=
user_plmn_list
[
hplmn_index
].
mcc
[
0
];
usim_data
->
imsi
.
u
.
num
.
digit2
=
user_plmn_list
[
hplmn_index
].
mcc
[
1
];
usim_data
->
imsi
.
u
.
num
.
digit3
=
user_plmn_list
[
hplmn_index
].
mcc
[
2
];
usim_data
.
imsi
.
u
.
num
.
digit4
=
user_plmn_list
[
hplmn_index
].
mnc
[
0
];
usim_data
.
imsi
.
u
.
num
.
digit5
=
user_plmn_list
[
hplmn_index
].
mnc
[
1
];
usim_data
->
imsi
.
u
.
num
.
digit4
=
user_plmn_list
[
hplmn_index
].
mnc
[
0
];
usim_data
->
imsi
.
u
.
num
.
digit5
=
user_plmn_list
[
hplmn_index
].
mnc
[
1
];
if
(
strlen
(
user_plmn_list
[
hplmn_index
].
mnc
)
==
2
)
{
usim_data
.
imsi
.
u
.
num
.
digit6
=
msin
[
0
];
usim_data
.
imsi
.
u
.
num
.
digit7
=
msin
[
1
];
usim_data
.
imsi
.
u
.
num
.
digit8
=
msin
[
2
];
usim_data
.
imsi
.
u
.
num
.
digit9
=
msin
[
3
];
usim_data
.
imsi
.
u
.
num
.
digit10
=
msin
[
4
];
usim_data
.
imsi
.
u
.
num
.
digit11
=
msin
[
5
];
usim_data
.
imsi
.
u
.
num
.
digit12
=
msin
[
6
];
usim_data
.
imsi
.
u
.
num
.
digit13
=
msin
[
7
];
usim_data
.
imsi
.
u
.
num
.
digit14
=
msin
[
8
];
usim_data
.
imsi
.
u
.
num
.
digit15
=
msin
[
9
];
usim_data
->
imsi
.
u
.
num
.
digit6
=
msin
[
0
];
usim_data
->
imsi
.
u
.
num
.
digit7
=
msin
[
1
];
usim_data
->
imsi
.
u
.
num
.
digit8
=
msin
[
2
];
usim_data
->
imsi
.
u
.
num
.
digit9
=
msin
[
3
];
usim_data
->
imsi
.
u
.
num
.
digit10
=
msin
[
4
];
usim_data
->
imsi
.
u
.
num
.
digit11
=
msin
[
5
];
usim_data
->
imsi
.
u
.
num
.
digit12
=
msin
[
6
];
usim_data
->
imsi
.
u
.
num
.
digit13
=
msin
[
7
];
usim_data
->
imsi
.
u
.
num
.
digit14
=
msin
[
8
];
usim_data
->
imsi
.
u
.
num
.
digit15
=
msin
[
9
];
}
else
{
usim_data
.
imsi
.
u
.
num
.
digit6
=
user_plmn_list
[
hplmn_index
].
mnc
[
2
];
usim_data
.
imsi
.
u
.
num
.
digit7
=
msin
[
0
];
usim_data
.
imsi
.
u
.
num
.
digit8
=
msin
[
1
];
usim_data
.
imsi
.
u
.
num
.
digit9
=
msin
[
2
];
usim_data
.
imsi
.
u
.
num
.
digit10
=
msin
[
3
];
usim_data
.
imsi
.
u
.
num
.
digit11
=
msin
[
4
];
usim_data
.
imsi
.
u
.
num
.
digit12
=
msin
[
5
];
usim_data
.
imsi
.
u
.
num
.
digit13
=
msin
[
6
];
usim_data
.
imsi
.
u
.
num
.
digit14
=
msin
[
7
];
usim_data
.
imsi
.
u
.
num
.
digit15
=
msin
[
8
];
usim_data
->
imsi
.
u
.
num
.
digit6
=
user_plmn_list
[
hplmn_index
].
mnc
[
2
];
usim_data
->
imsi
.
u
.
num
.
digit7
=
msin
[
0
];
usim_data
->
imsi
.
u
.
num
.
digit8
=
msin
[
1
];
usim_data
->
imsi
.
u
.
num
.
digit9
=
msin
[
2
];
usim_data
->
imsi
.
u
.
num
.
digit10
=
msin
[
3
];
usim_data
->
imsi
.
u
.
num
.
digit11
=
msin
[
4
];
usim_data
->
imsi
.
u
.
num
.
digit12
=
msin
[
5
];
usim_data
->
imsi
.
u
.
num
.
digit13
=
msin
[
6
];
usim_data
->
imsi
.
u
.
num
.
digit14
=
msin
[
7
];
usim_data
->
imsi
.
u
.
num
.
digit15
=
msin
[
8
];
}
/*
* Ciphering and Integrity Keys
*/
usim_data
.
keys
.
ksi
=
KSI
;
memset
(
&
usim_data
.
keys
.
ck
,
0
,
USIM_CK_SIZE
);
memset
(
&
usim_data
.
keys
.
ik
,
0
,
USIM_IK_SIZE
);
usim_data
->
keys
.
ksi
=
KSI
;
memset
(
&
usim_data
->
keys
.
ck
,
0
,
USIM_CK_SIZE
);
memset
(
&
usim_data
->
keys
.
ik
,
0
,
USIM_IK_SIZE
);
/*
* Higher Priority PLMN search period
*/
usim_data
.
hpplmn
=
0x00
;
/* Disable timer */
usim_data
->
hpplmn
=
0x00
;
/* Disable timer */
/*
* List of Forbidden PLMNs
*/
for
(
int
i
=
0
;
i
<
USIM_FPLMN_MAX
;
i
++
)
{
memset
(
&
usim_data
.
fplmn
[
i
],
0xff
,
sizeof
(
plmn_t
));
memset
(
&
usim_data
->
fplmn
[
i
],
0xff
,
sizeof
(
plmn_t
));
}
if
(
fplmn_nb
>
0
)
{
for
(
int
i
=
0
;
i
<
fplmn_nb
;
i
++
)
{
usim_data
.
fplmn
[
i
]
=
user_network_record_list
[
fplmn
[
i
]].
plmn
;
usim_data
->
fplmn
[
i
]
=
user_network_record_list
[
fplmn
[
i
]].
plmn
;
}
}
/*
* Location Information
*/
usim_data
.
loci
.
tmsi
=
DEFAULT_TMSI
;
usim_data
.
loci
.
lai
.
plmn
=
user_network_record_list
[
hplmn_index
].
plmn
;
usim_data
.
loci
.
lai
.
lac
=
DEFAULT_LAC
;
usim_data
.
loci
.
status
=
USIM_LOCI_NOT_UPDATED
;
usim_data
->
loci
.
tmsi
=
DEFAULT_TMSI
;
usim_data
->
loci
.
lai
.
plmn
=
user_network_record_list
[
hplmn_index
].
plmn
;
usim_data
->
loci
.
lai
.
lac
=
DEFAULT_LAC
;
usim_data
->
loci
.
status
=
USIM_LOCI_NOT_UPDATED
;
/*
* Packet Switched Location Information
*/
usim_data
.
psloci
.
p_tmsi
=
DEFAULT_P_TMSI
;
usim_data
.
psloci
.
signature
[
0
]
=
0x01
;
usim_data
.
psloci
.
signature
[
1
]
=
0x02
;
usim_data
.
psloci
.
signature
[
2
]
=
0x03
;
usim_data
.
psloci
.
rai
.
plmn
=
user_network_record_list
[
hplmn_index
].
plmn
;
usim_data
.
psloci
.
rai
.
lac
=
DEFAULT_LAC
;
usim_data
.
psloci
.
rai
.
rac
=
DEFAULT_RAC
;
usim_data
.
psloci
.
status
=
USIM_PSLOCI_NOT_UPDATED
;
usim_data
->
psloci
.
p_tmsi
=
DEFAULT_P_TMSI
;
usim_data
->
psloci
.
signature
[
0
]
=
0x01
;
usim_data
->
psloci
.
signature
[
1
]
=
0x02
;
usim_data
->
psloci
.
signature
[
2
]
=
0x03
;
usim_data
->
psloci
.
rai
.
plmn
=
user_network_record_list
[
hplmn_index
].
plmn
;
usim_data
->
psloci
.
rai
.
lac
=
DEFAULT_LAC
;
usim_data
->
psloci
.
rai
.
rac
=
DEFAULT_RAC
;
usim_data
->
psloci
.
status
=
USIM_PSLOCI_NOT_UPDATED
;
/*
* Administrative Data
*/
usim_data
.
ad
.
UE_Operation_Mode
=
USIM_NORMAL_MODE
;
usim_data
.
ad
.
Additional_Info
=
0xffff
;
usim_data
.
ad
.
MNC_Length
=
strlen
(
user_plmn_list
[
hplmn_index
].
mnc
);
usim_data
->
ad
.
UE_Operation_Mode
=
USIM_NORMAL_MODE
;
usim_data
->
ad
.
Additional_Info
=
0xffff
;
usim_data
->
ad
.
MNC_Length
=
strlen
(
user_plmn_list
[
hplmn_index
].
mnc
);
/*
* EPS NAS security context
*/
usim_data
.
securityctx
.
length
=
52
;
usim_data
.
securityctx
.
KSIasme
.
type
=
USIM_KSI_ASME_TAG
;
usim_data
.
securityctx
.
KSIasme
.
length
=
1
;
usim_data
.
securityctx
.
KSIasme
.
value
[
0
]
=
KSI_ASME
;
usim_data
.
securityctx
.
Kasme
.
type
=
USIM_K_ASME_TAG
;
usim_data
.
securityctx
.
Kasme
.
length
=
USIM_K_ASME_SIZE
;
memset
(
usim_data
.
securityctx
.
Kasme
.
value
,
0
,
usim_data
.
securityctx
.
Kasme
.
length
);
usim_data
.
securityctx
.
ulNAScount
.
type
=
USIM_UL_NAS_COUNT_TAG
;
usim_data
.
securityctx
.
ulNAScount
.
length
=
USIM_UL_NAS_COUNT_SIZE
;
memset
(
usim_data
.
securityctx
.
ulNAScount
.
value
,
0
,
usim_data
.
securityctx
.
ulNAScount
.
length
);
usim_data
.
securityctx
.
dlNAScount
.
type
=
USIM_DL_NAS_COUNT_TAG
;
usim_data
.
securityctx
.
dlNAScount
.
length
=
USIM_DL_NAS_COUNT_SIZE
;
memset
(
usim_data
.
securityctx
.
dlNAScount
.
value
,
0
,
usim_data
.
securityctx
.
dlNAScount
.
length
);
usim_data
.
securityctx
.
algorithmID
.
type
=
USIM_INT_ENC_ALGORITHMS_TAG
;
usim_data
.
securityctx
.
algorithmID
.
length
=
1
;
usim_data
.
securityctx
.
algorithmID
.
value
[
0
]
=
SECURITY_ALGORITHMS
;
usim_data
->
securityctx
.
length
=
52
;
usim_data
->
securityctx
.
KSIasme
.
type
=
USIM_KSI_ASME_TAG
;
usim_data
->
securityctx
.
KSIasme
.
length
=
1
;
usim_data
->
securityctx
.
KSIasme
.
value
[
0
]
=
KSI_ASME
;
usim_data
->
securityctx
.
Kasme
.
type
=
USIM_K_ASME_TAG
;
usim_data
->
securityctx
.
Kasme
.
length
=
USIM_K_ASME_SIZE
;
memset
(
usim_data
->
securityctx
.
Kasme
.
value
,
0
,
usim_data
->
securityctx
.
Kasme
.
length
);
usim_data
->
securityctx
.
ulNAScount
.
type
=
USIM_UL_NAS_COUNT_TAG
;
usim_data
->
securityctx
.
ulNAScount
.
length
=
USIM_UL_NAS_COUNT_SIZE
;
memset
(
usim_data
->
securityctx
.
ulNAScount
.
value
,
0
,
usim_data
->
securityctx
.
ulNAScount
.
length
);
usim_data
->
securityctx
.
dlNAScount
.
type
=
USIM_DL_NAS_COUNT_TAG
;
usim_data
->
securityctx
.
dlNAScount
.
length
=
USIM_DL_NAS_COUNT_SIZE
;
memset
(
usim_data
->
securityctx
.
dlNAScount
.
value
,
0
,
usim_data
->
securityctx
.
dlNAScount
.
length
);
usim_data
->
securityctx
.
algorithmID
.
type
=
USIM_INT_ENC_ALGORITHMS_TAG
;
usim_data
->
securityctx
.
algorithmID
.
length
=
1
;
usim_data
->
securityctx
.
algorithmID
.
value
[
0
]
=
SECURITY_ALGORITHMS
;
/*
* Subcriber's Number
*/
usim_data
.
msisdn
.
length
=
7
;
usim_data
.
msisdn
.
number
.
ext
=
1
;
usim_data
.
msisdn
.
number
.
ton
=
MSISDN_TON_UNKNOWKN
;
usim_data
.
msisdn
.
number
.
npi
=
MSISDN_NPI_ISDN_TELEPHONY
;
usim_data
.
msisdn
.
conf1_record_id
=
0xff
;
/* Not used */
usim_data
.
msisdn
.
ext1_record_id
=
0xff
;
/* Not used */
usim_data
->
msisdn
.
length
=
7
;
usim_data
->
msisdn
.
number
.
ext
=
1
;
usim_data
->
msisdn
.
number
.
ton
=
MSISDN_TON_UNKNOWKN
;
usim_data
->
msisdn
.
number
.
npi
=
MSISDN_NPI_ISDN_TELEPHONY
;
usim_data
->
msisdn
.
conf1_record_id
=
0xff
;
/* Not used */
usim_data
->
msisdn
.
ext1_record_id
=
0xff
;
/* Not used */
int
j
=
0
;
for
(
int
i
=
0
;
i
<
strlen
(
msisdn
);
i
+=
2
)
{
usim_data
.
msisdn
.
number
.
digit
[
j
].
msb
=
msisdn
[
i
];
usim_data
->
msisdn
.
number
.
digit
[
j
].
msb
=
msisdn
[
i
];
j
++
;
}
j
=
0
;
for
(
int
i
=
1
;
i
<
strlen
(
msisdn
);
i
+=
2
)
{
usim_data
.
msisdn
.
number
.
digit
[
j
].
lsb
=
msisdn
[
i
];
usim_data
->
msisdn
.
number
.
digit
[
j
].
lsb
=
msisdn
[
i
];
j
++
;
}
if
(
strlen
(
msisdn
)
%
2
==
0
)
{
for
(
int
i
=
strlen
(
msisdn
)
/
2
;
i
<
10
;
i
++
)
{
usim_data
.
msisdn
.
number
.
digit
[
i
].
msb
=
0xf
;
usim_data
.
msisdn
.
number
.
digit
[
i
].
lsb
=
0xf
;
usim_data
->
msisdn
.
number
.
digit
[
i
].
msb
=
0xf
;
usim_data
->
msisdn
.
number
.
digit
[
i
].
lsb
=
0xf
;
}
}
else
{
usim_data
.
msisdn
.
number
.
digit
[
strlen
(
msisdn
)
/
2
].
lsb
=
0xf
;
usim_data
->
msisdn
.
number
.
digit
[
strlen
(
msisdn
)
/
2
].
lsb
=
0xf
;
for
(
int
i
=
(
strlen
(
msisdn
)
/
2
)
+
1
;
i
<
10
;
i
++
)
{
usim_data
.
msisdn
.
number
.
digit
[
i
].
msb
=
0xf
;
usim_data
.
msisdn
.
number
.
digit
[
i
].
lsb
=
0xf
;
usim_data
->
msisdn
.
number
.
digit
[
i
].
msb
=
0xf
;
usim_data
->
msisdn
.
number
.
digit
[
i
].
lsb
=
0xf
;
}
}
/*
...
...
@@ -304,22 +310,22 @@ void gen_usim_data(int user_id) {
*/
for
(
int
i
=
0
;
i
<
oplmn_nb
;
i
++
)
{
network_record_t
record
=
user_network_record_list
[
oplmn
[
i
]];
usim_data
.
pnn
[
i
].
fullname
.
type
=
USIM_PNN_FULLNAME_TAG
;
usim_data
.
pnn
[
i
].
fullname
.
length
=
strlen
(
record
.
fullname
);
strncpy
((
char
*
)
usim_data
.
pnn
[
i
].
fullname
.
value
,
record
.
fullname
,
usim_data
.
pnn
[
i
].
fullname
.
length
);
usim_data
.
pnn
[
i
].
shortname
.
type
=
USIM_PNN_SHORTNAME_TAG
;
usim_data
.
pnn
[
i
].
shortname
.
length
=
strlen
(
record
.
shortname
);
strncpy
((
char
*
)
usim_data
.
pnn
[
i
].
shortname
.
value
,
record
.
shortname
,
usim_data
.
pnn
[
i
].
shortname
.
length
);
usim_data
.
opl
[
i
].
plmn
=
record
.
plmn
;
usim_data
.
opl
[
i
].
start
=
record
.
tac_start
;
usim_data
.
opl
[
i
].
end
=
record
.
tac_end
;
usim_data
.
opl
[
i
].
record_id
=
i
;
usim_data
->
pnn
[
i
].
fullname
.
type
=
USIM_PNN_FULLNAME_TAG
;
usim_data
->
pnn
[
i
].
fullname
.
length
=
strlen
(
record
.
fullname
);
strncpy
((
char
*
)
usim_data
->
pnn
[
i
].
fullname
.
value
,
record
.
fullname
,
usim_data
->
pnn
[
i
].
fullname
.
length
);
usim_data
->
pnn
[
i
].
shortname
.
type
=
USIM_PNN_SHORTNAME_TAG
;
usim_data
->
pnn
[
i
].
shortname
.
length
=
strlen
(
record
.
shortname
);
strncpy
((
char
*
)
usim_data
->
pnn
[
i
].
shortname
.
value
,
record
.
shortname
,
usim_data
->
pnn
[
i
].
shortname
.
length
);
usim_data
->
opl
[
i
].
plmn
=
record
.
plmn
;
usim_data
->
opl
[
i
].
start
=
record
.
tac_start
;
usim_data
->
opl
[
i
].
end
=
record
.
tac_end
;
usim_data
->
opl
[
i
].
record_id
=
i
;
}
if
(
oplmn_nb
<
USIM_OPL_MAX
)
{
for
(
int
i
=
oplmn_nb
;
i
<
USIM_OPL_MAX
;
i
++
)
{
memset
(
&
usim_data
.
opl
[
i
].
plmn
,
0xff
,
sizeof
(
plmn_t
));
memset
(
&
usim_data
->
opl
[
i
].
plmn
,
0xff
,
sizeof
(
plmn_t
));
}
}
...
...
@@ -327,155 +333,162 @@ void gen_usim_data(int user_id) {
* List of Equivalent HPLMNs
*/
for
(
int
i
=
0
;
i
<
ehplmn_nb
;
i
++
)
{
usim_data
.
ehplmn
[
i
]
=
user_network_record_list
[
ehplmn
[
i
]].
plmn
;
usim_data
->
ehplmn
[
i
]
=
user_network_record_list
[
ehplmn
[
i
]].
plmn
;
}
if
(
ehplmn_nb
<
USIM_EHPLMN_MAX
)
{
for
(
int
i
=
ehplmn_nb
;
i
<
USIM_EHPLMN_MAX
;
i
++
)
{
memset
(
&
usim_data
.
ehplmn
[
i
],
0xff
,
sizeof
(
plmn_t
));
memset
(
&
usim_data
->
ehplmn
[
i
],
0xff
,
sizeof
(
plmn_t
));
}
}
/*
* Home PLMN Selector with Access Technology
*/
usim_data
.
hplmn
.
plmn
=
user_network_record_list
[
hplmn_index
].
plmn
;
usim_data
.
hplmn
.
AcT
=
(
USIM_ACT_GSM
|
USIM_ACT_UTRAN
|
USIM_ACT_EUTRAN
);
usim_data
->
hplmn
.
plmn
=
user_network_record_list
[
hplmn_index
].
plmn
;
usim_data
->
hplmn
.
AcT
=
(
USIM_ACT_GSM
|
USIM_ACT_UTRAN
|
USIM_ACT_EUTRAN
);
/*
* List of user controlled PLMN selector with Access Technology
*/
for
(
int
i
=
0
;
i
<
USIM_PLMN_MAX
;
i
++
)
{
memset
(
&
usim_data
.
plmn
[
i
],
0xff
,
sizeof
(
plmn_t
));
memset
(
&
usim_data
->
plmn
[
i
],
0xff
,
sizeof
(
plmn_t
));
}
if
(
ucplmn_nb
>
0
)
{
for
(
int
i
=
0
;
i
<
ucplmn_nb
;
i
++
)
{
usim_data
.
plmn
[
i
].
plmn
=
user_network_record_list
[
ucplmn
[
i
]].
plmn
;
usim_data
->
plmn
[
i
].
plmn
=
user_network_record_list
[
ucplmn
[
i
]].
plmn
;
}
}
// List of operator controlled PLMN selector with Access Technology
for
(
int
i
=
0
;
i
<
USIM_OPLMN_MAX
;
i
++
)
{
memset
(
&
usim_data
.
oplmn
[
i
],
0xff
,
sizeof
(
plmn_t
));
memset
(
&
usim_data
->
oplmn
[
i
],
0xff
,
sizeof
(
plmn_t
));
}
if
(
ocplmn_nb
>
0
)
{
for
(
int
i
=
0
;
i
<
ocplmn_nb
;
i
++
)
{
usim_data
.
oplmn
[
i
].
plmn
=
user_network_record_list
[
ocplmn
[
i
]].
plmn
;
usim_data
.
oplmn
[
i
].
AcT
=
(
USIM_ACT_GSM
|
USIM_ACT_UTRAN
usim_data
->
oplmn
[
i
].
plmn
=
user_network_record_list
[
ocplmn
[
i
]].
plmn
;
usim_data
->
oplmn
[
i
].
AcT
=
(
USIM_ACT_GSM
|
USIM_ACT_UTRAN
|
USIM_ACT_EUTRAN
);
}
}
/*
* EPS Location Information
*/
usim_data
.
epsloci
.
guti
.
gummei
.
plmn
=
usim_data
->
epsloci
.
guti
.
gummei
.
plmn
=
user_network_record_list
[
hplmn_index
].
plmn
;
usim_data
.
epsloci
.
guti
.
gummei
.
MMEgid
=
DEFAULT_MME_ID
;
usim_data
.
epsloci
.
guti
.
gummei
.
MMEcode
=
DEFAULT_MME_CODE
;
usim_data
.
epsloci
.
guti
.
m_tmsi
=
DEFAULT_M_TMSI
;
usim_data
.
epsloci
.
tai
.
plmn
=
usim_data
.
epsloci
.
guti
.
gummei
.
plmn
;
usim_data
.
epsloci
.
tai
.
tac
=
DEFAULT_TAC
;
usim_data
.
epsloci
.
status
=
USIM_EPSLOCI_UPDATED
;
usim_data
->
epsloci
.
guti
.
gummei
.
MMEgid
=
DEFAULT_MME_ID
;
usim_data
->
epsloci
.
guti
.
gummei
.
MMEcode
=
DEFAULT_MME_CODE
;
usim_data
->
epsloci
.
guti
.
m_tmsi
=
DEFAULT_M_TMSI
;
usim_data
->
epsloci
.
tai
.
plmn
=
usim_data
->
epsloci
.
guti
.
gummei
.
plmn
;
usim_data
->
epsloci
.
tai
.
tac
=
DEFAULT_TAC
;
usim_data
->
epsloci
.
status
=
USIM_EPSLOCI_UPDATED
;
/*
* Non-Access Stratum configuration
*/
usim_data
.
nasconfig
.
NAS_SignallingPriority
.
type
=
usim_data
->
nasconfig
.
NAS_SignallingPriority
.
type
=
USIM_NAS_SIGNALLING_PRIORITY_TAG
;
usim_data
.
nasconfig
.
NAS_SignallingPriority
.
length
=
1
;
usim_data
.
nasconfig
.
NAS_SignallingPriority
.
value
[
0
]
=
0x00
;
usim_data
.
nasconfig
.
NMO_I_Behaviour
.
type
=
USIM_NMO_I_BEHAVIOUR_TAG
;
usim_data
.
nasconfig
.
NMO_I_Behaviour
.
length
=
1
;
usim_data
.
nasconfig
.
NMO_I_Behaviour
.
value
[
0
]
=
0x00
;
usim_data
.
nasconfig
.
AttachWithImsi
.
type
=
USIM_ATTACH_WITH_IMSI_TAG
;
usim_data
.
nasconfig
.
AttachWithImsi
.
length
=
1
;
usim_data
->
nasconfig
.
NAS_SignallingPriority
.
length
=
1
;
usim_data
->
nasconfig
.
NAS_SignallingPriority
.
value
[
0
]
=
0x00
;
usim_data
->
nasconfig
.
NMO_I_Behaviour
.
type
=
USIM_NMO_I_BEHAVIOUR_TAG
;
usim_data
->
nasconfig
.
NMO_I_Behaviour
.
length
=
1
;
usim_data
->
nasconfig
.
NMO_I_Behaviour
.
value
[
0
]
=
0x00
;
usim_data
->
nasconfig
.
AttachWithImsi
.
type
=
USIM_ATTACH_WITH_IMSI_TAG
;
usim_data
->
nasconfig
.
AttachWithImsi
.
length
=
1
;
#if defined(START_WITH_GUTI)
usim_data
.
nasconfig
.
AttachWithImsi
.
value
[
0
]
=
0x00
;
usim_data
->
nasconfig
.
AttachWithImsi
.
value
[
0
]
=
0x00
;
#else
usim_data
.
nasconfig
.
AttachWithImsi
.
value
[
0
]
=
0x01
;
usim_data
->
nasconfig
.
AttachWithImsi
.
value
[
0
]
=
0x01
;
#endif
usim_data
.
nasconfig
.
MinimumPeriodicSearchTimer
.
type
=
usim_data
->
nasconfig
.
MinimumPeriodicSearchTimer
.
type
=
USIM_MINIMUM_PERIODIC_SEARCH_TIMER_TAG
;
usim_data
.
nasconfig
.
MinimumPeriodicSearchTimer
.
length
=
1
;
usim_data
.
nasconfig
.
MinimumPeriodicSearchTimer
.
value
[
0
]
=
0x00
;
usim_data
.
nasconfig
.
ExtendedAccessBarring
.
type
=
usim_data
->
nasconfig
.
MinimumPeriodicSearchTimer
.
length
=
1
;
usim_data
->
nasconfig
.
MinimumPeriodicSearchTimer
.
value
[
0
]
=
0x00
;
usim_data
->
nasconfig
.
ExtendedAccessBarring
.
type
=
USIM_EXTENDED_ACCESS_BARRING_TAG
;
usim_data
.
nasconfig
.
ExtendedAccessBarring
.
length
=
1
;
usim_data
.
nasconfig
.
ExtendedAccessBarring
.
value
[
0
]
=
0x00
;
usim_data
.
nasconfig
.
Timer_T3245_Behaviour
.
type
=
usim_data
->
nasconfig
.
ExtendedAccessBarring
.
length
=
1
;
usim_data
->
nasconfig
.
ExtendedAccessBarring
.
value
[
0
]
=
0x00
;
usim_data
->
nasconfig
.
Timer_T3245_Behaviour
.
type
=
USIM_TIMER_T3245_BEHAVIOUR_TAG
;
usim_data
.
nasconfig
.
Timer_T3245_Behaviour
.
length
=
1
;
usim_data
.
nasconfig
.
Timer_T3245_Behaviour
.
value
[
0
]
=
0x00
;
usim_data
->
nasconfig
.
Timer_T3245_Behaviour
.
length
=
1
;
usim_data
->
nasconfig
.
Timer_T3245_Behaviour
.
value
[
0
]
=
0x00
;
/* initialize the subscriber authentication security key */
hex_string_to_hex_value
(
usim_data
.
keys
.
usim_api_k
,
hex_string_to_hex_value
(
usim_data
->
keys
.
usim_api_k
,
usim_api_k
,
USIM_API_K_SIZE
);
hex_string_to_hex_value
(
usim_data
.
keys
.
opc
,
opc
,
hex_string_to_hex_value
(
usim_data
->
keys
.
opc
,
opc
,
OPC_SIZE
);
}
char
*
path
=
make_filename
(
output_dir
,
USIM_API_NVRAM_FILENAME
,
user_id
);
usim_api_write
(
path
,
&
usim_data
);
free
(
path
);
int
write_usim_data
(
const
char
*
directory
,
int
user_id
,
usim_data_t
*
usim_data
){
int
rc
;
char
*
filename
=
make_filename
(
directory
,
USIM_API_NVRAM_FILENAME
,
user_id
);
rc
=
usim_api_write
(
filename
,
usim_data
);
free
(
filename
);
return
rc
;
}
void
gen_emm_data
(
int
user_id
)
{
void
gen_emm_data
(
int
user_id
,
emm_nvdata_t
*
emm_data
)
{
hplmn_index
=
get_plmn_index
(
hplmn
);
emm_nvdata_t
emm_data
;
int
rc
;
memset
(
&
emm_data
,
0
,
sizeof
(
emm_nvdata_t
));
memset
(
emm_data
,
0
,
sizeof
(
emm_nvdata_t
));
int
hplmn_index
=
get_plmn_index
(
hplmn
);
emm_data
.
imsi
.
length
=
8
;
emm_data
.
imsi
.
u
.
num
.
parity
=
get_msin_parity
(
msin
);
emm_data
.
imsi
.
u
.
num
.
digit1
=
user_plmn_list
[
hplmn_index
].
mcc
[
0
];
emm_data
.
imsi
.
u
.
num
.
digit2
=
user_plmn_list
[
hplmn_index
].
mcc
[
1
];
emm_data
.
imsi
.
u
.
num
.
digit3
=
user_plmn_list
[
hplmn_index
].
mcc
[
2
];
emm_data
->
imsi
.
length
=
8
;
emm_data
->
imsi
.
u
.
num
.
parity
=
get_msin_parity
(
msin
);
emm_data
->
imsi
.
u
.
num
.
digit1
=
user_plmn_list
[
hplmn_index
].
mcc
[
0
];
emm_data
->
imsi
.
u
.
num
.
digit2
=
user_plmn_list
[
hplmn_index
].
mcc
[
1
];
emm_data
->
imsi
.
u
.
num
.
digit3
=
user_plmn_list
[
hplmn_index
].
mcc
[
2
];
emm_data
.
imsi
.
u
.
num
.
digit4
=
user_plmn_list
[
hplmn_index
].
mnc
[
0
];
emm_data
.
imsi
.
u
.
num
.
digit5
=
user_plmn_list
[
hplmn_index
].
mnc
[
1
];
emm_data
->
imsi
.
u
.
num
.
digit4
=
user_plmn_list
[
hplmn_index
].
mnc
[
0
];
emm_data
->
imsi
.
u
.
num
.
digit5
=
user_plmn_list
[
hplmn_index
].
mnc
[
1
];
if
(
strlen
(
user_plmn_list
[
hplmn_index
].
mnc
)
==
3
)
{
emm_data
.
rplmn
.
MNCdigit3
=
user_plmn_list
[
hplmn_index
].
mnc
[
2
];
emm_data
.
imsi
.
u
.
num
.
digit6
=
user_plmn_list
[
hplmn_index
].
mnc
[
2
];
emm_data
.
imsi
.
u
.
num
.
digit7
=
msin
[
0
];
emm_data
.
imsi
.
u
.
num
.
digit8
=
msin
[
1
];
emm_data
.
imsi
.
u
.
num
.
digit9
=
msin
[
2
];
emm_data
.
imsi
.
u
.
num
.
digit10
=
msin
[
3
];
emm_data
.
imsi
.
u
.
num
.
digit11
=
msin
[
4
];
emm_data
.
imsi
.
u
.
num
.
digit12
=
msin
[
5
];
emm_data
.
imsi
.
u
.
num
.
digit13
=
msin
[
6
];
emm_data
.
imsi
.
u
.
num
.
digit14
=
msin
[
7
];
emm_data
.
imsi
.
u
.
num
.
digit15
=
msin
[
8
];
emm_data
->
rplmn
.
MNCdigit3
=
user_plmn_list
[
hplmn_index
].
mnc
[
2
];
emm_data
->
imsi
.
u
.
num
.
digit6
=
user_plmn_list
[
hplmn_index
].
mnc
[
2
];
emm_data
->
imsi
.
u
.
num
.
digit7
=
msin
[
0
];
emm_data
->
imsi
.
u
.
num
.
digit8
=
msin
[
1
];
emm_data
->
imsi
.
u
.
num
.
digit9
=
msin
[
2
];
emm_data
->
imsi
.
u
.
num
.
digit10
=
msin
[
3
];
emm_data
->
imsi
.
u
.
num
.
digit11
=
msin
[
4
];
emm_data
->
imsi
.
u
.
num
.
digit12
=
msin
[
5
];
emm_data
->
imsi
.
u
.
num
.
digit13
=
msin
[
6
];
emm_data
->
imsi
.
u
.
num
.
digit14
=
msin
[
7
];
emm_data
->
imsi
.
u
.
num
.
digit15
=
msin
[
8
];
}
else
{
emm_data
.
rplmn
.
MNCdigit3
=
0xf
;
emm_data
->
rplmn
.
MNCdigit3
=
0xf
;
emm_data
.
imsi
.
u
.
num
.
digit6
=
msin
[
0
];
emm_data
.
imsi
.
u
.
num
.
digit7
=
msin
[
1
];
emm_data
.
imsi
.
u
.
num
.
digit8
=
msin
[
2
];
emm_data
.
imsi
.
u
.
num
.
digit9
=
msin
[
3
];
emm_data
.
imsi
.
u
.
num
.
digit10
=
msin
[
4
];
emm_data
.
imsi
.
u
.
num
.
digit11
=
msin
[
5
];
emm_data
.
imsi
.
u
.
num
.
digit12
=
msin
[
6
];
emm_data
.
imsi
.
u
.
num
.
digit13
=
msin
[
7
];
emm_data
.
imsi
.
u
.
num
.
digit14
=
msin
[
8
];
emm_data
.
imsi
.
u
.
num
.
digit15
=
msin
[
9
];
emm_data
->
imsi
.
u
.
num
.
digit6
=
msin
[
0
];
emm_data
->
imsi
.
u
.
num
.
digit7
=
msin
[
1
];
emm_data
->
imsi
.
u
.
num
.
digit8
=
msin
[
2
];
emm_data
->
imsi
.
u
.
num
.
digit9
=
msin
[
3
];
emm_data
->
imsi
.
u
.
num
.
digit10
=
msin
[
4
];
emm_data
->
imsi
.
u
.
num
.
digit11
=
msin
[
5
];
emm_data
->
imsi
.
u
.
num
.
digit12
=
msin
[
6
];
emm_data
->
imsi
.
u
.
num
.
digit13
=
msin
[
7
];
emm_data
->
imsi
.
u
.
num
.
digit14
=
msin
[
8
];
emm_data
->
imsi
.
u
.
num
.
digit15
=
msin
[
9
];
}
emm_data
.
rplmn
.
MCCdigit1
=
user_plmn_list
[
hplmn_index
].
mcc
[
0
];
emm_data
.
rplmn
.
MCCdigit2
=
user_plmn_list
[
hplmn_index
].
mcc
[
1
];
emm_data
.
rplmn
.
MCCdigit3
=
user_plmn_list
[
hplmn_index
].
mcc
[
2
];
emm_data
.
rplmn
.
MNCdigit1
=
user_plmn_list
[
hplmn_index
].
mnc
[
0
];
emm_data
.
rplmn
.
MNCdigit2
=
user_plmn_list
[
hplmn_index
].
mnc
[
1
];
emm_data
->
rplmn
.
MCCdigit1
=
user_plmn_list
[
hplmn_index
].
mcc
[
0
];
emm_data
->
rplmn
.
MCCdigit2
=
user_plmn_list
[
hplmn_index
].
mcc
[
1
];
emm_data
->
rplmn
.
MCCdigit3
=
user_plmn_list
[
hplmn_index
].
mcc
[
2
];
emm_data
->
rplmn
.
MNCdigit1
=
user_plmn_list
[
hplmn_index
].
mnc
[
0
];
emm_data
->
rplmn
.
MNCdigit2
=
user_plmn_list
[
hplmn_index
].
mnc
[
1
];
emm_data
.
eplmn
.
n_plmns
=
ehplmn_nb
;
emm_data
->
eplmn
.
n_plmns
=
ehplmn_nb
;
}
char
*
path
=
make_filename
(
output_dir
,
EMM_NVRAM_FILENAME
,
user_id
);
rc
=
memory_write
(
path
,
&
emm_data
,
sizeof
(
emm_nvdata_t
));
free
(
path
);
int
write_emm_data
(
const
char
*
directory
,
int
user_id
,
emm_nvdata_t
*
emm_data
)
{
int
rc
;
char
*
filename
=
make_filename
(
directory
,
EMM_NVRAM_FILENAME
,
user_id
);
rc
=
memory_write
(
filename
,
emm_data
,
sizeof
(
emm_nvdata_t
));
free
(
filename
);
if
(
rc
!=
RETURNok
)
{
perror
(
"ERROR
\t
: memory_write() failed"
);
exit
(
EXIT_FAILURE
);
}
return
(
EXIT_SUCCESS
);
}
int
parse_plmn_param
(
config_setting_t
*
plmn_setting
,
int
index
)
{
...
...
@@ -632,9 +645,8 @@ 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
)
{
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
;
user_nvdata_t
user_data
;
const
char
*
imei
=
NULL
;
const
char
*
manufacturer
=
NULL
;
const
char
*
model
=
NULL
;
...
...
@@ -667,29 +679,34 @@ int parse_ue_user_param(config_setting_t *ue_setting, int user_id) {
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
));
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
);
strncpy
(
user_data
->
manufacturer
,
manufacturer
,
USER_MANUFACTURER_SIZE
);
/*
* Model identifier
*/
strncpy
(
user_data
.
model
,
model
,
USER_MODEL_SIZE
);
strncpy
(
user_data
->
model
,
model
,
USER_MODEL_SIZE
);
/*
* SIM Personal Identification Number
*/
strncpy
(
user_data
.
PIN
,
pin
,
USER_PIN_SIZE
);
strncpy
(
user_data
->
PIN
,
pin
,
USER_PIN_SIZE
);
char
*
path
=
make_filename
(
output_dir
,
USER_NVRAM_FILENAME
,
user_id
);
rc
=
memory_write
(
path
,
&
user_data
,
sizeof
(
user_nvdata_t
));
free
(
path
);
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
);
}
return
EXIT_SUCCESS
;
}
int
fill_ucplmn
(
config_setting_t
*
setting
,
int
user_id
)
{
...
...
openair3/NAS/TOOLS/conf2uedata.h
View file @
ef2dee59
...
...
@@ -2,7 +2,10 @@
#define _CONF2UEDATA_H
#include <libconfig.h>
#include "emmData.h"
#include "usim_api.h"
#include "userDef.h"
#define USER "USER"
#define UE "UE"
...
...
@@ -70,8 +73,6 @@ typedef struct {
const
char
*
mcc
;
}
plmn_conf_param_t
;
extern
const
char
*
output_dir
;
extern
const
char
*
msin
;
extern
const
char
*
usim_api_k
;
extern
const
char
*
msisdn
;
...
...
@@ -96,16 +97,21 @@ extern plmn_conf_param_t* user_plmn_list;
extern
network_record_t
*
user_network_record_list
;
int
get_config_from_file
(
const
char
*
filename
,
config_t
*
config
);
int
parse_config_file
(
const
char
*
filename
);
int
parse_config_file
(
const
char
*
output_dir
,
const
char
*
filename
);
void
_display_usage
(
void
);
void
gen_emm_data
(
int
user_id
)
;
void
gen_usim_data
(
int
user_id
);
void
gen_emm_data
(
int
user_id
,
emm_nvdata_t
*
emm_data
);
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_emm_data
(
const
char
*
directory
,
int
user_id
,
emm_nvdata_t
*
emm_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_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_plmn_param
(
config_setting_t
*
plmn_setting
,
int
index
);
int
parse_plmns
(
config_setting_t
*
all_plmn_setting
);
...
...
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