Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-AUSF
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-AUSF
Commits
eb05f8d6
Commit
eb05f8d6
authored
May 21, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support multiple UEs
parent
36cfa8c5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
0 deletions
+104
-0
src/ausf_app/ausf_app.cpp
src/ausf_app/ausf_app.cpp
+56
-0
src/ausf_app/ausf_app.hpp
src/ausf_app/ausf_app.hpp
+35
-0
src/common/ausf.h
src/common/ausf.h
+2
-0
src/common/conversions.cpp
src/common/conversions.cpp
+10
-0
src/common/conversions.hpp
src/common/conversions.hpp
+1
-0
No files found.
src/ausf_app/ausf_app.cpp
View file @
eb05f8d6
...
...
@@ -78,6 +78,26 @@ ausf_app::~ausf_app() {
Logger
::
ausf_app
().
debug
(
"Delete AUSF_APP instance..."
);
}
//------------------------------------------------------------------------------
bool
ausf_app
::
is_supi_2_security_context
(
const
std
::
string
&
supi
)
const
{
std
::
shared_lock
lock
(
m_supi2security_context
);
return
bool
{
supi2security_context
.
count
(
supi
)
>
0
};
}
//------------------------------------------------------------------------------
std
::
shared_ptr
<
security_context
>
ausf_app
::
supi_2_security_context
(
const
std
::
string
&
supi
)
const
{
std
::
shared_lock
lock
(
m_supi2security_context
);
return
supi2security_context
.
at
(
supi
);
}
//------------------------------------------------------------------------------
void
ausf_app
::
set_supi_2_security_context
(
const
std
::
string
&
supi
,
std
::
shared_ptr
<
security_context
>
sc
)
{
std
::
unique_lock
lock
(
m_supi2security_context
);
supi2security_context
[
supi
]
=
sc
;
}
//------------------------------------------------------------------------------
void
ausf_app
::
handle_ue_authentications
(
const
AuthenticationInfo
&
authenticationInfo
,
nlohmann
::
json
&
json_data
,
...
...
@@ -93,6 +113,7 @@ void ausf_app::handle_ue_authentications(
std
::
string
snn
=
authenticationInfo
.
getServingNetworkName
();
// serving network name
std
::
string
supi
=
authenticationInfo
.
getSupiOrSuci
();
// supi
// TODO: supi64_t supi64 = {};
Logger
::
ausf_server
().
info
(
"servingNetworkName %s"
,
snn
.
c_str
());
Logger
::
ausf_server
().
info
(
"supiOrSuci %s"
,
supi
.
c_str
());
...
...
@@ -238,6 +259,41 @@ void ausf_app::handle_ue_authentications(
KAUSF_TMP
=
conv
::
uint8_to_hex_string
(
kausf_ausf
,
32
);
// store kausf_tmp in ausf
// Store the security context
std
::
shared_ptr
<
security_context
>
sc
=
{};
if
(
is_supi_2_security_context
(
supi
))
{
Logger
::
ausf_app
().
debug
(
"Update SMF context with SUPI: "
,
supi
);
sc
=
supi_2_security_context
(
supi
);
sc
->
supi_ausf
=
supi
;
// TODO: setter/getter
memcpy
(
sc
->
ausf_av_s
.
rand
,
rand_ausf
,
16
);
// store 5g av in ausf
memcpy
(
sc
->
ausf_av_s
.
autn
,
autn_ausf
,
16
);
memcpy
(
sc
->
ausf_av_s
.
hxresStar
,
hxresStar
,
16
);
memcpy
(
sc
->
ausf_av_s
.
kseaf
,
kseaf
,
32
);
memcpy
(
sc
->
xres_star
,
xresStar
,
16
);
// store xres* in ausf
sc
->
supi_ausf
=
authenticationInfo
.
getSupiOrSuci
();
// store supi in ausf
sc
->
serving_nn
=
snn
;
// store snn in ausf
sc
->
auth_type
=
authType_udm
;
// store authType in ausf
sc
->
kausf_tmp
=
conv
::
uint8_to_hex_string
(
kausf_ausf
,
32
);
// store kausf_tmp in ausf
}
else
{
Logger
::
ausf_app
().
debug
(
"Create a new security context with SUPI "
,
supi
);
// sc = std::shared_ptr<security_context>(new security_context());
sc
=
std
::
make_shared
<
security_context
>
();
sc
->
supi_ausf
=
supi
;
// TODO: setter/getter
memcpy
(
sc
->
ausf_av_s
.
rand
,
rand_ausf
,
16
);
// store 5g av in ausf
memcpy
(
sc
->
ausf_av_s
.
autn
,
autn_ausf
,
16
);
memcpy
(
sc
->
ausf_av_s
.
hxresStar
,
hxresStar
,
16
);
memcpy
(
sc
->
ausf_av_s
.
kseaf
,
kseaf
,
32
);
memcpy
(
sc
->
xres_star
,
xresStar
,
16
);
// store xres* in ausf
sc
->
supi_ausf
=
authenticationInfo
.
getSupiOrSuci
();
// store supi in ausf
sc
->
serving_nn
=
snn
;
// store snn in ausf
sc
->
auth_type
=
authType_udm
;
// store authType in ausf
sc
->
kausf_tmp
=
conv
::
uint8_to_hex_string
(
kausf_ausf
,
32
);
// store kausf_tmp in ausf
set_supi_2_security_context
(
supi
,
sc
);
}
/*----------------ausf --> seaf-----------*/
//---form UEAuthenticationCtx
UEAuthenticationCtx
UEAuthCtx
;
...
...
src/ausf_app/ausf_app.hpp
View file @
eb05f8d6
...
...
@@ -35,6 +35,8 @@
#include "UEAuthenticationCtx.h"
#include "ConfirmationData.h"
#include "ausf.h"
#include <map>
#include <shared_mutex>
namespace
oai
{
namespace
ausf
{
...
...
@@ -42,6 +44,26 @@ namespace app {
using
namespace
oai
::
ausf_server
::
model
;
class
security_context
{
public:
security_context
()
:
xres_star
()
{
// supi = {};
ausf_av_s
=
{};
supi_ausf
=
""
;
auth_type
=
""
;
serving_nn
=
""
;
kausf_tmp
=
""
;
}
// supi64_t supi;
AUSF_AV_s
ausf_av_s
;
uint8_t
xres_star
[
16
];
// store xres*
std
::
string
supi_ausf
;
// store supi
std
::
string
auth_type
;
// store authType
std
::
string
serving_nn
;
// store serving network name
std
::
string
kausf_tmp
;
// store Kausf(string)
};
// class ausf_config;
class
ausf_app
{
public:
...
...
@@ -59,6 +81,12 @@ class ausf_app {
const
std
::
string
&
authCtxId
,
const
ConfirmationData
&
confirmation_data
,
nlohmann
::
json
&
json_data
,
uint16_t
&
http_response_code
);
bool
is_supi_2_security_context
(
const
std
::
string
&
supi
)
const
;
std
::
shared_ptr
<
security_context
>
supi_2_security_context
(
const
std
::
string
&
supi
)
const
;
void
set_supi_2_security_context
(
const
std
::
string
&
supi
,
std
::
shared_ptr
<
security_context
>
sc
);
private:
AUSF_AV_s
ausf_av_s
;
// stored temporarily
...
...
@@ -67,6 +95,13 @@ class ausf_app {
std
::
string
AUTH_TYPE
;
// store authType
std
::
string
SERVING_NN
;
// store serving network name
std
::
string
KAUSF_TMP
;
// store Kausf(string)
std
::
map
<
supi64_t
,
std
::
shared_ptr
<
security_context
>>
imsi2security_context
;
mutable
std
::
shared_mutex
m_imsi2security_context
;
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
security_context
>>
supi2security_context
;
mutable
std
::
shared_mutex
m_supi2security_context
;
};
}
// namespace app
}
// namespace ausf
...
...
src/common/ausf.h
View file @
eb05f8d6
...
...
@@ -81,4 +81,6 @@ typedef struct {
uint8_t
kseaf
[
32
];
}
AUSF_AV_s
;
typedef
uint64_t
supi64_t
;
#endif
src/common/conversions.cpp
View file @
eb05f8d6
...
...
@@ -199,3 +199,13 @@ void conv::hex_str_to_uint8(const char* string, uint8_t* des) {
index
++
;
}
}
uint64_t
supi_to_u64
(
std
::
string
&
supi
)
{
uint64_t
uint_supi
;
try
{
uint_supi
=
std
::
stoull
(
supi
,
nullptr
,
10
);
}
catch
(
const
std
::
exception
&
e
)
{
}
return
uint_supi
;
}
src/common/conversions.hpp
View file @
eb05f8d6
...
...
@@ -57,5 +57,6 @@ class conv {
const
uint8_t
digit1
,
const
uint8_t
digit2
,
const
uint8_t
digit3
);
static
std
::
string
uint8_to_hex_string
(
const
uint8_t
*
v
,
const
size_t
s
);
static
void
hex_str_to_uint8
(
const
char
*
string
,
uint8_t
*
des
);
static
uint64_t
supi_to_u64
(
std
::
string
&
supi
);
};
#endif
/* FILE_CONVERSIONS_HPP_SEEN */
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