Nmap Development mailing list archives

Re: Enhanced nsock logging


From: Henri Doreau <henri.doreau () gmail com>
Date: Fri, 14 Dec 2012 16:33:12 +0100

2012/12/8 Henri Doreau <henri.doreau () gmail com>:
Hello,

I've been working on improving the nsock logging abilities recently.
The initial problem was that nsock loglevel could not be easily set to
a desired value from command line (the easiest was to patch
nsock_pool.c and rebuild...) and also that this level could not be
adjusted at runtime by pressing d/D. Additionally, I had this personal
frustration with the nsock code which directly printed out the
messages instead of generating log objects.

The patched version of nsock that you can find in my nsock-logging
branch[1] exports the following:
  * four different log levels
    - NSOCK_LOG_DBG_ALL
    - NSOCK_LOG_DBG
    - NSOCK_LOG_INFO
    - NSOCK_LOG_ERROR
  * getter/setter to the loglevel of a given nsock_pool
  * a nsock_log_rec structure type that contains the log message as
well as some context information (date, line, file, function name...)
  * a way to set a custom logging function that will receive every
nsock_log_rec object whose level is >= the one set for the current
nsock_pool.

With this in hand, I've modified nmap, ncat and nping to fix the
issues mentioned above. Within nsock, logging is now more consistent
and cleaner. Nmap has a mapping between its own log level and nsock
(see nmap_adjust_loglevel() in output.cc) , plus this is adaptive.
Highest log levels can now be enabled with ncat (was only 0 or 1
before). Things don't change much for nping.


Testing feedback and suggestions are welcome!


Regards.

[1] https://svn.nmap.org/nmap-exp/henri/nsock-logging

I think the code is ready and I'd like to merge it to ease other
ongoing nsock developments.

Let me know if I can provide more explanations, details or anything
that would be helpful.

Regards

-- 
Henri
_______________________________________________
Sent through the dev mailing list
http://nmap.org/mailman/listinfo/dev
Archived at http://seclists.org/nmap-dev/


Current thread: