Move everything in util.h to zeek::util namespace.

This commit includes renaming a number of methods prefixed with bro_ to be prefixed with zeek_.
This commit is contained in:
Tim Wojtulewicz 2020-08-06 10:40:24 -07:00
parent 8862b585fa
commit 8d2d867a65
179 changed files with 1277 additions and 1033 deletions

View file

@ -58,7 +58,7 @@ namespace zeek::detail {
class DNS_Mgr_Request {
public:
DNS_Mgr_Request(const char* h, int af, bool is_txt)
: host(copy_string(h)), fam(af), qtype(is_txt ? 16 : 0), addr(),
: host(zeek::util::copy_string(h)), fam(af), qtype(is_txt ? 16 : 0), addr(),
request_pending()
{ }
@ -140,7 +140,7 @@ public:
if ( req_host && num_addrs == 0)
return false; // nothing to expire
return current_time() > (creation_time + req_ttl);
return zeek::util::current_time() > (creation_time + req_ttl);
}
int Type() const { return map_type; }
@ -187,11 +187,11 @@ static zeek::TableValPtr empty_addr_set()
DNS_Mapping::DNS_Mapping(const char* host, struct hostent* h, uint32_t ttl)
{
Init(h);
req_host = copy_string(host);
req_host = zeek::util::copy_string(host);
req_ttl = ttl;
if ( names && ! names[0] )
names[0] = copy_string(host);
names[0] = zeek::util::copy_string(host);
}
DNS_Mapping::DNS_Mapping(const zeek::IPAddr& addr, struct hostent* h, uint32_t ttl)
@ -231,13 +231,13 @@ DNS_Mapping::DNS_Mapping(FILE* f)
failed = static_cast<bool>(failed_local);
if ( is_req_host )
req_host = copy_string(req_buf);
req_host = zeek::util::copy_string(req_buf);
else
req_addr = zeek::IPAddr(req_buf);
num_names = 1;
names = new char*[num_names];
names[0] = copy_string(name_buf);
names[0] = zeek::util::copy_string(name_buf);
if ( num_addrs > 0 )
{
@ -318,7 +318,7 @@ void DNS_Mapping::Init(struct hostent* h)
{
no_mapping = false;
init_failed = false;
creation_time = current_time();
creation_time = zeek::util::current_time();
host_val = nullptr;
addrs_val = nullptr;
@ -331,7 +331,7 @@ void DNS_Mapping::Init(struct hostent* h)
map_type = h->h_addrtype;
num_names = 1; // for now, just use official name
names = new char*[num_names];
names[0] = h->h_name ? copy_string(h->h_name) : nullptr;
names[0] = h->h_name ? zeek::util::copy_string(h->h_name) : nullptr;
for ( num_addrs = 0; h->h_addr_list[num_addrs]; ++num_addrs )
;
@ -411,7 +411,7 @@ void DNS_Mgr::InitSource()
// script-layer option to configure the DNS resolver as it may not be
// configured to the user's desired address at the time when we need to to
// the lookup.
auto dns_resolver = zeekenv("ZEEK_DNS_RESOLVER");
auto dns_resolver = zeek::util::zeekenv("ZEEK_DNS_RESOLVER");
auto dns_resolver_addr = dns_resolver ? zeek::IPAddr(dns_resolver) : zeek::IPAddr();
char err[NB_DNS_ERRSIZE];
@ -1204,7 +1204,7 @@ void DNS_Mgr::IssueAsyncRequests()
continue;
}
req->time = current_time();
req->time = zeek::util::current_time();
asyncs_timeouts.push(req);
++asyncs_pending;
@ -1350,7 +1350,7 @@ void DNS_Mgr::Process()
{
AsyncRequest* req = asyncs_timeouts.top();
if ( req->time + DNS_TIMEOUT > current_time() && ! zeek::net::terminating )
if ( req->time + DNS_TIMEOUT > zeek::util::current_time() && ! zeek::net::terminating )
break;
if ( ! req->processed )