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
c438f8e9
Commit
c438f8e9
authored
May 25, 2022
by
yangjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify mysql connect
parent
682df33c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
25 deletions
+75
-25
build/scripts/build_udr
build/scripts/build_udr
+9
-6
src/impl/AuthenticationStatusDocumentApiImpl.cpp
src/impl/AuthenticationStatusDocumentApiImpl.cpp
+51
-7
src/impl/AuthenticationSubscriptionDocumentApiImpl.cpp
src/impl/AuthenticationSubscriptionDocumentApiImpl.cpp
+5
-2
src/udr_app/main.cpp
src/udr_app/main.cpp
+10
-10
No files found.
build/scripts/build_udr
View file @
c438f8e9
...
@@ -107,6 +107,8 @@ function main()
...
@@ -107,6 +107,8 @@ function main()
if
[[
$install_deps
-ne
0
]]
;
then
if
[[
$install_deps
-ne
0
]]
;
then
apt-get
install
cmake make libconfig++-dev libspdlog-dev mysql-server mysql-client libmysqlclient-dev phpmyadmin
-y
apt-get
install
cmake make libconfig++-dev libspdlog-dev mysql-server mysql-client libmysqlclient-dev phpmyadmin
-y
read
-p
"Do you want to install Nlohmann Json ? <y/N> "
prompt
if
[[
$prompt
=
~
[
yY]
(
es
)
*
]]
;
then
if
[
!
-d
"
$OPENXGUDR_DIR
/build/ext/json/build"
]
;
then
if
[
!
-d
"
$OPENXGUDR_DIR
/build/ext/json/build"
]
;
then
mkdir
$OPENXGUDR_DIR
/build/ext/json/build
mkdir
$OPENXGUDR_DIR
/build/ext/json/build
fi
fi
...
@@ -114,6 +116,7 @@ function main()
...
@@ -114,6 +116,7 @@ function main()
cmake ..
cmake ..
make
make
make
install
make
install
fi
echo
"install successful!"
echo
"install successful!"
return
0
return
0
fi
fi
...
...
src/impl/AuthenticationStatusDocumentApiImpl.cpp
View file @
c438f8e9
...
@@ -14,6 +14,11 @@
...
@@ -14,6 +14,11 @@
#include "AuthenticationStatusDocumentApiImpl.h"
#include "AuthenticationStatusDocumentApiImpl.h"
#include "logger.hpp"
#include "logger.hpp"
#include "udr_config.hpp"
using
namespace
config
;
extern
udr_config
udr_cfg
;
namespace
org
{
namespace
org
{
namespace
openapitools
{
namespace
openapitools
{
namespace
server
{
namespace
server
{
...
@@ -31,6 +36,18 @@ void AuthenticationStatusDocumentApiImpl::create_authentication_status(
...
@@ -31,6 +36,18 @@ void AuthenticationStatusDocumentApiImpl::create_authentication_status(
const
std
::
string
&
ueId
,
const
AuthEvent
&
authEvent
,
const
std
::
string
&
ueId
,
const
AuthEvent
&
authEvent
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
Pistache
::
Http
::
ResponseWriter
&
response
)
{
// response.send(Pistache::Http::Code::Ok, "create_authentication_status\n");
// response.send(Pistache::Http::Code::Ok, "create_authentication_status\n");
Logger
::
udr_server
().
info
(
"AuthenticationStatus PUT - response->UDM"
);
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
,
""
);
MYSQL
mysqldb
;
mysql_init
(
&
mysqldb
);
if
(
!
mysql_real_connect
(
&
mysqldb
,
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
(),
udr_cfg
.
mysql
.
mysql_port
,
0
,
0
))
{
Logger
::
udr_server
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
&
mysqldb
));
return
;
}
MYSQL_RES
*
res
=
NULL
;
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
...
@@ -39,17 +56,19 @@ void AuthenticationStatusDocumentApiImpl::create_authentication_status(
...
@@ -39,17 +56,19 @@ void AuthenticationStatusDocumentApiImpl::create_authentication_status(
std
::
string
query
;
std
::
string
query
;
nlohmann
::
json
j
;
nlohmann
::
json
j
;
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
select_AuthenticationStatus
.
c_str
(),
if
(
mysql_real_query
(
&
mysqldb
,
select_AuthenticationStatus
.
c_str
(),
(
unsigned
long
)
select_AuthenticationStatus
.
size
()))
{
(
unsigned
long
)
select_AuthenticationStatus
.
size
()))
{
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s)"
,
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s)"
,
select_AuthenticationStatus
.
c_str
());
select_AuthenticationStatus
.
c_str
());
mysql_close
(
&
mysqldb
);
return
;
return
;
}
}
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
res
=
mysql_store_result
(
&
mysqldb
);
if
(
res
==
NULL
)
{
if
(
res
==
NULL
)
{
Logger
::
udr_server
().
error
(
"mysql_store_result failure!SQL(%s)"
,
Logger
::
udr_server
().
error
(
"mysql_store_result failure!SQL(%s)"
,
select_AuthenticationStatus
.
c_str
());
select_AuthenticationStatus
.
c_str
());
mysql_close
(
&
mysqldb
);
return
;
return
;
}
}
if
(
mysql_num_rows
(
res
))
{
if
(
mysql_num_rows
(
res
))
{
...
@@ -82,13 +101,14 @@ void AuthenticationStatusDocumentApiImpl::create_authentication_status(
...
@@ -82,13 +101,14 @@ void AuthenticationStatusDocumentApiImpl::create_authentication_status(
}
}
mysql_free_result
(
res
);
mysql_free_result
(
res
);
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
if
(
mysql_real_query
(
&
mysqldb
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
()))
{
(
unsigned
long
)
query
.
size
()))
{
Logger
::
udr_server
().
error
(
"mysql create failure!SQL(%s)"
,
query
.
c_str
());
Logger
::
udr_server
().
error
(
"mysql create failure!SQL(%s)"
,
query
.
c_str
());
mysql_close
(
&
mysqldb
);
return
;
return
;
}
}
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
,
""
);
mysql_close
(
&
mysqldb
);
to_json
(
j
,
authEvent
);
to_json
(
j
,
authEvent
);
Logger
::
udr_server
().
debug
(
"AuthenticationStatus PUT - json:
\n\"
%s
\"
"
,
Logger
::
udr_server
().
debug
(
"AuthenticationStatus PUT - json:
\n\"
%s
\"
"
,
...
@@ -98,16 +118,27 @@ void AuthenticationStatusDocumentApiImpl::create_authentication_status(
...
@@ -98,16 +118,27 @@ void AuthenticationStatusDocumentApiImpl::create_authentication_status(
void
AuthenticationStatusDocumentApiImpl
::
delete_authentication_status
(
void
AuthenticationStatusDocumentApiImpl
::
delete_authentication_status
(
const
std
::
string
&
ueId
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
const
std
::
string
&
ueId
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
MYSQL
mysqldb
;
mysql_init
(
&
mysqldb
);
if
(
!
mysql_real_connect
(
&
mysqldb
,
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
(),
udr_cfg
.
mysql
.
mysql_port
,
0
,
0
))
{
Logger
::
udr_server
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
&
mysqldb
));
return
;
}
const
std
::
string
query
=
const
std
::
string
query
=
"DELETE from AuthenticationStatus WHERE ueid='"
+
ueId
+
"'"
;
"DELETE from AuthenticationStatus WHERE ueid='"
+
ueId
+
"'"
;
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
if
(
mysql_real_query
(
&
mysqldb
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
()))
{
(
unsigned
long
)
query
.
size
()))
{
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s)"
,
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s)"
,
query
.
c_str
());
query
.
c_str
());
mysql_close
(
&
mysqldb
);
return
;
return
;
}
}
mysql_close
(
&
mysqldb
);
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
,
""
);
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
,
""
);
Logger
::
udr_server
().
debug
(
"AuthenticationStatus DELETE - successful"
);
Logger
::
udr_server
().
debug
(
"AuthenticationStatus DELETE - successful"
);
}
}
...
@@ -126,16 +157,28 @@ void AuthenticationStatusDocumentApiImpl::query_authentication_status(
...
@@ -126,16 +157,28 @@ void AuthenticationStatusDocumentApiImpl::query_authentication_status(
const
std
::
string
query
=
const
std
::
string
query
=
"select * from AuthenticationStatus WHERE ueid='"
+
ueId
+
"'"
;
"select * from AuthenticationStatus WHERE ueid='"
+
ueId
+
"'"
;
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
MYSQL
mysqldb
;
mysql_init
(
&
mysqldb
);
if
(
!
mysql_real_connect
(
&
mysqldb
,
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
(),
udr_cfg
.
mysql
.
mysql_port
,
0
,
0
))
{
Logger
::
udr_server
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
&
mysqldb
));
mysql_close
(
&
mysqldb
);
return
;
}
if
(
mysql_real_query
(
&
mysqldb
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
()))
{
(
unsigned
long
)
query
.
size
()))
{
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s)"
,
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s)"
,
query
.
c_str
());
query
.
c_str
());
mysql_close
(
&
mysqldb
);
return
;
return
;
}
}
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
res
=
mysql_store_result
(
&
mysqldb
);
if
(
res
==
NULL
)
{
if
(
res
==
NULL
)
{
Logger
::
udr_server
().
error
(
"mysql_store_result failure!"
);
Logger
::
udr_server
().
error
(
"mysql_store_result failure!"
);
mysql_close
(
&
mysqldb
);
return
;
return
;
}
}
...
@@ -176,6 +219,7 @@ void AuthenticationStatusDocumentApiImpl::query_authentication_status(
...
@@ -176,6 +219,7 @@ void AuthenticationStatusDocumentApiImpl::query_authentication_status(
}
}
mysql_free_result
(
res
);
mysql_free_result
(
res
);
mysql_close
(
&
mysqldb
);
}
}
}
// namespace api
}
// namespace api
...
...
src/impl/AuthenticationSubscriptionDocumentApiImpl.cpp
View file @
c438f8e9
...
@@ -43,6 +43,9 @@ void AuthenticationSubscriptionDocumentApiImpl::
...
@@ -43,6 +43,9 @@ void AuthenticationSubscriptionDocumentApiImpl::
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
Pistache
::
Http
::
ResponseWriter
&
response
)
{
Logger
::
udr_server
().
info
(
"AuthenticationSubscription PATCH - response->UDM"
);
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
,
""
);
MYSQL
mysqldb
;
MYSQL
mysqldb
;
mysql_init
(
&
mysqldb
);
mysql_init
(
&
mysqldb
);
if
(
!
mysql_real_connect
(
&
mysqldb
,
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
(),
udr_cfg
.
mysql
.
mysql_port
,
0
,
0
))
if
(
!
mysql_real_connect
(
&
mysqldb
,
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
(),
udr_cfg
.
mysql
.
mysql_port
,
0
,
0
))
...
@@ -108,13 +111,13 @@ void AuthenticationSubscriptionDocumentApiImpl::
...
@@ -108,13 +111,13 @@ void AuthenticationSubscriptionDocumentApiImpl::
return
;
return
;
}
}
}
}
mysql_close
(
&
mysqldb
);
to_json
(
tmp_j
,
patchItem
[
i
]);
to_json
(
tmp_j
,
patchItem
[
i
]);
j
+=
tmp_j
;
j
+=
tmp_j
;
}
}
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
,
""
);
mysql_close
(
&
mysqldb
);
// response.send(Pistache::Http::Code::No_Content, "");
std
::
string
out
=
j
.
dump
();
std
::
string
out
=
j
.
dump
();
Logger
::
udr_server
().
debug
(
"AuthenticationSubscription PATCH - json:
\n\"
%s
\"
"
,
Logger
::
udr_server
().
debug
(
"AuthenticationSubscription PATCH - json:
\n\"
%s
\"
"
,
...
...
src/udr_app/main.cpp
View file @
c438f8e9
...
@@ -53,15 +53,15 @@ int main(int argc, char **argv) {
...
@@ -53,15 +53,15 @@ int main(int argc, char **argv) {
Pistache
::
Address
addr
(
udr_cfg
.
sbi
.
addr4
,
Pistache
::
Port
(
udr_cfg
.
sbi
.
port
));
Pistache
::
Address
addr
(
udr_cfg
.
sbi
.
addr4
,
Pistache
::
Port
(
udr_cfg
.
sbi
.
port
));
MYSQL
mysql
;
MYSQL
mysql
;
mysql_init
(
&
mysql
);
//
mysql_init(&mysql);
if
(
!
mysql_real_connect
(
&
mysql
,
udr_cfg
.
mysql
.
mysql_server
.
c_str
(),
//
if (!mysql_real_connect(&mysql, udr_cfg.mysql.mysql_server.c_str(),
udr_cfg
.
mysql
.
mysql_user
.
c_str
(),
//
udr_cfg.mysql.mysql_user.c_str(),
udr_cfg
.
mysql
.
mysql_pass
.
c_str
(),
//
udr_cfg.mysql.mysql_pass.c_str(),
udr_cfg
.
mysql
.
mysql_db
.
c_str
(),
udr_cfg
.
mysql
.
mysql_port
,
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"
,
//
Logger::udr_app().error("An error occurred while connecting to db: %s",
mysql_error
(
&
mysql
));
//
mysql_error(&mysql));
return
0
;
//
return 0;
}
//
}
UDRApiServer
udrApiServer
(
addr
,
&
mysql
);
UDRApiServer
udrApiServer
(
addr
,
&
mysql
);
udrApiServer
.
init
(
PISTACHE_SERVER_THREADS
);
udrApiServer
.
init
(
PISTACHE_SERVER_THREADS
);
...
@@ -69,6 +69,6 @@ int main(int argc, char **argv) {
...
@@ -69,6 +69,6 @@ int main(int argc, char **argv) {
Logger
::
udr_app
().
debug
(
"Initiating Done!"
);
Logger
::
udr_app
().
debug
(
"Initiating Done!"
);
pause
();
pause
();
mysql_close
(
&
mysql
);
//
mysql_close(&mysql);
return
0
;
return
0
;
}
}
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