1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +00:00

LookupServer: Move DNS name serialization to DNSName class

This commit is contained in:
Sergey Bugaev 2021-02-14 15:16:20 +03:00 committed by Andreas Kling
parent 42bc5f2cc1
commit d6f7ced4f1
3 changed files with 17 additions and 12 deletions

View file

@ -83,22 +83,12 @@ ByteBuffer DNSPacket::to_byte_buffer() const
stream << ReadonlyBytes { &header, sizeof(header) };
for (auto& question : m_questions) {
auto parts = question.name().as_string().split('.');
for (auto& part : parts) {
stream << (u8)part.length();
stream << part.bytes();
}
stream << '\0';
stream << question.name();
stream << htons(question.record_type());
stream << htons(question.class_code());
}
for (auto& answer : m_answers) {
auto parts = answer.name().as_string().split('.');
for (auto& part : parts) {
stream << (u8)part.length();
stream << part.bytes();
}
stream << '\0';
stream << answer.name();
stream << htons(answer.type());
stream << htons(answer.class_code());
stream << htonl(answer.ttl());