Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-UDM
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-UDM
Commits
cf408440
Commit
cf408440
authored
Feb 05, 2021
by
Chenyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
amf3GppAccessRegistration tested ok
parent
4c919467
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
9 deletions
+75
-9
.gitignore
.gitignore
+2
-0
src/common/logger.cpp
src/common/logger.cpp
+2
-0
src/common/logger.hpp
src/common/logger.hpp
+4
-0
src/impl/AMFRegistrationFor3GPPAccessApiImpl.cpp
src/impl/AMFRegistrationFor3GPPAccessApiImpl.cpp
+48
-2
src/impl/AMFRegistrationFor3GPPAccessApiImpl.h
src/impl/AMFRegistrationFor3GPPAccessApiImpl.h
+1
-1
src/udm_app/main.cpp
src/udm_app/main.cpp
+10
-0
src/utils/curl.cpp
src/utils/curl.cpp
+7
-5
src/utils/curl.hpp
src/utils/curl.hpp
+1
-1
No files found.
.gitignore
0 → 100644
View file @
cf408440
build/UDM/
.vscode/
src/common/logger.cpp
View file @
cf408440
...
...
@@ -79,6 +79,8 @@ void Logger::_init(const char *app, const bool log_stdout,
// m_amf_server = new _Logger("amf_server", m_sinks, ss.str().c_str());
// m_task_amf_n2 = new _Logger("task_amf_n2", m_sinks, ss.str().c_str());
m_udm_ueau
=
new
_Logger
(
"udm_ueau"
,
m_sinks
,
ss
.
str
().
c_str
());
m_udm_uecm
=
new
_Logger
(
"udm_uecm"
,
m_sinks
,
ss
.
str
().
c_str
());
m_udm_sdm
=
new
_Logger
(
"udm_sdm"
,
m_sinks
,
ss
.
str
().
c_str
());
}
//------------------------------------------------------------------------------
...
...
src/common/logger.hpp
View file @
cf408440
...
...
@@ -95,6 +95,8 @@ public:
// static _Logger &amf_server() { return *singleton().m_amf_server; }
// static _Logger &task_amf_n2() { return *singleton().m_task_amf_n2; }
static
_Logger
&
udm_ueau
()
{
return
*
singleton
().
m_udm_ueau
;
}
static
_Logger
&
udm_uecm
()
{
return
*
singleton
().
m_udm_uecm
;
}
static
_Logger
&
udm_sdm
()
{
return
*
singleton
().
m_udm_sdm
;
}
private:
static
Logger
*
m_singleton
;
...
...
@@ -127,6 +129,8 @@ private:
// _Logger *m_amf_server;
// _Logger *m_task_amf_n2;
_Logger
*
m_udm_ueau
;
_Logger
*
m_udm_uecm
;
_Logger
*
m_udm_sdm
;
};
#endif
src/impl/AMFRegistrationFor3GPPAccessApiImpl.cpp
View file @
cf408440
...
...
@@ -11,6 +11,12 @@
*/
#include "AMFRegistrationFor3GPPAccessApiImpl.h"
#include "udm_config.hpp"
#include "logger.hpp"
#include "curl.hpp"
using
namespace
config
;
extern
config
::
udm_config
udm_cfg
;
namespace
org
{
namespace
openapitools
{
...
...
@@ -23,8 +29,48 @@ AMFRegistrationFor3GPPAccessApiImpl::AMFRegistrationFor3GPPAccessApiImpl(std::sh
:
AMFRegistrationFor3GPPAccessApi
(
rtr
)
{
}
void
AMFRegistrationFor3GPPAccessApiImpl
::
_3_gpp_registration
(
const
std
::
string
&
ueId
,
const
Amf3GppAccessRegistration
&
amf3GppAccessRegistration
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Do some magic
\n
"
);
void
AMFRegistrationFor3GPPAccessApiImpl
::
xg_3gpp_registration
(
const
std
::
string
&
ueId
,
const
Amf3GppAccessRegistration
&
amf3GppAccessRegistration
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
std
::
string
udr_ip
=
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
udm_cfg
.
nudr
.
addr4
)));
std
::
string
udr_port
=
std
::
to_string
(
udm_cfg
.
nudr
.
port
);
std
::
string
remoteUri
;
std
::
string
Method
;
std
::
string
msgBody
;
std
::
string
Response
;
nlohmann
::
json
j_ProblemDetails
;
ProblemDetails
m_ProblemDetails
;
// UDR GET interface ----- get authentication related info--------------------
remoteUri
=
udr_ip
+
":"
+
udr_port
+
"/nudr-dr/v2/subscription-data/"
+
ueId
+
"/context-data/amf-3gpp-access"
;
Logger
::
udm_uecm
().
debug
(
"PUT Request:"
+
remoteUri
);
Method
=
"PUT"
;
nlohmann
::
json
amf3GppAccessRegistration_j
;
to_json
(
amf3GppAccessRegistration_j
,
amf3GppAccessRegistration
);
long
http_code
;
http_code
=
Curl
::
curl_http_client
(
remoteUri
,
Method
,
amf3GppAccessRegistration_j
.
dump
(),
Response
);
nlohmann
::
json
response_data
=
{};
try
{
Logger
::
udm_uecm
().
debug
(
"PUT Reponse:"
+
Response
);
response_data
=
nlohmann
::
json
::
parse
(
Response
.
c_str
());
}
catch
(
nlohmann
::
json
::
exception
&
e
)
{
// error handling
Logger
::
udm_uecm
().
info
(
"Could not get Json content from UDR response"
);
m_ProblemDetails
.
setCause
(
"USER_NOT_FOUND"
);
m_ProblemDetails
.
setStatus
(
404
);
m_ProblemDetails
.
setDetail
(
"User "
+
ueId
+
" not found in Database"
);
to_json
(
j_ProblemDetails
,
m_ProblemDetails
);
Logger
::
udm_uecm
().
error
(
"User "
+
ueId
+
" not found in Database"
);
Logger
::
udm_uecm
().
info
(
"Send 404 Not_Found response to client"
);
response
.
send
(
Pistache
::
Http
::
Code
::
Not_Found
,
j_ProblemDetails
.
dump
());
return
;
}
Logger
::
udm_uecm
().
debug
(
"http reponse code %d.
\n
"
,
http_code
);
response
.
send
(
static_cast
<
Pistache
::
Http
::
Code
>
(
http_code
),
amf3GppAccessRegistration_j
.
dump
());
}
}
...
...
src/impl/AMFRegistrationFor3GPPAccessApiImpl.h
View file @
cf408440
...
...
@@ -45,7 +45,7 @@ public:
AMFRegistrationFor3GPPAccessApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
);
~
AMFRegistrationFor3GPPAccessApiImpl
()
{}
void
_3_
gpp_registration
(
const
std
::
string
&
ueId
,
const
Amf3GppAccessRegistration
&
amf3GppAccessRegistration
,
Pistache
::
Http
::
ResponseWriter
&
response
);
void
xg_3
gpp_registration
(
const
std
::
string
&
ueId
,
const
Amf3GppAccessRegistration
&
amf3GppAccessRegistration
,
Pistache
::
Http
::
ResponseWriter
&
response
);
};
...
...
src/udm_app/main.cpp
View file @
cf408440
...
...
@@ -50,6 +50,9 @@
#include "DeleteAuthApiImpl.h"
#include "GenerateAuthDataApiImpl.h"
#include "SMFSmfRegistrationApiImpl.h"
#include "AMFRegistrationFor3GPPAccessApiImpl.h"
#include "options.hpp"
#include "udm_config.hpp"
...
...
@@ -92,6 +95,7 @@ static void setUpUnixSignals(std::vector<int> quitSignals) {
using
namespace
oai
::
udm
::
api
;
using
namespace
config
;
using
namespace
org
::
openapitools
::
server
::
api
;
udm_config
udm_cfg
;
...
...
@@ -189,6 +193,12 @@ int main(int argc, char **argv) {
GenerateAuthDataApiImpl
GenerateAuthDataApiserver
(
router
);
GenerateAuthDataApiserver
.
init
();
SMFSmfRegistrationApiImpl
SMFSmfRegistrationApiserver
(
router
);
SMFSmfRegistrationApiserver
.
init
();
AMFRegistrationFor3GPPAccessApiImpl
AMFRegistrationFor3GPPAccessApiserver
(
router
);
AMFRegistrationFor3GPPAccessApiserver
.
init
();
httpEndpoint
->
setHandler
(
router
->
handler
());
httpEndpoint
->
serve
();
...
...
src/utils/curl.cpp
View file @
cf408440
...
...
@@ -38,7 +38,7 @@ std::size_t callback(const char *in, std::size_t size, std::size_t num,
return
totalBytes
;
}
void
Curl
::
curl_http_client
(
std
::
string
remoteUri
,
std
::
string
Method
,
long
Curl
::
curl_http_client
(
std
::
string
remoteUri
,
std
::
string
Method
,
std
::
string
msgBody
,
std
::
string
&
Response
)
{
Logger
::
udm_ueau
().
info
(
"Send HTTP message with body %s"
,
msgBody
.
c_str
());
...
...
@@ -50,6 +50,7 @@ void Curl::curl_http_client(std::string remoteUri, std::string Method,
curl_global_init
(
CURL_GLOBAL_ALL
);
CURL
*
curl
=
curl_easy_init
();
long
httpCode
=
{
0
};
if
(
curl
)
{
CURLcode
res
=
{};
...
...
@@ -78,7 +79,6 @@ void Curl::curl_http_client(std::string remoteUri, std::string Method,
udm_cfg
.
nudr
.
if_name
);
// Response information.
long
httpCode
=
{
0
};
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
std
::
unique_ptr
<
std
::
string
>
httpHeaderData
(
new
std
::
string
());
...
...
@@ -107,7 +107,7 @@ void Curl::curl_http_client(std::string remoteUri, std::string Method,
// free curl before returning
curl_slist_free_all
(
headers
);
curl_easy_cleanup
(
curl
);
return
;
return
httpCode
;
}
nlohmann
::
json
response_data
=
{};
...
...
@@ -117,11 +117,11 @@ void Curl::curl_http_client(std::string remoteUri, std::string Method,
if
(
response
.
size
()
<
1
)
{
Logger
::
udm_ueau
().
info
(
"There's no content in the response"
);
// TODO: send context response error
return
;
return
httpCode
;
}
Logger
::
udm_ueau
().
info
(
"Wrong response code"
);
return
;
return
httpCode
;
}
else
{
// httpCode = 200 || httpCode = 201 || httpCode = 204
...
...
@@ -184,4 +184,6 @@ void Curl::curl_http_client(std::string remoteUri, std::string Method,
body_data
=
NULL
;
}
fflush
(
stdout
);
return
httpCode
;
}
src/utils/curl.hpp
View file @
cf408440
...
...
@@ -48,7 +48,7 @@
class
Curl
{
public:
/****** curl function ********/
static
void
curl_http_client
(
std
::
string
remoteUri
,
std
::
string
Method
,
static
long
curl_http_client
(
std
::
string
remoteUri
,
std
::
string
Method
,
std
::
string
msgBody
,
std
::
string
&
Response
);
private:
...
...
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