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
c5f54b5f
Commit
c5f54b5f
authored
Aug 03, 2021
by
Niuhaiwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add upf data service
parent
622905a5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
283 additions
and
4 deletions
+283
-4
src/minimal-ws-server/CMakeLists.txt
src/minimal-ws-server/CMakeLists.txt
+2
-1
src/minimal-ws-server/minimal-ws-server.c
src/minimal-ws-server/minimal-ws-server.c
+151
-1
src/minimal-ws-server/!
src/minimal-ws-server/!
+123
-0
src/oai_smf/CMakeLists.txt
src/oai_smf/CMakeLists.txt
+2
-2
src/oai_smf/main.cpp
src/oai_smf/main.cpp
+5
-0
No files found.
src/minimal-ws-server/CMakeLists.txt
View file @
c5f54b5f
...
@@ -7,6 +7,7 @@ include(LwsCheckRequirements)
...
@@ -7,6 +7,7 @@ include(LwsCheckRequirements)
set
(
SAMP lws-minimal-ws-server
)
set
(
SAMP lws-minimal-ws-server
)
set
(
SRCS minimal-ws-server.c
)
set
(
SRCS minimal-ws-server.c
)
set
(
SRCS http_server.c
)
#set(requirements 1)
#set(requirements 1)
#require_lws_config(LWS_ROLE_WS 1 requirements)
#require_lws_config(LWS_ROLE_WS 1 requirements)
...
...
src/minimal-ws-server/minimal-ws-server.c
View file @
c5f54b5f
...
@@ -18,9 +18,28 @@
...
@@ -18,9 +18,28 @@
#include <string.h>
#include <string.h>
#include <signal.h>
#include <signal.h>
#include <event.h>
#include <event2/event.h>
#include <event2/http.h>
#include <event2/listener.h>
#include <event2/buffer.h>
#include <event2/util.h>
#include <event2/http_struct.h>
#include <event2/keyvalq_struct.h>
#include <event2/bufferevent.h>
#include <event2/bufferevent_compat.h>
#include <event2/http_compat.h>
//#include "cjson/cJSON.h"
#define HTTP_BUF 1024
volatile
int
g_force_exit
=
0
;
#define LWS_PLUGIN_STATIC
#define LWS_PLUGIN_STATIC
#include "protocol_lws_minimal.c"
#include "protocol_lws_minimal.c"
static
struct
lws_protocols
protocols
[]
=
{
static
struct
lws_protocols
protocols
[]
=
{
{
"http"
,
lws_callback_http_dummy
,
0
,
0
,
0
,
NULL
,
0
},
{
"http"
,
lws_callback_http_dummy
,
0
,
0
,
0
,
NULL
,
0
},
LWS_PLUGIN_PROTOCOL_MINIMAL
,
LWS_PLUGIN_PROTOCOL_MINIMAL
,
...
@@ -123,3 +142,134 @@ int ws_thread(int argc, const char **argv)
...
@@ -123,3 +142,134 @@ int ws_thread(int argc, const char **argv)
int
ret
=
pthread_create
(
&
tids
,
NULL
,
ws_server
,
NULL
);
int
ret
=
pthread_create
(
&
tids
,
NULL
,
ws_server
,
NULL
);
printf
(
"pthread_create error: error_code= %d
\n
"
,
ret
);
printf
(
"pthread_create error: error_code= %d
\n
"
,
ret
);
}
}
//curl -X POST --data "{\"ueip_s\": [{ \"ue_ip\":\"192.169.0.3\"},{ \"ue_ip\":\"192.169.0.4\"},{ \"ue_ip\":\"192.169.0.5\"}]}" http://192.168.2.142:8081/upf/v1/subscriptions/get_traffic_by_ueip
static
void
get_traffic_by_ueip_cb
(
struct
evhttp_request
*
req
,
void
*
arg
)
{
printf
(
"begin...
\n
"
);
//struct evkeyvalq *headers;
//struct evkeyval *header;
struct
evbuffer
*
buf
;
struct
evbuffer
*
retbuff
=
NULL
;
//cJSON * reqRoot = NULL;
char
jsonStr
[
HTTP_BUF
]
=
{
0
};
#if 0
if(EVHTTP_REQ_POST != evhttp_request_get_command(req))
{
clib_upf_debug(um_http->log_fd,"http method not post\n");
return ;
}
headers = evhttp_request_get_input_headers(req);
for (header = headers->tqh_first; header; header = header->next.tqe_next)
{
clib_upf_debug(um_http->log_fd, "%s:%s\n", header->key, header->value);
}
#endif
buf
=
evhttp_request_get_input_buffer
(
req
);
while
(
evbuffer_get_length
(
buf
))
{
int
n
;
n
=
evbuffer_remove
(
buf
,
jsonStr
,
sizeof
(
jsonStr
));
if
(
n
<=
0
)
printf
(
" req data len is 0"
);
//(void) fwrite(cbuf, 1, n, stdout);
}
#if 0
reqRoot = cJSON_Parse(jsonStr);
if (!reqRoot)
{
printf("Error before: [%s]\n",cJSON_GetErrorPtr());
}
else
{
printf("req:%s\n\n", cJSON_PrintUnformatted(reqRoot));
}
#endif
// cJSON_Delete(reqRoot);
//char *resp_Data = "recv data\n";
retbuff
=
evbuffer_new
();
if
(
!
retbuff
)
{
printf
(
"%s
\n
"
,
"retbuff is NULL."
);
goto
ERROR
;
}
evbuffer_add
(
retbuff
,
jsonStr
,
strlen
(
jsonStr
));
evhttp_send_reply
(
req
,
200
,
"OK"
,
retbuff
);
printf
(
"send http 200 ok len:%d, jsonstr:%s
\n
"
,
strlen
(
jsonStr
),
jsonStr
);
update_client
(
strlen
(
jsonStr
),
jsonStr
);
//websocket_client_send_data(jsonStr, strlen(jsonStr));
printf
(
"end...
\n
"
);
ERROR:
if
(
retbuff
)
evbuffer_free
(
retbuff
);
}
void
*
http_server_thread_fn
(
void
*
arg
)
{
struct
event_base
*
base
=
NULL
;
struct
evhttp
*
http_server
=
NULL
;
char
*
http_addr
=
"192.168.199.235"
;
int
http_port
=
8081
;
/* Initialize the event library */
base
=
event_base_new
();
http_server
=
evhttp_new
(
base
);
if
(
!
http_server
)
{
printf
(
"%s:%d http server start failed
\n
"
,
http_addr
,
http_port
);
return
NULL
;
}
evhttp_bind_socket
(
http_server
,
http_addr
,
http_port
);
evhttp_set_cb
(
http_server
,
"/upf/v1/subscriptions/get_traffic_by_ueip"
,
get_traffic_by_ueip_cb
,
NULL
);
//Loop monitoring
event_base_dispatch
(
base
);
if
(
http_server
)
evhttp_free
(
http_server
);
if
(
base
)
event_base_free
(
base
);
return
NULL
;
}
int
run_http_server_thread
()
{
pthread_t
ntid
;
int
err
;
err
=
pthread_create
(
&
ntid
,
NULL
,
http_server_thread_fn
,
NULL
);
if
(
err
!=
0
)
{
printf
(
"can't create thread: %s"
,
strerror
(
err
));
return
-
1
;
}
//pthread_join(ntid, NULL);
return
0
;
}
int
http_service
()
{
printf
(
"http_service ..................
\n
"
);
run_http_server_thread
();
return
0
;
}
src/minimal-ws-server/!
0 → 100644
View file @
c5f54b5f
# $OpenBSD: sshd_config,v 1.101 2017/03/14 07:19:07 djm Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key
# Ciphers and keying
#RekeyLimit default none
# Logging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#PubkeyAuthentication yes
# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
# override default of no subsystems
Subsystem sftp /usr/lib/openssh/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
PermitRootLogin yes
src/oai_smf/CMakeLists.txt
View file @
c5f54b5f
...
@@ -319,5 +319,5 @@ IF(STATIC_LINKING)
...
@@ -319,5 +319,5 @@ IF(STATIC_LINKING)
ENDIF
(
STATIC_LINKING
)
ENDIF
(
STATIC_LINKING
)
target_link_libraries
(
smf
${
ASAN
}
target_link_libraries
(
smf
${
ASAN
}
-Wl,--start-group CN_UTILS SMF UDP PFCP 3GPP_COMMON_TYPES SMF_API -lnettle
${
NETTLE_LIBRARIES
}
${
CRYPTO_LIBRARIES
}
-lnghttp2_asio -lboost_system -lboost_thread -lssl -lcrypto NAS gflags glog dl double-conversion folly -Wl,--end-group pthread m rt config++ event boost_system pistache curl WSSERVER -lwebsockets
)
-Wl,--start-group CN_UTILS SMF UDP PFCP 3GPP_COMMON_TYPES SMF_API -lnettle
${
NETTLE_LIBRARIES
}
${
CRYPTO_LIBRARIES
}
-lnghttp2_asio -lboost_system -lboost_thread -lssl -lcrypto NAS gflags glog dl double-conversion folly -Wl,--end-group pthread m rt config++ event boost_system pistache curl WSSERVER -lwebsockets
-levent
)
src/oai_smf/main.cpp
View file @
c5f54b5f
...
@@ -91,6 +91,10 @@ void my_app_signal_handler(int s) {
...
@@ -91,6 +91,10 @@ void my_app_signal_handler(int s) {
exit
(
0
);
exit
(
0
);
}
}
extern
"C"
{
void
http_service
();
}
extern
"C"
{
extern
"C"
{
int
ws_thread
();
int
ws_thread
();
}
}
...
@@ -109,6 +113,7 @@ int main(int argc, char** argv) {
...
@@ -109,6 +113,7 @@ int main(int argc, char** argv) {
Logger
::
smf_app
().
startup
(
"Options parsed"
);
Logger
::
smf_app
().
startup
(
"Options parsed"
);
ws_thread
();
ws_thread
();
http_service
();
struct
sigaction
sigIntHandler
;
struct
sigaction
sigIntHandler
;
sigIntHandler
.
sa_handler
=
my_app_signal_handler
;
sigIntHandler
.
sa_handler
=
my_app_signal_handler
;
...
...
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