mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralgw.git
synced 2025-10-30 18:28:03 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -142,7 +142,7 @@ namespace OpenWifi {
|
||||
RADIUS::RadiusPacket P(session.second.Packet_);
|
||||
P.P_.identifier++;
|
||||
P.ReplaceAttribute(RADIUS::ACCT_STATUS_TYPE, (std::uint32_t) RADIUS::ACCT_STATUS_TYPE_STOP);
|
||||
P.ReplaceAttribute(RADIUS::EVENT_TIMESTAMP, (std::uint32_t) std::time(nullptr));
|
||||
P.ReplaceOrAdd(RADIUS::EVENT_TIMESTAMP, (std::uint32_t) std::time(nullptr));
|
||||
|
||||
RADIUS_proxy_server()->RouteAndSendAccountingPacket(session.second.Destination, SerialNumber, P, true);
|
||||
store_packet(SerialNumber, (const char *)P.Buffer(), P.Size());
|
||||
|
||||
@@ -931,6 +931,45 @@ namespace OpenWifi::RADIUS {
|
||||
AddAttribute(location, attribute, attribute_value.c_str(), attribute_value.size());
|
||||
}
|
||||
|
||||
bool HasAttribute(std::uint8_t attribute) {
|
||||
return std::any_of(Attrs_.begin(),Attrs_.end(),[attribute](const RadiusAttribute &Attr) { return Attr.type ==attribute; });
|
||||
}
|
||||
|
||||
void ReplaceOrAdd(std::uint8_t attribute, std::uint8_t attribute_value) {
|
||||
if(HasAttribute(attribute))
|
||||
ReplaceAttribute(attribute, attribute_value);
|
||||
else
|
||||
AppendAttribute(attribute, attribute_value);
|
||||
}
|
||||
|
||||
void ReplaceOrAdd(std::uint8_t attribute, std::uint16_t attribute_value) {
|
||||
if(HasAttribute(attribute))
|
||||
ReplaceAttribute(attribute, attribute_value);
|
||||
else
|
||||
AppendAttribute(attribute, attribute_value);
|
||||
}
|
||||
|
||||
void ReplaceOrAdd(std::uint8_t attribute, std::uint32_t attribute_value) {
|
||||
if(HasAttribute(attribute))
|
||||
ReplaceAttribute(attribute, attribute_value);
|
||||
else
|
||||
AppendAttribute(attribute, attribute_value);
|
||||
}
|
||||
|
||||
void ReplaceOrAdd(std::uint8_t attribute, const char *attribute_value, std::uint8_t attribute_len) {
|
||||
if(HasAttribute(attribute))
|
||||
ReplaceAttribute(attribute, attribute_value, attribute_len);
|
||||
else
|
||||
AppendAttribute(attribute, attribute_value, attribute_len);
|
||||
}
|
||||
|
||||
void ReplaceOrAdd(std::uint8_t attribute, const std::string & attribute_value) {
|
||||
if(HasAttribute(attribute))
|
||||
ReplaceAttribute(attribute, attribute_value.c_str(), attribute_value.size());
|
||||
else
|
||||
AppendAttribute(attribute, attribute_value.c_str(), attribute_value.size());
|
||||
|
||||
}
|
||||
|
||||
AttributeList Attrs_;
|
||||
RawRadiusPacket P_;
|
||||
|
||||
Reference in New Issue
Block a user