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
7ca69347
Commit
7ca69347
authored
Feb 25, 2022
by
chen2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
核心网smf openxg-smf/v1/uemsg
parent
befb9620
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
218 additions
and
0 deletions
+218
-0
src/api-server/api/SmfToDataApi.cpp
src/api-server/api/SmfToDataApi.cpp
+54
-0
src/api-server/api/SmfToDataApi.h
src/api-server/api/SmfToDataApi.h
+42
-0
src/api-server/impl/SmfToDataApiImpl.cpp
src/api-server/impl/SmfToDataApiImpl.cpp
+62
-0
src/api-server/impl/SmfToDataApiImpl.h
src/api-server/impl/SmfToDataApiImpl.h
+53
-0
src/api-server/smf-api-server.cpp
src/api-server/smf-api-server.cpp
+2
-0
src/api-server/smf-api-server.h
src/api-server/smf-api-server.h
+5
-0
No files found.
src/api-server/api/SmfToDataApi.cpp
0 → 100755
View file @
7ca69347
#include "SmfToDataApi.h"
#include "Helpers.h"
#include "smf_config.hpp"
extern
smf
::
smf_config
smf_cfg
;
namespace
oai
{
namespace
smf_server
{
namespace
api
{
using
namespace
oai
::
smf_server
::
helpers
;
SmfToDataApi
::
SmfToDataApi
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
)
{
router
=
rtr
;
}
void
SmfToDataApi
::
init
()
{
setupRoutes
();
}
void
SmfToDataApi
::
setupRoutes
()
{
using
namespace
Pistache
::
Rest
;
//获取uemsg
Routes
::
Get
(
*
router
,
base
+
"/v1/uemsg/"
,
Routes
::
bind
(
&
SmfToDataApi
::
uemsg_get_am_data_handler
,
this
));
router
->
addCustomHandler
(
Routes
::
bind
(
&
SmfToDataApi
::
uemsg_default_handler
,
this
));
}
//获取uemsg
void
SmfToDataApi
::
uemsg_get_am_data_handler
(
const
Pistache
::
Rest
::
Request
&
request
,
Pistache
::
Http
::
ResponseWriter
response
)
{
try
{
this
->
uemsg_get_am_data
(
response
);
}
catch
(
nlohmann
::
detail
::
exception
&
e
)
{
//send a 400 error
response
.
send
(
Pistache
::
Http
::
Code
::
Bad_Request
,
e
.
what
());
return
;
}
catch
(
Pistache
::
Http
::
HttpError
&
e
)
{
response
.
send
(
static_cast
<
Pistache
::
Http
::
Code
>
(
e
.
code
()),
e
.
what
());
return
;
}
catch
(
std
::
exception
&
e
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Internal_Server_Error
,
e
.
what
());
return
;
}
}
void
SmfToDataApi
::
uemsg_default_handler
(
const
Pistache
::
Rest
::
Request
&
,
Pistache
::
Http
::
ResponseWriter
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Not_Found
,
"The requested method does not exist"
);
}
}
// namespace api
}
// namespace smf_server
}
// namespace oai
src/api-server/api/SmfToDataApi.h
0 → 100755
View file @
7ca69347
#ifndef SmfToDataApi_H_
#define SmfToDataApi_H_
#include <pistache/http.h>
#include <pistache/router.h>
#include <pistache/http_headers.h>
#include <pistache/optional.h>
namespace
oai
{
namespace
smf_server
{
namespace
api
{
class
SmfToDataApi
{
public:
SmfToDataApi
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
);
virtual
~
SmfToDataApi
()
{}
void
init
();
const
std
::
string
base
=
"/openxg-smf/"
;
private:
void
setupRoutes
();
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
router
;
//获取uemsg
void
uemsg_get_am_data_handler
(
const
Pistache
::
Rest
::
Request
&
request
,
Pistache
::
Http
::
ResponseWriter
response
);
void
uemsg_default_handler
(
const
Pistache
::
Rest
::
Request
&
request
,
Pistache
::
Http
::
ResponseWriter
response
);
virtual
void
uemsg_get_am_data
(
Pistache
::
Http
::
ResponseWriter
&
response
)
=
0
;
};
}
// namespace api
}
// namespace smf_server
}
// namespace oai
#endif
/* SmfToDataApi_H_ */
src/api-server/impl/SmfToDataApiImpl.cpp
0 → 100755
View file @
7ca69347
#include "SmfToDataApiImpl.h"
#include "logger.hpp"
#include <nlohmann/json.hpp>
#include<iostream>
#include<ctime>
#include<cstdlib>
#include<cstdio>
#include <vector>
#include <algorithm> //标准算法头文件
#include "smf_procedure.hpp"
#include "smf.h"
// extern smf::smf_procedure proc;
extern
smf
::
smf_config
smf_cfg
;
extern
std
::
list
<
UeMsg
>
UeMsgList
;
namespace
oai
{
namespace
smf_server
{
namespace
api
{
SmfToDataApiImpl
::
SmfToDataApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
,
smf
::
smf_app
*
smf_app_inst
,
std
::
string
address
)
:
SmfToDataApi
(
rtr
),
m_smf_app
(
smf_app_inst
),
m_address
(
address
)
{}
void
SmfToDataApiImpl
::
uemsg_get_am_data
(
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
AccessControlAllowOrigin
>
(
"*"
);
nlohmann
::
json
response_data_json
=
{};
nlohmann
::
json
json_array
=
nlohmann
::
json
::
array
();
if
(
UeMsgList
.
size
()
>
0
)
{
//if(!UeMsgList.empty())
int
i
=
0
;
for
(
std
::
list
<
UeMsg
>::
iterator
it
=
UeMsgList
.
begin
();
it
!=
UeMsgList
.
end
();
it
++
)
{
//std::cout << "ueip " << (*it).ueip << " imsi " << it->imsi << " timestamp: " << it->timestamp << std::endl;
json_array
[
i
][
"imsi"
]
=
(
*
it
).
ueip
;
json_array
[
i
][
"ueip"
]
=
it
->
imsi
;
json_array
[
i
][
"timestamp"
]
=
it
->
timestamp
;
i
++
;
}
response_data_json
[
"code"
]
=
200
;
response_data_json
[
"msg"
]
=
"success"
;
response_data_json
[
"data"
]
=
json_array
;
}
else
{
response_data_json
[
"code"
]
=
201
;
response_data_json
[
"msg"
]
=
"没有此数据"
;
response_data_json
[
"data"
]
=
NULL
;
}
try
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
response_data_json
.
dump
());
return
;
}
catch
(
nlohmann
::
json
::
exception
&
e
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Not_Found
,
response_data_json
.
dump
());
return
;
}
}
}
// namespace api
}
// namespace smf_server
}
// namespace oai
src/api-server/impl/SmfToDataApiImpl.h
0 → 100755
View file @
7ca69347
#ifndef SMF_TO_DATA_API_IMPL_H_
#define SMF_TO_DATA_API_IMPL_H_
#include <pistache/endpoint.h>
#include <pistache/http.h>
#include <pistache/router.h>
#include <memory>
#include <pistache/optional.h>
#include "smf_app.hpp"
#include "conversions.hpp"
#include <SmfToDataApi.h>
namespace
oai
{
namespace
smf_server
{
namespace
api
{
class
SmfToDataApiImpl
:
public
oai
::
smf_server
::
api
::
SmfToDataApi
{
public:
SmfToDataApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
,
smf
::
smf_app
*
smf_app_inst
,
std
::
string
address
);
~
SmfToDataApiImpl
()
{}
//获取uemsg
void
uemsg_get_am_data
(
Pistache
::
Http
::
ResponseWriter
&
response
);
void
set_supi
(
const
supi_t
&
s
);
supi_t
get_supi
()
const
;
bool
ipv4
;
struct
in_addr
ipv4_address
;
private:
smf
::
smf_app
*
m_smf_app
;
std
::
string
m_address
;
supi_t
supi
;
protected:
};
}
// namespace api
}
// namespace smf_server
}
// namespace oai
#endif
src/api-server/smf-api-server.cpp
100644 → 100755
View file @
7ca69347
...
...
@@ -83,6 +83,8 @@ void SMFApiServer::init(size_t thr) {
m_individualSubscriptionDocumentApiImpl
->
init
();
m_subscriptionsCollectionApiImpl
->
init
();
m_nfStatusNotifyApiImpl
->
init
();
m_smfToDataApiImpl
->
init
();
}
void
SMFApiServer
::
start
()
{
Logger
::
smf_api_server
().
info
(
"HTTP1 server started"
);
...
...
src/api-server/smf-api-server.h
100644 → 100755
View file @
7ca69347
...
...
@@ -50,6 +50,7 @@
#include "IndividualSubscriptionDocumentApiImpl.h"
#include "SubscriptionsCollectionApiImpl.h"
#include "NFStatusNotifyApiImpl.h"
#include "SmfToDataApiImpl.h"
#include "smf_app.hpp"
...
...
@@ -79,6 +80,8 @@ class SMFApiServer {
m_router
,
smf_app_inst
,
m_address
);
m_nfStatusNotifyApiImpl
=
std
::
make_shared
<
NFStatusNotifyApiImpl
>
(
m_router
,
smf_app_inst
,
m_address
);
m_smfToDataApiImpl
=
std
::
make_shared
<
SmfToDataApiImpl
>
(
m_router
,
smf_app_inst
,
m_address
);
}
void
init
(
size_t
thr
=
1
);
void
start
();
...
...
@@ -97,6 +100,8 @@ class SMFApiServer {
std
::
shared_ptr
<
SubscriptionsCollectionApiImpl
>
m_subscriptionsCollectionApiImpl
;
std
::
shared_ptr
<
NFStatusNotifyApiImpl
>
m_nfStatusNotifyApiImpl
;
std
::
shared_ptr
<
SmfToDataApiImpl
>
m_smfToDataApiImpl
;
std
::
string
m_address
;
};
...
...
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