Google Answers Logo
View Question
 
Q: need source code for unix-style ICMP ping for windows ( No Answer,   3 Comments )
Question  
Subject: need source code for unix-style ICMP ping for windows
Category: Computers > Programming
Asked by: hl_slaughter-ga
List Price: $25.00
Posted: 05 Jul 2002 19:04 PDT
Expires: 22 Jul 2002 17:01 PDT
Question ID: 36921
i've been searching for and have not found the source code for a
commandline based ping program for winNT that meets the following
criteria:

- written in C (not C++ C# but *C*)
- no use of any windows API garbage (except for winsock or maybe
ICMP.dll)
- compiles with gcc (not MS Visual crap or Borland) on windows. should
compile under the Cygwin environment or something similar (ie unix for
windows)

i am looking for something that demonstrates a simple ICMP echo
request

i'm attempting to port a network scanning app to windows. i've gotten
everything to compile but the ping module because i am not familiar
with how to fake berkeley style sockets and ICMP under Winblows.

tks
Answer  
There is no answer at this time.

The following answer was rejected by the asker (they received a refund for the question).
Subject: Re: need source code for unix-style ICMP ping for windows
Answered By: blader-ga on 11 Jul 2002 14:34 PDT
Rated:1 out of 5 stars
 
Dear hl_slaughter:

I have found two pieces of source code that may fit your needs. One is
the original ping source code by Mike Muuss, and the other is a
modification of it to receive time stamps (rather than time delay).
Both are purported to work uunder GCC, but I don't have GCC on my
system to test it. If you have any problems with them, let me know:

Here is the original source code by Mike Muuss:
http://www.programmersheaven.com/zone15/cat241/2417.htm

This is the source code on which all other ping programs are based
upon.

Here is the icmpquery.c modification:
http://www.angio.net/security/icmpquery.c

The comments from the above source code:

 * Verified to work on:
 *    FreeBSD (2.x, 3.x)
 *    Linux 2.0.x, 2.2.0-pre1
 *    NetBSD 1.3
 *
 * Should work on Solaris and other platforms with BSD-ish stacks.
 *
 * If you compile it somewhere else, or it doesn't work somewhere,
 * please let me know.
 *
 * Compilation:  gcc icmpquery.c -o icmpquery
 *
 * One usage note:  In order to receive accurate time information,
 *                  the time on your computer must be correct; the
 *                  ICMP timestamp reply is a relative time figure.


Google Search Terms:
 

     icmp ping source code gcc   
://www.google.com/search?q=icmp+ping+source+code+gcc&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&start=10&sa=N

I hope this was what you were looking for! If you have any problems or
need any clarifications, please don't hesitate to ask. I would be more
than happy to assist you further.

Best Regards,
blader-ga

Clarification of Answer by blader-ga on 16 Jul 2002 20:17 PDT
Dear hl_slaughter:

I apologize for not reading your question more carefully in my
research. I'm happy to find that you have found code that does work.
If you would like to apply for a refund, you may do so here:
https://answers.google.com/answers/main?cmd=refundrequest

Sincerely,
blader-ga
Reason this answer was rejected by hl_slaughter-ga:
user who claimed the answer did not answer the question at all. i
asked for source for a winnt program, he provided readily available
source for unix program.

user donq did in fact provide a link with the info i wanted, but he
did not claim the answer (because he was not sure it was the answer).

donq should get the money, not user "blader".
hl_slaughter-ga rated this answer:1 out of 5 stars
Neither of these will compile under windows. These are apps written
specifically to work under Unix (for which most source code is easily
located on my computer :)

I was looking for something that would *compile under windows* using
nothing more than winsock calls.

in fact, the link found by donq-ga does include code that will compile
under windows using the following commands:

  gcc -D__USE_W32_SOCKETS -O -c -o ping.o ping.c
  gcc -D__USE_W32_SOCKETS -o ping.exe ping.o -s -lwsock32

But the original source for ping will not compile under Windows
because there is no support under Windows for ICMP (except through
something like winsock).

Comments  
Subject: Re: need source code for unix-style ICMP ping for windows
From: donq-ga on 05 Jul 2002 20:26 PDT
 
Hello hl_slaughter,

In this link (http://www.sockaddr.com/ExampleSourceCode.html) you can
find a file named Ping.zip which is described as a “Ping program using
ICMP and RAW sockets.”  I looked over the source code in the zip file,
and it was written in regular C (not CPP or C#). The source uses
winsock.h.  I am presently unable to verify if the file(s) compile
with gcc.

Hope this comment was useful to you.
Subject: Re: need source code for unix-style ICMP ping for windows
From: hl_slaughter-ga on 07 Jul 2002 23:58 PDT
 
thanks for the link. i'm checking it out. it may be what i need. it
doesn't compile under cygwin, but the errors may be minor.

if i can make this work, you can claim the answer : )
Subject: Re: need source code for unix-style ICMP ping for windows
From: hl_slaughter-ga on 08 Jul 2002 11:29 PDT
 
see, this is what i hate about trying to work with windows. not sure
if this is an issue with cygwin or winsock, but i get conflicting
definitions.

Administrator@HARRYS-VM /cygdrive/h/ant/src/ws2_ping
$ gcc ping.c
In file included from ping.c:7:
/usr/include/w32api/winsock.h:82: warning: #warning "fd_set and
associated macro
s have been defined in sys/types.      This can cause runtime problems
with W32
sockets"
ping.c: In function `main':
ping.c:24: warning: return type of `main' is not `int'
ping.c: In function `WaitForEchoReply':
ping.c:221: structure has no member named `fd_count'
ping.c:222: structure has no member named `fd_array'

Administrator@HARRYS-VM /cygdrive/h/ant/src/ws2_ping

there's a good thread on this topic here:
http://sources.redhat.com/ml/newlib/2001/msg00124.html

unfortunately there's no mention of what a humble, lowly guy like
myself is supposed to do about this (other than wait for patches).
there's no way i'm going to try to hunt down definition conflicts
within multi-nested includes (and have anything that works
afterwards).

i know someone has suffered through this before me in order that i may
live in freedom from compile errors. where is the mythical ping
program that compiles under cygwin?

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy