Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-SMF
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-SMF
Commits
97168b49
Commit
97168b49
authored
Oct 15, 2019
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
integrate NAS into the code
parent
c4ecfddc
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
732 additions
and
213 deletions
+732
-213
src/api-server/impl/SMContextsCollectionApiImpl.cpp
src/api-server/impl/SMContextsCollectionApiImpl.cpp
+6
-189
src/nas/3gpp_24.501.h
src/nas/3gpp_24.501.h
+1
-1
src/nas/nas_message.c
src/nas/nas_message.c
+0
-1
src/pgwc/pgw_app.cpp
src/pgwc/pgw_app.cpp
+613
-10
src/pgwc/pgw_app.hpp
src/pgwc/pgw_app.hpp
+44
-0
src/pgwc/pgw_context.cpp
src/pgwc/pgw_context.cpp
+47
-5
src/pgwc/smf_msg.hpp
src/pgwc/smf_msg.hpp
+0
-2
src/pgwc/smf_n11.cpp
src/pgwc/smf_n11.cpp
+18
-3
src/pgwc/smf_procedure.cpp
src/pgwc/smf_procedure.cpp
+1
-1
src/test/inputs/apitest.json
src/test/inputs/apitest.json
+2
-1
No files found.
src/api-server/impl/SMContextsCollectionApiImpl.cpp
View file @
97168b49
This diff is collapsed.
Click to expand it.
src/nas/3gpp_24.501.h
View file @
97168b49
src/nas/nas_message.c
View file @
97168b49
...
...
@@ -1022,7 +1022,6 @@ static int _nas_message_plain_decode (
* Decode 5G Session Management L3 message
*/
bytes
=
sm_msg_decode
(
&
msg
->
sm
,
(
uint8_t
*
)
buffer
,
length
);
printf
(
"
\n
dukl esm_msg_decode
\n
"
);
}
else
{
/*
* Discard L3 messages with not supported protocol discriminator
...
...
src/pgwc/pgw_app.cpp
View file @
97168b49
This diff is collapsed.
Click to expand it.
src/pgwc/pgw_app.hpp
View file @
97168b49
...
...
@@ -41,6 +41,11 @@
#include "pistache/router.h"
#include "smf_msg.hpp"
extern
"C"
{
#include "nas_message.h"
#include "mmData.h"
}
#include <map>
#include <set>
#include <shared_mutex>
...
...
@@ -177,6 +182,45 @@ public:
*/
void
send_create_session_response
(
Pistache
::
Http
::
ResponseWriter
&
httpResponse
,
oai
::
smf
::
model
::
SmContextCreateError
&
smContextCreateError
,
Pistache
::
Http
::
Code
code
);
/*
* Create N1 SM Container to send to AMF (using NAS lib)
* @param [std::shared_ptr<itti_n11_create_sm_context_response>] sm_context_res
* @param [uint8_t] msg_type Type of N1 message
* @param [std::string&] nas_msg_str store NAS message in form of string
*
*/
void
create_n1_sm_container
(
std
::
shared_ptr
<
itti_n11_create_sm_context_response
>
sm_context_res
,
uint8_t
msg_type
,
std
::
string
&
nas_msg_str
,
uint8_t
sm_cause
=
0
);
//for testing purpose!!
void
create_n1_sm_container
(
uint8_t
msg_type
,
std
::
string
&
nas_msg_str
,
uint8_t
sm_cause
=
0
);
/*
* Create N1 SM Container to send to AMF (using NAS lib)
* @param [std::shared_ptr<itti_n11_create_sm_context_request>] sm_context_req
* @param [uint8_t] msg_type Type of N1 message
* @param [std::string&] nas_msg_str store NAS message in form of string
*
*/
void
create_n1_sm_container
(
std
::
shared_ptr
<
itti_n11_create_sm_context_request
>
sm_context_req
,
uint8_t
msg_type
,
std
::
string
&
nas_msg_str
,
uint8_t
sm_cause
=
0
);
/*
* Create N2 SM Information to send to AMF (using NAS lib)
* @param [std::shared_ptr<itti_n11_create_sm_context_response>] sm_context_res
* @param [uint8_t] msg_type Type of N2 message
* @param [std::string&] ngap_msg_str store NGAP message in form of string
*
*/
void
create_n2_sm_information
(
std
::
shared_ptr
<
itti_n11_create_sm_context_response
>
sm_context_res
,
uint8_t
ngap_msg_type
,
uint8_t
ngap_ie_type
,
std
::
string
&
ngap_msg_str
);
/*
* Decode N1 SM Container into the NAS mesasge (using NAS lib)
* @param [nas_message_t&] nas_msg Store NAS message after decoded
* @param [std::string&] n1_sm_msg N1 SM Container from AMF
* @return status of the decode process
*/
uint8_t
decode_nas_message_n1_sm_container
(
nas_message_t
&
nas_msg
,
std
::
string
&
n1_sm_msg
);
};
}
#include "smf_config.hpp"
...
...
src/pgwc/pgw_context.cpp
View file @
97168b49
...
...
@@ -399,6 +399,7 @@ void pgw_context::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_req
itti_n11_create_sm_context_response
*
sm_context_resp
=
new
itti_n11_create_sm_context_response
(
TASK_PGWC_APP
,
TASK_SMF_N11
,
smreq
->
http_response
);
std
::
shared_ptr
<
itti_n11_create_sm_context_response
>
sm_context_resp_pending
=
std
::
shared_ptr
<
itti_n11_create_sm_context_response
>
(
sm_context_resp
);
sm_context_resp
->
res
.
set_supi
(
supi
);
sm_context_resp
->
res
.
set_cause
(
REQUEST_ACCEPTED
);
//Step 3. find pdn_connection
std
::
shared_ptr
<
dnn_context
>
sd
;
...
...
@@ -543,14 +544,13 @@ void pgw_context::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_req
//}
}
//Send reply to AMF
//Send reply to AMF
(PDUSession_CreateSMContextResponse including Cause, SMContextId)
//location header contains the URI of the created resource
Logger
::
pgwc_app
().
info
(
"Sending response to AMF!"
);
nlohmann
::
json
jsonData
;
oai
::
smf
::
model
::
SmContextCreatedData
smContextCreatedData
;
//include only SmfServiceInstanceId (See section 6.1.6.2.3, 3GPP TS 29.502 v16.0.0)
to_json
(
jsonData
,
smContextCreatedData
);
std
::
string
resBody
=
jsonData
.
dump
();
sm_context_resp
->
http_response
.
send
(
Pistache
::
Http
::
Code
::
Created
,
resBody
);
...
...
@@ -570,9 +570,51 @@ void pgw_context::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_req
//un-subscribe to the modifications of Session Management Subscription data for (SUPI, DNN, S-NSSAI)
}
//step 9. send ITTI message to SMF N11 for the pending session?
//step 9. if error when establishing the pdu session, send ITTI message to APP to trigger N1N2MessageTransfer towards AMFs
if
(
sm_context_resp
->
res
.
get_cause
()
!=
REQUEST_ACCEPTED
)
{
//clear pco, ambr
//TODO:
//free paa
paa_t
free_paa
=
{};
free_paa
=
sm_context_resp
->
res
.
get_paa
();
if
(
free_paa
.
is_ip_assigned
()){
switch
(
sp
->
pdn_type
.
pdn_type
)
{
case
PDN_TYPE_E_IPV4
:
case
PDN_TYPE_E_IPV4V6
:
paa_dynamic
::
get_instance
().
release_paa
(
sd
->
dnn_in_use
,
free_paa
.
ipv4_address
);
break
;
case
PDN_TYPE_E_IPV6
:
case
PDN_TYPE_E_NON_IP
:
default:
;
}
//sm_context_resp->res.clear_paa(); //TODO:
}
//clear the created context??
//TODO:
/*
for (auto it : sm_context_resp->res.bearer_contexts_to_be_created) {
gtpv2c::bearer_context_created_within_create_session_response bcc = {};
cause_t bcc_cause = {.cause_value = NO_RESOURCES_AVAILABLE, .pce = 0, .bce = 0, .cs = 0};
bcc.set(it.eps_bearer_id);
bcc.set(bcc_cause);
//sm_context_resp->res.add_bearer_context_created(bcc);
}
*/
//send ITTI message to N11 interface to trigger N1N2MessageTransfer towards AMFs
//with N1SM container with a PDU Session Establishment Reject message
//TODO
//sm_context_resp_pending->res.set
Logger
::
pgwc_app
().
info
(
"Sending ITTI message %s to task TASK_SMF_N11"
,
sm_context_resp_pending
->
get_msg_name
());
int
ret
=
itti_inst
->
send_msg
(
sm_context_resp_pending
);
if
(
RETURNok
!=
ret
)
{
Logger
::
pgwc_app
().
error
(
"Could not send ITTI message %s to task TASK_SMF_N11"
,
sm_context_resp_pending
->
get_msg_name
());
}
}
}
...
...
src/pgwc/smf_msg.hpp
View file @
97168b49
...
...
@@ -159,7 +159,6 @@ class pdu_session_create_sm_context_response {
public:
pdu_session_create_sm_context_response
(){
}
supi_t
get_supi
()
const
;
void
set_supi
(
supi_t
const
&
value
);
pdu_session_id_t
get_pdu_session_id
()
const
;
...
...
@@ -176,7 +175,6 @@ private:
pdu_session_id_t
m_pdu_session_id
;
uint8_t
m_cause
;
paa_t
m_paa
;
//Pistache::Http::ResponseWriter m_http_response;
Pistache
::
Http
::
Code
m_code
;
};
...
...
src/pgwc/smf_n11.cpp
View file @
97168b49
...
...
@@ -31,6 +31,7 @@
#include "itti.hpp"
#include "logger.hpp"
#include "smf_n11.hpp"
#include "pgw_app.hpp"
#include <curl/curl.h>
#include <nlohmann/json.hpp>
...
...
@@ -39,6 +40,7 @@
#define AMF_CURL_TIMEOUT_MS 100L
#define AMF_NUMBER_RETRIES 3
#define HTTP_STATUS_OK 200
#define DEBUG 1
using
namespace
pgwc
;
using
namespace
std
;
...
...
@@ -46,6 +48,7 @@ using json = nlohmann::json;
extern
itti_mw
*
itti_inst
;
extern
smf_n11
*
smf_n11_inst
;
extern
pgwc
::
pgw_app
*
pgw_app_inst
;
void
smf_n11_task
(
void
*
);
/*
...
...
@@ -119,6 +122,8 @@ void smf_n11::send_msg_to_amf(std::shared_ptr<itti_n11_create_sm_context_respons
//use curl to send data for the moment
nlohmann
::
json
jsonData
;
std
::
string
n1_message
;
curl_global_init
(
CURL_GLOBAL_DEFAULT
);
struct
curl_slist
*
headers
=
NULL
;
headers
=
curl_slist_append
(
headers
,
"Accept: application/json"
);
...
...
@@ -132,9 +137,19 @@ void smf_n11::send_msg_to_amf(std::shared_ptr<itti_n11_create_sm_context_respons
std
::
string
url
=
amf_addr
+
":"
+
std
::
to_string
(
amf_port
)
+
"/namf-comm/v1/ue-contexts/"
+
std
::
to_string
(
supi64
)
+
"/n1-n2-messages"
;
Logger
::
smf_n11
().
debug
(
"[get_sm_data] UDM's URL: %s "
,
url
.
c_str
());
//TODO: fill the content of N1N2MessageTransferReqData
//N1 SM container
if
(
sm_context_res
->
res
.
get_cause
()
!=
REQUEST_ACCEPTED
)
{
//PDU Session Establishment Reject
pgw_app_inst
->
create_n1_sm_container
(
sm_context_res
,
PDU_SESSION_ESTABLISHMENT_REJECT
,
n1_message
);
//need cause?
}
else
{
//PDU Session Establishment Accept
pgw_app_inst
->
create_n1_sm_container
(
sm_context_res
,
PDU_SESSION_ESTABLISHMENT_REJECT
,
n1_message
);
//need cause?
//pgw_app_inst->create_n1_sm_container(sm_context_res, PDU_SESSION_ESTABLISHMENT_ACCPET, n1_message); //need cause?
}
jsonData
[
"n1MessageContainer"
][
"n1MessageClass"
]
=
"SM"
;
jsonData
[
"n1MessageContainer"
][
"n1MessageContent"
][
"contentId"
]
=
"n1MessageContent"
;
jsonData
[
"n1MessageContainer"
][
"n1MessageContent"
][
"contentId"
]
=
n1_message
.
c_str
();
Logger
::
smf_n11
().
debug
(
"n1MessageContent: %s
\n
"
,
n1_message
.
c_str
());
//TODO: fill the content of N1N2MessageTransferReqData
//jsonData["n2InfoContainer"]["n2InformationClass"] = "SM";
//jsonData["n2InfoContainer"]["smInfo"]["PduSessionId"] = 123;
//jsonData["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapMessageType"] = 123; //NGAP message
...
...
@@ -187,7 +202,7 @@ void smf_n11::send_msg_to_amf(std::shared_ptr<itti_n11_create_sm_context_respons
}
curl_easy_cleanup
(
curl
);
}
//TODO: process the response if nec
c
essary
//TODO: process the response if necessary
}
...
...
src/pgwc/smf_procedure.cpp
View file @
97168b49
...
...
@@ -287,7 +287,7 @@ void session_create_sm_context_procedure::handle_itti_msg (itti_n4_session_estab
//address, interface identifier, Session-AMBR, selected PDU Session Type, Reflective QoS Timer (if available),
//P-CSCF address(es), [Always-on PDU Session])))
//send ITTI message to
APP
to trigger N1N2MessageTransfer towards AMFs
//send ITTI message to
N11 interface
to trigger N1N2MessageTransfer towards AMFs
Logger
::
pgwc_app
().
info
(
"Sending ITTI message %s to task TASK_SMF_N11"
,
n11_triggered_pending
->
get_msg_name
());
int
ret
=
itti_inst
->
send_msg
(
n11_triggered_pending
);
...
...
src/test/inputs/apitest.json
View file @
97168b49
...
...
@@ -38,7 +38,8 @@
"n2SmInfo"
:
{
"contentId"
:
"n2SmInfo"
},
"n1SmMsg"
:
{
"contentId"
:
"n1SmMsg"
}
},
"binaryDataN1SmMessage"
:
"00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 02 00 55 00 01 40 00 40 84 3c 25 7f 00 00 01 7f 00 00 01 df b0 96 0c ea 4c f5 4b 00 00 00 00 00 03 00 35 20 bc ec 86 00 00 00 00 00 00 00 00 00 0f 40 21 00 00 01 00 26 00 1a 19 2e 03 1f c1 00 ff 93 a2 39 0f 61 62 63 64 65 66 40 67 68 69 6a 6b 2e 6c 6d"
"binaryDataN1SmMessage"
:
"2e031fc100ff93a2390f616263646566406768696a6b2e6c6d"
,
"binaryDataN1SmMessage_full"
:
"00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 02 00 55 00 01 40 00 40 84 3c 25 7f 00 00 01 7f 00 00 01 df b0 96 0c ea 4c f5 4b 00 00 00 00 00 03 00 35 20 bc ec 86 00 00 00 00 00 00 00 00 00 0f 40 21 00 00 01 00 26 00 1a 19 2e 03 1f c1 00 ff 93 a2 39 0f 61 62 63 64 65 66 40 67 68 69 6a 6b 2e 6c 6d"
}
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