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
6f4baad5
Commit
6f4baad5
authored
Jul 19, 2021
by
Fang-WANG
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notify ip ok, but can't support 2 nofity in a short time
parent
4455c072
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
62 additions
and
33 deletions
+62
-33
.gitignore
.gitignore
+3
-1
build/ext/json
build/ext/json
+1
-0
build/ext/nghttp2
build/ext/nghttp2
+1
-0
build/ext/pistache
build/ext/pistache
+1
-0
build/ext/spdlog
build/ext/spdlog
+1
-0
src/common/utils/3gpp_conversions.cpp
src/common/utils/3gpp_conversions.cpp
+5
-6
src/minimal-ws-server/mount-origin/index.html
src/minimal-ws-server/mount-origin/index.html
+2
-2
src/minimal-ws-server/protocol_lws_minimal.c
src/minimal-ws-server/protocol_lws_minimal.c
+27
-19
src/smf_app/smf_app.cpp
src/smf_app/smf_app.cpp
+21
-5
No files found.
.gitignore
View file @
6f4baad5
build/*
build/smf/build
build/log
src/minimal-ws-server/build/*
src/minimal-ws-server/build/*
.vscode
json
@
350ff4f7
Subproject commit 350ff4f7ced7c4117eae2fb93df02823c8021fcb
nghttp2
@
43ba3125
Subproject commit 43ba3125932c1d56addaeded2b7f62637af255cd
pistache
@
e18ed9ba
Subproject commit e18ed9baeb2145af6f9ea41246cf48054ffd9907
spdlog
@
a51b4856
Subproject commit a51b4856377a71f81b6d74b9af459305c4c644f8
src/common/utils/3gpp_conversions.cpp
View file @
6f4baad5
...
@@ -415,13 +415,12 @@ void xgpp_conv::data_notification_from_openapi(
...
@@ -415,13 +415,12 @@ void xgpp_conv::data_notification_from_openapi(
// Only support UPF for now
// Only support UPF for now
// if (nd.getNfProfile().getNfType() == "UPF")
// if (nd.getNfProfile().getNfType() == "UPF")
p
=
std
::
make_shared
<
smf
::
upf_profile
>
();
p
=
std
::
make_shared
<
smf
::
upf_profile
>
();
nlohmann
::
json
pj
=
{};
to_json
(
pj
,
nd
.
getNfProfile
());
p
.
get
()
->
from_json
(
pj
);
// nlohmann::json pj = {};
// to_json(pj, nd.getNfProfile());
// p.get()->from_json(pj);
p
.
get
()
->
set_nf_type
(
nd
.
getNfProfile
().
getNfType
());
p
.
get
()
->
set_nf_status
(
nd
.
getNfProfile
().
getNfStatus
());
dn_msg
.
set_profile
(
p
);
dn_msg
.
set_profile
(
p
);
}
}
...
...
src/minimal-ws-server/mount-origin/index.html
View file @
6f4baad5
...
@@ -11,8 +11,8 @@
...
@@ -11,8 +11,8 @@
Chat is sent to all browsers open on this page.
Chat is sent to all browsers open on this page.
<br>
<br>
<br>
<br>
<textarea
id=
r
readonly
cols=
4
0
rows=
10
></textarea><br>
<textarea
id=
r
readonly
cols=
20
0
rows=
10
></textarea><br>
<input
type=
"text"
id=
m
cols=
4
0
rows=
1
>
<input
type=
"text"
id=
m
cols=
20
0
rows=
1
>
<button
id=
b
>
Send
</button>
<button
id=
b
>
Send
</button>
</body>
</body>
</html>
</html>
...
...
src/minimal-ws-server/protocol_lws_minimal.c
View file @
6f4baad5
...
@@ -59,26 +59,29 @@ __minimal_destroy_message(void *_msg)
...
@@ -59,26 +59,29 @@ __minimal_destroy_message(void *_msg)
msg
->
len
=
0
;
msg
->
len
=
0
;
}
}
struct
per_vhost_data__minimal
*
first_vhd
=
NULL
;
static
int
notifying
=
0
;
struct
lws
*
wsi_client
=
NULL
;
int
update_client
(
int
len
,
const
char
*
payload
)
int
update_client
(
int
len
,
const
char
*
payload
)
{
{
lwsl_user
(
"update_client %d.
\n
"
,
len
);
char
sendArr
[
1000
];
first_vhd
->
amsg
.
len
=
len
;
if
(
notifying
!=
0
)
/* notice we over-allocate by LWS_PRE */
return
0
;
first_vhd
->
amsg
.
payload
=
malloc
(
LWS_PRE
+
len
);
if
(
len
>
1000
)
if
(
!
first_vhd
->
amsg
.
payload
)
{
return
0
;
lwsl_user
(
"OOM: dropping
\n
"
);
if
(
wsi_client
==
NULL
)
return
;
return
0
;
notifying
=
1
;
lwsl_user
(
"update_client size %d. %s.
\n
"
,
len
,
payload
);
memcpy
(
sendArr
+
LWS_PRE
,
payload
,
len
);
/* notice we allowed for LWS_PRE in the payload already */
int
m
=
lws_write
(
wsi_client
,
sendArr
+
LWS_PRE
,
len
,
LWS_WRITE_TEXT
);
if
(
m
<
len
)
{
lwsl_err
(
"ERROR %d writing to ws
\n
"
,
m
);
}
}
notifying
=
0
;
int
client_num
=
0
;
return
(
m
-
len
);
memcpy
((
char
*
)
first_vhd
->
amsg
.
payload
+
LWS_PRE
,
payload
,
len
);
lws_start_foreach_llp
(
struct
per_session_data__minimal
**
,
ppss
,
first_vhd
->
pss_list
)
{
lws_callback_on_writable
((
*
ppss
)
->
wsi
);
lwsl_user
(
"lws_callback_on_writable client %d.
\n
"
,
client_num
++
);
}
lws_end_foreach_llp
(
ppss
,
pss_list
);
}
}
static
int
static
int
...
@@ -95,30 +98,34 @@ callback_minimal(struct lws *wsi, enum lws_callback_reasons reason,
...
@@ -95,30 +98,34 @@ callback_minimal(struct lws *wsi, enum lws_callback_reasons reason,
switch
(
reason
)
{
switch
(
reason
)
{
case
LWS_CALLBACK_PROTOCOL_INIT
:
case
LWS_CALLBACK_PROTOCOL_INIT
:
lwsl_user
(
"LWS_CALLBACK_PROTOCOL_INIT
\n
"
);
vhd
=
lws_protocol_vh_priv_zalloc
(
lws_get_vhost
(
wsi
),
vhd
=
lws_protocol_vh_priv_zalloc
(
lws_get_vhost
(
wsi
),
lws_get_protocol
(
wsi
),
lws_get_protocol
(
wsi
),
sizeof
(
struct
per_vhost_data__minimal
));
sizeof
(
struct
per_vhost_data__minimal
));
vhd
->
context
=
lws_get_context
(
wsi
);
vhd
->
context
=
lws_get_context
(
wsi
);
vhd
->
protocol
=
lws_get_protocol
(
wsi
);
vhd
->
protocol
=
lws_get_protocol
(
wsi
);
vhd
->
vhost
=
lws_get_vhost
(
wsi
);
vhd
->
vhost
=
lws_get_vhost
(
wsi
);
first_vhd
=
vhd
;
break
;
break
;
case
LWS_CALLBACK_ESTABLISHED
:
case
LWS_CALLBACK_ESTABLISHED
:
lwsl_user
(
"LWS_CALLBACK_ESTABLISHED
\n
"
);
/* add ourselves to the list of live pss held in the vhd */
/* add ourselves to the list of live pss held in the vhd */
lws_ll_fwd_insert
(
pss
,
pss_list
,
vhd
->
pss_list
);
lws_ll_fwd_insert
(
pss
,
pss_list
,
vhd
->
pss_list
);
pss
->
wsi
=
wsi
;
pss
->
wsi
=
wsi
;
pss
->
last
=
vhd
->
current
;
pss
->
last
=
vhd
->
current
;
wsi_client
=
wsi
;
break
;
break
;
case
LWS_CALLBACK_CLOSED
:
case
LWS_CALLBACK_CLOSED
:
lwsl_user
(
"LWS_CALLBACK_CLOSED
\n
"
);
/* remove our closing pss from the list of live pss */
/* remove our closing pss from the list of live pss */
lws_ll_fwd_remove
(
struct
per_session_data__minimal
,
pss_list
,
lws_ll_fwd_remove
(
struct
per_session_data__minimal
,
pss_list
,
pss
,
vhd
->
pss_list
);
pss
,
vhd
->
pss_list
);
wsi_client
=
NULL
;
break
;
break
;
case
LWS_CALLBACK_SERVER_WRITEABLE
:
case
LWS_CALLBACK_SERVER_WRITEABLE
:
lwsl_user
(
"LWS_CALLBACK_SERVER_WRITEABLE len %d
"
,
vhd
->
amsg
.
len
);
lwsl_user
(
"LWS_CALLBACK_SERVER_WRITEABLE len %d
%p
\n
"
,
vhd
->
amsg
.
len
,
vhd
->
amsg
.
payload
);
if
(
!
vhd
->
amsg
.
payload
)
if
(
!
vhd
->
amsg
.
payload
)
break
;
break
;
...
@@ -137,6 +144,7 @@ callback_minimal(struct lws *wsi, enum lws_callback_reasons reason,
...
@@ -137,6 +144,7 @@ callback_minimal(struct lws *wsi, enum lws_callback_reasons reason,
break
;
break
;
case
LWS_CALLBACK_RECEIVE
:
case
LWS_CALLBACK_RECEIVE
:
lwsl_user
(
"LWS_CALLBACK_RECEIVE len %d
\n
"
,
vhd
->
amsg
.
len
);
if
(
vhd
->
amsg
.
payload
)
if
(
vhd
->
amsg
.
payload
)
__minimal_destroy_message
(
&
vhd
->
amsg
);
__minimal_destroy_message
(
&
vhd
->
amsg
);
...
...
src/smf_app/smf_app.cpp
View file @
6f4baad5
...
@@ -61,6 +61,7 @@
...
@@ -61,6 +61,7 @@
#include "smf_n4.hpp"
#include "smf_n4.hpp"
#include "smf_paa_dynamic.hpp"
#include "smf_paa_dynamic.hpp"
#include "string.hpp"
#include "string.hpp"
#include "../../build/ext/json/test/thirdparty/fifo_map/fifo_map.hpp"
extern
"C"
{
extern
"C"
{
#include "dynamic_memory_check.h"
#include "dynamic_memory_check.h"
...
@@ -68,6 +69,12 @@ extern "C" {
...
@@ -68,6 +69,12 @@ extern "C" {
}
}
using
namespace
smf
;
using
namespace
smf
;
using
namespace
nlohmann
;
template
<
class
K
,
class
V
,
class
dummy_compare
,
class
A
>
// A workaround to give to use fifo_map as map, we are just ignoring the 'less' compare
using
my_workaround_fifo_map
=
fifo_map
<
K
,
V
,
fifo_map_compare
<
K
>
,
A
>
;
using
my_json
=
basic_json
<
my_workaround_fifo_map
>
;
extern
util
::
async_shell_cmd
*
async_shell_cmd_inst
;
extern
util
::
async_shell_cmd
*
async_shell_cmd_inst
;
extern
smf_app
*
smf_app_inst
;
extern
smf_app
*
smf_app_inst
;
...
@@ -1292,12 +1299,21 @@ bool smf_app::handle_nf_status_notification(
...
@@ -1292,12 +1299,21 @@ bool smf_app::handle_nf_status_notification(
std
::
shared_ptr
<
nf_profile
>
profile
=
{};
std
::
shared_ptr
<
nf_profile
>
profile
=
{};
notification_msg
.
get_profile
(
profile
);
notification_msg
.
get_profile
(
profile
);
Logger
::
smf_app
().
debug
(
my_json
json_data
=
{};
"handle_nf_status_notification NF %s is %s !"
,
profile
.
get
()
->
get_nf_type
().
c_str
(),
event_type
.
c_str
()
);
json_data
[
"nfInstanceName"
]
=
profile
.
get
()
->
get_nf_instance_name
().
c_str
(
);
json_data
[
"nfEvent"
]
=
event_type
.
c_str
();
nlohmann
::
json
json_data
=
{}
;
json_data
[
"nfStatus"
]
=
profile
.
get
()
->
get_nf_status
().
c_str
()
;
json_data
[
"nf
Status"
]
=
event_type
.
c_str
();
json_data
[
"nf
InstanceId"
]
=
profile
.
get
()
->
get_nf_instance_id
()
.
c_str
();
json_data
[
"nfType"
]
=
profile
.
get
()
->
get_nf_type
().
c_str
();
json_data
[
"nfType"
]
=
profile
.
get
()
->
get_nf_type
().
c_str
();
json_data
[
"ipv4Addresses"
]
=
nlohmann
::
json
::
array
();
std
::
vector
<
struct
in_addr
>
nfIpv4Addresses
;
profile
.
get
()
->
get_nf_ipv4_addresses
(
nfIpv4Addresses
);
for
(
auto
address
:
nfIpv4Addresses
)
{
json_data
[
"ipv4Addresses"
].
push_back
(
inet_ntoa
(
address
));
}
Logger
::
smf_app
().
error
(
"json_data %s
\n
"
,
json_data
.
dump
().
c_str
());
update_client
(
json_data
.
dump
().
length
(),
json_data
.
dump
().
c_str
());
update_client
(
json_data
.
dump
().
length
(),
json_data
.
dump
().
c_str
());
return
true
;
return
true
;
}
}
...
...
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