1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-22 15:39:03 +00:00
Commit Graph

373 Commits

Author SHA1 Message Date
david
d52a6fd23c Straighten out port computation in nsock_connect_internal.
There was a bug here where AF_INET6 was used instead of AF_UNIX in the
HAVE_SYS_UN_H section. This masked another bug, which was that the
HAVE_SYS_UN_H section inadvertently extended into what was supposed to
be the HAVE_IPV6 section.
2012-11-27 21:47:25 +00:00
david
d81b4112a0 Don't add rc to write_count when rc is negative.
Noticed by Tomas Hozza.
2012-11-26 22:13:30 +00:00
david
0232192312 Move inclusion of <errno.h> to after HAVE_POLL.
Suggested by Henri.
http://seclists.org/nmap-dev/2012/q4/286
2012-11-20 19:43:55 +00:00
david
8f5ed637f9 Include <errno.h> in engine_poll.c for EINTR.
I'm not sure why I wasn't seeing this error before:
engine_poll.c: In function ‘poll_loop’:
engine_poll.c:352:46: error: ‘EINTR’ undeclared (first use in this function)
engine_poll.c:352:46: note: each undeclared identifier is reported only once for each function it appears in
2012-11-20 18:59:41 +00:00
david
641dddafb5 Use socket_bindtodevice instead of bare setsockopt in Nsock. 2012-11-16 21:02:57 +00:00
david
8dd3a8a66e Fix SO_BINDTODEVICE Nsock error message. 2012-11-16 21:02:54 +00:00
fyodor
ea05ae2586 Latest auto-generated files in prep for upcoming 6.20BETA1 release 2012-11-16 00:54:16 +00:00
david
7b371609a3 Refactor get_hostaddr_string to get_peeraddr_string.
All the information passed as arguments is present in an iod, and we
only call this with members of one iod. Change it to accept just an iod
as an argument.
2012-11-12 20:44:49 +00:00
david
f5ac3e9f4e Put brackets on PEER_STR_LEN.
Maybe we'll decide to add these; anyway more space doesn't hurt.
2012-11-12 20:44:46 +00:00
david
f01e3800fb Implementation of UNIX-domain sockets for Nsock.
Implementation of UNIX-domain sockets functionality
for Nsock. Also some minor necessary changes to
existing Nsock functions, to work properly with
UNIX-domain sockets.
2012-11-12 20:44:37 +00:00
henri
99424a2b3e Only set HAVE_POLL on Vista and later.
Patch by Gisle Vanem
2012-11-02 10:53:24 +00:00
henri
cb3d88247b Fixed function name in error message. 2012-10-30 09:45:14 +00:00
henri
4b1e2a94bb A couple adjustemnt for windows.
- Do not set the X flags as events to be watched.
  - Do not use POLLPRI as a R flag.

