stephb9959
2023-04-02 23:32:09 -07:00
parent 37a02b699d
commit 0d6e2c0e33
11 changed files with 389 additions and 68 deletions

View File

@@ -195,7 +195,7 @@ add_executable( owgw
src/AP_WS_Process_telemetry.cpp
src/AP_WS_Process_venuebroadcast.cpp
src/RADSEC_server.h
src/UI_GW_WebSocketNotifications.cpp src/UI_GW_WebSocketNotifications.h src/framework/RESTAPI_SystemConfiguration.h src/ScriptManager.cpp src/ScriptManager.h src/RESTAPI/RESTAPI_scripts_handler.cpp src/RESTAPI/RESTAPI_scripts_handler.h src/RESTAPI/RESTAPI_script_handler.cpp src/RESTAPI/RESTAPI_script_handler.h src/storage/storage_scripts.cpp src/storage/storage_scripts.h src/SignatureMgr.h src/AP_WS_Process_event.cpp src/AP_WS_Process_wifiscan.cpp src/AP_WS_Process_alarm.cpp src/GWKafkaEvents.cpp src/GWKafkaEvents.h src/RegulatoryInfo.cpp src/RegulatoryInfo.h src/RESTAPI/RESTAPI_regulatory.cpp src/RESTAPI/RESTAPI_regulatory.h src/RADIUSSessionTracker.cpp src/RADIUSSessionTracker.h)
src/UI_GW_WebSocketNotifications.cpp src/UI_GW_WebSocketNotifications.h src/framework/RESTAPI_SystemConfiguration.h src/ScriptManager.cpp src/ScriptManager.h src/RESTAPI/RESTAPI_scripts_handler.cpp src/RESTAPI/RESTAPI_scripts_handler.h src/RESTAPI/RESTAPI_script_handler.cpp src/RESTAPI/RESTAPI_script_handler.h src/storage/storage_scripts.cpp src/storage/storage_scripts.h src/SignatureMgr.h src/AP_WS_Process_event.cpp src/AP_WS_Process_wifiscan.cpp src/AP_WS_Process_alarm.cpp src/GWKafkaEvents.cpp src/GWKafkaEvents.h src/RegulatoryInfo.cpp src/RegulatoryInfo.h src/RESTAPI/RESTAPI_regulatory.cpp src/RESTAPI/RESTAPI_regulatory.h src/RADIUSSessionTracker.cpp src/RADIUSSessionTracker.h src/RESTAPI/RESTAPI_radiussessions_handler.cpp src/RESTAPI/RESTAPI_radiussessions_handler.h)
if(NOT SMALL_BUILD)

2
build
View File

@@ -1 +1 @@
16
17

View File

@@ -2,7 +2,7 @@ openapi: 3.0.1
info:
title: uCentral gateway API
description: A process to manage configuration for devices.
version: 2.5.0
version: 2.10.0
license:
name: BSD3
url: https://github.com/Telecominfraproject/wlan-cloud-ucentralgw/blob/master/LICENSE
@@ -1269,6 +1269,55 @@ components:
items:
$ref: '#/components/schemas/RadiusProxyPool'
RadiusSession:
type: object
properties:
started:
type: integer
format: int64
lastTransaction:
type: integer
format: int64
inputPackets:
type: integer
format: int64
outputPackets:
type: integer
format: int64
inputOctets:
type: integer
format: int64
outputOctets:
type: integer
format: int64
inputGigaWords:
type: integer
format: int64
outputGigaWords:
type: integer
format: int64
sessionTime:
type: integer
format: int64
destination:
type: string
userName:
type: string
accountingSessionId:
type: string
accountingMultiSessionId:
type: string
callingStationId:
type: string
RadiusSessionList:
type: object
properties:
sessions:
type: array
items:
$ref: '#/components/schemas/RadiusSession'
paths:
/devices:
get:
@@ -2723,9 +2772,6 @@ paths:
404:
$ref: '#/components/responses/NotFound'
/blacklist:
get:
tags:
@@ -2918,6 +2964,39 @@ paths:
403:
$ref: '#/components/responses/Unauthorized'
/radiusSessions/{serialNumber}:
get:
tags:
- Radius Sessions
summary: Retrieve the RADIUS sessions for a given AP
operationId: getAPRadiusSessions
parameters:
- in: path
name: serialNumber
schema:
type: string
required: true
- in: query
name: serialNumberOnly
schema:
type: boolean
required: false
responses:
200:
description: AP List
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/RadiusSessionList'
- $ref: '#/components/schemas/SerialNumberList'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
/deviceDashboard:
get:
tags:

