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
536206c5
Commit
536206c5
authored
Jun 09, 2022
by
yangjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up udm code
parent
ecb0f0a5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
27 deletions
+32
-27
build/scripts/build_udm
build/scripts/build_udm
+9
-6
src/impl/ConfirmAuthApiImpl.cpp
src/impl/ConfirmAuthApiImpl.cpp
+6
-5
src/impl/GenerateAuthDataApiImpl.cpp
src/impl/GenerateAuthDataApiImpl.cpp
+13
-12
src/utils/curl.cpp
src/utils/curl.cpp
+3
-3
src/utils/curl.hpp
src/utils/curl.hpp
+1
-1
No files found.
build/scripts/build_udm
View file @
536206c5
...
...
@@ -107,13 +107,16 @@ function main()
if
[[
$install_deps
-ne
0
]]
;
then
apt-get
install
cmake curl git libboost-all-dev libconfig++-dev libcurl4-gnutls-dev libgmp-dev libspdlog-dev nettle-dev
-y
if
[
!
-d
"
$OPENXGUDM_DIR
/build/ext/json/git_src/build"
]
;
then
mkdir
$OPENXGUDM_DIR
/build/ext/json/git_src/build
read
-p
"Do you want to install Nlohmann Json ? <y/N> "
prompt
if
[[
$prompt
=
~
[
yY]
(
es
)
*
]]
;
then
if
[
!
-d
"
$OPENXGUDM_DIR
/build/ext/json/git_src/build"
]
;
then
mkdir
$OPENXGUDM_DIR
/build/ext/json/git_src/build
fi
cd
$OPENXGUDM_DIR
/build/ext/json/git_src/build
cmake ..
make
make
install
fi
cd
$OPENXGUDM_DIR
/build/ext/json/git_src/build
cmake ..
make
make
install
echo
"install successful!"
return
0
fi
...
...
src/impl/ConfirmAuthApiImpl.cpp
View file @
536206c5
...
...
@@ -30,7 +30,8 @@ void ConfirmAuthApiImpl::confirm_auth(
const
std
::
string
&
supi
,
const
AuthEvent
&
authEvent
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
Logger
::
udm_ueau
().
info
(
"
\n\n
Entering confirm_auth()"
);
std
::
cout
<<
std
::
endl
;
Logger
::
udm_ueau
().
info
(
"Entering confirm_auth()"
);
std
::
string
udr_ip
=
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
udm_cfg
.
nudr
.
addr4
)));
...
...
@@ -48,7 +49,7 @@ void ConfirmAuthApiImpl::confirm_auth(
// UDR GET interface ----- get user info--------------------
remoteUri
=
udr_ip
+
":"
+
udr_port
+
"/nudr-dr/v2/subscription-data/"
+
supi
+
"/authentication-data/authentication-subscription"
;
Logger
::
udm_ueau
().
debug
(
"
GET Request:
"
+
remoteUri
);
Logger
::
udm_ueau
().
debug
(
"
Send GET Request URI:
"
+
remoteUri
);
Method
=
"GET"
;
Curl
::
curl_http_client
(
remoteUri
,
Method
,
""
,
Response
);
...
...
@@ -87,21 +88,21 @@ void ConfirmAuthApiImpl::confirm_auth(
remoteUri
=
udr_ip
+
":"
+
udr_port
+
"/nudr-dr/v2/subscription-data/"
+
supi
+
"/authentication-data/authentication-status"
;
Logger
::
udm_ueau
().
debug
(
"PUT Request:
"
+
remoteUri
);
Logger
::
udm_ueau
().
info
(
"Send PUT Request URI:
"
+
remoteUri
);
Method
=
"PUT"
;
nlohmann
::
json
j_authEvent
;
to_json
(
j_authEvent
,
authEvent
);
msgBody
=
j_authEvent
.
dump
();
Logger
::
udm_ueau
().
debug
(
"P
ATCH
Request body = "
+
msgBody
);
Logger
::
udm_ueau
().
debug
(
"P
UT
Request body = "
+
msgBody
);
Curl
::
curl_http_client
(
remoteUri
,
Method
,
msgBody
,
Response
);
std
::
string
hash_value
=
sha256
(
supi
+
authEvent
.
getServingNetworkName
());
// Logger::udm_ueau().debug("\n\nauthEventId=" +
// hash_value.substr(0,hash_value.length()/2));
Logger
::
udm_ueau
().
debug
(
"authEventId="
+
hash_value
);
//
Logger::udm_ueau().debug("authEventId=" + hash_value);
authEventId
=
hash_value
;
// Represents the authEvent Id per UE per serving
// network assigned by the UDM during
...
...
src/impl/GenerateAuthDataApiImpl.cpp
View file @
536206c5
...
...
@@ -35,7 +35,8 @@ void GenerateAuthDataApiImpl::generate_auth_data(
const
AuthenticationInfoRequest
&
authenticationInfoRequest
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
Logger
::
udm_ueau
().
info
(
"
\n\n
Entering generate_auth_data()"
);
std
::
cout
<<
std
::
endl
;
Logger
::
udm_ueau
().
info
(
"Entering generate_auth_data()"
);
// test data
// uint8_t rand[] = {0x23, 0x55, 0x3c, 0xbe, 0x96, 0x37, 0xa8, 0x9d, 0x21,
...
...
@@ -95,7 +96,7 @@ void GenerateAuthDataApiImpl::generate_auth_data(
// UDR GET interface ----- get authentication related info--------------------
remoteUri
=
udr_ip
+
":"
+
udr_port
+
"/nudr-dr/v2/subscription-data/"
+
supi
+
"/authentication-data/authentication-subscription"
;
Logger
::
udm_ueau
().
debug
(
"GET Request:
"
+
remoteUri
);
Logger
::
udm_ueau
().
info
(
"Send GET Request - URI:
"
+
remoteUri
);
Method
=
"GET"
;
Curl
::
curl_http_client
(
remoteUri
,
Method
,
""
,
Response
);
...
...
@@ -194,8 +195,8 @@ void GenerateAuthDataApiImpl::generate_auth_data(
std
::
string
r_rand_s
=
m_ResynchronizationInfo
.
getRand
();
std
::
string
r_auts_s
=
m_ResynchronizationInfo
.
getAuts
();
Logger
::
udm_ueau
().
debug
(
"[resync] r_rand = "
+
r_rand_s
);
Logger
::
udm_ueau
().
debug
(
"[resync] r_auts = "
+
r_auts_s
);
//
Logger::udm_ueau().debug("[resync] r_rand = " + r_rand_s);
//
Logger::udm_ueau().debug("[resync] r_auts = " + r_auts_s);
conv
::
hex_str_to_uint8
(
r_rand_s
.
c_str
(),
r_rand
);
conv
::
hex_str_to_uint8
(
r_auts_s
.
c_str
(),
r_auts
);
...
...
@@ -203,7 +204,7 @@ void GenerateAuthDataApiImpl::generate_auth_data(
r_sqn
=
Authentication_5gaka
::
sqn_ms_derive
(
opc
,
key
,
r_auts
,
r_rand
,
amf
);
if
(
r_sqn
)
{
// Not NULL (validate auts)
Logger
::
udm_ueau
().
debug
(
"Valid AUTS, generate new AV with SQNms"
);
//
Logger::udm_ueau().debug("Valid AUTS, generate new AV with SQNms");
// UDR PATCH interface ------- replace SQNhe with
// SQNms------------------------------
...
...
@@ -236,8 +237,8 @@ void GenerateAuthDataApiImpl::generate_auth_data(
// Curl::curl_http_client(remoteUri, Method, msgBody, Response);
// replace SQNhe with SQNms
uint64_t
sqn_value
=
0
;
for
(
int
i
=
0
;
i
<
6
;
i
++
)
uint64_t
sqn_value
=
0
;
for
(
int
i
=
0
;
i
<
6
;
i
++
)
{
sqn
[
i
]
=
r_sqn
[
i
];
// generate first, increase later
...
...
@@ -254,7 +255,7 @@ void GenerateAuthDataApiImpl::generate_auth_data(
sqn_s
=
conv
::
uint8_to_hex_string
(
sqn
,
6
);
print_buffer
(
"udm_ueau"
,
"SQNms"
,
sqn
,
6
);
//
print_buffer("udm_ueau", "SQNms", sqn, 6);
if
(
r_sqn
)
{
// free
free
(
r_sqn
);
...
...
@@ -310,13 +311,13 @@ void GenerateAuthDataApiImpl::generate_auth_data(
sqn_s
=
conv
::
uint8_to_hex_string
(
sqn
,
6
);
Logger
::
udm_ueau
().
debug
(
"new_sqn = "
+
sqn_s
);
//
Logger::udm_ueau().debug("new_sqn = " + sqn_s);
// UDR PATCH interface ------- increase
// sqn------------------------------------
remoteUri
=
udr_ip
+
":"
+
udr_port
+
"/nudr-dr/v2/subscription-data/"
+
supi
+
"/authentication-data/authentication-subscription"
;
Logger
::
udm_ueau
().
debug
(
"
PATCH Request:
"
+
remoteUri
);
Logger
::
udm_ueau
().
debug
(
"
Send PATCH Request URI:
"
+
remoteUri
);
Method
=
"PATCH"
;
nlohmann
::
json
j_SequenceNumber
;
...
...
@@ -337,10 +338,10 @@ void GenerateAuthDataApiImpl::generate_auth_data(
to_json
(
j_PatchItem
,
m_PatchItem
);
msgBody
=
"["
+
j_PatchItem
.
dump
()
+
"]"
;
//
Logger::udm_ueau().debug("PATCH Request body = " + msgBody);
Logger
::
udm_ueau
().
debug
(
"PATCH Request body = "
+
msgBody
);
Curl
::
curl_http_client
(
remoteUri
,
Method
,
msgBody
,
Response
);
Logger
::
udm_ueau
().
info
(
"Update sqn in Database"
);
//
Logger::udm_ueau().info("Update sqn in Database");
}
}
// namespace api
...
...
src/utils/curl.cpp
View file @
536206c5
...
...
@@ -41,7 +41,7 @@ std::size_t callback(const char *in, std::size_t size, std::size_t num,
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
());
//
Logger::udm_ueau().info("Send HTTP message with body %s", msgBody.c_str());
uint32_t
str_len
=
msgBody
.
length
();
char
*
body_data
=
(
char
*
)
malloc
(
str_len
+
1
);
...
...
@@ -75,8 +75,8 @@ long Curl::curl_http_client(std::string remoteUri, std::string Method,
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
CURL_TIMEOUT_MS
);
curl_easy_setopt
(
curl
,
CURLOPT_TCP_KEEPALIVE
,
1
);
curl_easy_setopt
(
curl
,
CURLOPT_INTERFACE
,
udm_cfg
.
nudr
.
if_name
.
c_str
());
Logger
::
udm_ueau
().
info
(
"[CURL] request sent by interface "
+
udm_cfg
.
nudr
.
if_name
);
//
Logger::udm_ueau().info("[CURL] request sent by interface " +
//
udm_cfg.nudr.if_name);
// Response information.
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
...
...
src/utils/curl.hpp
View file @
536206c5
...
...
@@ -43,7 +43,7 @@
#include "logger.hpp"
#include "udm_config.hpp"
#define CURL_TIMEOUT_MS
3
00L
#define CURL_TIMEOUT_MS
10
00L
class
Curl
{
public:
...
...
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