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
fd73dd63
Commit
fd73dd63
authored
May 31, 2021
by
liuyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add gnb_context from json and test ok
parent
7d22ef45
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
266 additions
and
134 deletions
+266
-134
build/scripts/oai_db.sql
build/scripts/oai_db.sql
+2
-1
src/amf-app/amf_n2.cpp
src/amf-app/amf_n2.cpp
+103
-131
src/amf-app/amf_n2.hpp
src/amf-app/amf_n2.hpp
+1
-1
src/contexts/CMakeLists.txt
src/contexts/CMakeLists.txt
+1
-0
src/contexts/gNB_context.cpp
src/contexts/gNB_context.cpp
+150
-0
src/contexts/gNB_context.hpp
src/contexts/gNB_context.hpp
+8
-1
src/sctp/sctp_server.cpp
src/sctp/sctp_server.cpp
+1
-0
No files found.
build/scripts/oai_db.sql
View file @
fd73dd63
This diff is collapsed.
Click to expand it.
src/amf-app/amf_n2.cpp
View file @
fd73dd63
This diff is collapsed.
Click to expand it.
src/amf-app/amf_n2.hpp
View file @
fd73dd63
...
@@ -54,7 +54,7 @@ class amf_n2 : public ngap::ngap_app{
...
@@ -54,7 +54,7 @@ class amf_n2 : public ngap::ngap_app{
bool
verifyPlmn
(
std
::
vector
<
SupportedItem_t
>
list
);
bool
verifyPlmn
(
std
::
vector
<
SupportedItem_t
>
list
);
std
::
vector
<
SupportedItem_t
>
get_common_plmn
(
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
,
nlohmann
::
json
&
udsf_response
)
;
bool
curl_http_client_udsf
(
std
::
string
remoteUri
,
std
::
string
jsonData
,
std
::
string
http_mothed
,
nlohmann
::
json
&
udsf_response
)
;
private:
private:
std
::
map
<
uint32_t
,
std
::
shared_ptr
<
ue_ngap_context
>>
ranid2uecontext
;
// ran ue ngap id
std
::
map
<
uint32_t
,
std
::
shared_ptr
<
ue_ngap_context
>>
ranid2uecontext
;
// ran ue ngap id
...
...
src/contexts/CMakeLists.txt
View file @
fd73dd63
...
@@ -35,6 +35,7 @@ include_directories(${SRC_TOP_DIR}/secu_algorithms/5gaka)
...
@@ -35,6 +35,7 @@ include_directories(${SRC_TOP_DIR}/secu_algorithms/5gaka)
include_directories
(
${
SRC_TOP_DIR
}
/secu_algorithms/nas_enc_int
)
include_directories
(
${
SRC_TOP_DIR
}
/secu_algorithms/nas_enc_int
)
include_directories
(
${
SRC_TOP_DIR
}
/utils
)
include_directories
(
${
SRC_TOP_DIR
}
/utils
)
include_directories
(
${
SRC_TOP_DIR
}
/utils/bstr
)
include_directories
(
${
SRC_TOP_DIR
}
/utils/bstr
)
include_directories
(
${
SRC_TOP_DIR
}
/sbi/amf_server/model
)
add_library
(
CONTEXTS STATIC
add_library
(
CONTEXTS STATIC
${
CMAKE_CURRENT_SOURCE_DIR
}
/gNB_context.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/gNB_context.cpp
...
...
src/contexts/gNB_context.cpp
View file @
fd73dd63
...
@@ -27,4 +27,154 @@
...
@@ -27,4 +27,154 @@
*/
*/
#include "gNB_context.hpp"
#include "gNB_context.hpp"
#include <nlohmann/json.hpp>
#include "logger.hpp"
#include "Record.h"
using
namespace
std
;
using
namespace
oai
::
amf
::
model
;
bool
get_value_string
(
const
nlohmann
::
json
&
j
,
const
string
&
nm
,
string
&
value
){
Record
record
;
nlohmann
::
json
::
parse
(
j
.
dump
()).
get_to
(
record
);
std
::
set
<
nlohmann
::
json
>
block_set
=
record
.
getBlocks
();
std
::
set
<
nlohmann
::
json
>::
iterator
it_block
;
for
(
it_block
=
block_set
.
begin
();
it_block
!=
block_set
.
end
();)
{
if
(
it_block
->
at
(
"Content-ID"
)
==
nm
)
{
//if((it_block->at("Content-Type") == "varhcar")
value
=
it_block
->
at
(
"content"
);
return
true
;
}
block_set
.
erase
(
it_block
++
);
}
return
false
;
}
// bool get_value_int(const nlohmann::json &j, const string & nm, long &value){
// Record record;
// nlohmann::json::parse(j.dump()).get_to(record);
// std::set<nlohmann::json> block_set = record.getBlocks();
// std::set<nlohmann::json>::iterator it_block;
// for(it_block=block_set.begin();it_block!=block_set.end();)
// {
// if(it_block->at("Content-ID") == nm)
// {
// string s = it_block->at("content");
// value = atoi(s.c_str());
// return true;
// }
// block_set.erase(it_block++);
// }
// return false;
// }
long
gnb_context
::
gnb_context_globalRanNodeId_from_json
(
nlohmann
::
json
j
)
{
Record
record
;
nlohmann
::
json
::
parse
(
j
.
dump
()).
get_to
(
record
);
std
::
set
<
nlohmann
::
json
>
block_set
=
record
.
getBlocks
();
std
::
set
<
nlohmann
::
json
>::
iterator
it_block
;
for
(
it_block
=
block_set
.
begin
();
it_block
!=
block_set
.
end
();)
{
if
(
it_block
->
at
(
"Content-ID"
)
==
"globalRanNodeId"
)
{
string
s
=
it_block
->
at
(
"content"
);
return
atoi
(
s
.
c_str
());
}
block_set
.
erase
(
it_block
++
);
}
Logger
::
amf_server
().
error
(
"get_value from json is error"
);
// long a;
// if(!get_value_int(j,"globalRanNodeId",a))
// Logger::amf_server().error("get_value from json is error");
// return a;
}
std
::
string
gnb_context
::
gnb_context_gnb_name_from_json
(
nlohmann
::
json
j
)
{
Record
record
;
nlohmann
::
json
::
parse
(
j
.
dump
()).
get_to
(
record
);
std
::
set
<
nlohmann
::
json
>
block_set
=
record
.
getBlocks
();
std
::
set
<
nlohmann
::
json
>::
iterator
it_block
;
for
(
it_block
=
block_set
.
begin
();
it_block
!=
block_set
.
end
();)
{
if
(
it_block
->
at
(
"Content-ID"
)
==
"gnb_name"
)
{
string
s
=
it_block
->
at
(
"content"
);
return
s
;
}
block_set
.
erase
(
it_block
++
);
}
Logger
::
amf_server
().
error
(
"get_value from json is error"
);
}
int
gnb_context
::
gnb_context_ng_state_from_json
(
nlohmann
::
json
j
)
{
Record
record
;
nlohmann
::
json
::
parse
(
j
.
dump
()).
get_to
(
record
);
std
::
set
<
nlohmann
::
json
>
block_set
=
record
.
getBlocks
();
std
::
set
<
nlohmann
::
json
>::
iterator
it_block
;
for
(
it_block
=
block_set
.
begin
();
it_block
!=
block_set
.
end
();)
{
if
(
it_block
->
at
(
"Content-ID"
)
==
"ng_state"
)
{
string
s
=
it_block
->
at
(
"content"
);
return
atoi
(
s
.
c_str
());
}
block_set
.
erase
(
it_block
++
);
}
Logger
::
amf_server
().
error
(
"get_value from json is error"
);
}
sctp_stream_id_t
gnb_context
::
gnb_context_next_sctp_stream_from_json
(
nlohmann
::
json
j
)
{
Record
record
;
nlohmann
::
json
::
parse
(
j
.
dump
()).
get_to
(
record
);
std
::
set
<
nlohmann
::
json
>
block_set
=
record
.
getBlocks
();
std
::
set
<
nlohmann
::
json
>::
iterator
it_block
;
for
(
it_block
=
block_set
.
begin
();
it_block
!=
block_set
.
end
();)
{
if
(
it_block
->
at
(
"Content-ID"
)
==
"next_sctp_stream"
)
{
string
s
=
it_block
->
at
(
"content"
);
return
atoi
(
s
.
c_str
());
}
block_set
.
erase
(
it_block
++
);
}
Logger
::
amf_server
().
error
(
"get_value from json is error"
);
}
sctp_stream_id_t
gnb_context
::
gnb_context_instreams_from_json
(
nlohmann
::
json
j
)
{
Record
record
;
nlohmann
::
json
::
parse
(
j
.
dump
()).
get_to
(
record
);
std
::
set
<
nlohmann
::
json
>
block_set
=
record
.
getBlocks
();
std
::
set
<
nlohmann
::
json
>::
iterator
it_block
;
for
(
it_block
=
block_set
.
begin
();
it_block
!=
block_set
.
end
();)
{
if
(
it_block
->
at
(
"Content-ID"
)
==
"instreams"
)
{
string
s
=
it_block
->
at
(
"content"
);
return
atoi
(
s
.
c_str
());
}
block_set
.
erase
(
it_block
++
);
}
Logger
::
amf_server
().
error
(
"get_value from json is error"
);
}
bool
gnb_context
::
gnb_context_from_json
(
nlohmann
::
json
j
)
{
//std::shared_ptr<gnb_context> gc1;
globalRanNodeId
=
gnb_context_globalRanNodeId_from_json
(
j
);
gnb_name
=
gnb_context_gnb_name_from_json
(
j
);
ng_state
=
amf_ng_gnb_state_s
(
gnb_context_ng_state_from_json
(
j
));
next_sctp_stream
=
gnb_context_next_sctp_stream_from_json
(
j
);
next_sctp_stream
=
gnb_context_instreams_from_json
(
j
);
// printf("gnbname-%s\n",gnb_name.c_str());
// printf("globalgnbid-%d\n",globalRanNodeId);
// printf("next stream-%d\n",next_sctp_stream);
return
true
;
}
\ No newline at end of file
src/contexts/gNB_context.hpp
View file @
fd73dd63
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
#include <stdint.h>
#include <stdint.h>
#include <string>
#include <string>
#include <vector>
#include <vector>
#include <nlohmann/json.hpp>
#include "sctp_server.hpp"
#include "sctp_server.hpp"
#include "NgapIEsStruct.hpp"
#include "NgapIEsStruct.hpp"
...
@@ -43,6 +43,7 @@ extern "C" {
...
@@ -43,6 +43,7 @@ extern "C" {
using
namespace
sctp
;
using
namespace
sctp
;
using
namespace
ngap
;
using
namespace
ngap
;
using
namespace
std
;
enum
amf_ng_gnb_state_s
{
enum
amf_ng_gnb_state_s
{
NGAP_INIT
,
NGAP_INIT
,
...
@@ -52,6 +53,12 @@ enum amf_ng_gnb_state_s {
...
@@ -52,6 +53,12 @@ enum amf_ng_gnb_state_s {
};
};
class
gnb_context
{
class
gnb_context
{
public:
public:
long
gnb_context_globalRanNodeId_from_json
(
nlohmann
::
json
j
);
std
::
string
gnb_context_gnb_name_from_json
(
nlohmann
::
json
j
);
int
gnb_context_ng_state_from_json
(
nlohmann
::
json
j
);
sctp_stream_id_t
gnb_context_next_sctp_stream_from_json
(
nlohmann
::
json
j
);
sctp_stream_id_t
gnb_context_instreams_from_json
(
nlohmann
::
json
j
);
bool
gnb_context_from_json
(
nlohmann
::
json
j
);
enum
amf_ng_gnb_state_s
ng_state
;
enum
amf_ng_gnb_state_s
ng_state
;
std
::
string
gnb_name
;
std
::
string
gnb_name
;
...
...
src/sctp/sctp_server.cpp
View file @
fd73dd63
...
@@ -426,6 +426,7 @@ void sctp_server::curl_http_client_Plugin(sctp_assoc_id_t assoc_id, sctp_stream_
...
@@ -426,6 +426,7 @@ void sctp_server::curl_http_client_Plugin(sctp_assoc_id_t assoc_id, sctp_stream_
// std::string(CURL_MIME_BOUNDARY);
// std::string(CURL_MIME_BOUNDARY);
// headers = curl_slist_append(headers, content_type.c_str());
// headers = curl_slist_append(headers, content_type.c_str());
headers
=
curl_slist_append
(
headers
,
"content-type: application/json"
);
headers
=
curl_slist_append
(
headers
,
"content-type: application/json"
);
headers
=
curl_slist_append
(
headers
,
"Expect:"
);
curl_easy_setopt
(
curl
,
CURLOPT_HTTPHEADER
,
headers
);
curl_easy_setopt
(
curl
,
CURLOPT_HTTPHEADER
,
headers
);
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_HTTPGET
,
1
);
curl_easy_setopt
(
curl
,
CURLOPT_HTTPGET
,
1
);
...
...
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