mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 14:49:29 +00:00
Improve string representation of DNS query in debug output
This commit is contained in:
parent
e1a2577ffd
commit
37e0f7f80b
2 changed files with 7 additions and 4 deletions
|
|
@ -1823,8 +1823,10 @@ size_t DNS::Packet::parseFromBuffer(const u8 *buf, size_t maxlen)
|
|||
return ret;
|
||||
}
|
||||
|
||||
const char *DNS::Request::repr()
|
||||
const char *DNS::Request::repr() const
|
||||
{
|
||||
#define REPR_BUFSIZE (FQDN_LEN + 16)
|
||||
static char buf[REPR_BUFSIZE] = "\0";
|
||||
switch(type) {
|
||||
case DNS::NONE:
|
||||
return "Uninitialized request";
|
||||
|
|
@ -1832,7 +1834,7 @@ const char *DNS::Request::repr()
|
|||
case DNS::A:
|
||||
case DNS::AAAA:
|
||||
case DNS::ANY:
|
||||
return name.c_str();
|
||||
Snprintf(buf, REPR_BUFSIZE, "%s/%d", name.c_str(), type);
|
||||
break;
|
||||
case DNS::PTR:
|
||||
if (ssv.size() > 0) {
|
||||
|
|
@ -1843,7 +1845,8 @@ const char *DNS::Request::repr()
|
|||
}
|
||||
break;
|
||||
default:
|
||||
return "Invalid request";
|
||||
Snprintf(buf, REPR_BUFSIZE, "Invalid request: %d", type);
|
||||
break;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ struct Request
|
|||
std::string name;
|
||||
void *userdata;
|
||||
Request() : type(NONE), ssv(), name(), userdata(NULL) {}
|
||||
const char *repr(); // string representation
|
||||
const char *repr() const; // string representation
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue