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
7427dad0
Commit
7427dad0
authored
Jan 12, 2021
by
yangjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update AuthenticationSubscription: add database
parent
4cf68dd5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
116 additions
and
15 deletions
+116
-15
CMakeLists.txt
CMakeLists.txt
+1
-1
api/AuthenticationSubscriptionDocumentApi.cpp
api/AuthenticationSubscriptionDocumentApi.cpp
+3
-3
impl/AuthenticationSubscriptionDocumentApiImpl.cpp
impl/AuthenticationSubscriptionDocumentApiImpl.cpp
+94
-9
impl/AuthenticationSubscriptionDocumentApiImpl.h
impl/AuthenticationSubscriptionDocumentApiImpl.h
+6
-1
main-api-server.cpp
main-api-server.cpp
+12
-1
No files found.
CMakeLists.txt
View file @
7427dad0
...
...
@@ -34,4 +34,4 @@ file(GLOB SRCS
add_executable
(
${
PROJECT_NAME
}
${
SRCS
}
)
add_dependencies
(
${
PROJECT_NAME
}
PISTACHE NLOHMANN
)
target_link_libraries
(
${
PROJECT_NAME
}
pistache pthread
)
target_link_libraries
(
${
PROJECT_NAME
}
pistache pthread
mysqlclient
)
api/AuthenticationSubscriptionDocumentApi.cpp
View file @
7427dad0
...
...
@@ -81,9 +81,9 @@ void AuthenticationSubscriptionDocumentApi::read_authentication_subscription_han
{
// Getting the path params
auto
ueId
=
request
.
param
(
":ueId"
).
as
<
std
::
string
>
();
std
::
cout
<<
"***** ueId ("
<<
ueId
<<
")******"
<<
std
::
endl
;
std
::
cout
<<
"***** request.body() ("
<<
request
.
body
()
<<
")******"
<<
std
::
endl
;
//
std::cout<<"***** ueId ("<<ueId<<")******"<<std::endl;
//
//
std::cout<<"***** request.body() ("<<request.body()<<")******"<<std::endl;
// Getting the query params
auto
supportedFeaturesQuery
=
request
.
query
().
get
(
"supported-features"
);
...
...
impl/AuthenticationSubscriptionDocumentApiImpl.cpp
View file @
7427dad0
...
...
@@ -13,6 +13,10 @@
#include "AuthenticationSubscriptionDocumentApiImpl.h"
#include "PatchResult.h"
#include <AuthenticationSubscription.h>
namespace
org
{
namespace
openapitools
{
namespace
server
{
...
...
@@ -20,9 +24,12 @@ namespace api {
using
namespace
org
::
openapitools
::
server
::
model
;
AuthenticationSubscriptionDocumentApiImpl
::
AuthenticationSubscriptionDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
)
AuthenticationSubscriptionDocumentApiImpl
::
AuthenticationSubscriptionDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
,
MYSQL
*
mysql
)
:
AuthenticationSubscriptionDocumentApi
(
rtr
)
{
}
{
mysql_WitcommUDRDB
=
mysql
;
}
void
AuthenticationSubscriptionDocumentApiImpl
::
modify_authentication_subscription
(
const
std
::
string
&
ueId
,
const
std
::
vector
<
PatchItem
>
&
patchItem
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
...
...
@@ -46,16 +53,94 @@ void AuthenticationSubscriptionDocumentApiImpl::modify_authentication_subscripti
void
AuthenticationSubscriptionDocumentApiImpl
::
read_authentication_subscription
(
const
std
::
string
&
ueId
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
MYSQL_FIELD
*
field
=
nullptr
;
/************************ test ************************/
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"read_authentication_subscription"
);
//response.send(Pistache::Http::Code::Ok, "Do some magic hello\n");
/******************************************************/
nlohmann
::
json
j
;
//1.read handler database
//2.send data
//response.send(Pistache::Http::Code::Ok, j.dump());
AuthenticationSubscription
authenticationsubscription
;
const
std
::
string
query
=
"select * from AuthenticationSubscription WHERE ueid="
+
ueId
;
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
()))
{
std
::
cout
<<
"mysql_real_query failure!"
<<
std
::
endl
;
return
;
}
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
if
(
res
==
NULL
)
{
std
::
cout
<<
"mysql_store_result failure!"
<<
std
::
endl
;
return
;
}
row
=
mysql_fetch_row
(
res
);
for
(
int
i
=
0
;
field
=
mysql_fetch_field
(
res
);
i
++
)
{
if
(
!
strcmp
(
"authenticationMethod"
,
field
->
name
))
{
//authenticationsubscription.setAuthenticationMethod((AuthMethod) row[i]);
}
else
if
(
!
strcmp
(
"encPermanentKey"
,
field
->
name
))
{
authenticationsubscription
.
setEncPermanentKey
(
row
[
i
]);
}
else
if
(
!
strcmp
(
"protectionParameterId"
,
field
->
name
))
{
authenticationsubscription
.
setProtectionParameterId
(
row
[
i
]);
}
else
if
(
!
strcmp
(
"sequenceNumber"
,
field
->
name
))
{
//authenticationsubscription.setSequenceNumber((SequenceNumber) row[i]);
}
else
if
(
!
strcmp
(
"authenticationManagementField"
,
field
->
name
))
{
authenticationsubscription
.
setAuthenticationManagementField
(
row
[
i
]);
}
else
if
(
!
strcmp
(
"algorithmId"
,
field
->
name
))
{
authenticationsubscription
.
setAlgorithmId
(
row
[
i
]);
}
else
if
(
!
strcmp
(
"encOpcKey"
,
field
->
name
))
{
authenticationsubscription
.
setEncOpcKey
(
row
[
i
]);
}
else
if
(
!
strcmp
(
"encTopcKey"
,
field
->
name
))
{
authenticationsubscription
.
setEncTopcKey
(
row
[
i
]);
}
else
if
(
!
strcmp
(
"vectorGenerationInHss"
,
field
->
name
))
{
std
::
cout
<<
row
[
i
]
<<
std
::
endl
;
if
(
strcmp
(
row
[
i
],
"0"
))
authenticationsubscription
.
setVectorGenerationInHss
(
true
);
else
authenticationsubscription
.
setVectorGenerationInHss
(
false
);
}
else
if
(
!
strcmp
(
"n5gcAuthMethod"
,
field
->
name
))
{
//authenticationsubscription.setN5gcAuthMethod(AuthMethod const & value);
}
else
if
(
!
strcmp
(
"rgAuthenticationInd"
,
field
->
name
))
{
std
::
cout
<<
row
[
i
]
<<
std
::
endl
;
if
(
strcmp
(
row
[
i
],
"0"
))
authenticationsubscription
.
setRgAuthenticationInd
(
true
);
else
authenticationsubscription
.
setRgAuthenticationInd
(
false
);
}
else
if
(
!
strcmp
(
"supi"
,
field
->
name
))
{
authenticationsubscription
.
setSupi
(
row
[
i
]);
}
}
to_json
(
j
,
authenticationsubscription
);
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
j
.
dump
());
mysql_free_result
(
res
);
}
...
...
impl/AuthenticationSubscriptionDocumentApiImpl.h
View file @
7427dad0
...
...
@@ -35,6 +35,8 @@
#include <string>
#include <vector>
#include <mysql/mysql.h>
namespace
org
{
namespace
openapitools
{
namespace
server
{
...
...
@@ -44,12 +46,15 @@ using namespace org::openapitools::server::model;
class
AuthenticationSubscriptionDocumentApiImpl
:
public
org
::
openapitools
::
server
::
api
::
AuthenticationSubscriptionDocumentApi
{
public:
AuthenticationSubscriptionDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
);
AuthenticationSubscriptionDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
,
MYSQL
*
mysql
);
~
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
read_authentication_subscription
(
const
std
::
string
&
ueId
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
Pistache
::
Http
::
ResponseWriter
&
response
);
private:
MYSQL
*
mysql_WitcommUDRDB
;
};
}
...
...
main-api-server.cpp
View file @
7427dad0
...
...
@@ -106,6 +106,8 @@
#include "UsageMonitoringInformationDocumentApiImpl.h"
#include "V2XSubscriptionDataApiImpl.h"
#include <mysql/mysql.h>
#define PISTACHE_SERVER_THREADS 2
#define PISTACHE_SERVER_MAX_REQUEST_SIZE 32768
#define PISTACHE_SERVER_MAX_RESPONSE_SIZE 32768
...
...
@@ -160,6 +162,14 @@ int main() {
opts
.
maxResponseSize
(
PISTACHE_SERVER_MAX_RESPONSE_SIZE
);
httpEndpoint
->
init
(
opts
);
MYSQL
mysql
;
mysql_init
(
&
mysql
);
if
(
!
mysql_real_connect
(
&
mysql
,
"127.0.0.1"
,
"yunshou"
,
"123456"
,
"Witcomm-UDR-DB"
,
0
,
0
,
0
))
{
std
::
cout
<<
"mysql_real_connect failure!"
<<
std
::
endl
;
return
0
;
}
AMF3GPPAccessRegistrationDocumentApiImpl
AMF3GPPAccessRegistrationDocumentApiserver
(
router
);
AMF3GPPAccessRegistrationDocumentApiserver
.
init
();
...
...
@@ -179,7 +189,7 @@ int main() {
AuthenticationSoRDocumentApiserver
.
init
();
AuthenticationStatusDocumentApiImpl
AuthenticationStatusDocumentApiserver
(
router
);
AuthenticationStatusDocumentApiserver
.
init
();
AuthenticationSubscriptionDocumentApiImpl
AuthenticationSubscriptionDocumentApiserver
(
router
);
AuthenticationSubscriptionDocumentApiImpl
AuthenticationSubscriptionDocumentApiserver
(
router
,
&
mysql
);
AuthenticationSubscriptionDocumentApiserver
.
init
();
AuthenticationUPUDocumentApiImpl
AuthenticationUPUDocumentApiserver
(
router
);
AuthenticationUPUDocumentApiserver
.
init
();
...
...
@@ -336,6 +346,7 @@ int main() {
httpEndpoint
->
serve
();
httpEndpoint
->
shutdown
();
mysql_close
(
&
mysql
);
}
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