Add the user's specified host name to XML output, if available. It looks

like this:

<hostnames>
<hostname name="openbsd.org" type="user"/>
<hostname name="cvs.openbsd.org" type="PTR"/>
</hostnames>
This commit is contained in:
david 2009-10-24 01:01:08 +00:00
parent f037a4828c
commit 719d9c9442
2 changed files with 16 additions and 13 deletions

View file

@ -55,7 +55,7 @@
<!-- don't know how to escape states like open|filtered -->
<!ENTITY % port_states "CDATA" >
<!ENTITY % hostname_types "(PTR)" >
<!ENTITY % hostname_types "(user|PTR)" >
<!-- see output.c:output_xml_scaninfo_records for scan types -->
<!ENTITY % scan_types "(syn|ack|bounce|connect|null|xmas|window|maimon|fin|udp|sctpinit|sctpcookieecho|ipproto)" >

View file

@ -1378,23 +1378,26 @@ static void print_MAC_XML_Info(Target * currenths) {
/* Helper function to write the status and address/hostname info of a host
into the XML log */
static void write_xml_initial_hostinfo(Target * currenths,
static void write_xml_initial_hostinfo(Target *currenths,
const char *status) {
log_write(LOG_XML, "<status state=\"%s\" reason=\"%s\"/>\n", status,
reason_str(currenths->reason.reason_id, SINGULAR));
log_write(LOG_XML, "<address addr=\"%s\" addrtype=\"%s\" />\n",
currenths->targetipstr(),
(o.af() == AF_INET) ? "ipv4" : "ipv6");
currenths->targetipstr(), (o.af() == AF_INET) ? "ipv4" : "ipv6");
print_MAC_XML_Info(currenths);
if (*currenths->HostName()) {
log_write(LOG_XML,
"<hostnames><hostname name=\"%s\" type=\"PTR\" /></hostnames>\n",
currenths->HostName());
} else {
/* If machine is up, put blank hostname so front ends know that no name
resolution is forthcoming */
if (strcmp(status, "up") == 0)
log_write(LOG_XML, "<hostnames />\n");
/* Output a hostnames element whenever we have a name to write or the target
is up. */
if (currenths->TargetName() != NULL || *currenths->HostName() || strcmp(status, "up") == 0) {
log_write(LOG_XML, "<hostnames>\n");
if (currenths->TargetName() != NULL) {
log_write(LOG_XML, "<hostname name=\"%s\" type=\"user\"/>\n",
currenths->TargetName());
}
if (*currenths->HostName()) {
log_write(LOG_XML, "<hostname name=\"%s\" type=\"PTR\"/>\n",
currenths->HostName());
}
log_write(LOG_XML, "</hostnames>\n");
}
log_flush_all();
}