mirror of
https://github.com/nmap/nmap.git
synced 2025-12-15 20:29:03 +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() -->
|
||||
|
||||
<!ELEMENT ports (extraports* , extrareasons*, port*) >
|
||||
<!ELEMENT ports (extraports* , port*) >
|
||||
|
||||
<!ELEMENT extraports EMPTY >
|
||||
<!ELEMENT extraports (extrareasons)* >
|
||||
<!ATTLIST extraports
|
||||
state %port_states; #REQUIRED
|
||||
count %attr_numeric; #REQUIRED
|
||||
|
||||
@@ -505,15 +505,15 @@
|
||||
<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>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
|
||||
<ul>
|
||||
<xsl:for-each select="extrareasons">
|
||||
<xsl:if test="@count > 0">
|
||||
<li><p><xsl:value-of select="@count" /> ports replied with: <b><xsl:value-of select="@reason" /></b></p></li>
|
||||
</xsl:if>
|
||||
<ul>
|
||||
<xsl:for-each select="extrareasons">
|
||||
<xsl:if test="@count > 0">
|
||||
<li><p><xsl:value-of select="@count" /> ports replied with: <b><xsl:value-of select="@reason" /></b></p></li>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</ul>
|
||||
</xsl:for-each>
|
||||
</ul>
|
||||
|
||||
<xsl:if test="count(port) > 0">
|
||||
<table cellspacing="1">
|
||||
|
||||
@@ -456,13 +456,13 @@ void printportoutput(Target *currenths, PortList *plist) {
|
||||
int istate;
|
||||
|
||||
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));
|
||||
print_xml_state_summary(plist, istate);
|
||||
log_write(LOG_XML, "</extraports>\n");
|
||||
prevstate = istate;
|
||||
}
|
||||
|
||||
print_xml_state_summary(plist);
|
||||
|
||||
if (numignoredports == plist->numports) {
|
||||
log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,
|
||||
"%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.ip_addr.s_addr = ip_addr;
|
||||
answer->reason.ttl = ttl;
|
||||
answer->reason.state = answer->state;
|
||||
setPortEntry(portno, proto, answer);
|
||||
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
|
||||
* 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;
|
||||
state_reason_summary_t *reason;
|
||||
unsigned int total = 0;
|
||||
@@ -260,7 +260,7 @@ static unsigned int get_state_summary(state_reason_summary_t *head, PortList *Po
|
||||
return 0;
|
||||
reason = head;
|
||||
|
||||
while((current = Ports->nextPort(current, proto, 0)) != NULL) {
|
||||
while((current = Ports->nextPort(current, proto, state)) != NULL) {
|
||||
if(Ports->isIgnoredState(current->state)) {
|
||||
total++;
|
||||
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 */
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
if((get_state_summary(reason_head, Ports) < 1)) {
|
||||
if((get_state_summary(reason_head, Ports, state) < 1)) {
|
||||
state_reason_summary_dinit(reason_head);
|
||||
return NULL;
|
||||
}
|
||||
@@ -316,7 +316,7 @@ void print_state_summary(PortList *Ports, unsigned short type) {
|
||||
char *separator = ", ";
|
||||
int states;
|
||||
|
||||
if((reason_head = print_state_summary_internal(Ports)) == NULL)
|
||||
if((reason_head = print_state_summary_internal(Ports, 0)) == NULL)
|
||||
return;
|
||||
|
||||
if(type == STATE_REASON_EMPTY)
|
||||
@@ -346,10 +346,10 @@ void print_state_summary(PortList *Ports, unsigned short type) {
|
||||
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;
|
||||
|
||||
if((currentr = reason_head = print_state_summary_internal(Ports)) == NULL)
|
||||
if((currentr = reason_head = print_state_summary_internal(Ports, state)) == NULL)
|
||||
return;
|
||||
|
||||
while(currentr != NULL) {
|
||||
|
||||
3
reason.h
3
reason.h
@@ -119,6 +119,7 @@ typedef struct port_reason {
|
||||
reason_t reason_id;
|
||||
struct in_addr ip_addr;
|
||||
unsigned short ttl;
|
||||
int state;
|
||||
} state_reason_t;
|
||||
|
||||
/* 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 */
|
||||
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.
|
||||
* Uses static return value so previous values will be over
|
||||
|
||||
Reference in New Issue
Block a user