Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-12692
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Oct 20, 2023
1 parent 04be75f commit ad1a3c6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/RADIUS_Destination.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ namespace OpenWifi {
}
}
} else if ((Utils::Now() - LastKeepAlive) > Pool_.radsecKeepAlive) {
RADIUS::RadiusOutputPacket P(Pool_.acctConfig.servers[ServerIndex_].radsecSecret);
RADIUS::RadiusOutputPacket P(Pool_.authConfig.servers[ServerIndex_].radsecSecret);
P.MakeStatusMessage();
poco_trace(Logger_, fmt::format("{}: Keep-Alive message.", Pool_.acctConfig.servers[ServerIndex_].name));
poco_trace(Logger_, fmt::format("{}: Keep-Alive message.", Pool_.authConfig.servers[ServerIndex_].name));
Socket_->sendBytes(P.Data(), P.Len());
LastKeepAlive = Utils::Now();
}
Expand All @@ -89,14 +89,14 @@ namespace OpenWifi {
if (Connected_) {
RADIUS::RadiusPacket P(buffer, length);
int sent_bytes;
if (P.VerifyMessageAuthenticator(Pool_.acctConfig.servers[ServerIndex_].radsecSecret)) {
if (P.VerifyMessageAuthenticator(Pool_.authConfig.servers[ServerIndex_].radsecSecret)) {
poco_trace(Logger_, fmt::format("{}: {} Sending {} bytes", serial_number,
P.PacketType(), length));
sent_bytes = Socket_->sendBytes(buffer, length);
} else {
poco_trace(Logger_, fmt::format("{}: {} Sending {} bytes", serial_number,
P.PacketType(), length));
P.ComputeMessageAuthenticator(Pool_.acctConfig.servers[ServerIndex_].radsecSecret);
P.ComputeMessageAuthenticator(Pool_.authConfig.servers[ServerIndex_].radsecSecret);
sent_bytes = Socket_->sendBytes(P.Buffer(), length);
}
return (sent_bytes == length);
Expand Down Expand Up @@ -125,6 +125,10 @@ namespace OpenWifi {
P.PacketType(), NumberOfReceivedBytes));
AP_WS_Server()->SendRadiusAuthenticationData(SerialNumber, Buffer,
NumberOfReceivedBytes);
} else if(P.IsStatusMessageReply()) {
poco_debug(Logger_,
fmt::format("{}: Keepalive message received.", SerialNumber));

} else {
poco_debug(Logger_, "AUTH packet dropped.");
}
Expand Down Expand Up @@ -354,7 +358,7 @@ namespace OpenWifi {
Socket_->connect(Destination, Poco::Timespan(20, 0));
Socket_->completeHandshake();

if (!Pool_.acctConfig.servers[ServerIndex_].allowSelfSigned) {
if (!Pool_.authConfig.servers[ServerIndex_].allowSelfSigned) {
Socket_->verifyPeerCertificate();
}

Expand Down Expand Up @@ -444,7 +448,7 @@ namespace OpenWifi {
Socket_->connect(Destination, Poco::Timespan(100, 0));
Socket_->completeHandshake();

if (!Pool_.acctConfig.servers[ServerIndex_].allowSelfSigned) {
if (!Pool_.authConfig.servers[ServerIndex_].allowSelfSigned) {
Socket_->verifyPeerCertificate();
}

Expand Down
17 changes: 16 additions & 1 deletion src/RADIUS_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,20 @@ namespace OpenWifi::RADIUS {
P_.code == RADIUS::CoA_ACK || P_.code == RADIUS::CoA_NAK);
}

inline bool IsStatusMessageReply() {
std::string Result;
for (const auto &attribute : Attrs_) {
if (attribute.type == RADIUS::Attributes::PROXY_STATE) {
std::string Attr33;
// format is serial:IP:port:interface
Attr33.assign((const char *)(const char *)&P_.attributes[attribute.pos],
attribute.len);
return Attr33 == "status";
}
}
return false;

}
void Log(std::ostream &os) {
uint16_t p = 0;

Expand Down Expand Up @@ -992,9 +1006,10 @@ namespace OpenWifi::RADIUS {
P_.identifier = std::rand() & 0x00ff;
MakeRadiusAuthenticator(P_.authenticator);
unsigned char MessageAuthenticator[16]{0};
AddAttribute(RADIUS::Attributes::PROXY_STATE, 6, (const unsigned char *)"status" );
AddAttribute(RADIUS::Attributes::MESSAGE_AUTHENTICATOR, sizeof(MessageAuthenticator),
MessageAuthenticator);
int PktLen = 1 + 1 + 2 + 16 + 1 + 1 + 16;
int PktLen = 1 + 1 + 2 + 16 + 1 + 1 + 16 + 6;
P_.rawlen = htons(PktLen);

Poco::HMACEngine<Poco::MD5Engine> H(Secret_);
Expand Down

0 comments on commit ad1a3c6

Please sign in to comment.