1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 10:08:10 +00:00

LookupServer+LibC: Pass IP addresses in binary

Now that we no longer depend on the textual IPC format, we can pass IP addresses
in the format most code actually has and needs it: in binary. The only places we
actually have to deal with textual address representation is:

* When reading /etc/hosts, we have to parse textual addresses & convert them to
  binary;
* When doing reverse lookups, we have to form a pseudo-hostname of the form
  x.x.x.x.in-addr.arpa.

So we do the conversion in those two cases.

This also increases uniformity between how we handle A (IPv4 address) and other
resource record types. Namely, we now store the raw binary data as received from
a DNS server.
This commit is contained in:
Sergey Bugaev 2021-02-06 17:30:33 +03:00 committed by Andreas Kling
parent 04ff46bff4
commit d8967e4dff
4 changed files with 12 additions and 19 deletions

View file

@ -96,9 +96,10 @@ void LookupServer::load_etc_hosts()
(u8)atoi(sections[2].characters()),
(u8)atoi(sections[3].characters()),
};
auto raw_addr = addr.to_in_addr_t();
auto name = fields[1];
m_etc_hosts.set(name, addr.to_string());
m_etc_hosts.set(name, String { (const char*)&raw_addr, sizeof(raw_addr) });
IPv4Address reverse_addr {
(u8)atoi(sections[3].characters()),