mirror of
https://github.com/nmap/nmap.git
synced 2025-12-08 05:31:31 +00:00
merge soc07 r4914 - dynamic rowed table improvements
This commit is contained in:
@@ -264,9 +264,8 @@ bool NmapOutputTable::emptyRow(unsigned int nrow) {
|
|||||||
// function again, and it will also be invalidated if you free the
|
// function again, and it will also be invalidated if you free the
|
||||||
// table. If size is not NULL, it will be filled with the size of
|
// table. If size is not NULL, it will be filled with the size of
|
||||||
// the ASCII table in bytes (not including the terminating NUL)
|
// the ASCII table in bytes (not including the terminating NUL)
|
||||||
// If trim is true, excess empty rows are not returned
|
// All blank rows are removed from the returned string
|
||||||
//
|
char *NmapOutputTable::printableTable(int *size) {
|
||||||
char *NmapOutputTable::internalPrintableTable(int *size, bool trim) {
|
|
||||||
unsigned int col, row;
|
unsigned int col, row;
|
||||||
int maxsz = printableSize();
|
int maxsz = printableSize();
|
||||||
char *p;
|
char *p;
|
||||||
@@ -284,11 +283,8 @@ char *NmapOutputTable::internalPrintableTable(int *size, bool trim) {
|
|||||||
for(row = 0; row < numRows; row++) {
|
for(row = 0; row < numRows; row++) {
|
||||||
validthisrow = 0;
|
validthisrow = 0;
|
||||||
|
|
||||||
/* If this was called by printableTrimmedTable
|
if(emptyRow(row))
|
||||||
* (trim == true) we can ignore everything after an
|
continue;
|
||||||
* empty row */
|
|
||||||
if(trim && emptyRow(row))
|
|
||||||
break;
|
|
||||||
|
|
||||||
cell = getCellAddy(row, 0);
|
cell = getCellAddy(row, 0);
|
||||||
if(cell->fullrow && cell->strlength > 0) {
|
if(cell->fullrow && cell->strlength > 0) {
|
||||||
@@ -316,11 +312,3 @@ char *NmapOutputTable::internalPrintableTable(int *size, bool trim) {
|
|||||||
if (size) *size = p - tableout;
|
if (size) *size = p - tableout;
|
||||||
return tableout;
|
return tableout;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *NmapOutputTable::printableTable(int *size) {
|
|
||||||
return internalPrintableTable(size, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *NmapOutputTable::printableTrimmedTable(int *size) {
|
|
||||||
return internalPrintableTable(size, true);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -123,7 +123,10 @@ struct NmapOutputTableCell {
|
|||||||
|
|
||||||
class NmapOutputTable {
|
class NmapOutputTable {
|
||||||
public:
|
public:
|
||||||
// Create a table of the given dimensions
|
// Create a table of the given dimensions. Any completely
|
||||||
|
// blank rows will be removed when printableTable() is called.
|
||||||
|
// If the number of table rows is unknown then the highest
|
||||||
|
// number of possible rows should be specified.
|
||||||
NmapOutputTable(int nrows, int ncols);
|
NmapOutputTable(int nrows, int ncols);
|
||||||
~NmapOutputTable();
|
~NmapOutputTable();
|
||||||
|
|
||||||
@@ -146,14 +149,11 @@ class NmapOutputTable {
|
|||||||
// function again, and it will also be invalidated if you free the
|
// function again, and it will also be invalidated if you free the
|
||||||
// table. If size is not NULL, it will be filled with the size of
|
// table. If size is not NULL, it will be filled with the size of
|
||||||
// the ASCII table in bytes (not including the terminating NUL)
|
// the ASCII table in bytes (not including the terminating NUL)
|
||||||
|
// All blank rows will be removed from the returned string
|
||||||
char *printableTable(int *size);
|
char *printableTable(int *size);
|
||||||
|
|
||||||
// same as printableTable() but with excess empty rows removed
|
|
||||||
char *printableTrimmedTable(int *size);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
char *internalPrintableTable(int *size, bool trim);
|
|
||||||
bool emptyRow(unsigned int nrow);
|
bool emptyRow(unsigned int nrow);
|
||||||
// The table, squished into 1D. Access a member via getCellAddy
|
// The table, squished into 1D. Access a member via getCellAddy
|
||||||
struct NmapOutputTableCell *table;
|
struct NmapOutputTableCell *table;
|
||||||
|
|||||||
@@ -967,6 +967,8 @@ Traceroute::outputTarget (Target * t) {
|
|||||||
Tbl->addItem (row_count, HOST_COL, false, "ADDRESS", 7);
|
Tbl->addItem (row_count, HOST_COL, false, "ADDRESS", 7);
|
||||||
|
|
||||||
for (ttl_count = 1; ttl_count <= tg->hopDistance; ttl_count++) {
|
for (ttl_count = 1; ttl_count <= tg->hopDistance; ttl_count++) {
|
||||||
|
|
||||||
|
assert(row_count <= tg->hopDistance);
|
||||||
|
|
||||||
/* consolidate hops based on the reference trace (commonPath) */
|
/* consolidate hops based on the reference trace (commonPath) */
|
||||||
if(commonPath[ttl_count] && ttl_count <= tg->consolidation_start) {
|
if(commonPath[ttl_count] && ttl_count <= tg->consolidation_start) {
|
||||||
@@ -1057,7 +1059,7 @@ Traceroute::outputTarget (Target * t) {
|
|||||||
log_write(LOG_PLAIN, "\nTRACEROUTE (using proto %d/%s)\n", tg->proto, proto?proto->p_name:"unknown");
|
log_write(LOG_PLAIN, "\nTRACEROUTE (using proto %d/%s)\n", tg->proto, proto?proto->p_name:"unknown");
|
||||||
else
|
else
|
||||||
log_write(LOG_PLAIN, "\nTRACEROUTE (using port %d/%s)\n", tg->dport, proto2ascii(tg->proto));
|
log_write(LOG_PLAIN, "\nTRACEROUTE (using port %d/%s)\n", tg->dport, proto2ascii(tg->proto));
|
||||||
log_write (LOG_PLAIN, "%s", Tbl->printableTrimmedTable(NULL));
|
log_write (LOG_PLAIN, "%s", Tbl->printableTable(NULL));
|
||||||
|
|
||||||
if(G_TTL(tg->getState()))
|
if(G_TTL(tg->getState()))
|
||||||
log_write(LOG_PLAIN, "! maximum TTL reached (50)\n");
|
log_write(LOG_PLAIN, "! maximum TTL reached (50)\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user