mirror of
https://github.com/nmap/nmap.git
synced 2025-12-17 13:09:02 +00:00
merge soc07 r4957 - Put <extrareasons> inside <extraports> as this should really simplify XML parsers' jobs because they won't have to keep track of what states and reasons go together
This commit is contained in:
@@ -161,9 +161,9 @@
|
|||||||
|
|
||||||
<!-- these elements are written by output.c:printportoutput() -->
|
<!-- these elements are written by output.c:printportoutput() -->
|
||||||
|
|
||||||
<!ELEMENT ports (extraports* , extrareasons*, port*) >
|
<!ELEMENT ports (extraports* , port*) >
|
||||||
|
|
||||||
<!ELEMENT extraports EMPTY >
|
<!ELEMENT extraports (extrareasons)* >
|
||||||
<!ATTLIST extraports
|
<!ATTLIST extraports
|
||||||
state %port_states; #REQUIRED
|
state %port_states; #REQUIRED
|
||||||
count %attr_numeric; #REQUIRED
|
count %attr_numeric; #REQUIRED
|
||||||
|
|||||||
@@ -505,7 +505,6 @@
|
|||||||
<xsl:if test="@count > 0">
|
<xsl:if test="@count > 0">
|
||||||
<p>The <xsl:value-of select="@count" /> ports scanned but not shown below are in state: <b><xsl:value-of select="@state" /></b></p>
|
<p>The <xsl:value-of select="@count" /> ports scanned but not shown below are in state: <b><xsl:value-of select="@state" /></b></p>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:for-each>
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<xsl:for-each select="extrareasons">
|
<xsl:for-each select="extrareasons">
|
||||||
@@ -514,6 +513,7 @@
|
|||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</ul>
|
</ul>
|
||||||
|
</xsl:for-each>
|
||||||
|
|
||||||
<xsl:if test="count(port) > 0">
|
<xsl:if test="count(port) > 0">
|
||||||
<table cellspacing="1">
|
<table cellspacing="1">
|
||||||
|
|||||||
@@ -456,13 +456,13 @@ void printportoutput(Target *currenths, PortList *plist) {
|
|||||||
int istate;
|
int istate;
|
||||||
|
|
||||||
while ((istate = plist->nextIgnoredState(prevstate)) != PORT_UNKNOWN) {
|
while ((istate = plist->nextIgnoredState(prevstate)) != PORT_UNKNOWN) {
|
||||||
log_write(LOG_XML, "<extraports state=\"%s\" count=\"%d\" />\n",
|
log_write(LOG_XML, "<extraports state=\"%s\" count=\"%d\">\n",
|
||||||
statenum2str(istate), plist->getStateCounts(istate));
|
statenum2str(istate), plist->getStateCounts(istate));
|
||||||
|
print_xml_state_summary(plist, istate);
|
||||||
|
log_write(LOG_XML, "</extraports>\n");
|
||||||
prevstate = istate;
|
prevstate = istate;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_xml_state_summary(plist);
|
|
||||||
|
|
||||||
if (numignoredports == plist->numports) {
|
if (numignoredports == plist->numports) {
|
||||||
log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,
|
log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,
|
||||||
"%s %d scanned %s on %s %s ",
|
"%s %d scanned %s on %s %s ",
|
||||||
|
|||||||
@@ -744,6 +744,7 @@ int PortList::setStateReason(u16 portno, u8 proto, reason_t reason, u8 ttl, u32
|
|||||||
answer->reason.reason_id = reason;
|
answer->reason.reason_id = reason;
|
||||||
answer->reason.ip_addr.s_addr = ip_addr;
|
answer->reason.ip_addr.s_addr = ip_addr;
|
||||||
answer->reason.ttl = ttl;
|
answer->reason.ttl = ttl;
|
||||||
|
answer->reason.state = answer->state;
|
||||||
setPortEntry(portno, proto, answer);
|
setPortEntry(portno, proto, answer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
14
reason.cc
14
reason.cc
@@ -250,7 +250,7 @@ static int update_state_summary(state_reason_summary_t *head, reason_t reason_id
|
|||||||
|
|
||||||
/* Converts Port objects and their corrosponsing state_reason structures into
|
/* Converts Port objects and their corrosponsing state_reason structures into
|
||||||
* state_reason_summary structures using update_state_summary */
|
* state_reason_summary structures using update_state_summary */
|
||||||
static unsigned int get_state_summary(state_reason_summary_t *head, PortList *Ports) {
|
static unsigned int get_state_summary(state_reason_summary_t *head, PortList *Ports, int state) {
|
||||||
Port *current = NULL;
|
Port *current = NULL;
|
||||||
state_reason_summary_t *reason;
|
state_reason_summary_t *reason;
|
||||||
unsigned int total = 0;
|
unsigned int total = 0;
|
||||||
@@ -260,7 +260,7 @@ static unsigned int get_state_summary(state_reason_summary_t *head, PortList *Po
|
|||||||
return 0;
|
return 0;
|
||||||
reason = head;
|
reason = head;
|
||||||
|
|
||||||
while((current = Ports->nextPort(current, proto, 0)) != NULL) {
|
while((current = Ports->nextPort(current, proto, state)) != NULL) {
|
||||||
if(Ports->isIgnoredState(current->state)) {
|
if(Ports->isIgnoredState(current->state)) {
|
||||||
total++;
|
total++;
|
||||||
update_state_summary(reason, current->reason.reason_id);
|
update_state_summary(reason, current->reason.reason_id);
|
||||||
@@ -270,7 +270,7 @@ static unsigned int get_state_summary(state_reason_summary_t *head, PortList *Po
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* parse and sort reason summary for main print_* functions */
|
/* parse and sort reason summary for main print_* functions */
|
||||||
static state_reason_summary_t *print_state_summary_internal(PortList *Ports) {
|
static state_reason_summary_t *print_state_summary_internal(PortList *Ports, int state) {
|
||||||
state_reason_summary_t *reason_head;
|
state_reason_summary_t *reason_head;
|
||||||
|
|
||||||
if((reason_head = (state_reason_summary_t *)malloc(sizeof(state_reason_summary_t))) == NULL) {
|
if((reason_head = (state_reason_summary_t *)malloc(sizeof(state_reason_summary_t))) == NULL) {
|
||||||
@@ -280,7 +280,7 @@ static state_reason_summary_t *print_state_summary_internal(PortList *Ports) {
|
|||||||
|
|
||||||
state_reason_summary_init(reason_head);
|
state_reason_summary_init(reason_head);
|
||||||
|
|
||||||
if((get_state_summary(reason_head, Ports) < 1)) {
|
if((get_state_summary(reason_head, Ports, state) < 1)) {
|
||||||
state_reason_summary_dinit(reason_head);
|
state_reason_summary_dinit(reason_head);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -316,7 +316,7 @@ void print_state_summary(PortList *Ports, unsigned short type) {
|
|||||||
char *separator = ", ";
|
char *separator = ", ";
|
||||||
int states;
|
int states;
|
||||||
|
|
||||||
if((reason_head = print_state_summary_internal(Ports)) == NULL)
|
if((reason_head = print_state_summary_internal(Ports, 0)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(type == STATE_REASON_EMPTY)
|
if(type == STATE_REASON_EMPTY)
|
||||||
@@ -346,10 +346,10 @@ void print_state_summary(PortList *Ports, unsigned short type) {
|
|||||||
state_reason_summary_dinit(reason_head);
|
state_reason_summary_dinit(reason_head);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_xml_state_summary(PortList *Ports) {
|
void print_xml_state_summary(PortList *Ports, int state) {
|
||||||
state_reason_summary_t *reason_head, *currentr;
|
state_reason_summary_t *reason_head, *currentr;
|
||||||
|
|
||||||
if((currentr = reason_head = print_state_summary_internal(Ports)) == NULL)
|
if((currentr = reason_head = print_state_summary_internal(Ports, state)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while(currentr != NULL) {
|
while(currentr != NULL) {
|
||||||
|
|||||||
3
reason.h
3
reason.h
@@ -119,6 +119,7 @@ typedef struct port_reason {
|
|||||||
reason_t reason_id;
|
reason_t reason_id;
|
||||||
struct in_addr ip_addr;
|
struct in_addr ip_addr;
|
||||||
unsigned short ttl;
|
unsigned short ttl;
|
||||||
|
int state;
|
||||||
} state_reason_t;
|
} state_reason_t;
|
||||||
|
|
||||||
/* used to calculate state reason summaries.
|
/* used to calculate state reason summaries.
|
||||||
@@ -173,7 +174,7 @@ const char *reason_str(reason_t reason_id, unsigned int number);
|
|||||||
|
|
||||||
/* Displays reason summary messages */
|
/* Displays reason summary messages */
|
||||||
void print_state_summary(PortList *Ports, unsigned short type);
|
void print_state_summary(PortList *Ports, unsigned short type);
|
||||||
void print_xml_state_summary(PortList *Ports);
|
void print_xml_state_summary(PortList *Ports, int state);
|
||||||
|
|
||||||
/* Build an output string based on reason and source ip address.
|
/* Build an output string based on reason and source ip address.
|
||||||
* Uses static return value so previous values will be over
|
* Uses static return value so previous values will be over
|
||||||
|
|||||||
Reference in New Issue
Block a user