This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mtr compilation problem


On 3/16/2011 10:59 AM, Olivier Lefevre wrote:
> Re. raw sockets and the need for elevated privilege,
> can't you use the RunAs trick to get around it?

Maybe.  Or you could recode the underlying implementation to use,
instead of the cygwin/posix socket interface, the Win32 ICMP dll
services, just like MS's own ping and tracert executables -- at least, when
	#if defined _WIN32 || defined __CYGWIN__
This allows to send ICMP packets as a regular user, but you don't have
as much flexibility in composing those packets (you can't set TTL, for
instance).

This is what FPing does (http://www.kwakkelflap.com/fping.html, not to
be confused with http://fping.sourceforge.net/).  However, FPing is
free-as-in-beer, but not free-as-in-speech (no source available).


The ICMP dll interface is technically undocumented for desktop systems,
but MS does provide documentation for the WinCE implementations.  It is
likely that the interface is the same.
"ICMP Reference" Windows CE .NET
http://msdn.microsoft.com/en-us/library/ms907315.aspx


I found this page:
http://www.sockets.com/ms_icmp.htm
which provides
	ms_icmp.h: ICMP API declarations, but apparently derived from
                   the documentation, not the MS SDK header. Also
	           (re)defines various constants (which cygwin w32api
	           provides in ipinfoid.h).  No copyright information on
	           this file -- but that's ok, it can be completely
	           re-written using the docu reference above.

	ms_icmp.c: implements 'ping' and 'traceroute' using these
	           functions. "Copyright by Bob Quinn, 1997" but with
	           no associated license information.  You'll need to
	           contact Bob directly (contact info at the webpage)
	           for explicit licensing info, if you want to use his
	           source code as the basis for a patch to mtr.

There are other references out there for "using ICMP API", some with
explicit licensing info
   http://tangentsoft.net/wskfaq/examples/dllping.html
	explicitly placed in the public domain

   http://serious-code.net/moin.cgi/ICMP
	seems to be a c++ wrapper around the sockets.com impl
	no licensing info

   http://www.hackchina.com/en/r/13544/pingi.c__html
	no licensing info

but they all either assume you are using the Windows SDK IcmpAPI.h, or
provide their own declarations of the functions/structs without saying
how they determined what they were (did they copy from IcmpAPI.h?).  So,
in order to use /those/ implementations as a basis for developing a
patch for mtr, you'll need to get the ICMP API stuff integrated into
cygwin's w32api using the procedure below.


=====================================
FYI: IcmpAPI.h from the windows SDK has no corresponding element in
cygwin's w32api.  To correct this, one would need to propose a patch
upstream to mingw-users AT lists DOT sourceforge DOT net...and be
prepared to show that your patch derives from http://msdn.com/.... and
NOT from "I looked at the MS Windows SDK IcmpAPI.h file and..."  That's
why I gave the direct msdn link, above.

=====================================
I also found this, applicable for receiving unfiltered packets (e.g.
Destination Unreachable, or TTL Expired) on Vista+

http://www.okob.net/wp/index.php/2009/04/30/icmp-over-raw-sockets-under-windows-vista/

but that doesn't help for sending raw packets. It uses a couple of
constants in a WSAIoctl() call [RCVALL_IPLEVEL, SIO_RCVALL] which are
not currently defined in cygwin's w32api.

These are documented here
http://msdn.microsoft.com/en-us/library/ee309610%28v=vs.85%29.aspx
but unfortunately does not define the actual numerical VALUES. Sigh.
=======================================

--
Chuck

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]