Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-NRF
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-NRF
Commits
f3bdcc56
Commit
f3bdcc56
authored
Dec 17, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a new subscription
parent
5507552f
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
510 additions
and
221 deletions
+510
-221
src/api-server/impl/NFInstanceIDDocumentApiImpl.cpp
src/api-server/impl/NFInstanceIDDocumentApiImpl.cpp
+53
-56
src/api-server/impl/SubscriptionsCollectionApiImpl.cpp
src/api-server/impl/SubscriptionsCollectionApiImpl.cpp
+44
-13
src/common/nrf.h
src/common/nrf.h
+8
-0
src/common/utils/api_conversions.cpp
src/common/utils/api_conversions.cpp
+57
-79
src/common/utils/api_conversions.hpp
src/common/utils/api_conversions.hpp
+15
-4
src/nrf_app/CMakeLists.txt
src/nrf_app/CMakeLists.txt
+1
-1
src/nrf_app/nrf_app.cpp
src/nrf_app/nrf_app.cpp
+130
-63
src/nrf_app/nrf_app.hpp
src/nrf_app/nrf_app.hpp
+28
-1
src/nrf_app/nrf_event.cpp
src/nrf_app/nrf_event.cpp
+7
-0
src/nrf_app/nrf_event.hpp
src/nrf_app/nrf_event.hpp
+3
-0
src/nrf_app/nrf_event_sig.hpp
src/nrf_app/nrf_event_sig.hpp
+11
-4
src/nrf_app/nrf_subscription.cpp
src/nrf_app/nrf_subscription.cpp
+82
-0
src/nrf_app/nrf_subscription.hpp
src/nrf_app/nrf_subscription.hpp
+71
-0
No files found.
src/api-server/impl/NFInstanceIDDocumentApiImpl.cpp
View file @
f3bdcc56
/**
* NRF NFManagement Service
* NRF NFManagement Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
* NRF NFManagement Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS,
* CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
(https://openapi-generator.tech).
*
https://openapi-generator.tech
*
Do not edit
the class manually.
* NOTE: This class is auto generated by OpenAPI Generator
*
(https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "NFInstanceIDDocumentApiImpl.h"
#include "3gpp_29.500.h"
#include "ProblemDetails.h"
#include "logger.hpp"
#include "nrf_app.hpp"
#include "nrf_config.hpp"
#include "nrf_profile.hpp"
#include "ProblemDetails.h"
#include "3gpp_29.500.h"
extern
oai
::
nrf
::
app
::
nrf_config
nrf_cfg
;
...
...
@@ -31,11 +32,9 @@ using namespace oai::nrf;
NFInstanceIDDocumentApiImpl
::
NFInstanceIDDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
,
nrf_app
*
nrf_app_inst
,
std
::
string
address
)
:
NFInstanceIDDocumentApi
(
rtr
),
m_nrf_app
(
nrf_app_inst
),
m_address
(
address
)
{
}
:
NFInstanceIDDocumentApi
(
rtr
),
m_nrf_app
(
nrf_app_inst
),
m_address
(
address
)
{}
//------------------------------------------------------------------------------
void
NFInstanceIDDocumentApiImpl
::
deregister_nf_instance
(
...
...
@@ -45,43 +44,43 @@ void NFInstanceIDDocumentApiImpl::deregister_nf_instance(
nfInstanceID
.
c_str
());
int
http_code
=
0
;
ProblemDetails
problem_details
=
{
};
ProblemDetails
problem_details
=
{};
m_nrf_app
->
handle_deregister_nf_instance
(
nfInstanceID
,
http_code
,
1
,
problem_details
);
nlohmann
::
json
json_data
=
{
};
nlohmann
::
json
json_data
=
{};
std
::
string
content_type
=
"application/json"
;
if
(
http_code
!=
HTTP_STATUS_CODE_204_NO_CONTENT
)
{
to_json
(
json_data
,
problem_details
);
content_type
=
"application/problem+json"
;
//content type
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
//
content type
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
response
.
send
(
Pistache
::
Http
::
Code
(
http_code
),
json_data
.
dump
().
c_str
());
return
;
}
else
{
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
response
.
send
(
Pistache
::
Http
::
Code
(
http_code
));
}
}
//------------------------------------------------------------------------------
void
NFInstanceIDDocumentApiImpl
::
get_nf_instance
(
const
std
::
string
&
nfInstanceID
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
Logger
::
nrf_sbi
().
info
(
"Got a request to retrieve the profile of a given NF Instance, Instance ID: %s"
,
"Got a request to retrieve the profile of a given NF Instance, Instance "
"ID: %s"
,
nfInstanceID
.
c_str
());
int
http_code
=
0
;
std
::
shared_ptr
<
nrf_profile
>
profile
=
{
};
ProblemDetails
problem_details
=
{
};
std
::
shared_ptr
<
nrf_profile
>
profile
=
{};
ProblemDetails
problem_details
=
{};
m_nrf_app
->
handle_get_nf_instance
(
nfInstanceID
,
profile
,
http_code
,
1
,
problem_details
);
nlohmann
::
json
json_data
=
{
};
nlohmann
::
json
json_data
=
{};
std
::
string
content_type
=
"application/json"
;
if
(
http_code
!=
HTTP_STATUS_CODE_200_OK
)
{
...
...
@@ -91,11 +90,10 @@ void NFInstanceIDDocumentApiImpl::get_nf_instance(
profile
.
get
()
->
to_json
(
json_data
);
}
//content type
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
//
content type
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
response
.
send
(
Pistache
::
Http
::
Code
(
http_code
),
json_data
.
dump
().
c_str
());
}
//------------------------------------------------------------------------------
...
...
@@ -104,34 +102,34 @@ void NFInstanceIDDocumentApiImpl::register_nf_instance(
const
Pistache
::
Optional
<
Pistache
::
Http
::
Header
::
Raw
>
&
contentEncoding
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
Logger
::
nrf_sbi
().
info
(
"Got a request to register an NF instance/Update an NF instance, Instance ID: %s"
,
"Got a request to register an NF instance/Update an NF instance, "
"Instance ID: %s"
,
nfInstanceID
.
c_str
());
NFProfile
nf_profile
=
nFProfile
;
int
http_code
=
0
;
ProblemDetails
problem_details
=
{
};
ProblemDetails
problem_details
=
{};
m_nrf_app
->
handle_register_nf_instance
(
nfInstanceID
,
nFProfile
,
http_code
,
1
,
problem_details
);
nlohmann
::
json
json_data
=
{
};
nlohmann
::
json
json_data
=
{};
std
::
string
content_type
=
"application/json"
;
if
((
http_code
!=
HTTP_STATUS_CODE_200_OK
)
and
(
http_code
!=
HTTP_STATUS_CODE_201_CREATED
)
and
(
http_code
!=
HTTP_STATUS_CODE_202_ACCEPTED
))
{
if
((
http_code
!=
HTTP_STATUS_CODE_200_OK
)
and
(
http_code
!=
HTTP_STATUS_CODE_201_CREATED
)
and
(
http_code
!=
HTTP_STATUS_CODE_202_ACCEPTED
))
{
to_json
(
json_data
,
problem_details
);
content_type
=
"application/problem+json"
;
}
else
{
to_json
(
json_data
,
nf_profile
);
to_json
(
json_data
,
nFProfile
);
// Location header
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
Location
>
(
m_address
+
base
+
nrf_cfg
.
sbi_api_version
+
"/nf-instances/"
+
nfInstanceID
);
}
//content type
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
//Location header
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
Location
>
(
m_address
+
base
+
nrf_cfg
.
sbi_api_version
+
"/nf-instances/"
+
nfInstanceID
);
// content type
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
response
.
send
(
Pistache
::
Http
::
Code
(
http_code
),
json_data
.
dump
().
c_str
());
}
...
...
@@ -144,37 +142,36 @@ void NFInstanceIDDocumentApiImpl::update_nf_instance(
nfInstanceID
.
c_str
());
int
http_code
=
0
;
ProblemDetails
problem_details
=
{
};
ProblemDetails
problem_details
=
{};
m_nrf_app
->
handle_update_nf_instance
(
nfInstanceID
,
patchItem
,
http_code
,
1
,
problem_details
);
nlohmann
::
json
json_data
=
{
};
nlohmann
::
json
json_data
=
{};
std
::
string
content_type
=
"application/json"
;
std
::
shared_ptr
<
nrf_profile
>
profile
=
m_nrf_app
->
find_nf_profile
(
nfInstanceID
);
std
::
shared_ptr
<
nrf_profile
>
profile
=
m_nrf_app
->
find_nf_profile
(
nfInstanceID
);
if
((
http_code
!=
HTTP_STATUS_CODE_200_OK
)
and
(
http_code
!=
HTTP_STATUS_CODE_204_NO_CONTENT
))
{
if
((
http_code
!=
HTTP_STATUS_CODE_200_OK
)
and
(
http_code
!=
HTTP_STATUS_CODE_204_NO_CONTENT
))
{
to_json
(
json_data
,
problem_details
);
content_type
=
"application/problem+json"
;
}
else
if
(
http_code
==
HTTP_STATUS_CODE_200_OK
)
{
//convert the profile to Json
//
convert the profile to Json
profile
.
get
()
->
to_json
(
json_data
);
}
Logger
::
nrf_sbi
().
debug
(
"Json data: %s"
,
json_data
.
dump
().
c_str
());
//content type
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
//
content type
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
if
(
http_code
!=
HTTP_STATUS_CODE_204_NO_CONTENT
)
response
.
send
(
Pistache
::
Http
::
Code
(
http_code
),
json_data
.
dump
().
c_str
());
else
response
.
send
(
Pistache
::
Http
::
Code
(
http_code
));
}
}
}
}
}
// namespace api
}
// namespace nrf
}
// namespace oai
src/api-server/impl/SubscriptionsCollectionApiImpl.cpp
View file @
f3bdcc56
/**
* NRF NFManagement Service
* NRF NFManagement Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
* NRF NFManagement Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS,
* CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
(https://openapi-generator.tech).
*
https://openapi-generator.tech
*
Do not edit
the class manually.
* NOTE: This class is auto generated by OpenAPI Generator
*
(https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "SubscriptionsCollectionApiImpl.h"
#include "3gpp_29.500.h"
#include "ProblemDetails.h"
#include "logger.hpp"
#include "nrf_app.hpp"
#include "nrf_config.hpp"
extern
oai
::
nrf
::
app
::
nrf_config
nrf_cfg
;
namespace
oai
{
namespace
nrf
{
...
...
@@ -22,19 +30,42 @@ using namespace oai::nrf::app;
SubscriptionsCollectionApiImpl
::
SubscriptionsCollectionApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
,
nrf_app
*
nrf_app_inst
,
std
::
string
address
)
:
SubscriptionsCollectionApi
(
rtr
),
m_nrf_app
(
nrf_app_inst
),
m_address
(
address
)
{
}
:
SubscriptionsCollectionApi
(
rtr
),
m_nrf_app
(
nrf_app_inst
),
m_address
(
address
)
{}
void
SubscriptionsCollectionApiImpl
::
create_subscription
(
const
SubscriptionData
&
subscriptionData
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Do some magic
\n
"
);
}
Logger
::
nrf_sbi
().
info
(
"Got a request to create a new subscription"
);
}
}
int
http_code
=
0
;
ProblemDetails
problem_details
=
{};
std
::
string
sub_id
;
m_nrf_app
->
handle_create_subscription
(
subscriptionData
,
sub_id
,
http_code
,
1
,
problem_details
);
nlohmann
::
json
json_data
=
{};
std
::
string
content_type
=
"application/json"
;
if
(
http_code
!=
HTTP_STATUS_CODE_201_CREATED
)
{
to_json
(
json_data
,
problem_details
);
content_type
=
"application/problem+json"
;
}
else
{
to_json
(
json_data
,
subscriptionData
);
json_data
[
"subscriptionId"
]
=
sub_id
;
// Location header
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
Location
>
(
m_address
+
base
+
nrf_cfg
.
sbi_api_version
+
"/subscriptions/"
+
sub_id
);
}
// content type
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
response
.
send
(
Pistache
::
Http
::
Code
(
http_code
),
json_data
.
dump
().
c_str
());
}
}
// namespace api
}
// namespace nrf
}
// namespace oai
src/common/nrf.h
View file @
f3bdcc56
...
...
@@ -126,4 +126,12 @@ typedef struct smf_info_s {
std
::
vector
<
snssai_smf_info_item_t
>
snssai_smf_info_list
;
}
smf_info_t
;
// Event Subscription IDs)
typedef
uint32_t
evsub_id_t
;
#define EVSUB_ID_FMT "0x%" PRIx32
#define EVSUB_ID_SCAN_FMT SCNx32
#define INVALID_EVSUB_ID ((evsub_id_t)0x00000000)
#define UNASSIGNED_EVSUB_ID ((evsub_id_t)0x00000000)
#endif
src/common/utils/api_conversions.cpp
View file @
f3bdcc56
...
...
@@ -32,10 +32,10 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <regex>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <regex>
#include "AmfInfo.h"
#include "api_conversions.hpp"
...
...
@@ -48,9 +48,8 @@ using namespace oai::nrf::app;
using
namespace
oai
::
nrf
;
//------------------------------------------------------------------------------
bool
api_conv
::
profile_api_to_
am
f_profile
(
bool
api_conv
::
profile_api_to_
nr
f_profile
(
const
NFProfile
&
api_profile
,
std
::
shared_ptr
<
nrf_profile
>
&
profile
)
{
Logger
::
nrf_app
().
debug
(
"Convert a json-type profile a NF profile (profile ID: %s)"
,
api_profile
.
getNfInstanceId
().
c_str
());
...
...
@@ -72,10 +71,10 @@ bool api_conv::profile_api_to_amf_profile(
profile
.
get
()
->
set_nf_capacity
(
api_profile
.
getCapacity
());
Logger
::
nrf_app
().
debug
(
"............Capacity: %d"
,
profile
.
get
()
->
get_nf_capacity
());
//SNSSAIs
//
SNSSAIs
std
::
vector
<
Snssai
>
snssai
=
api_profile
.
getSNssais
();
for
(
auto
s
:
snssai
)
{
snssai_t
sn
=
{
};
snssai_t
sn
=
{};
sn
.
sD
=
s
.
getSd
();
sn
.
sST
=
s
.
getSst
();
profile
.
get
()
->
add_snssai
(
sn
);
...
...
@@ -83,9 +82,9 @@ bool api_conv::profile_api_to_amf_profile(
sn
.
sD
.
c_str
());
}
std
::
vector
<
std
::
string
>
ipv4_addr_str
=
api_profile
.
getIpv4Addresses
();
std
::
vector
<
std
::
string
>
ipv4_addr_str
=
api_profile
.
getIpv4Addresses
();
for
(
auto
address
:
ipv4_addr_str
)
{
struct
in_addr
addr4
=
{
};
struct
in_addr
addr4
=
{};
unsigned
char
buf_in_addr
[
sizeof
(
struct
in_addr
)];
if
(
inet_pton
(
AF_INET
,
util
::
trim
(
address
).
c_str
(),
buf_in_addr
)
==
1
)
{
memcpy
(
&
addr4
,
buf_in_addr
,
sizeof
(
struct
in_addr
));
...
...
@@ -104,7 +103,7 @@ bool api_conv::profile_api_to_amf_profile(
case
NF_TYPE_AMF
:
{
Logger
::
nrf_app
().
debug
(
"............AMF profile, AMF Info"
);
profile
.
get
()
->
set_nf_type
(
NF_TYPE_AMF
);
amf_info_t
info
=
{
};
amf_info_t
info
=
{};
AmfInfo
amf_info_api
=
api_profile
.
getAmfInfo
();
info
.
amf_region_id
=
amf_info_api
.
getAmfRegionId
();
info
.
amf_set_id
=
amf_info_api
.
getAmfSetId
();
...
...
@@ -114,7 +113,7 @@ bool api_conv::profile_api_to_amf_profile(
info
.
amf_region_id
.
c_str
());
for
(
auto
g
:
amf_info_api
.
getGuamiList
())
{
guami_t
guami
=
{
};
guami_t
guami
=
{};
guami
.
amf_id
=
g
.
getAmfId
();
guami
.
plmn
.
mcc
=
g
.
getPlmnId
().
getMcc
();
guami
.
plmn
.
mnc
=
g
.
getPlmnId
().
getMnc
();
...
...
@@ -124,20 +123,19 @@ bool api_conv::profile_api_to_amf_profile(
Logger
::
nrf_app
().
debug
(
"....................., PLMN (MCC: %s, MNC: %s)"
,
guami
.
plmn
.
mcc
.
c_str
(),
guami
.
plmn
.
mnc
.
c_str
());
}
(
std
::
static_pointer_cast
<
amf_profile
>
(
profile
)).
get
()
->
add_amf_info
(
info
);
}
break
;
(
std
::
static_pointer_cast
<
amf_profile
>
(
profile
))
.
get
()
->
add_amf_info
(
info
);
}
break
;
case
NF_TYPE_SMF
:
{
Logger
::
nrf_app
().
debug
(
"............SMF profile, SMF Info"
);
profile
.
get
()
->
set_nf_type
(
NF_TYPE_SMF
);
smf_info_t
info
=
{
};
smf_info_t
info
=
{};
SmfInfo
smf_info_api
=
api_profile
.
getSmfInfo
();
for
(
auto
s
:
smf_info_api
.
getSNssaiSmfInfoList
())
{
snssai_smf_info_item_t
snssai
=
{
};
snssai_smf_info_item_t
snssai
=
{};
snssai
.
snssai
.
sD
=
s
.
getSNssai
().
getSd
();
snssai
.
snssai
.
sST
=
s
.
getSNssai
().
getSst
();
Logger
::
nrf_app
().
debug
(
".......................NSSAI SD: %s, SST: %d"
,
...
...
@@ -152,86 +150,66 @@ bool api_conv::profile_api_to_amf_profile(
info
.
snssai_smf_info_list
.
push_back
(
snssai
);
}
(
std
::
static_pointer_cast
<
smf_profile
>
(
profile
)).
get
()
->
add_smf_info
(
info
);
}
break
;
default:
{
}
(
std
::
static_pointer_cast
<
smf_profile
>
(
profile
))
.
get
()
->
add_smf_info
(
info
);
}
break
;
default:
{}
}
return
true
;
}
//------------------------------------------------------------------------------
bool
api_conv
::
subscription_api_to_nrf_subscription
(
const
SubscriptionData
&
api_sub
,
std
::
shared_ptr
<
nrf_subscription
>
&
sub
)
{
Logger
::
nrf_app
().
debug
(
"Convert a json-type Subscription data a NRF subscription data"
);
sub
.
get
()
->
set_notification_uri
(
api_sub
.
getNfStatusNotificationUri
());
//TODO:
}
//------------------------------------------------------------------------------
nf_type_t
api_conv
::
string_to_nf_type
(
const
std
::
string
&
str
)
{
if
(
str
.
compare
(
"NRF"
)
==
0
)
return
NF_TYPE_NRF
;
if
(
str
.
compare
(
"AMF"
)
==
0
)
return
NF_TYPE_AMF
;
if
(
str
.
compare
(
"SMF"
)
==
0
)
return
NF_TYPE_SMF
;
if
(
str
.
compare
(
"AUSF"
)
==
0
)
return
NF_TYPE_AUSF
;
if
(
str
.
compare
(
"NEF"
)
==
0
)
return
NF_TYPE_NEF
;
if
(
str
.
compare
(
"PCP"
)
==
0
)
return
NF_TYPE_PCF
;
if
(
str
.
compare
(
"SMSF"
)
==
0
)
return
NF_TYPE_SMSF
;
if
(
str
.
compare
(
"NSSF"
)
==
0
)
return
NF_TYPE_NSSF
;
if
(
str
.
compare
(
"UDR"
)
==
0
)
return
NF_TYPE_UDR
;
if
(
str
.
compare
(
"LMF"
)
==
0
)
return
NF_TYPE_LMF
;
if
(
str
.
compare
(
"GMLC"
)
==
0
)
return
NF_TYPE_GMLC
;
if
(
str
.
compare
(
"5G_EIR"
)
==
0
)
return
NF_TYPE_5G_EIR
;
if
(
str
.
compare
(
"SEPP"
)
==
0
)
return
NF_TYPE_SEPP
;
if
(
str
.
compare
(
"UPF"
)
==
0
)
return
NF_TYPE_UPF
;
if
(
str
.
compare
(
"N3IWF"
)
==
0
)
return
NF_TYPE_N3IWF
;
if
(
str
.
compare
(
"AF"
)
==
0
)
return
NF_TYPE_AF
;
if
(
str
.
compare
(
"UDSF"
)
==
0
)
return
NF_TYPE_UDSF
;
if
(
str
.
compare
(
"BSF"
)
==
0
)
return
NF_TYPE_BSF
;
if
(
str
.
compare
(
"CHF"
)
==
0
)
return
NF_TYPE_CHF
;
if
(
str
.
compare
(
"NWDAF"
)
==
0
)
return
NF_TYPE_NWDAF
;
//default
if
(
str
.
compare
(
"NRF"
)
==
0
)
return
NF_TYPE_NRF
;
if
(
str
.
compare
(
"AMF"
)
==
0
)
return
NF_TYPE_AMF
;
if
(
str
.
compare
(
"SMF"
)
==
0
)
return
NF_TYPE_SMF
;
if
(
str
.
compare
(
"AUSF"
)
==
0
)
return
NF_TYPE_AUSF
;
if
(
str
.
compare
(
"NEF"
)
==
0
)
return
NF_TYPE_NEF
;
if
(
str
.
compare
(
"PCP"
)
==
0
)
return
NF_TYPE_PCF
;
if
(
str
.
compare
(
"SMSF"
)
==
0
)
return
NF_TYPE_SMSF
;
if
(
str
.
compare
(
"NSSF"
)
==
0
)
return
NF_TYPE_NSSF
;
if
(
str
.
compare
(
"UDR"
)
==
0
)
return
NF_TYPE_UDR
;
if
(
str
.
compare
(
"LMF"
)
==
0
)
return
NF_TYPE_LMF
;
if
(
str
.
compare
(
"GMLC"
)
==
0
)
return
NF_TYPE_GMLC
;
if
(
str
.
compare
(
"5G_EIR"
)
==
0
)
return
NF_TYPE_5G_EIR
;
if
(
str
.
compare
(
"SEPP"
)
==
0
)
return
NF_TYPE_SEPP
;
if
(
str
.
compare
(
"UPF"
)
==
0
)
return
NF_TYPE_UPF
;
if
(
str
.
compare
(
"N3IWF"
)
==
0
)
return
NF_TYPE_N3IWF
;
if
(
str
.
compare
(
"AF"
)
==
0
)
return
NF_TYPE_AF
;
if
(
str
.
compare
(
"UDSF"
)
==
0
)
return
NF_TYPE_UDSF
;
if
(
str
.
compare
(
"BSF"
)
==
0
)
return
NF_TYPE_BSF
;
if
(
str
.
compare
(
"CHF"
)
==
0
)
return
NF_TYPE_CHF
;
if
(
str
.
compare
(
"NWDAF"
)
==
0
)
return
NF_TYPE_NWDAF
;
// default
return
NF_TYPE_UNKNOWN
;
}
//------------------------------------------------------------------------------
patch_op_type_t
api_conv
::
string_to_patch_operation
(
const
std
::
string
&
str
)
{
if
(
str
.
compare
(
"add"
)
==
0
)
return
PATCH_OP_ADD
;
if
(
str
.
compare
(
"copy"
)
==
0
)
return
PATCH_OP_COPY
;
if
(
str
.
compare
(
"move"
)
==
0
)
return
PATCH_OP_MOVE
;
if
(
str
.
compare
(
"remove"
)
==
0
)
return
PATCH_OP_REMOVE
;
if
(
str
.
compare
(
"replace"
)
==
0
)
return
PATCH_OP_REPLACE
;
if
(
str
.
compare
(
"test"
)
==
0
)
return
PATCH_OP_TEST
;
//default
if
(
str
.
compare
(
"add"
)
==
0
)
return
PATCH_OP_ADD
;
if
(
str
.
compare
(
"copy"
)
==
0
)
return
PATCH_OP_COPY
;
if
(
str
.
compare
(
"move"
)
==
0
)
return
PATCH_OP_MOVE
;
if
(
str
.
compare
(
"remove"
)
==
0
)
return
PATCH_OP_REMOVE
;
if
(
str
.
compare
(
"replace"
)
==
0
)
return
PATCH_OP_REPLACE
;
if
(
str
.
compare
(
"test"
)
==
0
)
return
PATCH_OP_TEST
;
// default
return
PATCH_OP_UNKNOWN
;
}
bool
api_conv
::
validate_uuid
(
const
std
::
string
&
str
)
{
//should be verified with Capital letter
//
should be verified with Capital letter
static
const
std
::
regex
e
(
"[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}"
);
return
regex_match
(
str
,
e
);
...
...
src/common/utils/api_conversions.hpp
View file @
f3bdcc56
...
...
@@ -32,6 +32,8 @@
#include "NFProfile.h"
#include "nrf_profile.hpp"
#include "nrf_subscription.hpp"
#include "SubscriptionData.h"
#include "nrf.h"
using
namespace
oai
::
nrf
::
model
;
...
...
@@ -47,9 +49,19 @@ namespace api_conv {
* @param [std::shared_ptr<nrf_profile> &] profile: NF profile
* @return true if successful, otherwise, return false
*/
bool
profile_api_to_
am
f_profile
(
const
NFProfile
&
api_profile
,
bool
profile_api_to_
nr
f_profile
(
const
NFProfile
&
api_profile
,
std
::
shared_ptr
<
nrf_profile
>
&
profile
);
/*
* Convert a json-type profile to a subscription profile
* @param [const SubscriptionData &] subData: Json-type subscription data from
* OpenAPITool
* @param [std::shared_ptr<nrf_subscription> &] sub: NRF Subscription
* @return true if successful, otherwise, return false
*/
bool
subscription_api_to_nrf_subscription
(
const
SubscriptionData
&
api_sub
,
std
::
shared_ptr
<
nrf_subscription
>
&
sub
);
/*
* Convert a string to nf type
* @param [const std::string &] str: string input
...
...
@@ -64,11 +76,10 @@ nf_type_t string_to_nf_type(const std::string &str);
*/
patch_op_type_t
string_to_patch_operation
(
const
std
::
string
&
str
);
bool
validate_uuid
(
const
std
::
string
&
str
);
}
// namespace api_conv
}
}
}
// namespace nrf
}
// namespace oai
#endif
/* FILE_API_CONVERSIONS_HPP_SEEN */
src/nrf_app/CMakeLists.txt
View file @
f3bdcc56
...
...
@@ -30,9 +30,9 @@ add_library (NRF STATIC
nrf_app.cpp
nrf_config.cpp
nrf_profile.cpp
nrf_subscription.cpp
task_manager.cpp
nrf_event.cpp
)
src/nrf_app/nrf_app.cpp
View file @
f3bdcc56
This diff is collapsed.
Click to expand it.
src/nrf_app/nrf_app.hpp
View file @
f3bdcc56
...
...
@@ -33,10 +33,12 @@
#include <string>
#include "NFProfile.h"
#include "nrf_profile.hpp"
#include "nrf_subscription.hpp"
#include "nrf_event.hpp"
#include "PatchItem.h"
#include "ProblemDetails.h"
#include "SubscriptionData.h"
#include "uint_generator.hpp"
namespace
oai
{
namespace
nrf
{
...
...
@@ -122,6 +124,19 @@ class nrf_app {
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
/*
* Handle a Register NF Instance request
* @param [SubscriptionData &] subscription_data: Subscription data
* @param [int &] http_code: HTTP code used to return to the consumer
* @param [const uint8_t] http_version: HTTP version
* @param [ProblemDetails &] problem_details: Store details of the error
* @return void
*/
void
handle_create_subscription
(
const
SubscriptionData
&
subscription_data
,
std
::
string
&
sub_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
/*
* Insert a nrf profile
* @param [const std::string &] profile_id: Profile ID
...
...
@@ -187,13 +202,25 @@ class nrf_app {
*/
bool
remove_nf_profile
(
const
std
::
string
&
profile_id
);
bool
add_subscription
(
const
std
::
string
&
sub_id
,
const
std
::
shared_ptr
<
nrf_subscription
>
&
s
);
void
subscribe_task_tick
(
uint64_t
ms
);
void
handle_heartbeart_timeout
(
uint64_t
ms
);
bool
authorize_subscription
(
const
std
::
shared_ptr
<
nrf_subscription
>
&
s
)
const
;
void
generate_ev_subscription_id
(
std
::
string
&
sub_id
);
evsub_id_t
generate_ev_subscription_id
();
private:
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
nrf_profile
>>
instance_id2nrf_profile
;
mutable
std
::
shared_mutex
m_instance_id2nrf_profile
;
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
nrf_subscription
>>
instance_id2nrf_subscription
;
mutable
std
::
shared_mutex
m_instance_id2nrf_subscription
;
nrf_event
&
m_event_sub
;
util
::
uint_generator
<
uint32_t
>
evsub_id_generator
;
};
}
}
...
...
src/nrf_app/nrf_event.cpp
View file @
f3bdcc56
...
...
@@ -65,4 +65,11 @@ bs2::connection nrf_event::subscribe_task_tick_extended(
}
//------------------------------------------------------------------------------
bs2
::
connection
nrf_event
::
subscribe_nf_status_change
(
const
nf_status_sig_t
::
slot_type
&
sig
)
{
return
nf_status_change
.
connect
(
sig
);
}
src/nrf_app/nrf_event.hpp
View file @
f3bdcc56
...
...
@@ -70,8 +70,11 @@ class nrf_event {
uint64_t
period
,
uint64_t
start
=
0
);
bs2
::
connection
subscribe_nf_status_change
(
const
nf_status_sig_t
::
slot_type
&
sig
);
private:
task_sig_t
task_tick
;
nf_status_sig_t
nf_status_change
;
};
}
...
...
src/nrf_app/nrf_event_sig.hpp
View file @
f3bdcc56
...
...
@@ -38,10 +38,17 @@ namespace nrf {
namespace
app
{
typedef
bs2
::
signal_type
<
void
(
uint64_t
),
bs2
::
keywords
::
mutex_type
<
bs2
::
dummy_mutex
>>::
type
task_sig_t
;
bs2
::
keywords
::
mutex_type
<
bs2
::
dummy_mutex
>>::
type
task_sig_t
;
}
}
}
// Signal for NF Status
// Subscription ID, NF Status
typedef
bs2
::
signal_type
<
void
(
std
::
string
sub_id
,
uint8_t
),
bs2
::
keywords
::
mutex_type
<
bs2
::
dummy_mutex
>>::
type
nf_status_sig_t
;
}
// namespace app
}
// namespace nrf
}
// namespace oai
#endif
/* FILE_NRF_EVENT_SIG_HPP_SEEN */
src/nrf_app/nrf_subscription.cpp
0 → 100644
View file @
f3bdcc56
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nrf_subscription.cpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2020
\email: tien-thinh.nguyen@eurecom.fr
*/
#include "nrf_subscription.hpp"
#include "logger.hpp"
using
namespace
oai
::
nrf
::
app
;
//------------------------------------------------------------------------------
void
nrf_subscription
::
set_subscription_id
(
const
std
::
string
&
sub
)
{
subscription_id
=
sub
;
}
//------------------------------------------------------------------------------
void
nrf_subscription
::
get_subscription_id
(
std
::
string
&
sub
)
const
{
sub
=
subscription_id
;
}
//------------------------------------------------------------------------------
std
::
string
nrf_subscription
::
get_subscription_id
()
const
{
return
subscription_id
;
}
void
nrf_subscription
::
set_notification_uri
(
const
std
::
string
&
notification_uri
)
{
nf_status_notification_uri
=
notification_uri
;
}
void
nrf_subscription
::
get_notification_uri
(
std
::
string
&
notification_uri
)
const
{
notification_uri
=
nf_status_notification_uri
;
}
//------------------------------------------------------------------------------
void
nrf_subscription
::
display
()
{
Logger
::
nrf_app
().
debug
(
"Subscription ID: %s"
,
subscription_id
.
c_str
());
Logger
::
nrf_app
().
debug
(
"Notification URI: %s"
,
nf_status_notification_uri
.
c_str
());
}
//------------------------------------------------------------------------------
void
nrf_subscription
::
subscribe_nf_status_change
()
{
Logger
::
nrf_app
().
debug
(
"Subscribe to NF status change event"
);
ev_connection
=
m_event_sub
.
subscribe_nf_status_change
(
boost
::
bind
(
&
nrf_subscription
::
handle_nf_status_change
,
this
));
}
//------------------------------------------------------------------------------
void
nrf_subscription
::
handle_nf_status_change
()
{
Logger
::
nrf_app
().
info
(
"Handle NF status change (subscription ID %s)"
,
subscription_id
.
c_str
());
}
src/nrf_app/nrf_subscription.hpp
0 → 100644
View file @
f3bdcc56
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nrf_subscription.hpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2020
\email: tien-thinh.nguyen@eurecom.fr
*/
#ifndef FILE_NRF_SUBSCRIPTION_HPP_SEEN
#define FILE_NRF_SUBSCRIPTION_HPP_SEEN
#include <string>
#include "nrf_event.hpp"
#include "logger.hpp"
namespace
oai
{
namespace
nrf
{
namespace
app
{
using
namespace
std
;
class
nrf_subscription
{
public:
nrf_subscription
(
nrf_event
&
ev
)
:
m_event_sub
(
ev
){};
nrf_subscription
(
nrf_subscription
const
&
)
=
delete
;
virtual
~
nrf_subscription
()
{
Logger
::
nrf_app
().
debug
(
"Delete instance..."
);
ev_connection
.
disconnect
();
}
void
operator
=
(
nrf_subscription
const
&
)
=
delete
;
void
set_subscription_id
(
const
std
::
string
&
sub_id
);
void
get_subscription_id
(
std
::
string
&
sub_id
)
const
;
std
::
string
get_subscription_id
()
const
;
void
set_notification_uri
(
const
std
::
string
&
notification_uri
);
void
get_notification_uri
(
std
::
string
&
notification_uri
)
const
;
void
display
();
void
subscribe_nf_status_change
();
void
handle_nf_status_change
();
private:
std
::
string
nf_status_notification_uri
;
std
::
string
subscription_id
;
nrf_event
&
m_event_sub
;
bs2
::
connection
ev_connection
;
};
}
// namespace app
}
// namespace nrf
}
// namespace oai
#endif
/* FILE_NRF_SUBSCRIPTION_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