Not doing so causes WSAPoll() to fail with an "invalid argument" error.
2012-10-22 17:57:58 +00:00
henri
ef9f4fcba5 Reverted r30104 and r30105. 2012-10-22 17:17:28 +00:00
henri
34b0f235cd Include nbase_winunix.h from nsock_internal.h 2012-10-22 15:55:46 +00:00
henri
aef88b5b1b Do not include Winsock.h before including nsock_internal.h (that
includes nbase_winconfig.h). Otherwise WSAEINTR doesn't get redefined
as EINTR as desired.
2012-10-22 15:43:30 +00:00
henri
9865b8f828 Cleaning up: consistently get event masks from a static inline get_evmask() function. 2012-10-22 04:26:19 +00:00
david
62570b7be7 Needed for HAVE_POLL. 2012-10-22 02:16:35 +00:00
david
0176367387 Regen configure. 2012-10-21 23:22:37 +00:00
henri
0d3dda36d4 Added new poll and kqueue/kevent nsock engines.
poll should be available almost everywhere.
kqueue/kevent are available on BSD systems (including MacOS).
2012-10-21 23:20:35 +00:00
henri
4cedcef575 Separate engine names by spaces instead of commas for consistency with
the other lines produced by nmap -V
2012-10-21 22:56:54 +00:00
henri
e76d41fa04 Don't fatal() in nsock_set_default_engine()
Return negative value instead. Moved the fatal() statement to nmap.cc
2012-10-21 22:56:53 +00:00
henri
3d2eeaa94d Finally added a function to list the available nsock engines. 2012-10-21 20:21:01 +00:00
henri
615de92974 Ensure that the nsock engine_hint refers to a valid one. If not, abort
execution.
2012-10-21 19:44:26 +00:00
henri
e2fb7301de Avoid sending error message to stdout 2012-10-10 18:59:13 +00:00
david
3e9f862ce3 Add nsock_setdevice function.
This function allows setting the device that will be used in
SO_BINDTODEVICE setsockopt calls for all new sockets.
2012-10-03 15:43:16 +00:00
david
2f2e826487 Remove OpenSSL directory, moved to /nmap-mswin32-aux. 2012-10-02 00:53:12 +00:00
henri
e60ba1b617 Use nse_errorcode() to get the actual errors. 2012-09-21 09:08:24 +00:00
henri
b4607a5071 Style fixes.
indent -nut -i2 -kr -br -brs -brf -l0 -bad -npcs -nprs -ncs <files> and manual adjustments.
2012-09-21 09:05:59 +00:00
david
7e5c9a8914 Regen with Autoconf 2.68 and aclocal 1.11.6.
for DIR in . nbase ncat nsock/src nping;
	do (echo $DIR; cd $DIR && aclocal --force && autoconf --force);
done
2012-09-19 16:41:35 +00:00
henri
a1d5763563 Fixed filename in header. 2012-09-10 21:03:17 +00:00
david
5ab8e37be6 Recognize WSAEADDRINUSE in handle_connect_result.
This happens on Windows when two sockets bind to the same local port and
connect to the same remote port on a remote host. I tried this on Linux;
Linux prevents the second bind from succeeding.

http://seclists.org/nmap-dev/2012/q2/513
2012-09-06 20:11:08 +00:00
david
66c296e27f Use socket_strerror in Nsock callback traces.
Otherwise WinSock error numbers are not understood; you get "Unknown
error" instead of "Only one usage of each socket address
(protocol/network address/port) is normally permitted." for example.
2012-09-06 20:11:04 +00:00
david
640714f63d Use a more sophisticated configure check for epoll.
This is from the GNU Autoconf archive.

http://www.gnu.org/software/autoconf-archive/ax_have_epoll.html

http://seclists.org/nmap-dev/2012/q3/598
http://seclists.org/nmap-dev/2012/q3/657
2012-09-02 22:47:09 +00:00
henri
89537773ce Removed extra '\n', another one being added by the function. 2012-07-30 19:54:11 +00:00
henri
a111b5bcdc [NSOCK] Sandwitched pcap_read_on_nonselect() statements between #ifndef
PCAP_CAN_DO_SELECT guards to prevent them from being executed on systems that
actually provide selectable pcap descriptors.
2012-07-17 16:38:15 +00:00
henri
a2f308a8f8 Removed duplicate declaration of a msiod *nsi variable.
It's used two times, in two separate blocks of the function. Therefore it was
declared twice (once per block), then got moved toplevel but the second
declaration was forgotten somehow.

This doesn't actually change anything (identical objdump -d diff) but makes code
nicer.
2012-07-13 21:18:03 +00:00
henri
87fcddad2b Fixed a couple nsock problems described in
http://seclists.org/nmap-dev/2012/q3/56.  r29134 already addressed the issue but
was incomplete.

This replaces r29134 with an engine-agnostic approach, and additionally enforces
the reset of IOD flags before use or re-use.
2012-07-09 16:45:49 +00:00
henri
9baacdf9e3 [NSOCK] Fixed an epoll-engine-specific bug. The engine didn't recognized FDs
that were internally closed and replaced by other ones. This happened during
reconnect attempts.

