1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-20 06:29:02 +00:00

Merged nsock-logging from nmap-exp/henri/nsock-logging/

Reworked the logging infrastructure to make it more flexible
and consistent.

Updated nmap, nping and ncat accordingly.  Nsock log level can
now be adjusted at runtime by pressing d/D in nmap.
This commit is contained in:
henri
2012-12-15 10:59:30 +00:00
parent 26816736b5
commit 809f1eda68
31 changed files with 563 additions and 330 deletions

View File

@@ -57,6 +57,7 @@
/* $Id$ */
#include "nsock_internal.h"
#include "nsock_log.h"
#include "netutils.h"
@@ -74,15 +75,12 @@ nsock_event_id nsock_readlines(nsock_pool nsp, nsock_iod ms_iod, nsock_ev_handle
nse = msevent_new(ms, NSE_TYPE_READ, nsi, timeout_msecs, handler, userdata);
assert(nse);
if (ms->tracelevel > 0) {
if (nsi->peerlen > 0)
nsock_trace(ms, "Read request for %d lines from IOD #%li [%s] EID %li",
nlines, nsi->id, get_peeraddr_string(nsi),
nse->id);
else
nsock_trace(ms, "Read request for %d lines from IOD #%li (peer unspecified) EID %li",
nlines, nsi->id, nse->id);
}
if (nsi->peerlen > 0)
nsock_log_info(ms, "Read request for %d lines from IOD #%li [%s] EID %li",
nlines, nsi->id, get_peeraddr_string(nsi), nse->id);
else
nsock_log_info(ms, "Read request for %d lines from IOD #%li (peer unspecified) EID %li",
nlines, nsi->id, nse->id);
nse->readinfo.read_type = NSOCK_READLINES;
nse->readinfo.num = nlines;
@@ -103,15 +101,12 @@ nsock_event_id nsock_readbytes(nsock_pool nsp, nsock_iod ms_iod, nsock_ev_handle
nse = msevent_new(ms, NSE_TYPE_READ, nsi, timeout_msecs, handler, userdata);
assert(nse);
if (ms->tracelevel > 0) {
if (nsi->peerlen > 0)
nsock_trace(ms, "Read request for %d bytes from IOD #%li [%s] EID %li",
nbytes, nsi->id, get_peeraddr_string(nsi),
nse->id);
else
nsock_trace(ms, "Read request for %d bytes from IOD #%li (peer unspecified) EID %li",
nbytes, nsi->id, nse->id);
}
if (nsi->peerlen > 0)
nsock_log_info(ms, "Read request for %d bytes from IOD #%li [%s] EID %li",
nbytes, nsi->id, get_peeraddr_string(nsi), nse->id);
else
nsock_log_info(ms, "Read request for %d bytes from IOD #%li (peer unspecified) EID %li",
nbytes, nsi->id, nse->id);
nse->readinfo.read_type = NSOCK_READBYTES;
nse->readinfo.num = nbytes;
@@ -132,15 +127,12 @@ nsock_event_id nsock_read(nsock_pool nsp, nsock_iod ms_iod, nsock_ev_handler han
nse = msevent_new(ms, NSE_TYPE_READ, nsi, timeout_msecs, handler, userdata);
assert(nse);
if (ms->tracelevel > 0) {
if (nsi->peerlen > 0)
nsock_trace(ms, "Read request from IOD #%li [%s] (timeout: %dms) EID %li",
nsi->id, get_peeraddr_string(nsi),
timeout_msecs, nse->id);
else
nsock_trace(ms, "Read request from IOD #%li (peer unspecified) (timeout: %dms) EID %li",
nsi->id, timeout_msecs, nse->id);
}
if (nsi->peerlen > 0)
nsock_log_info(ms, "Read request from IOD #%li [%s] (timeout: %dms) EID %li",
nsi->id, get_peeraddr_string(nsi), timeout_msecs, nse->id);
else
nsock_log_info(ms, "Read request from IOD #%li (peer unspecified) (timeout: %dms) EID %li",
nsi->id, timeout_msecs, nse->id);
nse->readinfo.read_type = NSOCK_READ;