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
wangjie
OpenXG-RAN
Commits
51c77535
Commit
51c77535
authored
Aug 23, 2016
by
Frédéric Leroy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(conf2uedata): move networks function to conf_networks.[c|h]
parent
1b54e18a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
170 additions
and
155 deletions
+170
-155
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
+2
-111
openair3/NAS/TOOLS/conf2uedata.h
openair3/NAS/TOOLS/conf2uedata.h
+1
-44
openair3/NAS/TOOLS/conf_network.c
openair3/NAS/TOOLS/conf_network.c
+112
-0
openair3/NAS/TOOLS/conf_network.h
openair3/NAS/TOOLS/conf_network.h
+54
-0
No files found.
cmake_targets/nas_sim_tools/CMakeLists.txt
View file @
51c77535
...
@@ -20,6 +20,7 @@ set(conf2uedata_SRC
...
@@ -20,6 +20,7 @@ set(conf2uedata_SRC
${
OPENAIR_DIR
}
/openair3/NAS/TOOLS/conf_emm.c
${
OPENAIR_DIR
}
/openair3/NAS/TOOLS/conf_emm.c
${
OPENAIR_DIR
}
/openair3/NAS/TOOLS/conf_user_data.c
${
OPENAIR_DIR
}
/openair3/NAS/TOOLS/conf_user_data.c
${
OPENAIR_DIR
}
/openair3/NAS/TOOLS/conf_usim.c
${
OPENAIR_DIR
}
/openair3/NAS/TOOLS/conf_usim.c
${
OPENAIR_DIR
}
/openair3/NAS/TOOLS/conf_network.c
${
OPENAIR_DIR
}
/openair3/NAS/TOOLS/fs.c
${
OPENAIR_DIR
}
/openair3/NAS/TOOLS/fs.c
${
OPENAIR_DIR
}
/openair3/NAS/TOOLS/display.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
...
...
openair3/NAS/TOOLS/conf2uedata.c
View file @
51c77535
...
@@ -82,9 +82,8 @@ int parse_config_file(const char *output_dir, const char *conf_filename) {
...
@@ -82,9 +82,8 @@ int parse_config_file(const char *output_dir, const char *conf_filename) {
return
(
EXIT_FAILURE
);
return
(
EXIT_FAILURE
);
}
}
rc
=
parse_plmns
(
all_plmn_setting
,
&
networks
);
if
(
parse_plmns
(
all_plmn_setting
,
&
networks
)
==
false
)
{
if
(
rc
==
EXIT_FAILURE
)
{
return
EXIT_FAILURE
;
return
rc
;
}
}
for
(
int
i
=
0
;
i
<
ue_nb
;
i
++
)
{
for
(
int
i
=
0
;
i
<
ue_nb
;
i
++
)
{
...
@@ -159,65 +158,6 @@ int get_config_from_file(const char *filename, config_t *config) {
...
@@ -159,65 +158,6 @@ int get_config_from_file(const char *filename, config_t *config) {
}
}
int
parse_plmn_param
(
config_setting_t
*
plmn_setting
,
plmn_conf_param_t
*
conf
)
{
int
rc
=
0
;
rc
=
config_setting_lookup_string
(
plmn_setting
,
FULLNAME
,
&
conf
->
fullname
);
if
(
rc
!=
1
)
{
printf
(
"Error on FULLNAME
\n
"
);
return
EXIT_FAILURE
;
}
rc
=
config_setting_lookup_string
(
plmn_setting
,
SHORTNAME
,
&
conf
->
shortname
);
if
(
rc
!=
1
)
{
printf
(
"Error on SHORTNAME
\n
"
);
return
EXIT_FAILURE
;
}
rc
=
config_setting_lookup_string
(
plmn_setting
,
MNC
,
&
conf
->
mnc
);
if
(
rc
!=
1
||
strlen
(
conf
->
mnc
)
>
3
||
strlen
(
conf
->
mnc
)
<
2
)
{
printf
(
"Error ond MNC. Exiting
\n
"
);
return
EXIT_FAILURE
;
}
rc
=
config_setting_lookup_string
(
plmn_setting
,
MCC
,
&
conf
->
mcc
);
if
(
rc
!=
1
||
strlen
(
conf
->
mcc
)
!=
3
)
{
printf
(
"Error on MCC
\n
"
);
return
EXIT_FAILURE
;
}
return
EXIT_SUCCESS
;
}
int
parse_plmns
(
config_setting_t
*
all_plmn_setting
,
networks_t
*
networks
)
{
config_setting_t
*
plmn_setting
=
NULL
;
char
plmn
[
10
];
int
rc
=
EXIT_SUCCESS
;
int
size
=
0
;
size
=
config_setting_length
(
all_plmn_setting
);
networks
->
size
=
size
;
networks
->
items
=
malloc
(
sizeof
(
network_t
)
*
size
);
for
(
int
i
=
0
;
i
<
size
;
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
);
plmn_setting
=
config_setting_get_member
(
all_plmn_setting
,
plmn
);
if
(
plmn_setting
!=
NULL
)
{
rc
=
parse_plmn_param
(
plmn_setting
,
&
network
->
conf
);
if
(
rc
==
EXIT_FAILURE
)
{
return
rc
;
}
}
else
{
printf
(
"Problem in PLMN%d. Exiting...
\n
"
,
i
);
return
EXIT_FAILURE
;
}
gen_network_record_from_conf
(
&
network
->
conf
,
&
network
->
record
);
network
->
plmn
=
network
->
record
.
plmn
;
}
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
)
{
const
networks_t
networks
)
{
...
@@ -285,55 +225,6 @@ int parse_Xplmn(config_setting_t *ue_setting, const char *section,
...
@@ -285,55 +225,6 @@ int parse_Xplmn(config_setting_t *ue_setting, const char *section,
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
int
get_plmn_index
(
const
char
*
mccmnc
,
const
networks_t
networks
)
{
char
mcc
[
4
];
char
mnc
[
strlen
(
mccmnc
)
-
2
];
strncpy
(
mcc
,
mccmnc
,
3
);
mcc
[
3
]
=
'\0'
;
strncpy
(
mnc
,
mccmnc
+
3
,
3
);
mnc
[
strlen
(
mccmnc
)
-
3
]
=
'\0'
;
for
(
int
i
=
0
;
i
<
networks
.
size
;
i
++
)
{
if
(
strcmp
(
networks
.
items
[
i
].
conf
.
mcc
,
mcc
)
==
0
)
{
if
(
strcmp
(
networks
.
items
[
i
].
conf
.
mnc
,
mnc
)
==
0
)
{
return
i
;
}
}
}
return
-
1
;
}
plmn_t
make_plmn_from_conf
(
const
plmn_conf_param_t
*
plmn_conf
)
{
plmn_t
plmn
;
char
num
[
6
];
memset
(
&
plmn
,
0xff
,
sizeof
(
plmn
));
snprintf
(
num
,
6
,
"%s%s"
,
plmn_conf
->
mcc
,
plmn_conf
->
mnc
);
plmn
.
MCCdigit2
=
plmn_conf
->
mcc
[
1
];
plmn
.
MCCdigit1
=
plmn_conf
->
mcc
[
0
];
plmn
.
MCCdigit3
=
plmn_conf
->
mcc
[
2
];
plmn
.
MNCdigit2
=
plmn_conf
->
mnc
[
1
];
plmn
.
MNCdigit1
=
plmn_conf
->
mnc
[
0
];
if
(
strlen
(
plmn_conf
->
mnc
)
>
2
)
{
plmn
.
MNCdigit3
=
plmn_conf
->
mnc
[
2
];
}
return
plmn
;
}
void
gen_network_record_from_conf
(
const
plmn_conf_param_t
*
conf
,
network_record_t
*
record
)
{
strcpy
(
record
->
fullname
,
conf
->
fullname
);
strcpy
(
record
->
shortname
,
conf
->
shortname
);
char
num
[
6
];
sprintf
(
num
,
"%s%s"
,
conf
->
mcc
,
conf
->
mnc
);
record
->
num
=
atoi
(
num
);
record
->
plmn
=
make_plmn_from_conf
(
conf
);
record
->
tac_end
=
0xfffd
;
record
->
tac_start
=
0x0001
;
}
/*
/*
* Displays command line usage
* Displays command line usage
*/
*/
...
...
openair3/NAS/TOOLS/conf2uedata.h
View file @
51c77535
...
@@ -4,16 +4,10 @@
...
@@ -4,16 +4,10 @@
#include <libconfig.h>
#include <libconfig.h>
#include "usim_api.h"
#include "usim_api.h"
#include "conf_network.h"
#define UE "UE"
#define UE "UE"
#define PLMN "PLMN"
#define FULLNAME "FULLNAME"
#define SHORTNAME "SHORTNAME"
#define MNC "MNC"
#define MCC "MCC"
#define HPLMN "HPLMN"
#define HPLMN "HPLMN"
#define UCPLMN "UCPLMN_LIST"
#define UCPLMN "UCPLMN_LIST"
#define OPLMN "OPLMN_LIST"
#define OPLMN "OPLMN_LIST"
...
@@ -21,28 +15,6 @@
...
@@ -21,28 +15,6 @@
#define FPLMN "FPLMN_LIST"
#define FPLMN "FPLMN_LIST"
#define EHPLMN "EHPLMN_LIST"
#define EHPLMN "EHPLMN_LIST"
#define MIN_TAC 0x0000
#define MAX_TAC 0xFFFE
/*
* PLMN network operator record
*/
typedef
struct
{
unsigned
int
num
;
plmn_t
plmn
;
char
fullname
[
NET_FORMAT_LONG_SIZE
+
1
];
char
shortname
[
NET_FORMAT_SHORT_SIZE
+
1
];
tac_t
tac_start
;
tac_t
tac_end
;
}
network_record_t
;
typedef
struct
{
const
char
*
fullname
;
const
char
*
shortname
;
const
char
*
mnc
;
const
char
*
mcc
;
}
plmn_conf_param_t
;
typedef
struct
{
typedef
struct
{
int
size
;
int
size
;
int
*
items
;
int
*
items
;
...
@@ -56,26 +28,11 @@ typedef struct {
...
@@ -56,26 +28,11 @@ typedef struct {
plmns_list
equivalents_home
;
plmns_list
equivalents_home
;
}
user_plmns_t
;
}
user_plmns_t
;
typedef
struct
{
plmn_conf_param_t
conf
;
network_record_t
record
;
plmn_t
plmn
;
}
network_t
;
typedef
struct
{
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
gen_network_record_from_conf
(
const
plmn_conf_param_t
*
conf
,
network_record_t
*
record
);
int
parse_plmn_param
(
config_setting_t
*
plmn_setting
,
plmn_conf_param_t
*
conf
);
int
parse_plmns
(
config_setting_t
*
all_plmn_setting
,
networks_t
*
plmns
);
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
);
const
networks_t
networks
);
...
...
openair3/NAS/TOOLS/conf_network.c
0 → 100644
View file @
51c77535
#include <stdlib.h>
#include <string.h>
#include "conf_network.h"
int
get_plmn_index
(
const
char
*
mccmnc
,
const
networks_t
networks
)
{
char
mcc
[
4
];
char
mnc
[
strlen
(
mccmnc
)
-
2
];
strncpy
(
mcc
,
mccmnc
,
3
);
mcc
[
3
]
=
'\0'
;
strncpy
(
mnc
,
mccmnc
+
3
,
3
);
mnc
[
strlen
(
mccmnc
)
-
3
]
=
'\0'
;
for
(
int
i
=
0
;
i
<
networks
.
size
;
i
++
)
{
if
(
strcmp
(
networks
.
items
[
i
].
conf
.
mcc
,
mcc
)
==
0
)
{
if
(
strcmp
(
networks
.
items
[
i
].
conf
.
mnc
,
mnc
)
==
0
)
{
return
i
;
}
}
}
return
-
1
;
}
plmn_t
make_plmn_from_conf
(
const
plmn_conf_param_t
*
plmn_conf
)
{
plmn_t
plmn
;
char
num
[
6
];
memset
(
&
plmn
,
0xff
,
sizeof
(
plmn
));
snprintf
(
num
,
6
,
"%s%s"
,
plmn_conf
->
mcc
,
plmn_conf
->
mnc
);
plmn
.
MCCdigit2
=
plmn_conf
->
mcc
[
1
];
plmn
.
MCCdigit1
=
plmn_conf
->
mcc
[
0
];
plmn
.
MCCdigit3
=
plmn_conf
->
mcc
[
2
];
plmn
.
MNCdigit2
=
plmn_conf
->
mnc
[
1
];
plmn
.
MNCdigit1
=
plmn_conf
->
mnc
[
0
];
if
(
strlen
(
plmn_conf
->
mnc
)
>
2
)
{
plmn
.
MNCdigit3
=
plmn_conf
->
mnc
[
2
];
}
return
plmn
;
}
void
gen_network_record_from_conf
(
const
plmn_conf_param_t
*
conf
,
network_record_t
*
record
)
{
strcpy
(
record
->
fullname
,
conf
->
fullname
);
strcpy
(
record
->
shortname
,
conf
->
shortname
);
char
num
[
6
];
sprintf
(
num
,
"%s%s"
,
conf
->
mcc
,
conf
->
mnc
);
record
->
num
=
atoi
(
num
);
record
->
plmn
=
make_plmn_from_conf
(
conf
);
record
->
tac_end
=
0xfffd
;
record
->
tac_start
=
0x0001
;
}
bool
parse_plmn_param
(
config_setting_t
*
plmn_setting
,
plmn_conf_param_t
*
conf
)
{
int
rc
=
0
;
rc
=
config_setting_lookup_string
(
plmn_setting
,
FULLNAME
,
&
conf
->
fullname
);
if
(
rc
!=
1
)
{
printf
(
"Error on FULLNAME
\n
"
);
return
false
;
}
rc
=
config_setting_lookup_string
(
plmn_setting
,
SHORTNAME
,
&
conf
->
shortname
);
if
(
rc
!=
1
)
{
printf
(
"Error on SHORTNAME
\n
"
);
return
false
;
}
rc
=
config_setting_lookup_string
(
plmn_setting
,
MNC
,
&
conf
->
mnc
);
if
(
rc
!=
1
||
strlen
(
conf
->
mnc
)
>
3
||
strlen
(
conf
->
mnc
)
<
2
)
{
printf
(
"Error ond MNC. Exiting
\n
"
);
return
false
;
}
rc
=
config_setting_lookup_string
(
plmn_setting
,
MCC
,
&
conf
->
mcc
);
if
(
rc
!=
1
||
strlen
(
conf
->
mcc
)
!=
3
)
{
printf
(
"Error on MCC
\n
"
);
return
false
;
}
return
true
;
}
bool
parse_plmns
(
config_setting_t
*
all_plmn_setting
,
networks_t
*
networks
)
{
config_setting_t
*
plmn_setting
=
NULL
;
char
plmn
[
10
];
int
size
=
0
;
size
=
config_setting_length
(
all_plmn_setting
);
networks
->
size
=
size
;
networks
->
items
=
malloc
(
sizeof
(
network_t
)
*
size
);
for
(
int
i
=
0
;
i
<
size
;
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
);
plmn_setting
=
config_setting_get_member
(
all_plmn_setting
,
plmn
);
if
(
plmn_setting
==
NULL
)
{
printf
(
"PLMN%d not fouund
\n
"
,
i
);
return
false
;
}
if
(
parse_plmn_param
(
plmn_setting
,
&
network
->
conf
)
==
false
)
{
return
false
;
}
gen_network_record_from_conf
(
&
network
->
conf
,
&
network
->
record
);
network
->
plmn
=
network
->
record
.
plmn
;
}
return
true
;
}
openair3/NAS/TOOLS/conf_network.h
0 → 100644
View file @
51c77535
#ifndef _CONF_NETWORK_H
#define _CONF_NETWORK_H
#include <stdbool.h>
#include <libconfig.h>
#include "usim_api.h"
#define PLMN "PLMN"
#define FULLNAME "FULLNAME"
#define SHORTNAME "SHORTNAME"
#define MNC "MNC"
#define MCC "MCC"
#define MIN_TAC 0x0000
#define MAX_TAC 0xFFFE
/*
* PLMN network operator record
*/
typedef
struct
{
unsigned
int
num
;
plmn_t
plmn
;
char
fullname
[
NET_FORMAT_LONG_SIZE
+
1
];
char
shortname
[
NET_FORMAT_SHORT_SIZE
+
1
];
tac_t
tac_start
;
tac_t
tac_end
;
}
network_record_t
;
typedef
struct
{
const
char
*
fullname
;
const
char
*
shortname
;
const
char
*
mnc
;
const
char
*
mcc
;
}
plmn_conf_param_t
;
typedef
struct
{
plmn_conf_param_t
conf
;
network_record_t
record
;
plmn_t
plmn
;
}
network_t
;
typedef
struct
{
int
size
;
network_t
*
items
;
}
networks_t
;
bool
parse_plmn_param
(
config_setting_t
*
plmn_setting
,
plmn_conf_param_t
*
conf
);
bool
parse_plmns
(
config_setting_t
*
all_plmn_setting
,
networks_t
*
plmns
);
void
gen_network_record_from_conf
(
const
plmn_conf_param_t
*
conf
,
network_record_t
*
record
);
int
get_plmn_index
(
const
char
*
mccmnc
,
const
networks_t
networks
);
#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