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
c2099bd2
Commit
c2099bd2
authored
Oct 07, 2019
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add N11 interface
parent
14f11335
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
358 additions
and
12 deletions
+358
-12
src/common/logger.cpp
src/common/logger.cpp
+1
-0
src/common/logger.hpp
src/common/logger.hpp
+2
-0
src/common/msg/itti_msg_n11.hpp
src/common/msg/itti_msg_n11.hpp
+83
-0
src/itti/itti_msg.hpp
src/itti/itti_msg.hpp
+3
-0
src/nas/mm/msg/mm_msg.h
src/nas/mm/msg/mm_msg.h
+1
-0
src/pgwc/smf_msg.cpp
src/pgwc/smf_msg.cpp
+10
-4
src/pgwc/smf_msg.hpp
src/pgwc/smf_msg.hpp
+7
-6
src/pgwc/smf_n10.cpp
src/pgwc/smf_n10.cpp
+2
-2
src/pgwc/smf_n11.cpp
src/pgwc/smf_n11.cpp
+190
-0
src/pgwc/smf_n11.hpp
src/pgwc/smf_n11.hpp
+59
-0
No files found.
src/common/logger.cpp
View file @
c2099bd2
...
...
@@ -79,6 +79,7 @@ void Logger::_init( const char *app, const bool log_stdout, bool const log_rot_f
m_pfcp
=
new
_Logger
(
"pfcp "
,
m_sinks
,
ss
.
str
().
c_str
()
);
m_pfcp_switch
=
new
_Logger
(
"pfcp_sw "
,
m_sinks
,
ss
.
str
().
c_str
()
);
m_smf_n10
=
new
_Logger
(
"smf_n10 "
,
m_sinks
,
ss
.
str
().
c_str
()
);
m_smf_n11
=
new
_Logger
(
"smf_n11 "
,
m_sinks
,
ss
.
str
().
c_str
()
);
m_smf_api_server
=
new
_Logger
(
"smf_api_server "
,
m_sinks
,
ss
.
str
().
c_str
()
);
}
...
...
src/common/logger.hpp
View file @
c2099bd2
...
...
@@ -105,6 +105,7 @@ public:
static
_Logger
&
pfcp
()
{
return
*
singleton
().
m_pfcp
;
}
static
_Logger
&
pfcp_switch
()
{
return
*
singleton
().
m_pfcp_switch
;
}
static
_Logger
&
smf_n10
()
{
return
*
singleton
().
m_smf_n10
;
}
static
_Logger
&
smf_n11
()
{
return
*
singleton
().
m_smf_n11
;
}
static
_Logger
&
smf_api_server
()
{
return
*
singleton
().
m_smf_api_server
;
}
private:
...
...
@@ -148,6 +149,7 @@ private:
_Logger
*
m_pfcp
;
_Logger
*
m_pfcp_switch
;
_Logger
*
m_smf_n10
;
_Logger
*
m_smf_n11
;
_Logger
*
m_smf_api_server
;
};
...
...
src/common/msg/itti_msg_n11.hpp
0 → 100644
View file @
c2099bd2
/*
* 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
*/
/*
* itti_msg_n11.hpp
*
* Created on:
* Author:
*/
#ifndef ITTI_MSG_N11_HPP_INCLUDED_
#define ITTI_MSG_N11_HPP_INCLUDED_
#include "itti_msg.hpp"
#include "smf_msg.hpp"
#include "pistache/http.h"
class
itti_n11_msg
:
public
itti_msg
{
public:
itti_n11_msg
(
const
itti_msg_type_t
msg_type
,
const
task_id_t
orig
,
const
task_id_t
dest
)
:
itti_msg
(
msg_type
,
orig
,
dest
)
{
}
itti_n11_msg
(
const
itti_n11_msg
&
i
)
:
itti_msg
(
i
)
{}
itti_n11_msg
(
const
itti_n11_msg
&
i
,
const
task_id_t
orig
,
const
task_id_t
dest
)
:
itti_n11_msg
(
i
)
{
origin
=
orig
;
destination
=
dest
;
}
};
//-----------------------------------------------------------------------------
class
itti_n11_create_sm_context_request
:
public
itti_n11_msg
{
public:
itti_n11_create_sm_context_request
(
const
task_id_t
orig
,
const
task_id_t
dest
,
Pistache
::
Http
::
ResponseWriter
&
response
)
:
itti_n11_msg
(
N11_SESSION_CREATE_SM_CONTEXT_REQUEST
,
orig
,
dest
),
http_response
(
response
)
{}
itti_n11_create_sm_context_request
(
const
itti_n11_create_sm_context_request
&
i
)
:
itti_n11_msg
(
i
),
req
(
i
.
req
),
http_response
(
i
.
http_response
)
{}
itti_n11_create_sm_context_request
(
const
itti_n11_create_sm_context_request
&
i
,
const
task_id_t
orig
,
const
task_id_t
dest
)
:
itti_n11_msg
(
i
,
orig
,
dest
),
req
(
i
.
req
),
http_response
(
i
.
http_response
)
{}
const
char
*
get_msg_name
()
{
return
"N11_SESSION_CREATE_SM_CONTEXT_REQUEST"
;};
pgwc
::
pdu_session_create_sm_context_request
req
;
Pistache
::
Http
::
ResponseWriter
&
http_response
;
};
//-----------------------------------------------------------------------------
class
itti_n11_create_sm_context_response
:
public
itti_n11_msg
{
public:
itti_n11_create_sm_context_response
(
const
task_id_t
orig
,
const
task_id_t
dest
,
Pistache
::
Http
::
ResponseWriter
&
response
)
:
itti_n11_msg
(
N11_SESSION_CREATE_SM_CONTEXT_RESPONSE
,
orig
,
dest
),
http_response
(
response
.
clone
())
{}
itti_n11_create_sm_context_response
(
const
itti_n11_create_sm_context_response
&
i
)
:
itti_n11_msg
(
i
),
res
(
i
.
res
),
http_response
(
i
.
http_response
.
clone
())
{}
itti_n11_create_sm_context_response
(
const
itti_n11_create_sm_context_response
&
i
,
const
task_id_t
orig
,
const
task_id_t
dest
)
:
itti_n11_msg
(
i
,
orig
,
dest
),
res
(
i
.
res
),
http_response
(
i
.
http_response
.
clone
())
{}
const
char
*
get_msg_name
()
{
return
"N11_SESSION_CREATE_SM_CONTEXT_RESPONSE"
;};
pgwc
::
pdu_session_create_sm_context_response
res
;
Pistache
::
Http
::
ResponseWriter
http_response
;
};
#endif
/* ITTI_MSG_S5S8_HPP_INCLUDED_ */
src/itti/itti_msg.hpp
View file @
c2099bd2
...
...
@@ -54,6 +54,7 @@ typedef enum {
TASK_SPGWU_S1U
,
TASK_SGW_UDP
,
TASK_SMF_N10
,
TASK_SMF_N11
,
TASK_MAX
,
TASK_NONE
,
TASK_ALL
=
255
...
...
@@ -136,6 +137,8 @@ typedef enum {
SXAB_SESSION_REPORT_REQUEST
,
SXAB_SESSION_REPORT_RESPONSE
,
N10_GET_SESSION_MANAGEMENT_SUBSCRIPTION
,
N11_SESSION_CREATE_SM_CONTEXT_REQUEST
,
N11_SESSION_CREATE_SM_CONTEXT_RESPONSE
,
UDP_INIT
,
UDP_DATA_REQ
,
UDP_DATA_IND
,
...
...
src/nas/mm/msg/mm_msg.h
View file @
c2099bd2
#ifndef MM_MSG_H_
#define MM_MSG_H_
#include "mmMsgDef.h"
#include "AuthenticationRequest.h"
#include "AuthenticationResponse.h"
...
...
src/pgwc/smf_msg.cpp
View file @
c2099bd2
...
...
@@ -162,6 +162,16 @@ void pdu_session_create_sm_context_request::set_ipmdr(ipmdr_t const& ipmdr)
//------------------------------------------------------------------
supi_t
pdu_session_create_sm_context_response
::
get_supi
()
const
{
return
m_supi
;
}
void
pdu_session_create_sm_context_response
::
set_supi
(
supi_t
const
&
supi
)
{
m_supi
=
supi
;
}
void
pdu_session_create_sm_context_response
::
set_cause
(
uint8_t
cause
)
{
m_cause
=
cause
;
...
...
@@ -179,10 +189,6 @@ paa_t pdu_session_create_sm_context_response::get_paa()
return
m_paa
;
}
void
pdu_session_create_sm_context_response
::
send_msg_to_amf
(
std
::
string
resBody
){
m_http_response
.
send
(
m_code
,
resBody
);
}
void
pdu_session_create_sm_context_response
::
set_http_code
(
Pistache
::
Http
::
Code
code
)
{
m_code
=
code
;
...
...
src/pgwc/smf_msg.hpp
View file @
c2099bd2
...
...
@@ -157,22 +157,23 @@ private:
class
pdu_session_create_sm_context_response
{
public:
pdu_session_create_sm_context_response
(
Pistache
::
Http
::
ResponseWriter
&
http_response
)
:
m_http_response
(
http_response
.
clone
())
{
}
//pdu_session_create_sm_context_response(): {}
pdu_session_create_sm_context_response
(){
}
supi_t
get_supi
()
const
;
void
set_supi
(
supi_t
const
&
value
);
void
set_cause
(
uint8_t
cause
);
uint8_t
get_cause
();
void
set_paa
(
paa_t
paa
);
paa_t
get_paa
();
void
send_msg_to_amf
(
std
::
string
resBody
);
void
set_http_response
();
void
set_http_code
(
Pistache
::
Http
::
Code
code
);
Pistache
::
Http
::
Code
get_http_code
();
private:
supi_t
m_supi
;
uint8_t
m_cause
;
paa_t
m_paa
;
Pistache
::
Http
::
ResponseWriter
m_http_response
;
//
Pistache::Http::ResponseWriter m_http_response;
Pistache
::
Http
::
Code
m_code
;
};
...
...
src/pgwc/smf_n10.cpp
View file @
c2099bd2
...
...
@@ -101,8 +101,8 @@ void smf_n10_task (void *args_p)
//------------------------------------------------------------------------------
smf_n10
::
smf_n10
()
{
udm_addr
=
"172.
55.55.101
"
;
//TODO: hardcoded for the moment (should get from configuration file)
udm_port
=
8
181
;
//TODO: hardcoded for the moment (should get from configuration file)
udm_addr
=
"172.
16.1.105
"
;
//TODO: hardcoded for the moment (should get from configuration file)
udm_port
=
8
080
;
//TODO: hardcoded for the moment (should get from configuration file)
Logger
::
smf_n10
().
startup
(
"Starting..."
);
if
(
itti_inst
->
create_task
(
TASK_SMF_N10
,
smf_n10_task
,
nullptr
)
)
{
...
...
src/pgwc/smf_n11.cpp
0 → 100644
View file @
c2099bd2
/*
* 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 smf_n11.cpp
\brief
\author
\company Eurecom
\email:
*/
#include "smf.h"
#include "common_defs.h"
#include "itti.hpp"
#include "logger.hpp"
#include "smf_n11.hpp"
#include <curl/curl.h>
#include <nlohmann/json.hpp>
#include <stdexcept>
#define UDM_CURL_TIMEOUT_MS 100L
#define UDM_NUMBER_RETRIES 3
#define HTTP_STATUS_OK 200
using
namespace
pgwc
;
using
namespace
std
;
using
json
=
nlohmann
::
json
;
extern
itti_mw
*
itti_inst
;
extern
smf_n11
*
smf_n11_inst
;
void
smf_n11_task
(
void
*
);
/*
* To read content of the response from UDM
*/
static
std
::
size_t
callback
(
const
char
*
in
,
std
::
size_t
size
,
std
::
size_t
num
,
std
::
string
*
out
)
{
const
std
::
size_t
totalBytes
(
size
*
num
);
out
->
append
(
in
,
totalBytes
);
return
totalBytes
;
}
//------------------------------------------------------------------------------
void
smf_n11_task
(
void
*
args_p
)
{
const
task_id_t
task_id
=
TASK_SMF_N11
;
itti_inst
->
notify_task_ready
(
task_id
);
do
{
std
::
shared_ptr
<
itti_msg
>
shared_msg
=
itti_inst
->
receive_msg
(
task_id
);
auto
*
msg
=
shared_msg
.
get
();
switch
(
msg
->
msg_type
)
{
case
N11_SESSION_CREATE_SM_CONTEXT_RESPONSE
:
//if (itti_n10_get_session_management_subscription* m = dynamic_cast<itti_n10_get_session_management_subscription*>(msg)) {
// smf_n10_inst->send_sm_data_get_msg(ref(*m));
//}
break
;
case
TERMINATE
:
if
(
itti_msg_terminate
*
terminate
=
dynamic_cast
<
itti_msg_terminate
*>
(
msg
))
{
Logger
::
smf_n11
().
info
(
"Received terminate message"
);
return
;
}
break
;
default:
Logger
::
smf_n11
().
info
(
"no handler for msg type %d"
,
msg
->
msg_type
);
}
}
while
(
true
);
}
//------------------------------------------------------------------------------
smf_n11
::
smf_n11
()
{
amf_addr
=
"172.16.1.106"
;
//TODO: hardcoded for the moment (should get from configuration file)
amf_port
=
8080
;
//TODO: hardcoded for the moment (should get from configuration file)
Logger
::
smf_n11
().
startup
(
"Starting..."
);
if
(
itti_inst
->
create_task
(
TASK_SMF_N11
,
smf_n11_task
,
nullptr
)
)
{
Logger
::
smf_n11
().
error
(
"Cannot create task TASK_SMF_N11"
);
throw
std
::
runtime_error
(
"Cannot create task TASK_SMF_N11"
);
}
Logger
::
smf_n11
().
startup
(
"Started"
);
}
void
smf_n11
::
send_msg_to_amf
(
std
::
shared_ptr
<
itti_n11_create_sm_context_response
>
sm_context_res
)
{
//Transfer N1/N2 message via AMF by using N_amf_Communication_N1N2MessageTransfer (see TS29518_Namf_Communication.yaml)
//use curl to send data for the moment
nlohmann
::
json
jsonData
;
curl_global_init
(
CURL_GLOBAL_DEFAULT
);
struct
curl_slist
*
headers
=
NULL
;
headers
=
curl_slist_append
(
headers
,
"Accept: application/json"
);
headers
=
curl_slist_append
(
headers
,
"Content-Type: application/json"
);
headers
=
curl_slist_append
(
headers
,
"charsets: utf-8"
);
supi64_t
supi64
=
smf_supi_to_u64
(
sm_context_res
->
res
.
get_supi
());
CURL
*
curl
=
curl_easy_init
();
//hardcoded for the moment, should get from NRF/configuration file
std
::
string
url
=
amf_addr
+
":"
+
std
::
to_string
(
amf_port
)
+
"/ue-contexts/"
+
std
::
to_string
(
supi64
)
+
"/n1-n2-messages"
;
Logger
::
smf_n11
().
debug
(
"[get_sm_data] UDM's URL: %s "
,
url
.
c_str
());
std
::
string
body
=
""
;
if
(
curl
)
{
CURLcode
res
;
curl_easy_setopt
(
curl
,
CURLOPT_HTTPHEADER
,
headers
);
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
.
c_str
()
);
curl_easy_setopt
(
curl
,
CURLOPT_HTTPGET
,
1
);
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
UDM_CURL_TIMEOUT_MS
);
// Response information.
long
httpCode
(
0
);
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
// Hook up data handling function.
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
&
callback
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
httpData
.
get
());
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDS
,
body
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDSIZE
,
(
long
)
body
.
length
());
int
numRetries
=
0
;
while
(
numRetries
<
UDM_NUMBER_RETRIES
){
res
=
curl_easy_perform
(
curl
);
curl_easy_getinfo
(
curl
,
CURLINFO_RESPONSE_CODE
,
&
httpCode
);
Logger
::
smf_n11
().
debug
(
"[send_msg_to_amf] Response from AMF, Http Code: %d "
,
httpCode
);
if
(
httpCode
==
HTTP_STATUS_OK
)
{
Logger
::
smf_n11
().
debug
(
"[send_msg_to_amf] Got successful response from AMF, URL: %s "
,
url
.
c_str
());
try
{
jsonData
=
nlohmann
::
json
::
parse
(
*
httpData
.
get
());
//curl_easy_cleanup(curl);
break
;
}
catch
(
json
::
exception
&
e
){
Logger
::
smf_n10
().
warn
(
"[send_msg_to_amf] Couldn't Parse json data from AMF"
);
}
numRetries
++
;
}
else
{
Logger
::
smf_n10
().
warn
(
"[send_msg_to_amf] Couldn't GET response from AMF, URL %s, retry ..."
,
url
.
c_str
());
//retry
numRetries
++
;
}
}
curl_easy_cleanup
(
curl
);
}
//TODO: process the response if neccessary
}
src/pgwc/smf_n11.hpp
0 → 100644
View file @
c2099bd2
/*
* 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 smf_n11.hpp
\author
\date 2019
\email:
*/
#ifndef FILE_SMF_N11_HPP_SEEN
#define FILE_SMF_N11_HPP_SEEN
#include "smf.h"
#include "3gpp_29.503.h"
#include "pgw_context.hpp"
#include <thread>
#include <map>
namespace
pgwc
{
class
smf_n11
{
private:
std
::
thread
::
id
thread_id
;
std
::
thread
thread
;
void
handle_receive_sm_data_notification
();
std
::
string
amf_addr
;
int
amf_port
;
public:
smf_n11
();
smf_n11
(
smf_n11
const
&
)
=
delete
;
void
operator
=
(
smf_n11
const
&
)
=
delete
;
void
send_msg_to_amf
(
std
::
shared_ptr
<
itti_n11_create_sm_context_response
>
sm_context_res
);
};
}
#endif
/* FILE_SMF_N11_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