- attributes.push_back(new RadProto::String(m_dictionaries.attributeCode("User-Name"), "test"));
- attributes.push_back(new RadProto::Integer(m_dictionaries.attributeCode("NAS-Port"), 20));
- std::array<uint8_t, 4> address {127, 104, 22, 17};
- attributes.push_back(new RadProto::IpAddress(m_dictionaries.attributeCode("NAS-IP-Address"), address));
- std::vector<uint8_t> bytes {'1', '2', '3', 'a', 'b', 'c'};
- attributes.push_back(new RadProto::Bytes(m_dictionaries.attributeCode("Callback-Number"), bytes));
- std::vector<uint8_t> chapPassword {'1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g' };
- attributes.push_back(new RadProto::ChapPassword(m_dictionaries.attributeCode("CHAP-Password"), 1, chapPassword));
-
- std::vector<RadProto::VendorSpecific> vendorSpecific;
- std::vector<uint8_t> vendorValue {0, 0, 0, 3};
- vendorSpecific.push_back(RadProto::VendorSpecific(m_dictionaries.vendorCode("Dlink"), m_dictionaries.vendorAttributeCode("Dlink", "Dlink-User-Level"), vendorValue));
-
- if (request.type() != RadProto::ACCESS_REQUEST)
+
+ for (const auto& at : m_config.getAuth().send)
+ {
+ std::string attrValue;
+
+ if (at.second.type == Config::AttrValue::Type::PARAM_NAME)
+ attrValue = user->GetParamValue(at.second.value);
+ else
+ attrValue = at.second.value;
+
+ const auto attrName = at.first;
+ const auto attrCode = m_dictionaries.attributeCode(attrName);
+ const auto attrType = m_dictionaries.attributeType(attrCode);
+
+ if ((attrType == "integer") && (m_dictionaries.attributeValueFindByName(attrName, attrValue)))
+ attributes.push_back(RadProto::Attribute::make(attrCode, attrType, std::to_string(m_dictionaries.attributeValueCode(attrName, attrValue))));
+ else
+ attributes.push_back(RadProto::Attribute::make(attrCode, attrType, attrValue));
+ }
+ return attributes;
+}
+
+RadProto::Packet Server::makeResponse(const RadProto::Packet& request)
+{
+ if (request.code() != RadProto::ACCESS_REQUEST)