1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:37:35 +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

@ -26,6 +26,7 @@
*/
#include "DNSName.h"
#include <AK/Vector.h>
namespace LookupServer {
@ -69,4 +70,15 @@ DNSName DNSName::parse(const u8* data, size_t& offset, size_t max_offset, size_t
}
}
OutputStream& operator<<(OutputStream& stream, const DNSName& name)
{
auto parts = name.as_string().split_view('.');
for (auto& part : parts) {
stream << (u8)part.length();
stream << part.bytes();
}
stream << '\0';
return stream;
}
}