--

When reconnecting with SSL_OP_NO_SSLv2 (nsock_core.c:472), the libary closes the
fd of the current IOD, and replaces it by a new one.

The man page for epoll_ctl states that a close() on a fd makes it removed from
any epoll set it was in. Therefore, if epoll_ctl(EPOLL_CTL_MOD, ...) returns
ENOENT, we retry with EPOLL_CTL_ADD.
2012-07-05 14:35:51 +00:00
henri
d86d3f68c2 Made nsock messages more consistent.
- Always format function name without parens at the beginning of a message.
  - Added a nsi_new notification message.
  - Only trace the first call to nsi_delete() of a given IOD (i.e. don't log the
    calls issued from the resulting callbacks).
2012-07-05 14:22:26 +00:00
henri
f7ba1847cf Enforce proper variable initialization. 2012-07-03 12:19:24 +00:00
david
7f5d53184c Uniform handling of makefile.dep in makefiles.
"make clean" keeps makefile.dep and "make distclean" deletes it. This
patch is by Michael McTiernan.

http://seclists.org/nmap-dev/2012/q2/827
2012-06-19 14:06:49 +00:00
david
685f5fa4c3 Define SOLARIS_BPF_PCAP_CAPTURE for Solaris 11.
Solaris 11 uses BPF packet capture rather than DLPI, which requires
different handling in many cases. The new preprocessor symbol tells when
this is the case; it is additional granularity on top of SOLARIS.
2012-04-07 08:07:41 +00:00
david
05c713d22a Don't try to do FD_ISSET on a nonselectable pcap descriptor.
The Nsock select engine stores readiness information in a mask instead
of doing an FD_ISSET against the descriptor every time. This is a good
idea, but it removed a special case in the pre-engines code: in case
PCAP_CAN_DO_SELECT is not defined, we can't do FD_ISSET on the
descriptor because it is -1. Here we check for that occurrence and set
EV_READ in the mask so that a non-blocking pcap read can happen every
iteration.
2012-04-05 03:30:09 +00:00
david
4a541fc367 Add an assert that I am currently able to make fail. 2012-04-05 01:37:59 +00:00
david
b1583a66e6 Centralize nsock_tod updates in msevent_new.
This was being done manually for various types of events, and not doing
it in every case was causing hard-to-find bugs. See the log messages for
r19970 in /nsock and r28292 in /nmap.
2012-03-29 17:43:35 +00:00
david
9cd1ef697b Update nsock_tod before creating a timer.
nsock_tod is Nsock's idea of the current time. It is updated when an
nsock_pool is initialized, on each iteration of nsock_loop, and in a few
other places. What could go wrong, with respect to timers, is a sequence
like this:
	nsp_new
	[... some long delay ...]
	nsock_create_timer(timeout)
	nsock_loop
The time elapsed after the creatino of the timer until it fires would
not be timeout, but rather timeout - delay. If the delay was long
enough, the timer would fire as loop as nsock_loop was entered.

This showed itself in IPv6 OS detection. We schedule 6 timers
immediately, 100 ms apart. If the pcap_open or anything else took too
long, then the timers would fire all at once. This messed up the
calculation of the TCP_ISR feature.

Perhaps we should do this when any new event is created? It is already
done manually at the beginning of each of the connect functions.
2012-03-16 20:02:57 +00:00
henri
b1086ac340 Added a --nsock-engine option to nmap, nping and ncat to enforce use of a
given nsock IO engine. [Henri]
2012-03-01 09:05:02 +00:00
fyodor
e96a7b7b24 Update the headers for each code file. This updates code copyright dates to 2012, notes the awesome NSE in the list of technology, and slightly rewords the derivative works clarification 2012-03-01 06:32:23 +00:00
henri
dbda99204b Extreme nitpicking: added missing closing parentheses in comments. 2012-02-23 18:22:37 +00:00