Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-UDR
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
Operations
Operations
Metrics
Environments
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
OpenXG-UDR
Commits
3812bba8
Commit
3812bba8
authored
Mar 22, 2021
by
yangjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update configuration file
parent
d2eb70f8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
133 additions
and
37 deletions
+133
-37
etc/udr.conf
etc/udr.conf
+15
-10
etc/udr_docker.conf
etc/udr_docker.conf
+30
-0
src/impl/AuthenticationSubscriptionDocumentApiImpl.cpp
src/impl/AuthenticationSubscriptionDocumentApiImpl.cpp
+2
-2
src/udr_app/main.cpp
src/udr_app/main.cpp
+3
-3
src/udr_app/udr_config.cpp
src/udr_app/udr_config.cpp
+73
-16
src/udr_app/udr_config.hpp
src/udr_app/udr_config.hpp
+10
-6
No files found.
etc/udr.conf
100755 → 100644
View file @
3812bba8
## udr configuration file
UDR
=
{
INSTANCE_ID
=
10
;
# 0 is the default
PID_DIRECTORY
=
"
/var/run"
;
# /var/run is the default
INSTANCE_ID
=
@
INSTANCE
@;
# 0 is the default
PID_DIRECTORY
=
"
@PID_DIRECTORY@"
;
# /var/run is the default
INTERFACES
:
{
# UDR binded interface for Nudr interface
NUDR
:
SBI
:
{
INTERFACE_NAME
=
"
ens32"
;
# YOUR NETWORK CONFIG HERE
IPV4_ADDRESS
=
"
192.168.2.35
"
;
PORT
=
8081
;
# YOUR NETWORK CONFIG HERE
INTERFACE_NAME
=
"
@UDR_INTERFACE_NAME_FOR_SBI@"
;
# YOUR NETWORK CONFIG HERE
IPV4_ADDRESS
=
"
read
"
;
PORT
=
8081
;
# YOUR NETWORK CONFIG HERE
};
};
MYSQL
:
{
## MySQL mandatory options
MYSQL_SERVER
=
"127.0.0.1"
;
# MySQL Server address
MYSQL_USER
=
"yunshou"
;
# Database server login
MYSQL_PASS
=
"123456"
;
# Database server password
MYSQL_DB
=
"Witcomm-UDR-DB"
;
# Your database name
MYSQL_SERVER
=
"@MYSQL_SERVER@"
;
# MySQL Server address
MYSQL_USER
=
"@MYSQL_USER@"
;
# Database server login
MYSQL_PASS
=
"@MYSQL_PASS@"
;
# Database server password
MYSQL_DB
=
"@MYSQL_DB@"
;
# Your database name
# MYSQL_PORT = "@MYSQL_PORT@"; # MySQL Server port, 0 is the default
};
};
etc/udr_docker.conf
0 → 100644
View file @
3812bba8
## udr configuration file
UDR
=
{
INSTANCE_ID
=
10
;
# 0 is the default
PID_DIRECTORY
=
"/var/run"
;
# /var/run is the default
INTERFACES
:
{
# UDR binded interface for Nudr interface
SBI
:
{
INTERFACE_NAME
=
"eth0"
;
# YOUR NETWORK CONFIG HERE
IPV4_ADDRESS
=
"read"
;
PORT
=
8081
;
# YOUR NETWORK CONFIG HERE
};
};
MYSQL
:
{
## MySQL mandatory options
MYSQL_SERVER
=
"172.16.200.10"
;
# MySQL Server address
MYSQL_USER
=
"yunshou"
;
# Database server login
MYSQL_PASS
=
"123456"
;
# Database server password
MYSQL_DB
=
"Witcomm-UDR-DB"
;
# Your database name
# MYSQL_PORT = 3306 # MySQL Server port
};
};
src/impl/AuthenticationSubscriptionDocumentApiImpl.cpp
View file @
3812bba8
...
...
@@ -96,11 +96,11 @@ void AuthenticationSubscriptionDocumentApiImpl::
j
+=
tmp_j
;
}
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
,
""
);
std
::
string
out
=
j
.
dump
();
Logger
::
udr_server
().
debug
(
"AuthenticationSubscription PATCH - json:
\n\"
%s
\"
"
,
out
.
c_str
());
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
,
""
);
}
void
AuthenticationSubscriptionDocumentApiImpl
::
...
...
src/udr_app/main.cpp
View file @
3812bba8
...
...
@@ -45,19 +45,19 @@ int main(int argc, char **argv) {
Logger
::
udr_app
().
startup
(
"Options parsed!"
);
// add config file
udr_cfg
.
load
(
Options
::
getlibconfigConfig
())
;
if
(
udr_cfg
.
load
(
Options
::
getlibconfigConfig
())
<
0
)
return
0
;
udr_cfg
.
display
();
Logger
::
udr_app
().
debug
(
"Initiating UDR server endpoints"
);
// Pistache::Address addr(Pistache::Ipv4::any(), Pistache::Port(8080));
Pistache
::
Address
addr
(
udr_cfg
.
nudr
.
addr4
,
Pistache
::
Port
(
udr_cfg
.
nudr
.
port
));
Pistache
::
Address
addr
(
udr_cfg
.
sbi
.
addr4
,
Pistache
::
Port
(
udr_cfg
.
sbi
.
port
));
MYSQL
mysql
;
mysql_init
(
&
mysql
);
if
(
!
mysql_real_connect
(
&
mysql
,
udr_cfg
.
mysql
.
mysql_server
.
c_str
(),
udr_cfg
.
mysql
.
mysql_user
.
c_str
(),
udr_cfg
.
mysql
.
mysql_pass
.
c_str
(),
udr_cfg
.
mysql
.
mysql_db
.
c_str
(),
0
,
0
,
0
))
{
udr_cfg
.
mysql
.
mysql_db
.
c_str
(),
udr_cfg
.
mysql
.
mysql_port
,
0
,
0
))
{
Logger
::
udr_app
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
&
mysql
));
return
0
;
...
...
src/udr_app/udr_config.cpp
View file @
3812bba8
#include "udr_config.hpp"
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <arpa/inet.h>
#include <iostream>
#include <libconfig.h++>
...
...
@@ -38,71 +48,118 @@ int udr_config::load(const std ::string &config_file) {
try
{
udr_cfg
.
lookupValue
(
UDR_CONFIG_STRING_INSTANCE_ID
,
instance
);
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
udr_app
().
error
(
"%s : %s, using defaults"
,
nfex
.
what
(),
Logger
::
udr_app
().
warn
(
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
}
try
{
udr_cfg
.
lookupValue
(
UDR_CONFIG_STRING_PID_DIRECTORY
,
pid_dir
);
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
udr_app
().
error
(
"%s : %s, using defaults"
,
nfex
.
what
(),
Logger
::
udr_app
().
warn
(
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
}
try
{
const
Setting
&
new_if_cfg
=
udr_cfg
[
UDR_CONFIG_STRING_INTERFACES
];
const
Setting
&
nudr_cfg
=
new_if_cfg
[
UDR_CONFIG_STRING_INTERFACE_NUDR
];
load_interface
(
nudr_cfg
,
nudr
);
const
Setting
&
sbi_cfg
=
new_if_cfg
[
UDR_CONFIG_STRING_INTERFACE_SBI
];
load_interface
(
sbi_cfg
,
sbi
);
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
udr_app
().
error
(
"%s : %s
, using defaults
"
,
nfex
.
what
(),
Logger
::
udr_app
().
error
(
"%s : %s"
,
nfex
.
what
(),
nfex
.
getPath
());
return
-
1
;
}
try
{
const
Setting
&
mysql_cfg
=
udr_cfg
[
UDR_CONFIG_STRING_MYSQL
];
mysql_cfg
.
lookupValue
(
UDR_CONFIG_STRING_MYSQL_SERVER
,
mysql
.
mysql_server
);
mysql_cfg
.
lookupValue
(
UDR_CONFIG_STRING_MYSQL_USER
,
mysql
.
mysql_user
);
mysql_cfg
.
lookupValue
(
UDR_CONFIG_STRING_MYSQL_PASS
,
mysql
.
mysql_pass
);
mysql_cfg
.
lookupValue
(
UDR_CONFIG_STRING_MYSQL_DB
,
mysql
.
mysql_db
);
mysql_cfg
.
lookupValue
(
UDR_CONFIG_STRING_MYSQL_PORT
,
mysql
.
mysql_port
);
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
udr_app
().
error
(
"%s : %s
, using defaults
"
,
nfex
.
what
(),
Logger
::
udr_app
().
error
(
"%s : %s"
,
nfex
.
what
(),
nfex
.
getPath
());
return
-
1
;
}
return
0
;
}
int
udr_config
::
getip
(
std
::
string
&
ip
,
std
::
string
&
ifname
)
{
int
sock
;
struct
sockaddr_in
sin
;
struct
ifreq
ifr
;
sock
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
if
(
sock
==
-
1
)
{
perror
(
"socket"
);
return
-
1
;
}
strncpy
(
ifr
.
ifr_name
,
ifname
.
c_str
(),
IFNAMSIZ
);
ifr
.
ifr_name
[
IFNAMSIZ
-
1
]
=
0
;
if
(
ioctl
(
sock
,
SIOCGIFADDR
,
&
ifr
)
<
0
)
{
perror
(
"ioctl"
);
return
-
1
;
}
memcpy
(
&
sin
,
&
ifr
.
ifr_addr
,
sizeof
(
sin
));
printf
(
"ip = %s"
,
inet_ntoa
(
sin
.
sin_addr
));
//sprintf(ip, "%s", inet_ntoa(sin.sin_addr));
ip
=
std
::
string
(
inet_ntoa
(
sin
.
sin_addr
));
return
0
;
}
int
udr_config
::
load_interface
(
const
libconfig
::
Setting
&
if_cfg
,
interface_cfg_t
&
cfg
)
{
if_cfg
.
lookupValue
(
UDR_CONFIG_STRING_INTERFACE_NAME
,
cfg
.
if_name
);
if_cfg
.
lookupValue
(
UDR_CONFIG_STRING_IPV4_ADDRESS
,
cfg
.
addr4
);
if
(
!
cfg
.
addr4
.
compare
(
"read"
))
{
if
(
getip
(
cfg
.
addr4
,
cfg
.
if_name
)
<
0
)
return
-
1
;
}
if_cfg
.
lookupValue
(
UDR_CONFIG_STRING_PORT
,
cfg
.
port
);
return
0
;
}
void
udr_config
::
display
()
{
Logger
::
config
().
info
(
"====================== UDR ====================="
);
Logger
::
config
().
info
(
"Configuration UDR:"
);
Logger
::
config
().
info
(
""
);
Logger
::
config
().
info
(
"- Instance .........................................
..
: %d"
,
instance
);
"- Instance .........................................: %d"
,
instance
);
Logger
::
config
().
info
(
"- PID dir ..........................................
..
: %s"
,
"- PID dir ..........................................: %s"
,
pid_dir
.
c_str
());
Logger
::
config
().
info
(
""
);
Logger
::
config
().
info
(
"- SBI Networking:"
);
Logger
::
config
().
info
(
" iface ................: %s"
,
sbi
.
if_name
.
c_str
());
Logger
::
config
().
info
(
" ip ...................: %s"
,
sbi
.
addr4
.
c_str
());
Logger
::
config
().
info
(
" port .................: %d"
,
sbi
.
port
);
Logger
::
config
().
info
(
""
);
Logger
::
config
().
info
(
"- Database Configuration:"
);
Logger
::
config
().
info
(
"- MYSQL Server Addr.................................
..
: %s"
,
"- MYSQL Server Addr.................................: %s"
,
mysql
.
mysql_server
.
c_str
());
Logger
::
config
().
info
(
"- MYSQL
user ..
.......................................: %s"
,
"- MYSQL
User
.......................................: %s"
,
mysql
.
mysql_user
.
c_str
());
Logger
::
config
().
info
(
"- MYSQL
pass ..
.......................................: %s"
,
"- MYSQL
Pass
.......................................: %s"
,
mysql
.
mysql_pass
.
c_str
());
Logger
::
config
().
info
(
"- MYSQL
db ..
.........................................: %s"
,
"- MYSQL
DB
.........................................: %s"
,
mysql
.
mysql_db
.
c_str
());
Logger
::
config
().
info
(
"- MYSQL Port .......................................: %d"
,
mysql
.
mysql_port
);
Logger
::
config
().
info
(
""
);
Logger
::
config
().
info
(
"- Nudr Networking:"
);
Logger
::
config
().
info
(
" iface ................: %s"
,
nudr
.
if_name
.
c_str
());
Logger
::
config
().
info
(
" ip ...................: %s"
,
nudr
.
addr4
.
c_str
());
Logger
::
config
().
info
(
" port .................: %d"
,
nudr
.
port
);
}
}
// namespace config
src/udr_app/udr_config.hpp
View file @
3812bba8
...
...
@@ -8,7 +8,7 @@
#define UDR_CONFIG_STRING_INSTANCE_ID "INSTANCE_ID"
#define UDR_CONFIG_STRING_PID_DIRECTORY "PID_DIRECTORY"
#define UDR_CONFIG_STRING_INTERFACES "INTERFACES"
#define UDR_CONFIG_STRING_INTERFACE_
NUDR "NUDR
"
#define UDR_CONFIG_STRING_INTERFACE_
SBI "SBI
"
#define UDR_CONFIG_STRING_INTERFACE_NAME "INTERFACE_NAME"
#define UDR_CONFIG_STRING_IPV4_ADDRESS "IPV4_ADDRESS"
#define UDR_CONFIG_STRING_PORT "PORT"
...
...
@@ -18,16 +18,19 @@
#define UDR_CONFIG_STRING_MYSQL_USER "MYSQL_USER"
#define UDR_CONFIG_STRING_MYSQL_PASS "MYSQL_PASS"
#define UDR_CONFIG_STRING_MYSQL_DB "MYSQL_DB"
#define UDR_CONFIG_STRING_MYSQL_PORT "MYSQL_PORT"
using
namespace
libconfig
;
namespace
config
{
typedef
struct
{
std
::
string
mysql_server
;
std
::
string
mysql_user
;
std
::
string
mysql_pass
;
std
::
string
mysql_db
;
std
::
string
mysql_server
=
"127.0.0.1"
;
std
::
string
mysql_user
=
"yunshou"
;
std
::
string
mysql_pass
=
"123456"
;
std
::
string
mysql_db
=
"Witcomm-UDR-DB"
;
unsigned
int
mysql_port
=
0
;
}
mysql_conf_t
;
typedef
struct
interface_cfg_s
{
...
...
@@ -42,12 +45,13 @@ public:
~
udr_config
();
int
load
(
const
std
::
string
&
config_file
);
int
getip
(
std
::
string
&
ip
,
std
::
string
&
ifname
);
int
load_interface
(
const
Setting
&
if_cfg
,
interface_cfg_t
&
cfg
);
void
display
();
unsigned
int
instance
;
std
::
string
pid_dir
;
interface_cfg_t
nudr
;
interface_cfg_t
sbi
;
mysql_conf_t
mysql
;
};
}
// namespace config
...
...
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