Skip to content

Commit

Permalink
Merge pull request #791 from Barenboim/master
Browse files Browse the repository at this point in the history
add namespace protocol to DnsUtil
  • Loading branch information
Barenboim authored Mar 9, 2022
2 parents 55ee14d + 5f18077 commit 71b5531
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/manager/DnsCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class DnsCache
if (ai && (ai->ai_flags & AI_PASSIVE))
freeaddrinfo(ai);
else
DnsUtil::freeaddrinfo(ai);
protocol::DnsUtil::freeaddrinfo(ai);
}
};

Expand Down
7 changes: 5 additions & 2 deletions src/nameservice/WFDnsResolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ void WFResolverTask::dns_single_callback(WFDnsTask *dns_task)
if (dns_task->get_state() == WFT_STATE_SUCCESS)
{
struct addrinfo *ai = NULL;
int ret = DnsUtil::getaddrinfo(dns_task->get_resp(), port_, &ai);
int ret;

ret = protocol::DnsUtil::getaddrinfo(dns_task->get_resp(), port_, &ai);
DnsOutput out;
DnsRoutine::create(&out, ret, ai);
dns_callback_internal(&out, dns_ttl_default_, dns_ttl_min_);
Expand Down Expand Up @@ -529,7 +531,8 @@ void WFResolverTask::dns_partial_callback(WFDnsTask *dns_task)
if (ctx->state == WFT_STATE_SUCCESS)
{
protocol::DnsResponse *resp = dns_task->get_resp();
ctx->eai_error = DnsUtil::getaddrinfo(resp, ctx->port, &ctx->ai);
ctx->eai_error = protocol::DnsUtil::getaddrinfo(resp, ctx->port,
&ctx->ai);
}
else
ctx->eai_error = EAI_NONAME;
Expand Down
7 changes: 6 additions & 1 deletion src/protocol/DnsUtil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
#include <string>
#include "DnsUtil.h"

int DnsUtil::getaddrinfo(const protocol::DnsResponse *resp,
namespace protocol
{

int DnsUtil::getaddrinfo(const DnsResponse *resp,
unsigned short port,
struct addrinfo **addrinfo)
{
Expand Down Expand Up @@ -140,3 +143,5 @@ void DnsUtil::freeaddrinfo(struct addrinfo *ai)
}
}

}

9 changes: 7 additions & 2 deletions src/protocol/DnsUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
* @brief Dns toolbox
*/

namespace protocol
{

class DnsUtil
{
public:
static int getaddrinfo(const protocol::DnsResponse *resp,
static int getaddrinfo(const DnsResponse *resp,
unsigned short port,
struct addrinfo **res);
static void freeaddrinfo(struct addrinfo *ai);
Expand All @@ -39,7 +42,7 @@ class DnsUtil
class DnsResultCursor
{
public:
DnsResultCursor(const protocol::DnsResponse *resp) :
DnsResultCursor(const DnsResponse *resp) :
parser(resp->get_parser())
{
dns_answer_cursor_init(&cursor, parser);
Expand Down Expand Up @@ -88,5 +91,7 @@ class DnsResultCursor
struct dns_record *record;
};

}

#endif

0 comments on commit 71b5531

Please sign in to comment.