MCPcopy Create free account
hub / github.com/apache/trafficserver / ParseHostLine

Function ParseHostLine

src/iocore/hostdb/HostFile.cc:41–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39} // namespace
40
41static void
42ParseHostLine(swoc::TextView line, HostAddrMap &map, AddrHostMap &rmap)
43{
44 // Elements should be the address then a list of host names.
45 swoc::TextView addr_text = line.take_prefix_if(&isspace);
46 IpAddr addr;
47
48 // Don't use RecHttpLoadIp because the address *must* be literal.
49 if (TS_SUCCESS != addr.load(addr_text)) {
50 return;
51 }
52
53 while (!line.ltrim_if(&isspace).empty()) {
54 swoc::TextView name = line.take_prefix_if(&isspace);
55 if (addr.isIp6()) {
56 std::get<IPV6_IDX>(map[name]).push_back(addr);
57 } else if (addr.isIp4()) {
58 std::get<IPV4_IDX>(map[name]).push_back(addr);
59 }
60 // use insert here so only the first mapping in the file is used to provide a stable view between reloads
61 rmap.insert(std::pair(addr, name));
62 }
63}
64
65HostDBRecord::Handle
66HostFile::lookup(const HostDBHash &hash)

Callers 1

ParseHostFileFunction · 0.85

Calls 7

take_prefix_ifMethod · 0.80
isIp6Method · 0.80
isIp4Method · 0.80
loadMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected