stephb9959
2023-03-21 16:44:31 -07:00
parent 14877301e4
commit ec4a7f64de
3 changed files with 41 additions and 2 deletions

2
build
View File

@@ -1 +1 @@
9
10

View File

@@ -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());

View File

@@ -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_;