Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-AMF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
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-AMF
Commits
2026e6ea
Commit
2026e6ea
authored
May 24, 2021
by
liuyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change mothed .c_str() ,modify gnb_context model
parent
21860716
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
300 additions
and
5 deletions
+300
-5
etc/etc_amf_openxg.conf
etc/etc_amf_openxg.conf
+1
-1
qqq.pcap
qqq.pcap
+0
-0
src/amf-app/amf_app.cpp
src/amf-app/amf_app.cpp
+32
-1
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+108
-1
src/amf-app/amf_n2.cpp
src/amf-app/amf_n2.cpp
+154
-1
src/amf-app/amf_n2.hpp
src/amf-app/amf_n2.hpp
+5
-0
src/oai-amf/main.cpp
src/oai-amf/main.cpp
+0
-1
No files found.
etc/etc_amf_openxg.conf
View file @
2026e6ea
...
...
@@ -74,7 +74,7 @@ AMF =
PORT
=
8282
;
# YOUR NETWORK CONFIG HERE
SMF_INSTANCES_POOL
= (
{
SMF_INSTANCE_ID
=
1
;
IPV4_ADDRESS
=
"
192.168.122.197
"
;
PORT
=
"8889"
;
VERSION
=
"v2"
;
SELECTED
=
"true"
},
# YOUR SMF CONFIG HERE
{
SMF_INSTANCE_ID
=
1
;
IPV4_ADDRESS
=
"
192.168.70.133
"
;
PORT
=
"8889"
;
VERSION
=
"v2"
;
SELECTED
=
"true"
},
# YOUR SMF CONFIG HERE
{
SMF_INSTANCE_ID
=
2
;
IPV4_ADDRESS
=
"192.168.122.2"
;
PORT
=
"80"
;
VERSION
=
"v1"
;
SELECTED
=
"false"
}
# YOUR SMF CONFIG HERE
);
};
...
...
qqq.pcap
0 → 100644
View file @
2026e6ea
File added
src/amf-app/amf_app.cpp
View file @
2026e6ea
...
...
@@ -32,7 +32,7 @@
#include <iostream>
#include <cstdlib>
#include "itti.hpp"
#include <nlohmann/json.hpp>
#include "ngap_app.hpp"
#include "amf_config.hpp"
#include "amf_n2.hpp"
...
...
@@ -254,6 +254,37 @@ void amf_app::handle_itti_message(itti_nas_signalling_establishment_request &itt
if
(
is_guti_valid
)
{
itti_n1_msg
->
guti
=
guti
;
}
std
::
string
udsf_url
=
"http://10.28.234.76:8081/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"ue_context/records/"
)
+
ue_context_key
;
nlohmann
::
json
udsf_ue_context
;
udsf_ue_context
[
"meta"
]
[
"tags"
]
=
{
{
"record_id"
,
nlohmann
::
json
::
array
({
ue_context_key
})},
{
"from_nf_ID"
,
nlohmann
::
json
::
array
({
"AMF_1234"
})}
}
;
udsf_ue_context
[
"blocks"
]
=
nlohmann
::
json
::
array
({
nlohmann
::
json
::
object
({
{
"ran_ue_ngap_id"
,
to_string
(
uc
.
get
()
->
ran_ue_ngap_id
)},
{
"amf_ue_ngap_id"
,
to_string
(
uc
.
get
()
->
amf_ue_ngap_id
)},
{
"isUeContextRequest"
,
to_string
(
uc
.
get
()
->
isUeContextRequest
)},
{
"rrc_estb_cause"
,
to_string
(
uc
.
get
()
->
rrc_estb_cause
)},
{
"cgi"
,
nlohmann
::
json
::
object
({
{
"mcc"
,
uc
.
get
()
->
cgi
.
mcc
},
{
"mnc"
,
uc
.
get
()
->
cgi
.
mnc
},
{
"nrCellID"
,
to_string
(
uc
.
get
()
->
cgi
.
nrCellID
)},
})
},
{
"tai"
,
nlohmann
::
json
::
object
({
{
"mcc"
,
uc
.
get
()
->
tai
.
mcc
},
{
"mnc"
,
uc
.
get
()
->
tai
.
mnc
},
{
"tac"
,
to_string
(
uc
.
get
()
->
tai
.
tac
)},
})
}
})
});
std
::
string
json_part
=
udsf_ue_context
.
dump
();
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
json_part
,
"PUT"
);
std
::
shared_ptr
<
itti_uplink_nas_data_ind
>
i
=
std
::
shared_ptr
<
itti_uplink_nas_data_ind
>
(
itti_n1_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
...
...
src/amf-app/amf_n1.cpp
View file @
2026e6ea
This diff is collapsed.
Click to expand it.
src/amf-app/amf_n2.cpp
View file @
2026e6ea
...
...
@@ -27,7 +27,7 @@
*/
#include "amf_n2.hpp"
#include <curl/curl.h>
#include "amf_n1.hpp"
#include "amf_n11.hpp"
#include "amf_app.hpp"
...
...
@@ -282,8 +282,136 @@ void amf_n2::handle_itti_message(itti_ng_setup_request &itti_msg) {
Logger
::
amf_n2
().
debug
(
"gNB with gNB_id 0x%x, assoc_id %d has been attached to AMF"
,
gc
.
get
()
->
globalRanNodeId
,
itti_msg
.
assoc_id
);
stacs
.
gNB_connected
+=
1
;
stacs
.
gnbs
.
push_back
(
gnbItem
);
//TODO dongtai huode
std
::
string
udsf_url
=
"http://10.28.234.76:8081/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"gnb_context/records/"
)
+
std
::
to_string
(
itti_msg
.
assoc_id
)
;
nlohmann
::
json
udsf_gnb_context
;
udsf_gnb_context
[
"meta"
]
[
"tags"
]
=
{
{
"RECORD_ID"
,
nlohmann
::
json
::
array
({
to_string
(
itti_msg
.
assoc_id
)})},
{
"from_nf_ID"
,
nlohmann
::
json
::
array
({
"AMF_1234"
})}
}
;
udsf_gnb_context
[
"blocks"
]
=
nlohmann
::
json
::
array
({
{{
"Content-ID"
,
"sctp_assoc_id"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
itti_msg
.
assoc_id
)}},
{{
"Content-ID"
,
"outstreams"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
gc
.
get
()
->
outstreams
)}},
{{
"Content-ID"
,
"instreams"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
gc
.
get
()
->
instreams
)}},
{{
"Content-ID"
,
"next_sctp_stream"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
gc
.
get
()
->
next_sctp_stream
)}},
{{
"Content-ID"
,
"ng_state"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
gc
.
get
()
->
ng_state
)}},
{{
"Content-ID"
,
"globalRanNodeId"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
gc
->
globalRanNodeId
)}},
{{
"Content-ID"
,
"gnb_name"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
gc
->
gnb_name
}},
{{
"Content-ID"
,
"s_ta_list"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
"haimeizuo"
}},
{{
"Content-ID"
,
"mcc"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
gnbItem
.
mcc
}},
{{
"Content-ID"
,
"mnc"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
gnbItem
.
mnc
}},
{{
"Content-ID"
,
"tac"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
gnbItem
.
tac
)}},
{{
"Content-ID"
,
"plmn_list"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
" haimeizuo"
}}
});
std
::
string
json_part
=
udsf_gnb_context
.
dump
();
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
json_part
,
"PUT"
);
return
;
}
std
::
size_t
callback_udsf
(
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
amf_n2
::
curl_http_client_udsf
(
std
::
string
remoteUrl
,
std
::
string
jsonData
,
std
::
string
http_mothed
)
{
printf
(
"使用http发送到udsf
\n
"
);
// std::string ngapmsg;
// octet_stream_2_hex_stream((uint8_t*) bdata(payload), blength(payload), ngapmsg);
// Logger::sctp().debug(
// "[Assoc ID %d] Sending buffer %p of %d bytes on stream %d,ngapmsg length %d ",
// assoc_id, bdata(payload), blength(payload), stream,ngapmsg.length());
// nlohmann::json json_data = {};
// json_data["n2_data"] = ngapmsg;
Logger
::
sctp
().
debug
(
"Send to UDSF , UDSF URL %s"
,
remoteUrl
.
c_str
());
//std::string body = json_data.dump();
// Logger::sctp().debug(
// "Send N2 message to PLUGIN , msg body: \n %s", body.c_str());
curl_global_init
(
CURL_GLOBAL_ALL
);
CURL
*
curl
=
curl
=
curl_easy_init
();
if
(
curl
)
{
CURLcode
res
=
{};
struct
curl_slist
*
headers
=
nullptr
;
// std::string content_type = "content-type: multipart/related; boundary=" +
// std::string(CURL_MIME_BOUNDARY);
// headers = curl_slist_append(headers, content_type.c_str());
headers
=
curl_slist_append
(
headers
,
"content-type: application/json"
);
//headers = curl_slist_append(headers, "Content-length: 0");
curl_easy_setopt
(
curl
,
CURLOPT_HTTPHEADER
,
headers
);
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
remoteUrl
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_HTTPGET
,
1
);
curl_easy_setopt
(
curl
,
CURLOPT_CUSTOMREQUEST
,
http_mothed
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
UDSF_CURL_TIMEOUT_MS
);
// Response information.
long
httpCode
=
{
0
};
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
//std::unique_ptr<std::string> httpHeaderData(new std::string());
// Hook up data handling function.
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
&
callback_udsf
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
httpData
.
get
());
// curl_easy_setopt(curl, CURLOPT_HEADERDATA, httpHeaderData.get());
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDSIZE
,
jsonData
.
length
());
//curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body_data);
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDS
,
jsonData
.
c_str
());
res
=
curl_easy_perform
(
curl
);
curl_easy_getinfo
(
curl
,
CURLINFO_RESPONSE_CODE
,
&
httpCode
);
// std::string response = *httpData.get();
// Logger::amf_n2().debug("response from udsf = %s ",response);
Logger
::
amf_n2
().
debug
(
"Send message to UDSF, response from UDSF, HTTP Code: %d"
,
httpCode
);
if
(
static_cast
<
http_response_codes_e
>
(
httpCode
)
==
http_response_codes_e
::
HTTP_RESPONSE_CODE_0
)
{
Logger
::
sctp
().
info
(
"Cannot get response when calling %s"
,
remoteUrl
.
c_str
());
// free curl before returning
// try {
// response_data = nlohmann::json::parse(json_data_response);
// } catch (nlohmann::json::exception &e) {
// Logger::amf_n11().warn("Could not get Json content from the response");
// //Set the default Cause
// response_data["error"]["cause"] = "504 Gateway Timeout";
// }
// Logger::amf_n2().debug("Get response with jsonData: %s", json_data_response.c_str());
curl_slist_free_all
(
headers
);
curl_easy_cleanup
(
curl
);
return
;
}
if
(
static_cast
<
http_response_codes_e
>
(
httpCode
)
==
http_response_codes_e
::
HTTP_RESPONSE_CODE_200_OK
)
{
Logger
::
sctp
().
info
(
"sending successful when calling %s"
,
remoteUrl
.
c_str
());
curl_slist_free_all
(
headers
);
curl_easy_cleanup
(
curl
);
return
;
}
if
(
static_cast
<
http_response_codes_e
>
(
httpCode
)
==
http_response_codes_e
::
HTTP_RESPONSE_CODE_201_CREATED
)
{
Logger
::
sctp
().
info
(
"sending successful when calling %s"
,
remoteUrl
.
c_str
());
curl_slist_free_all
(
headers
);
curl_easy_cleanup
(
curl
);
return
;
}
curl_global_cleanup
();
}
}
//------------------------------------------------------------------------------
//INITIAL_UE_MESSAGE Handler
...
...
@@ -294,6 +422,9 @@ void amf_n2::handle_itti_message(itti_initial_ue_message &init_ue_msg) {
//check the gNB context on which this UE is attached with assoc_id
itti_nas_signalling_establishment_request
*
itti_msg
=
new
itti_nas_signalling_establishment_request
(
TASK_AMF_N2
,
TASK_AMF_APP
);
//get gnb_context from udsf.200 ok gnb_context is exist
std
::
string
udsf_url
=
"http://10.28.234.76:8081/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"gnb_context/records/"
)
+
std
::
to_string
(
init_ue_msg
.
assoc_id
)
;
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
);
if
(
!
is_assoc_id_2_gnb_context
(
init_ue_msg
.
assoc_id
))
{
Logger
::
amf_n2
().
error
(
"No existing gNG context with assoc_id (%d)"
,
init_ue_msg
.
assoc_id
);
...
...
@@ -379,6 +510,28 @@ void amf_n2::handle_itti_message(itti_initial_ue_message &init_ue_msg) {
}
itti_msg
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
-
1
;
//send udsf to storage us_ngap_context recordid=ran+ue_ngap_id
std
::
string
udsf_put_url
=
"http://10.28.234.76:8081/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"ue_ngap_context/records/"
)
+
std
::
to_string
(
itti_msg
->
ran_ue_ngap_id
)
;
nlohmann
::
json
udsf_ue_ngap_context
;
udsf_ue_ngap_context
[
"meta"
]
[
"tags"
]
=
{
{
"record_id"
,
nlohmann
::
json
::
array
({
to_string
(
unc
.
get
()
->
ran_ue_ngap_id
)})},
{
"from_nf_ID"
,
nlohmann
::
json
::
array
({
"AMF_1234"
})}
}
;
udsf_ue_ngap_context
[
"blocks"
]
=
nlohmann
::
json
::
array
({
nlohmann
::
json
::
object
({
{
"ran_ue_ngap_id"
,
to_string
(
itti_msg
->
ran_ue_ngap_id
)},
{
"amf_ue_ngap_id"
,
""
},
{
"sctp_stream_recv"
,
to_string
(
unc
.
get
()
->
sctp_stream_recv
)},
{
"sctp_stream_send"
,
to_string
(
unc
.
get
()
->
sctp_stream_send
)},
{
"gnb_assoc_id"
,
to_string
(
unc
.
get
()
->
gnb_assoc_id
)},
{
"s_tmsi_5g"
,
""
},
{
"ng_ue_state"
,
""
}
})
});
std
::
string
json_part
=
udsf_ue_ngap_context
.
dump
();
amf_n2_inst
->
curl_http_client_udsf
(
udsf_put_url
,
json_part
,
"PUT"
);
std
::
shared_ptr
<
itti_nas_signalling_establishment_request
>
i
=
std
::
shared_ptr
<
itti_nas_signalling_establishment_request
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
...
...
src/amf-app/amf_n2.hpp
View file @
2026e6ea
...
...
@@ -34,7 +34,9 @@
#include "ue_ngap_context.hpp"
#include "amf.hpp"
namespace
amf_application
{
#define UDSF_CURL_TIMEOUT_MS 100L
class
amf_n2
:
public
ngap
::
ngap_app
{
public:
...
...
@@ -51,6 +53,9 @@ class amf_n2 : public ngap::ngap_app{
void
handle_itti_message
(
itti_ue_radio_capability_indication
&
itti_msg
);
bool
verifyPlmn
(
std
::
vector
<
SupportedItem_t
>
list
);
std
::
vector
<
SupportedItem_t
>
get_common_plmn
(
std
::
vector
<
SupportedItem_t
>
list
);
void
curl_http_client_udsf
(
std
::
string
remoteUri
,
std
::
string
jsonData
,
std
::
string
http_mothed
)
;
private:
std
::
map
<
uint32_t
,
std
::
shared_ptr
<
ue_ngap_context
>>
ranid2uecontext
;
// ran ue ngap id
mutable
std
::
shared_mutex
m_ranid2uecontext
;
...
...
src/oai-amf/main.cpp
View file @
2026e6ea
...
...
@@ -50,7 +50,6 @@ extern void ue_gnb_simulator();
using
namespace
config
;
using
namespace
amf_application
;
amf_config
amf_cfg
;
amf_modules
modules
;
itti_mw
*
itti_inst
=
nullptr
;
...
...
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