HostsEntry
Description
One row from /etc/hosts – a hostname (or alias) paired with its IP address. We store IPv4 addresses in the first four bytes of ip[]; IPv6 uses all 16.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Dns.h:50:
u8 ip[16];
bool is_ipv6;
} HostsEntry;
typedef Vec(HostsEntry) HostsTable;- In
Dns.h:52:
} HostsEntry;
typedef Vec(HostsEntry) HostsTable;
typedef Vec(SocketAddr) DnsAddrs;- In
Dns.c:216:
}
HostsEntry e = {0};
e.name = StrInitFromCstr((Zstr)StrIterDataAt(&si, nm_start), nm_len, alloc);
ascii_lower((u8 *)StrBegin(&e.name), StrLen(&e.name));- In
SysDns.c:43:
static void hosts_push_v4(DnsResolver *r, Zstr name, u8 b0, u8 b1, u8 b2, u8 b3) {
HostsEntry e = {0};
e.name = StrInitFromCstr(name, ZstrLen(name), r->allocator);
e.ip[0] = b0;- In
SysDns.c:54:
static void hosts_push_v6(DnsResolver *r, Zstr name, const u8 ip16[16]) {
HostsEntry e = {0};
e.name = StrInitFromCstr(name, ZstrLen(name), r->allocator);
for (u64 i = 0; i < 16; ++i) {- In
SysDns.c:116:
}
static const HostsEntry *find_host(HostsTable *t, Zstr name) {
VecForeachPtr(t, e) {
if (StrLen(&e->name) > 0 && ZstrCompare(StrBegin(&e->name), name) == 0) {- In
SysDns.c:122:
}
}
return (const HostsEntry *)0;
}- In
SysDns.c:125:
}
static bool host_v4_is(const HostsEntry *e, u8 a, u8 b, u8 c, u8 d) {
return e && !e->is_ipv6 && e->ip[0] == a && e->ip[1] == b && e->ip[2] == c && e->ip[3] == d;
}- In
SysDns.c:361:
DnsResolverAddHostsPath(&r, &path);
const HostsEntry *e = find_host(&r.hosts, "localhost");
bool ok = VecLen(&r.hosts) == 1 && host_v4_is(e, 127, 0, 0, 1) && ZstrCompare(StrBegin(&e->name), "localhost") == 0;- In
SysDns.c:409:
bool ok = VecLen(&r.hosts) == 1 && host_v4_is(find_host(&r.hosts, "a"), 10, 0, 0, 1) &&
find_host(&r.hosts, "commented.host") == (const HostsEntry *)0;
drop_temp(&path);- In
SysDns.c:428:
bool ok = VecLen(&r.hosts) == 1 && host_v4_is(find_host(&r.hosts, "namex"), 10, 0, 0, 2) &&
find_host(&r.hosts, "trailing") == (const HostsEntry *)0 &&
find_host(&r.hosts, "#") == (const HostsEntry *)0;- In
SysDns.c:429:
bool ok = VecLen(&r.hosts) == 1 && host_v4_is(find_host(&r.hosts, "namex"), 10, 0, 0, 2) &&
find_host(&r.hosts, "trailing") == (const HostsEntry *)0 &&
find_host(&r.hosts, "#") == (const HostsEntry *)0;
drop_temp(&path);- In
SysDns.c:447:
DnsResolverAddHostsPath(&r, &path);
const HostsEntry *e = find_host(&r.hosts, "namex");
bool ok = VecLen(&r.hosts) == 1 && host_v4_is(e, 10, 0, 0, 2) && ZstrCompare(StrBegin(&e->name), "namex") == 0;- In
SysDns.c:487:
bool ok = VecLen(&r.hosts) == 1 && host_v4_is(find_host(&r.hosts, "mixedcasehost"), 10, 1, 1, 1) &&
find_host(&r.hosts, "MixedCaseHost") == (const HostsEntry *)0;
drop_temp(&path);- In
SysDns.c:507:
DnsResolverAddHostsPath(&r, &path);
const HostsEntry *e = find_host(&r.hosts, "@az[`m");
bool ok = VecLen(&r.hosts) == 1 && host_v4_is(e, 10, 1, 1, 2) && ZstrCompare(StrBegin(&e->name), "@az[`m") == 0;- In
SysDns.c:592:
DnsResolverAddHostsPath(&r, &path);
const HostsEntry *e = find_host(&r.hosts, "ip6-localhost");
bool ok = VecLen(&r.hosts) == 1 && e && e->is_ipv6;
if (ok) {- In
SysDns.c:626:
bool ok = VecLen(&r.hosts) == 1 && host_v4_is(find_host(&r.hosts, "realname"), 10, 0, 0, 7) &&
find_host(&r.hosts, "somename") == (const HostsEntry *)0;
drop_temp(&path);- In
SysDns.c:680:
bool ok = VecLen(&r.hosts) == 1 && host_v4_is(find_host(&r.hosts, "goodname"), 10, 0, 0, 4) &&
find_host(&r.hosts, "spuriousname") == (const HostsEntry *)0;
drop_temp(&path);- In
SysDns.c:704:
bool ok = VecLen(&r.hosts) == 1 && host_v4_is(find_host(&r.hosts, "realone"), 10, 0, 0, 6) &&
find_host(&r.hosts, "x") == (const HostsEntry *)0;
drop_temp(&path);
Last updated on