Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-12868
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Aug 31, 2023
1 parent 746458d commit fb265ff
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17
18
4 changes: 4 additions & 0 deletions openapi/owgw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,9 @@ components:
type: string
chargeableUserIdentity:
type: string
userName:
type: string


paths:
/devices:
Expand Down Expand Up @@ -3253,6 +3256,7 @@ paths:
type: string
enum:
- coadm
- disconnectUser
requestBody:
description: operationParameters
content:
Expand Down
15 changes: 15 additions & 0 deletions src/RADIUSSessionTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,21 @@ namespace OpenWifi {
return true;
}

bool RADIUSSessionTracker::DisconnectUser(const std::string &UserName) {
poco_information(Logger(),fmt::format("Disconnect user {}.", UserName));
std::lock_guard Guard(Mutex_);

for(const auto &AP:AccountingSessions_) {
for(const auto &Session:AP.second) {
if(Session.second->userName==UserName) {
SendCoADM(Session.second);
}
}
}

return true;
}

void RADIUSSessionTracker::DisconnectSession(const std::string &SerialNumber) {
poco_information(Logger(),fmt::format("{}: Disconnecting.", SerialNumber));

Expand Down
1 change: 1 addition & 0 deletions src/RADIUSSessionTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ namespace OpenWifi {

bool SendCoADM(const std::string &serialNumber, const std::string &sessionId);
bool SendCoADM(const RADIUSSessionPtr &session);
bool DisconnectUser(const std::string &UserName);

inline std::uint32_t HasSessions(const std::string & serialNumber) {
std::lock_guard G(Mutex_);
Expand Down
7 changes: 7 additions & 0 deletions src/RESTAPI/RESTAPI_radiussessions_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ namespace OpenWifi {
return BadRequest(RESTAPI::Errors::CouldNotPerformCommand);
}

if(Command=="disconnectUser" && !Parameters.userName.empty()) {
if(RADIUSSessionTracker()->DisconnectUser(Parameters.userName)) {
return OK();
}
return BadRequest(RESTAPI::Errors::CouldNotPerformCommand);
}

return BadRequest(RESTAPI::Errors::InvalidCommand);
}

Expand Down
1 change: 1 addition & 0 deletions src/RESTObjects/RESTAPI_GWobjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ namespace OpenWifi::GWObjects {
field_from_json(Obj, "accountingMultiSessionId", accountingMultiSessionId);
field_from_json(Obj, "callingStationId", callingStationId);
field_from_json(Obj, "chargeableUserIdentity", chargeableUserIdentity);
field_from_json(Obj, "userName", userName);
return true;
} catch (const Poco::Exception &E) {
}
Expand Down
3 changes: 2 additions & 1 deletion src/RESTObjects/RESTAPI_GWobjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ namespace OpenWifi::GWObjects {
std::string accountingSessionId,
accountingMultiSessionId,
callingStationId,
chargeableUserIdentity;
chargeableUserIdentity,
userName;

bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
Expand Down

0 comments on commit fb265ff

Please sign in to comment.