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
e29e19ce
Commit
e29e19ce
authored
Jun 09, 2022
by
yangjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up udr code
parent
c438f8e9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
138 additions
and
80 deletions
+138
-80
src/impl/AuthenticationStatusDocumentApiImpl.cpp
src/impl/AuthenticationStatusDocumentApiImpl.cpp
+72
-45
src/impl/AuthenticationStatusDocumentApiImpl.h
src/impl/AuthenticationStatusDocumentApiImpl.h
+1
-1
src/impl/AuthenticationSubscriptionDocumentApiImpl.cpp
src/impl/AuthenticationSubscriptionDocumentApiImpl.cpp
+64
-33
src/impl/AuthenticationSubscriptionDocumentApiImpl.h
src/impl/AuthenticationSubscriptionDocumentApiImpl.h
+1
-1
No files found.
src/impl/AuthenticationStatusDocumentApiImpl.cpp
View file @
e29e19ce
...
@@ -29,24 +29,42 @@ using namespace org::openapitools::server::model;
...
@@ -29,24 +29,42 @@ using namespace org::openapitools::server::model;
AuthenticationStatusDocumentApiImpl
::
AuthenticationStatusDocumentApiImpl
(
AuthenticationStatusDocumentApiImpl
::
AuthenticationStatusDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
,
MYSQL
*
mysql
)
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
,
MYSQL
*
mysql
)
:
AuthenticationStatusDocumentApi
(
rtr
)
{
:
AuthenticationStatusDocumentApi
(
rtr
)
{
mysql_WitcommUDRDB
=
mysql
;
// mysql_WitcommUDRDB = mysql;
mysql_WitcommUDRDB
=
new
MYSQL
();
mysql_init
(
mysql_WitcommUDRDB
);
if
(
!
mysql_real_connect
(
mysql_WitcommUDRDB
,
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
(
mysql_WitcommUDRDB
));
return
;
}
}
AuthenticationStatusDocumentApiImpl
::~
AuthenticationStatusDocumentApiImpl
()
{
if
(
mysql_WitcommUDRDB
)
mysql_close
(
mysql_WitcommUDRDB
);
}
}
void
AuthenticationStatusDocumentApiImpl
::
create_authentication_status
(
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
().
debug
(
"****** CreateAuthenticationStatus start:imsi-%s ******"
,
ueId
.
c_str
());
Logger
::
udr_server
().
info
(
"AuthenticationStatus PUT - response->UDM"
);
Logger
::
udr_server
().
info
(
"AuthenticationStatus PUT - response->UDM"
);
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
,
""
);
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
,
""
);
MYSQL
mysqldb
;
// MYSQL mysqldb;
mysql_init
(
&
mysqldb
);
// Logger::udr_server().debug("****** create_authentication_status mysql_init start ******");
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
))
// mysql_init(&mysqldb);
{
// Logger::udr_server().debug("****** create_authentication_status mysql_init end ******");
Logger
::
udr_server
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
&
mysqldb
));
// Logger::udr_server().debug("****** create_authentication_status mysql_real_connect start ******");
return
;
// 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 ;
// }
// Logger::udr_server().debug("****** create_authentication_status mysql_real_connect end ******");
MYSQL_RES
*
res
=
NULL
;
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
...
@@ -56,19 +74,19 @@ void AuthenticationStatusDocumentApiImpl::create_authentication_status(
...
@@ -56,19 +74,19 @@ void AuthenticationStatusDocumentApiImpl::create_authentication_status(
std
::
string
query
;
std
::
string
query
;
nlohmann
::
json
j
;
nlohmann
::
json
j
;
if
(
mysql_real_query
(
&
mysqldb
,
select_AuthenticationStatus
.
c_str
(),
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
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
);
//
mysql_close(&mysqldb);
return
;
return
;
}
}
res
=
mysql_store_result
(
&
mysqldb
);
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
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
);
//
mysql_close(&mysqldb);
return
;
return
;
}
}
if
(
mysql_num_rows
(
res
))
{
if
(
mysql_num_rows
(
res
))
{
...
@@ -101,43 +119,44 @@ void AuthenticationStatusDocumentApiImpl::create_authentication_status(
...
@@ -101,43 +119,44 @@ void AuthenticationStatusDocumentApiImpl::create_authentication_status(
}
}
mysql_free_result
(
res
);
mysql_free_result
(
res
);
if
(
mysql_real_query
(
&
mysqldb
,
query
.
c_str
(),
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
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
);
//
mysql_close(&mysqldb);
return
;
return
;
}
}
mysql_close
(
&
mysqldb
);
//
mysql_close(&mysqldb);
to_json
(
j
,
authEvent
);
Logger
::
udr_server
().
debug
(
"****** CreateAuthenticationStatus end:imsi-%s ******"
,
ueId
.
c_str
());
Logger
::
udr_server
().
debug
(
"AuthenticationStatus PUT - json:
\n\"
%s
\"
"
,
// to_json(j, authEvent);
j
.
dump
().
c_str
());
// Logger::udr_server().debug("AuthenticationStatus PUT - json:\n\"%s\"",
// j.dump().c_str());
}
}
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 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))
{
//
{
Logger
::
udr_server
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
&
mysqldb
));
//
Logger::udr_server().error("An error occurred while connecting to db: %s", mysql_error(&mysqldb));
return
;
//
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
(
&
mysqldb
,
query
.
c_str
(),
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
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
);
//
mysql_close(&mysqldb);
return
;
return
;
}
}
mysql_close
(
&
mysqldb
);
//
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"
);
...
@@ -147,6 +166,9 @@ void AuthenticationStatusDocumentApiImpl::query_authentication_status(
...
@@ -147,6 +166,9 @@ void AuthenticationStatusDocumentApiImpl::query_authentication_status(
const
Pistache
::
Optional
<
std
::
vector
<
std
::
string
>>
&
fields
,
const
Pistache
::
Optional
<
std
::
vector
<
std
::
string
>>
&
fields
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
Pistache
::
Http
::
ResponseWriter
&
response
)
{
Logger
::
udr_server
().
debug
(
"****** QueryAuthenticationStatus start:imsi-%s ******"
,
ueId
.
c_str
());
MYSQL_RES
*
res
=
NULL
;
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
MYSQL_FIELD
*
field
=
nullptr
;
MYSQL_FIELD
*
field
=
nullptr
;
...
@@ -157,28 +179,32 @@ void AuthenticationStatusDocumentApiImpl::query_authentication_status(
...
@@ -157,28 +179,32 @@ 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
+
"'"
;
MYSQL
mysqldb
;
// MYSQL mysqldb;
mysql_init
(
&
mysqldb
);
// Logger::udr_server().debug("****** query_authentication_status mysql_init start ******");
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
))
// mysql_init(&mysqldb);
{
// Logger::udr_server().debug("****** query_authentication_status mysql_init end ******");
Logger
::
udr_server
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
&
mysqldb
));
// Logger::udr_server().debug("****** query_authentication_status mysql_real_connect start ******");
mysql_close
(
&
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))
return
;
// {
}
// Logger::udr_server().error("An error occurred while connecting to db: %s", mysql_error(&mysqldb));
// mysql_close(&mysqldb);
if
(
mysql_real_query
(
&
mysqldb
,
query
.
c_str
(),
// return ;
// }
// Logger::udr_server().debug("****** query_authentication_status mysql_real_connect end ******");
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
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
);
//
mysql_close(&mysqldb);
return
;
return
;
}
}
res
=
mysql_store_result
(
&
mysqldb
);
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
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
);
//
mysql_close(&mysqldb);
return
;
return
;
}
}
...
@@ -211,15 +237,16 @@ void AuthenticationStatusDocumentApiImpl::query_authentication_status(
...
@@ -211,15 +237,16 @@ void AuthenticationStatusDocumentApiImpl::query_authentication_status(
to_json
(
j
,
authenticationstatus
);
to_json
(
j
,
authenticationstatus
);
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
j
.
dump
());
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
j
.
dump
());
Logger
::
udr_server
().
debug
(
"AuthenticationStatus GET - json:
\n\"
%s
\"
"
,
//
Logger::udr_server().debug("AuthenticationStatus GET - json:\n\"%s\"",
j
.
dump
().
c_str
());
//
j.dump().c_str());
}
else
{
}
else
{
Logger
::
udr_server
().
error
(
"AuthenticationStatus no data!SQL(%s)"
,
Logger
::
udr_server
().
error
(
"AuthenticationStatus no data!SQL(%s)"
,
query
.
c_str
());
query
.
c_str
());
}
}
mysql_free_result
(
res
);
mysql_free_result
(
res
);
mysql_close
(
&
mysqldb
);
// mysql_close(&mysqldb);
Logger
::
udr_server
().
debug
(
"****** QueryAuthenticationStatus end:imsi-%s ******"
,
ueId
.
c_str
());
}
}
}
// namespace api
}
// namespace api
...
...
src/impl/AuthenticationStatusDocumentApiImpl.h
View file @
e29e19ce
...
@@ -44,7 +44,7 @@ using namespace org::openapitools::server::model;
...
@@ -44,7 +44,7 @@ using namespace org::openapitools::server::model;
class
AuthenticationStatusDocumentApiImpl
:
public
org
::
openapitools
::
server
::
api
::
AuthenticationStatusDocumentApi
{
class
AuthenticationStatusDocumentApiImpl
:
public
org
::
openapitools
::
server
::
api
::
AuthenticationStatusDocumentApi
{
public:
public:
AuthenticationStatusDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
,
MYSQL
*
mysql
);
AuthenticationStatusDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
,
MYSQL
*
mysql
);
~
AuthenticationStatusDocumentApiImpl
()
{}
virtual
~
AuthenticationStatusDocumentApiImpl
();
void
create_authentication_status
(
const
std
::
string
&
ueId
,
const
AuthEvent
&
authEvent
,
Pistache
::
Http
::
ResponseWriter
&
response
);
void
create_authentication_status
(
const
std
::
string
&
ueId
,
const
AuthEvent
&
authEvent
,
Pistache
::
Http
::
ResponseWriter
&
response
);
...
...
src/impl/AuthenticationSubscriptionDocumentApiImpl.cpp
View file @
e29e19ce
...
@@ -34,7 +34,24 @@ AuthenticationSubscriptionDocumentApiImpl::
...
@@ -34,7 +34,24 @@ AuthenticationSubscriptionDocumentApiImpl::
AuthenticationSubscriptionDocumentApiImpl
(
AuthenticationSubscriptionDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
,
MYSQL
*
mysql
)
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
,
MYSQL
*
mysql
)
:
AuthenticationSubscriptionDocumentApi
(
rtr
)
{
:
AuthenticationSubscriptionDocumentApi
(
rtr
)
{
mysql_WitcommUDRDB
=
mysql
;
// mysql_WitcommUDRDB = mysql;
mysql_WitcommUDRDB
=
new
MYSQL
();
// MYSQL mysqldb;
mysql_init
(
mysql_WitcommUDRDB
);
if
(
!
mysql_real_connect
(
mysql_WitcommUDRDB
,
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
(
mysql_WitcommUDRDB
));
return
;
}
// mysql_WitcommUDRDB = &mysqldb;
}
AuthenticationSubscriptionDocumentApiImpl
::
~
AuthenticationSubscriptionDocumentApiImpl
(){
if
(
mysql_WitcommUDRDB
)
mysql_close
(
mysql_WitcommUDRDB
);
delete
mysql_WitcommUDRDB
;
}
}
void
AuthenticationSubscriptionDocumentApiImpl
::
void
AuthenticationSubscriptionDocumentApiImpl
::
...
@@ -42,17 +59,22 @@ void AuthenticationSubscriptionDocumentApiImpl::
...
@@ -42,17 +59,22 @@ void AuthenticationSubscriptionDocumentApiImpl::
const
std
::
string
&
ueId
,
const
std
::
vector
<
PatchItem
>
&
patchItem
,
const
std
::
string
&
ueId
,
const
std
::
vector
<
PatchItem
>
&
patchItem
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
Pistache
::
Http
::
ResponseWriter
&
response
)
{
Logger
::
udr_server
().
debug
(
"****** ModifyAuthenticationSubscription start:imsi-%s ******"
,
ueId
.
c_str
());
Logger
::
udr_server
().
info
(
"AuthenticationSubscription PATCH - response->UDM"
);
Logger
::
udr_server
().
info
(
"AuthenticationSubscription PATCH - response->UDM"
);
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
,
""
);
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
,
""
);
MYSQL
mysqldb
;
// MYSQL mysqldb;
mysql_init
(
&
mysqldb
);
// Logger::udr_server().debug("****** modify_authentication_subscription mysql_init start ******");
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
))
// mysql_init(&mysqldb);
{
// Logger::udr_server().debug("****** modify_authentication_subscription mysql_init end ******");
Logger
::
udr_server
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
&
mysqldb
));
// Logger::udr_server().debug("****** modify_authentication_subscription mysql_real_connect start ******");
return
;
// 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 ;
// }
// Logger::udr_server().debug("****** modify_authentication_subscription mysql_real_connect end ******");
MYSQL_RES
*
res
=
NULL
;
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
...
@@ -71,19 +93,19 @@ void AuthenticationSubscriptionDocumentApiImpl::
...
@@ -71,19 +93,19 @@ void AuthenticationSubscriptionDocumentApiImpl::
.
get_to
(
sequencenumber
);
.
get_to
(
sequencenumber
);
if
(
mysql_real_query
(
if
(
mysql_real_query
(
&
mysqldb
,
select_Authenticationsubscription
.
c_str
(),
mysql_WitcommUDRDB
,
select_Authenticationsubscription
.
c_str
(),
(
unsigned
long
)
select_Authenticationsubscription
.
size
()))
{
(
unsigned
long
)
select_Authenticationsubscription
.
size
()))
{
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s)"
,
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s)"
,
select_Authenticationsubscription
.
c_str
());
select_Authenticationsubscription
.
c_str
());
mysql_close
(
&
mysqldb
);
//
mysql_close(&mysqldb);
return
;
return
;
}
}
res
=
mysql_store_result
(
&
mysqldb
);
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
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_Authenticationsubscription
.
c_str
());
select_Authenticationsubscription
.
c_str
());
mysql_close
(
&
mysqldb
);
//
mysql_close(&mysqldb);
return
;
return
;
}
}
if
(
mysql_num_rows
(
res
))
{
if
(
mysql_num_rows
(
res
))
{
...
@@ -103,11 +125,11 @@ void AuthenticationSubscriptionDocumentApiImpl::
...
@@ -103,11 +125,11 @@ void AuthenticationSubscriptionDocumentApiImpl::
// Logger::udr_server().debug("modify content:
// Logger::udr_server().debug("modify content:
// %s",query.c_str());
// %s",query.c_str());
if
(
mysql_real_query
(
&
mysqldb
,
query
.
c_str
(),
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
()))
{
(
unsigned
long
)
query
.
size
()))
{
Logger
::
udr_server
().
error
(
"update mysql failure!SQL(%s)"
,
Logger
::
udr_server
().
error
(
"update mysql failure!SQL(%s)"
,
query
.
c_str
());
query
.
c_str
());
mysql_close
(
&
mysqldb
);
//
mysql_close(&mysqldb);
return
;
return
;
}
}
}
}
...
@@ -116,12 +138,13 @@ void AuthenticationSubscriptionDocumentApiImpl::
...
@@ -116,12 +138,13 @@ void AuthenticationSubscriptionDocumentApiImpl::
j
+=
tmp_j
;
j
+=
tmp_j
;
}
}
mysql_close
(
&
mysqldb
);
//
mysql_close(&mysqldb);
// response.send(Pistache::Http::Code::No_Content, "");
// response.send(Pistache::Http::Code::No_Content, "");
std
::
string
out
=
j
.
dump
();
// Logger::udr_server().debug("AuthenticationSubscription PATCH - json:\n\"%s\"",
Logger
::
udr_server
().
debug
(
"AuthenticationSubscription PATCH - json:
\n\"
%s
\"
"
,
// j.dump().c_str());
out
.
c_str
());
Logger
::
udr_server
().
debug
(
"****** ModifyAuthenticationSubscription end:imsi-%s ******"
,
ueId
.
c_str
());
}
}
void
AuthenticationSubscriptionDocumentApiImpl
::
void
AuthenticationSubscriptionDocumentApiImpl
::
...
@@ -129,37 +152,43 @@ void AuthenticationSubscriptionDocumentApiImpl::
...
@@ -129,37 +152,43 @@ void AuthenticationSubscriptionDocumentApiImpl::
const
std
::
string
&
ueId
,
const
std
::
string
&
ueId
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
Pistache
::
Http
::
ResponseWriter
&
response
)
{
Logger
::
udr_server
().
debug
(
"****** ReadAuthenticationSubscription start:imsi-%s ******"
,
ueId
.
c_str
());
MYSQL_RES
*
res
=
NULL
;
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
MYSQL_FIELD
*
field
=
nullptr
;
MYSQL_FIELD
*
field
=
nullptr
;
nlohmann
::
json
j
;
nlohmann
::
json
j
;
MYSQL
mysqldb
;
// MYSQL mysqldb;
mysql_init
(
&
mysqldb
);
// Logger::udr_server().debug("****** read_authentication_subscription mysql_init start ******");
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
))
// mysql_init(&mysqldb);
{
// Logger::udr_server().debug("****** read_authentication_subscription mysql_init end ******");
Logger
::
udr_server
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
&
mysqldb
));
return
;
// Logger::udr_server().debug("****** read_authentication_subscription mysql_real_connect start ******");
}
// 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 ;
// }
// Logger::udr_server().debug("****** read_authentication_subscription mysql_real_connect end ******");
AuthenticationSubscription
authenticationsubscription
;
AuthenticationSubscription
authenticationsubscription
;
const
std
::
string
query
=
const
std
::
string
query
=
"select * from AuthenticationSubscription WHERE ueid='"
+
ueId
+
"'"
;
"select * from AuthenticationSubscription WHERE ueid='"
+
ueId
+
"'"
;
if
(
mysql_real_query
(
&
mysqldb
,
query
.
c_str
(),
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
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
);
//
mysql_close(&mysqldb);
return
;
return
;
}
}
res
=
mysql_store_result
(
&
mysqldb
);
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
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)"
,
query
.
c_str
());
query
.
c_str
());
mysql_close
(
&
mysqldb
);
//
mysql_close(&mysqldb);
return
;
return
;
}
}
...
@@ -215,16 +244,18 @@ void AuthenticationSubscriptionDocumentApiImpl::
...
@@ -215,16 +244,18 @@ void AuthenticationSubscriptionDocumentApiImpl::
to_json
(
j
,
authenticationsubscription
);
to_json
(
j
,
authenticationsubscription
);
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
j
.
dump
());
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
j
.
dump
());
std
::
string
out
=
j
.
dump
();
//
std::string out = j.dump();
Logger
::
udr_server
().
debug
(
"AuthenticationSubscription GET - json:
\n\"
%s
\"
"
,
//
Logger::udr_server().debug("AuthenticationSubscription GET - json:\n\"%s\"",
out
.
c_str
());
//
out.c_str());
}
else
{
}
else
{
response
.
send
(
Pistache
::
Http
::
Code
::
Not_Implemented
,
""
);
Logger
::
udr_server
().
error
(
"AuthenticationSubscription no data!SQL(%s)"
,
Logger
::
udr_server
().
error
(
"AuthenticationSubscription no data!SQL(%s)"
,
query
.
c_str
());
query
.
c_str
());
}
}
mysql_free_result
(
res
);
mysql_free_result
(
res
);
mysql_close
(
&
mysqldb
);
// mysql_close(&mysqldb);
Logger
::
udr_server
().
debug
(
"****** ReadAuthenticationSubscription end:imsi-%s ******"
,
ueId
.
c_str
());
}
}
}
// namespace api
}
// namespace api
...
...
src/impl/AuthenticationSubscriptionDocumentApiImpl.h
View file @
e29e19ce
...
@@ -47,7 +47,7 @@ using namespace org::openapitools::server::model;
...
@@ -47,7 +47,7 @@ using namespace org::openapitools::server::model;
class
AuthenticationSubscriptionDocumentApiImpl
:
public
org
::
openapitools
::
server
::
api
::
AuthenticationSubscriptionDocumentApi
{
class
AuthenticationSubscriptionDocumentApiImpl
:
public
org
::
openapitools
::
server
::
api
::
AuthenticationSubscriptionDocumentApi
{
public:
public:
AuthenticationSubscriptionDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
,
MYSQL
*
mysql
);
AuthenticationSubscriptionDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
,
MYSQL
*
mysql
);
~
AuthenticationSubscriptionDocumentApiImpl
()
{}
virtual
~
AuthenticationSubscriptionDocumentApiImpl
();
void
modify_authentication_subscription
(
const
std
::
string
&
ueId
,
const
std
::
vector
<
PatchItem
>
&
patchItem
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
Pistache
::
Http
::
ResponseWriter
&
response
);
void
modify_authentication_subscription
(
const
std
::
string
&
ueId
,
const
std
::
vector
<
PatchItem
>
&
patchItem
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
Pistache
::
Http
::
ResponseWriter
&
response
);
void
read_authentication_subscription
(
const
std
::
string
&
ueId
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
Pistache
::
Http
::
ResponseWriter
&
response
);
void
read_authentication_subscription
(
const
std
::
string
&
ueId
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
Pistache
::
Http
::
ResponseWriter
&
response
);
...
...
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