1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 14:11:29 +00:00

constify Target::NameIP.

This commit is contained in:
david
2013-02-26 04:34:28 +00:00
parent af4f519f10
commit f42308248d
2 changed files with 5 additions and 5 deletions

View File

@@ -383,7 +383,7 @@ void Target::setTargetName(const char *name) {
(64.71.184.53)" or "fe80::202:e3ff:fe14:1102". The name is (64.71.184.53)" or "fe80::202:e3ff:fe14:1102". The name is
written into the buffer provided, which is also returned. Results written into the buffer provided, which is also returned. Results
that do not fit in buflen will be truncated. */ that do not fit in buflen will be truncated. */
const char *Target::NameIP(char *buf, size_t buflen) { const char *Target::NameIP(char *buf, size_t buflen) const {
assert(buf); assert(buf);
assert(buflen > 8); assert(buflen > 8);
if (targetname) if (targetname)
@@ -396,7 +396,7 @@ const char *Target::NameIP(char *buf, size_t buflen) {
} }
/* This next version returns a static buffer -- so no concurrency */ /* This next version returns a static buffer -- so no concurrency */
const char *Target::NameIP() { const char *Target::NameIP() const {
if (!nameIPBuf) nameIPBuf = (char *) safe_malloc(MAXHOSTNAMELEN + INET6_ADDRSTRLEN); if (!nameIPBuf) nameIPBuf = (char *) safe_malloc(MAXHOSTNAMELEN + INET6_ADDRSTRLEN);
return NameIP(nameIPBuf, MAXHOSTNAMELEN + INET6_ADDRSTRLEN); return NameIP(nameIPBuf, MAXHOSTNAMELEN + INET6_ADDRSTRLEN);
} }

View File

@@ -205,9 +205,9 @@ class Target {
(64.71.184.53)" or "fe80::202:e3ff:fe14:1102". The name is (64.71.184.53)" or "fe80::202:e3ff:fe14:1102". The name is
written into the buffer provided, which is also returned. Results written into the buffer provided, which is also returned. Results
that do not fit in buflen will be truncated. */ that do not fit in buflen will be truncated. */
const char *NameIP(char *buf, size_t buflen); const char *NameIP(char *buf, size_t buflen) const;
/* This next version returns a STATIC buffer -- so no concurrency */ /* This next version returns a STATIC buffer -- so no concurrency */
const char *NameIP(); const char *NameIP() const;
/* Give the name from the last setTargetName() call, which is the /* Give the name from the last setTargetName() call, which is the
name of the target given on the command line if it's a named name of the target given on the command line if it's a named
@@ -328,7 +328,7 @@ class Target {
int directly_connected; // -1 = unset; 0 = no; 1 = yes int directly_connected; // -1 = unset; 0 = no; 1 = yes
char targetipstring[INET6_ADDRSTRLEN]; char targetipstring[INET6_ADDRSTRLEN];
char sourceipstring[INET6_ADDRSTRLEN]; char sourceipstring[INET6_ADDRSTRLEN];
char *nameIPBuf; /* for the NameIP(void) function to return */ mutable char *nameIPBuf; /* for the NameIP(void) function to return */
u8 MACaddress[6], SrcMACaddress[6], NextHopMACaddress[6]; u8 MACaddress[6], SrcMACaddress[6], NextHopMACaddress[6];
bool MACaddress_set, SrcMACaddress_set, NextHopMACaddress_set; bool MACaddress_set, SrcMACaddress_set, NextHopMACaddress_set;
struct host_timeout_nfo htn; struct host_timeout_nfo htn;