View File

@@ -7,6 +7,10 @@
#include <framework/utils.h>
#include "RADIUS_proxy_server.h"
#include "framework/RESTAPI_utils.h"
using OpenWifi::RESTAPI_utils::field_from_json;
using OpenWifi::RESTAPI_utils::field_to_json;
namespace OpenWifi {
@@ -58,69 +62,176 @@ namespace OpenWifi {
void RADIUSSessionTracker::ProcessAuthenticationSession([[maybe_unused]] OpenWifi::SessionNotification &Notification) {
std::lock_guard Guard(Mutex_);
}
void
RADIUSSessionTracker::ProcessAccountingSession(OpenWifi::SessionNotification &Notification) {
std::lock_guard Guard(Mutex_);
std::string CallingStationId;
std::uint8_t AccountingPacketType = 0;
std::string CallingStationId, AccountingSessionId, AccountingMultiSessionId, UserName;
for (const auto &attribute : Notification.Packet_.Attrs_) {
switch (attribute.type) {
case RADIUS::AUTH_USERNAME: {
UserName.assign(
&Notification.Packet_.P_.attributes[attribute.pos],
&Notification.Packet_.P_.attributes[attribute.pos + attribute.len]);
} break;
case RADIUS::CALLING_STATION_ID: {
CallingStationId.assign(
&Notification.Packet_.P_.attributes[attribute.pos],
&Notification.Packet_.P_.attributes[attribute.pos + attribute.len]);
} break;
case RADIUS::ACCT_STATUS_TYPE: {
AccountingPacketType = Notification.Packet_.P_.attributes[attribute.pos + 3];
case RADIUS::ACCT_SESSION_ID: {
AccountingSessionId.assign(
&Notification.Packet_.P_.attributes[attribute.pos],
&Notification.Packet_.P_.attributes[attribute.pos + attribute.len]);
} break;
case RADIUS::ACCT_MULTI_SESSION_ID: {
AccountingMultiSessionId.assign(
&Notification.Packet_.P_.attributes[attribute.pos],
&Notification.Packet_.P_.attributes[attribute.pos + attribute.len]);
} break;
default: {
} break;
}
}
auto hint = AccountingSessions_.find(Notification.SerialNumber_);
if(hint==end(AccountingSessions_)) {
auto ap_hint = AccountingSessions_.find(Notification.SerialNumber_);
if(ap_hint==end(AccountingSessions_)) {
SessionMap M;
AccountingSessions_[Notification.SerialNumber_ ] = M;
ap_hint = AccountingSessions_.find(Notification.SerialNumber_);
}
auto Index = CallingStationId+AccountingSessionId+AccountingMultiSessionId;
auto session_hint = ap_hint->second.find(Index);
if(session_hint==end(ap_hint->second)) {
auto NewSession = std::make_shared<GWObjects::RADIUSSession>();
NewSession->Started_ = NewSession->LastTransaction_ = Utils::Now();
NewSession->UserName_ = UserName;
NewSession->CallingStationId_ = CallingStationId;
NewSession->AccountingSessionId_ = AccountingSessionId;
NewSession->AccountingMultiSessionId_ = AccountingMultiSessionId;
ap_hint->second[Index] = NewSession;
} else {
session_hint->second->LastTransaction_ = Utils::Now();
}
}
std::uint32_t GetUiInt32(const std::uint8_t *buf) {
return (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + (buf[3] << 0);
}
void
RADIUSSessionTracker::ProcessAccountingSession(OpenWifi::SessionNotification &Notification) {
std::lock_guard Guard(Mutex_);
std::string CallingStationId, AccountingSessionId, AccountingMultiSessionId, UserName;
std::uint8_t AccountingPacketType = 0;
std::uint32_t InputOctets=0, OutputOctets=0, InputPackets=0, OutputPackets=0, InputGigaWords=0, OutputGigaWords=0,
SessionTime = 0;
for (const auto &attribute : Notification.Packet_.Attrs_) {
switch (attribute.type) {
case RADIUS::AUTH_USERNAME: {
UserName.assign(
&Notification.Packet_.P_.attributes[attribute.pos],
&Notification.Packet_.P_.attributes[attribute.pos + attribute.len]);
} break;
case RADIUS::CALLING_STATION_ID: {
CallingStationId.assign(
&Notification.Packet_.P_.attributes[attribute.pos],
&Notification.Packet_.P_.attributes[attribute.pos + attribute.len]);
} break;
case RADIUS::ACCT_SESSION_ID: {
AccountingSessionId.assign(
&Notification.Packet_.P_.attributes[attribute.pos],
&Notification.Packet_.P_.attributes[attribute.pos + attribute.len]);
} break;
case RADIUS::ACCT_MULTI_SESSION_ID: {
AccountingMultiSessionId.assign(
&Notification.Packet_.P_.attributes[attribute.pos],
&Notification.Packet_.P_.attributes[attribute.pos + attribute.len]);
} break;
case RADIUS::ACCT_STATUS_TYPE: {
AccountingPacketType = Notification.Packet_.P_.attributes[attribute.pos + 3];
} break;
case RADIUS::ACCT_INPUT_OCTETS: {
InputOctets = GetUiInt32(&Notification.Packet_.P_.attributes[attribute.pos]);
} break;
case RADIUS::ACCT_INPUT_PACKETS: {
InputPackets = GetUiInt32(&Notification.Packet_.P_.attributes[attribute.pos]);
} break;
case RADIUS::ACCT_INPUT_GIGAWORDS: {
InputGigaWords = GetUiInt32(&Notification.Packet_.P_.attributes[attribute.pos]);
} break;
case RADIUS::ACCT_OUTPUT_OCTETS: {
OutputOctets = GetUiInt32(&Notification.Packet_.P_.attributes[attribute.pos]);
} break;
case RADIUS::ACCT_OUTPUT_PACKETS: {
OutputPackets= GetUiInt32(&Notification.Packet_.P_.attributes[attribute.pos]);
} break;
case RADIUS::ACCT_OUTPUT_GIGAWORDS: {
OutputGigaWords = GetUiInt32(&Notification.Packet_.P_.attributes[attribute.pos]);
} break;
case RADIUS::ACCT_SESSION_TIME: {
SessionTime = GetUiInt32(&Notification.Packet_.P_.attributes[attribute.pos]);
} break;
default: {
} break;
}
}
auto Index = CallingStationId+AccountingSessionId+AccountingMultiSessionId;
auto ap_hint = AccountingSessions_.find(Notification.SerialNumber_);
if(ap_hint==end(AccountingSessions_)) {
SessionMap M;
AccountingSessions_[Notification.SerialNumber_ ] = M;
ap_hint = AccountingSessions_.find(Notification.SerialNumber_);
}
auto session_hint = ap_hint->second.find(Notification.SerialNumber_);
if(session_hint==end(ap_hint->second)) {
// find the calling_station_id
// if we are getting a stop for something we do not know, nothing to do...
if( AccountingPacketType!=OpenWifi::RADIUS::ACCT_STATUS_TYPE_START &&
AccountingPacketType!=OpenWifi::RADIUS::ACCT_STATUS_TYPE_INTERIM_UPDATE)
AccountingPacketType!=OpenWifi::RADIUS::ACCT_STATUS_TYPE_INTERIM_UPDATE) {
return;
}
auto S = std::make_shared<RADIUSSession>();
S->Started_ = Utils::Now();
S->Destination_ = Notification.Destination_;
S->AccountingPacket_ = Notification.Packet_;
auto NewSession = std::make_shared<GWObjects::RADIUSSession>();
NewSession->Destination_ = Notification.Destination_;
NewSession->Started_ = NewSession->LastTransaction_ = Utils::Now();
NewSession->UserName_ = UserName;
NewSession->CallingStationId_ = CallingStationId;
NewSession->AccountingSessionId_ = AccountingSessionId;
NewSession->AccountingMultiSessionId_ = AccountingMultiSessionId;
NewSession->AccountingPacket_ = Notification.Packet_;
NewSession->Destination_ = Notification.Destination_;
NewSession->InputOctets_ = InputOctets;
NewSession->InputPackets_ = InputPackets;
NewSession->InputGigaWords_ = InputGigaWords;
NewSession->OutputOctets_ = OutputOctets;
NewSession->OutputOctets_ = OutputPackets;
NewSession->OutputGigaWords_ = OutputGigaWords;
NewSession->SessionTime_ = SessionTime;
SessionMap Sessions;
Sessions[CallingStationId] = S;
AccountingSessions_[Notification.SerialNumber_] = Sessions;
poco_debug(Logger(),fmt::format("{}: Creating session", CallingStationId));
ap_hint->second[Index] = NewSession;
} else {
// If we receive a stop, just remove that session
if(AccountingPacketType==OpenWifi::RADIUS::ACCT_STATUS_TYPE_STOP) {
poco_debug(Logger(),fmt::format("{}: Deleting session", CallingStationId));
hint->second.erase(CallingStationId);
ap_hint->second.erase(Index);
} else {
// we are either starting or interim, which means ths same.
auto device_session = hint->second.find(CallingStationId);
if(device_session == end(hint->second)) {
poco_debug(Logger(),fmt::format("{}: Creating session", CallingStationId));
auto S = std::make_shared<RADIUSSession>();
S->Started_ = Utils::Now();
S->Destination_ = Notification.Destination_;
S->AccountingPacket_ = Notification.Packet_;
S->LastTransaction_ = Utils::Now();
hint->second[CallingStationId] = S;
} else {
poco_debug(Logger(),fmt::format("{}: Updating session", CallingStationId));
device_session->second->AccountingPacket_ = Notification.Packet_;
device_session->second->Destination_ = Notification.Destination_;
device_session->second->LastTransaction_ = Utils::Now();
}
poco_debug(Logger(),fmt::format("{}: Updating session", CallingStationId));
session_hint->second->AccountingPacket_ = Notification.Packet_;
session_hint->second->Destination_ = Notification.Destination_;
session_hint->second->LastTransaction_ = Utils::Now();
session_hint->second->InputOctets_ = InputOctets;
session_hint->second->InputPackets_ = InputPackets;
session_hint->second->InputGigaWords_ = InputGigaWords;
session_hint->second->OutputOctets_ = OutputOctets;
session_hint->second->OutputOctets_ = OutputPackets;
session_hint->second->OutputGigaWords_ = OutputGigaWords;
session_hint->second->SessionTime_ = SessionTime;
}
}
}
@@ -160,7 +271,7 @@ namespace OpenWifi {
}
AccountingSessions_.erase(hint);
AuthenticationSessions_.erase(SerialNumber);
}
} // namespace OpenWifi

View File

@@ -8,9 +8,14 @@
#include <Poco/Runnable.h>
#include <Poco/Notification.h>
#include <Poco/NotificationQueue.h>
#include <Poco/JSON/Object.h>
#include "RADIUS_helpers.h"
#include <RESTObjects/RESTAPI_GWobjects.h>
// RADIUS::RadiusPacket AccountingPacket_;
namespace OpenWifi {
class SessionNotification : public Poco::Notification {
@@ -37,17 +42,6 @@ namespace OpenWifi {
RADIUS::RadiusPacket Packet_;
};
struct RADIUSSession {
std::uint64_t Started_=0,
LastTransaction_=0;
std::string Destination_;
std::string UserName_;
RADIUS::RadiusPacket AccountingPacket_;
std::string SessionId_;
std::string MultiSessionId_;
};
class RADIUSSessionTracker : public SubSystemServer, Poco::Runnable {
public:
@@ -72,13 +66,32 @@ namespace OpenWifi {
SessionMessageQueue_.enqueueNotification(new SessionNotification(serialNumber));
}
inline void GetAPList(std::vector<std::string> &SerialNumbers) {
std::lock_guard G(Mutex_);
for(const auto &[serialNumber,_]:AccountingSessions_) {
SerialNumbers.emplace_back(serialNumber);
}
}
inline void GetAPSessions(const std::string &SerialNumber, GWObjects::RADIUSSessionList & list) {
std::lock_guard G(Mutex_);
auto ap_hint = AccountingSessions_.find(SerialNumber);
if(ap_hint!=end(AccountingSessions_)) {
for(const auto &[index,session]:ap_hint->second) {
list.Sessions.emplace_back(*session);
}
}
}
private:
std::atomic_bool Running_=false;
Poco::NotificationQueue SessionMessageQueue_;
Poco::Thread QueueManager_;
using SessionMap = std::map<std::string,std::shared_ptr<RADIUSSession>>;
std::map<std::string,SessionMap> AuthenticationSessions_; // serial-number -> session< username -> session >
using SessionMap = std::map<std::string,std::shared_ptr<GWObjects::RADIUSSession>>; // calling-station-id + accounting-session-id
// std::map<std::string,SessionMap> AuthenticationSessions_; // serial-number -> session< username -> session >
std::map<std::string,SessionMap> AccountingSessions_; // serial-number -> session< accounting-session -> session>
void ProcessAccountingSession(SessionNotification &Notification);

View File

@@ -179,7 +179,19 @@ namespace OpenWifi::RADIUS {
constexpr std::uint8_t CALLING_STATION_ID = 31;
constexpr std::uint8_t ACCT_TERMINATE_CAUSE = 49;
static const struct tok radius_attribute_names[] = {{1, "User-Name"},
constexpr std::uint8_t AUTH_USERNAME = 1;
constexpr std::uint8_t ACCT_SESSION_ID = 44;
constexpr std::uint8_t ACCT_MULTI_SESSION_ID = 50;
constexpr std::uint8_t ACCT_INPUT_PACKETS = 47;
constexpr std::uint8_t ACCT_OUTPUT_PACKETS = 48;
constexpr std::uint8_t ACCT_INPUT_OCTETS = 42;
constexpr std::uint8_t ACCT_OUTPUT_OCTETS = 43;
constexpr std::uint8_t ACCT_INPUT_GIGAWORDS = 52;
constexpr std::uint8_t ACCT_OUTPUT_GIGAWORDS = 53;
constexpr std::uint8_t ACCT_SESSION_TIME = 46;
static const struct tok radius_attribute_names[] = {{AUTH_USERNAME, "User-Name"},
{2, "User-Password"},
{3, "CHAP-Password"},
{4, "NAS-IP Address"},
@@ -218,18 +230,18 @@ namespace OpenWifi::RADIUS {
{39, "Framed-AppleTalk-Zone"},
{ACCT_STATUS_TYPE, "Acct-Status-Type"},
{41, "Acct-Delay-Time"},
{42, "Acct-Input-Octets"},
{43, "Acct-Output-Octets"},
{44, "Acct-Session-Id"},
{ACCT_INPUT_OCTETS, "Acct-Input-Octets"},
{ACCT_OUTPUT_OCTETS, "Acct-Output-Octets"},
{ACCT_SESSION_ID, "Acct-Session-Id"},
{ACCT_AUTHENTIC, "Acct-Authentic"},
{46, "Acct-Session-Time"},
{47, "Acct-Input-Packets"},
{48, "Acct-Output-Packets"},
{ACCT_SESSION_TIME, "Acct-Session-Time"},
{ACCT_INPUT_PACKETS, "Acct-Input-Packets"},
{ACCT_OUTPUT_PACKETS, "Acct-Output-Packets"},
{ACCT_TERMINATE_CAUSE, "Acct-Terminate-Cause"},
{50, "Acct-Multi-Session-Id"},
{ACCT_MULTI_SESSION_ID, "Acct-Multi-Session-Id"},
{51, "Acct-Link-Count"},
{52, "Acct-Input-Gigawords"},
{53, "Acct-Output-Gigawords"},
{ACCT_INPUT_GIGAWORDS, "Acct-Input-Gigawords"},
{ACCT_OUTPUT_GIGAWORDS, "Acct-Output-Gigawords"},
{55, "Event-Timestamp"},
{60, "CHAP-Challenge"},
{61, "NAS-Port-Type"},

View File

@@ -0,0 +1,26 @@
//
// Created by stephane bourque on 2023-04-02.
//
#include "RESTAPI_radiussessions_handler.h"
#include <RESTObjects/RESTAPI_GWobjects.h>
#include <RADIUSSessionTracker.h>
namespace OpenWifi {
void RESTAPI_radiussessions_handler::DoGet() {
if(GetBoolParameter("serialNumberOnly")) {
std::vector<std::string> L;
RADIUSSessionTracker()->GetAPList(L);
return ReturnObject("serialNumbers",L);
}
auto SerialNumber = GetBinding("serialNumber","");
GWObjects::RADIUSSessionList L;
RADIUSSessionTracker()->GetAPSessions(SerialNumber,L);
return ReturnObject("sessions",L.Sessions);
}
} // namespace OpenWifi

View File

@@ -0,0 +1,27 @@
//
// Created by stephane bourque on 2023-04-02.
//
#pragma once
#include "framework/RESTAPI_Handler.h"
namespace OpenWifi {
class RESTAPI_radiussessions_handler : public RESTAPIHandler {
public:
RESTAPI_radiussessions_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L,
RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId,
bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET,
Poco::Net::HTTPRequest::HTTP_OPTIONS},
Server, TransactionId, Internal){};
static auto PathName() { return std::list<std::string>{"/api/v1/radiusSessions/{serialNumber}"}; };
void DoGet() final;
void DoDelete() final{};
void DoPost() final{};
void DoPut() final{};
};
} // namespace OpenWifi

View File

@@ -21,6 +21,7 @@
#include "RESTAPI/RESTAPI_script_handler.h"
#include "RESTAPI/RESTAPI_scripts_handler.h"
#include "RESTAPI/RESTAPI_telemetryWebSocket.h"
#include "RESTAPI/RESTAPI_radiussessions_handler.h"
#include "framework/RESTAPI_SystemCommand.h"
#include "framework/RESTAPI_SystemConfiguration.h"
@@ -39,7 +40,7 @@ namespace OpenWifi {
RESTAPI_system_configuration, RESTAPI_deviceDashboardHandler, RESTAPI_webSocketServer,
RESTAPI_blacklist, RESTAPI_blacklist_list, RESTAPI_iptocountry_handler,
RESTAPI_radiusProxyConfig_handler, RESTAPI_scripts_handler, RESTAPI_script_handler,
RESTAPI_capabilities_handler, RESTAPI_telemetryWebSocket,
RESTAPI_capabilities_handler, RESTAPI_telemetryWebSocket, RESTAPI_radiussessions_handler,
RESTAPI_regulatory>(Path, Bindings, L, S,
TransactionId);
}
@@ -53,7 +54,7 @@ namespace OpenWifi {
RESTAPI_default_configurations, RESTAPI_default_configuration, RESTAPI_command,
RESTAPI_commands, RESTAPI_ouis, RESTAPI_file, RESTAPI_blacklist,
RESTAPI_iptocountry_handler, RESTAPI_radiusProxyConfig_handler, RESTAPI_scripts_handler,
RESTAPI_script_handler, RESTAPI_blacklist_list,
RESTAPI_script_handler, RESTAPI_blacklist_list, RESTAPI_radiussessions_handler,
RESTAPI_regulatory>(Path, Bindings, L, S, TransactionId);
}
} // namespace OpenWifi

View File

@@ -580,4 +580,26 @@ namespace OpenWifi::GWObjects {
(T.commands != commands) || (T.developer != developer) || (T.ssh != ssh) ||
(T.key_info != key_info) || (T.country != country));
}
void RADIUSSession::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "started", Started_);
field_to_json(Obj, "lastTransaction", LastTransaction_);
field_to_json(Obj, "destination", Destination_);
field_to_json(Obj, "userName", UserName_);
field_to_json(Obj, "accountingSessionId", AccountingSessionId_);
field_to_json(Obj, "accountingMultiSessionId", AccountingMultiSessionId_);
field_to_json(Obj, "inputPackets", InputPackets_);
field_to_json(Obj, "outputPackets", OutputPackets_);
field_to_json(Obj, "inputOctets", InputOctets_);
field_to_json(Obj, "outputOctets", OutputOctets_);
field_to_json(Obj, "inputGigaWords", InputGigaWords_);
field_to_json(Obj, "outputGigaWords", OutputGigaWords_);
field_to_json(Obj, "sessionTime", SessionTime_);
field_to_json(Obj, "callingStationId", CallingStationId_);
}
void RADIUSSessionList::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "sessions", Sessions);
}
} // namespace OpenWifi::GWObjects

View File

@@ -11,6 +11,10 @@
#include "Poco/JSON/Object.h"
#include "RESTAPI_SecurityObjects.h"
#ifdef TIP_GATEWAY_SERVICE
#include <RADIUS_helpers.h>
#endif
namespace OpenWifi::GWObjects {
enum CertificateValidation { NO_CERTIFICATE, VALID_CERTIFICATE, MISMATCH_SERIAL, VERIFIED };
@@ -370,5 +374,31 @@ namespace OpenWifi::GWObjects {
using RegulatoryInfoCountryMap = std::map<std::string,RegulatoryCountryInfo>;
struct RADIUSSession {
std::uint64_t Started_=0,
LastTransaction_=0;
std::string Destination_;
std::string UserName_;
std::string AccountingSessionId_,
AccountingMultiSessionId_;
std::uint64_t InputPackets_ = 0,
OutputPackets_ = 0,
InputOctets_ = 0,
OutputOctets_ = 0,
InputGigaWords_ = 0,
OutputGigaWords_ = 0;
std::uint32_t SessionTime_ = 0;
std::string CallingStationId_;
#ifdef TIP_GATEWAY_SERVICE
RADIUS::RadiusPacket AccountingPacket_;
#endif
void to_json(Poco::JSON::Object &Obj) const;
};
struct RADIUSSessionList {
std::vector<RADIUSSession> Sessions;
void to_json(Poco::JSON::Object &Obj) const;
};
} // namespace OpenWifi::GWObjects