473,765 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ping source code

I was reading through original source code of ping for some insight
and was confused by unusual code.

Entire listing available at:
http://www.ping127001.com/pingpage/ping.html

#include #include #include
#include #include #include #include
#include #include #include #include #include

What does this mean? That is all of the #include's there are.

main(argc, argv)
char *argv[];
{

That is how the main function starts. Is that legal?

There are structs that are network related that I don't know where
they come from because of the lack of any recongnizable #include file.
The code is well organized and commented. I understand that this
program is from 1982. Just for fun, I ran it through gcc and it
generated a lot of errors, many of which are due to the lack of
legitimate #includes. What does this all mean? Shouldn't the famous
Ping code compile with gcc?

Compile errors:

pg.c:2: error: parse error before "I"
pg.c:24:10: #include expects "FILENAME" or <FILENAME>
pg.c:25:10: #include expects "FILENAME" or <FILENAME>
pg.c:26:10: #include expects "FILENAME" or <FILENAME>
pg.c: In function `main':
pg.c:72: error: storage size of `from' isn't known
pg.c:82: error: `SO_DEBUG' undeclared (first use in this function)
pg.c:82: error: (Each undeclared identifier is reported only once
pg.c:82: error: for each function it appears in.)
pg.c:85: error: `SO_DONTROUTE' undeclared (first use in this function)
pg.c:104: error: invalid application of `sizeof' to an incomplete type
pg.c:105: error: dereferencing pointer to incomplete type
pg.c:105: error: `AF_INET' undeclared (first use in this function)
pg.c:106: error: dereferencing pointer to incomplete type
pg.c:107: error: dereferencing pointer to incomplete type
pg.c:111: warning: assignment makes pointer from integer without a
cast
pg.c:113: error: dereferencing pointer to incomplete type
pg.c:113: error: dereferencing pointer to incomplete type
pg.c:114: error: dereferencing pointer to incomplete type
pg.c:114: error: `caddr_t' undeclared (first use in this function)
pg.c:114: error: dereferencing pointer to incomplete type
pg.c:114: error: dereferencing pointer to incomplete type
pg.c:115: error: dereferencing pointer to incomplete type
pg.c:127: error: `stderr' undeclared (first use in this function)
pg.c:130: error: invalid application of `sizeof' to an incomplete type
pg.c:141: warning: assignment makes pointer from integer without a
cast
pg.c:141: error: `NULL' undeclared (first use in this function)
pg.c:146: error: `SOCK_RAW' undeclared (first use in this function)
pg.c:146: error: dereferencing pointer to incomplete type
pg.c:153: error: `SOL_SOCKET' undeclared (first use in this function)
pg.c:161: error: dereferencing pointer to incomplete type
pg.c:163: error: dereferencing pointer to incomplete type
pg.c:167: error: `stdout' undeclared (first use in this function)
pg.c:169: error: `SIGINT' undeclared (first use in this function)
pg.c:170: error: `SIGALRM' undeclared (first use in this function)
pg.c:180: error: `packet' undeclared (first use in this function)
pg.c:183: error: storage size of `timeout' isn't known
pg.c:195: error: `EINTR' undeclared (first use in this function)
pg.c: In function `catcher':
pg.c:232: error: `SIGALRM' undeclared (first use in this function)
pg.c: In function `pinger':
pg.c:248: error: syntax error before "outpack"
pg.c:249: error: `outpack' undeclared (first use in this function)
pg.c:252: error: syntax error before '*' token
pg.c:254: error: dereferencing pointer to incomplete type
pg.c:254: error: `ICMP_ECHO' undeclared (first use in this function)
pg.c:255: error: dereferencing pointer to incomplete type
pg.c:256: error: dereferencing pointer to incomplete type
pg.c:257: error: dereferencing pointer to incomplete type
pg.c:258: error: dereferencing pointer to incomplete type
pg.c:265: error: `iicmp_cksum' undeclared (first use in this function)
pg.c:268: error: invalid application of `sizeof' to an incomplete type
pg.c:268: error: parse error before ';' token
pg.c:274: error: `stdout' undeclared (first use in this function)
pg.c: At top level:
pg.c:276: error: parse error before "if"
pg.c:278: warning: parameter names (without types) in function
declaration
pg.c:278: warning: data definition has no type or storage class
pg.c:279: error: parse error before '}' token
pg.c: In function `pr_pack':
pg.c:332: error: `packet' undeclared (first use in this function)
pg.c:334: error: storage size of `tv' isn't known
pg.c:338: error: dereferencing pointer to incomplete type
pg.c:338: error: dereferencing pointer to incomplete type
pg.c:342: error: dereferencing pointer to incomplete type
pg.c:343: error: `ICMP_MINLEN' undeclared (first use in this function)
pg.c:346: error: dereferencing pointer to incomplete type
pg.c:351: error: dereferencing pointer to incomplete type
pg.c:351: error: `ICMP_ECHOREPLY ' undeclared (first use in this
function)
pg.c:353: error: dereferencing pointer to incomplete type
pg.c:354: error: dereferencing pointer to incomplete type
pg.c:354: error: dereferencing pointer to incomplete type
pg.c:354: error: dereferencing pointer to incomplete type
pg.c:362: error: dereferencing pointer to incomplete type
pg.c:366: error: dereferencing pointer to incomplete type
pg.c:379: error: dereferencing pointer to incomplete type
pg.c:380: error: dereferencing pointer to incomplete type
pg.c:387: error: `stdout' undeclared (first use in this function)
pg.c: At top level:
pg.c:401: error: parse error before "u_short"
pg.c:401: warning: data definition has no type or storage class
pg.c:403: error: parse error before '{' token
pg.c:405: error: parse error before '*' token
pg.c:405: error: initializer element is not constant
pg.c:405: warning: data definition has no type or storage class
pg.c:406: error: parse error before "answer"
pg.c:406: warning: data definition has no type or storage class
pg.c:407: error: register name not specified for `sum'
pg.c:415: error: parse error before "while"
pg.c:424: error: parse error before '*' token
pg.c:431: error: redefinition of `sum'
pg.c:407: error: `sum' previously defined here
pg.c:431: error: initializer element is not constant
pg.c:431: warning: data definition has no type or storage class
pg.c:432: error: parse error before '+=' token
pg.c:433: error: initializer element is not constant
pg.c:433: warning: data definition has no type or storage class
pg.c:434: error: parse error before "return"
pg.c: In function `tvsub':
pg.c:447: error: dereferencing pointer to incomplete type
pg.c:447: error: dereferencing pointer to incomplete type
pg.c:448: error: dereferencing pointer to incomplete type
pg.c:449: error: dereferencing pointer to incomplete type
pg.c:451: error: dereferencing pointer to incomplete type
pg.c:451: error: dereferencing pointer to incomplete type
pg.c: In function `finish':
pg.c:466: error: `stdout' undeclared (first use in this function)
pg.c: At top level:
pg.c:42: error: storage size of `tz' isn't known
pg.c:44: error: storage size of `whereto' isn't known
Nov 14 '05
17 18210
Kenneth Brody <ke******@spamc op.net> scribbled the following:
Joona I Palaste wrote:
[...]
*NOW* I understand. It actually reads
#include <foo.h>
#include <bar.h>
#include <quux.h>
#include <quuux.h>
(replace the silly names with proper ones)
but because the idiot hosting the web server is serving the page as
HTML instead of plain text, the web browser is filtering the header
names away, thinking they're non-standard HMTL tags.
Don't blame "the idiot hosting the web server", blame "the idiot who
decided to use a '.html' extension on a plain text file". It's your
browser "filtering the header names away", not the server, and it's
doing it because it was told to do so.


Browsers are told how to display the content by a Content-Type header,
not by a file extension. At least Mozilla should be. I haven't checked
the Content-Type header on this page yet, though.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Life without ostriches is like coffee with milk."
- Mika P. Nieminen
Nov 14 '05 #11
Kenneth Brody <ke******@spamc op.net> scribbled the following:
Joona I Palaste wrote:
[...]
*NOW* I understand. It actually reads
#include <foo.h>
#include <bar.h>
#include <quux.h>
#include <quuux.h>
(replace the silly names with proper ones)
but because the idiot hosting the web server is serving the page as
HTML instead of plain text, the web browser is filtering the header
names away, thinking they're non-standard HMTL tags.
Don't blame "the idiot hosting the web server", blame "the idiot who
decided to use a '.html' extension on a plain text file". It's your
browser "filtering the header names away", not the server, and it's
doing it because it was told to do so.


By "the idiot hosting the web server" I actually meant the idiot who
wrote that web page and uploaded it on the server, not the person or
people who operate the server itself. My apologies for being so
confusing, it was late at night and I was drunk.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Shh! The maestro is decomposing!"
- Gary Larson
Nov 14 '05 #12
In article <ci**********@o ravannahka.hels inki.fi>,
Joona I Palaste <pa*****@cc.hel sinki.fi> wrote:
Kenneth Brody <ke******@spamc op.net> scribbled the following:
Joona I Palaste wrote:
[...]
*NOW* I understand. It actually reads
#include <foo.h>
#include <bar.h>
#include <quux.h>
#include <quuux.h>
(replace the silly names with proper ones)
but because the idiot hosting the web server is serving the page as
HTML instead of plain text, the web browser is filtering the header
names away, thinking they're non-standard HMTL tags.

Don't blame "the idiot hosting the web server", blame "the idiot who
decided to use a '.html' extension on a plain text file". It's your
browser "filtering the header names away", not the server, and it's
doing it because it was told to do so.


Browsers are told how to display the content by a Content-Type header,
not by a file extension. At least Mozilla should be. I haven't checked
the Content-Type header on this page yet, though.


--------
dj3vande@perpug illiam:~ (0) $ lynx -dump -head http://www.ping127001.com/pingpage/ping.html | grep 'Content-Type'
Content-Type: text/html
dj3vande@perpug illiam:~ (0) $
--------
So the swerver is believing whoever put the file there when they said
it was HTML.
dave

--
Dave Vandervies dj******@csclub .uwaterloo.ca
More and more often I wish I didn't know anything about the Internet so
things like this wouldn't disturb me so much.
--Steve VanDevender in the scary devil monastery
Nov 14 '05 #13
Kenneth Brody <ke******@spamc op.net> writes:
Joona I Palaste wrote:
[...]
*NOW* I understand. It actually reads
#include <foo.h>
#include <bar.h>
#include <quux.h>
#include <quuux.h>
(replace the silly names with proper ones)
but because the idiot hosting the web server is serving the page as
HTML instead of plain text, the web browser is filtering the header
names away, thinking they're non-standard HMTL tags.


Don't blame "the idiot hosting the web server", blame "the idiot who
decided to use a '.html' extension on a plain text file". It's your
browser "filtering the header names away", not the server, and it's
doing it because it was told to do so.


The first line of the html file is a "<pre>" directive. Apparently
the author mistakenly thought that a "<pre>" directive inhibits
special treatment of '<' characters (and didn't bother to check
how the pages is displayed).

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #14
Joona I Palaste wrote:

Kenneth Brody <ke******@spamc op.net> scribbled the following:
Joona I Palaste wrote:
[...]
*NOW* I understand. It actually reads
#include <foo.h>
#include <bar.h>
#include <quux.h>
#include <quuux.h>
(replace the silly names with proper ones)
but because the idiot hosting the web server is serving the page as
HTML instead of plain text, the web browser is filtering the header
names away, thinking they're non-standard HMTL tags.

Don't blame "the idiot hosting the web server", blame "the idiot who
decided to use a '.html' extension on a plain text file". It's your
browser "filtering the header names away", not the server, and it's
doing it because it was told to do so.


Browsers are told how to display the content by a Content-Type header,
not by a file extension. At least Mozilla should be. I haven't checked
the Content-Type header on this page yet, though.


And the server typically determine the Content-Type by the extension.
(Unless it's script-generate, in which case the script generates the
Content-Type header.) Once again, it's the ".html" extension put there
by the person who put the file there. The server is doing what it was
told -- send it as HTML.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer .h> |
+-------------------------+--------------------+-----------------------------+
Nov 14 '05 #15
Keith Thompson wrote:
[...]
Don't blame "the idiot hosting the web server", blame "the idiot who
decided to use a '.html' extension on a plain text file". It's your
browser "filtering the header names away", not the server, and it's
doing it because it was told to do so.


The first line of the html file is a "<pre>" directive. Apparently
the author mistakenly thought that a "<pre>" directive inhibits
special treatment of '<' characters (and didn't bother to check
how the pages is displayed).


Not to mention the lack of <HTML>, <BODY>, </PRE>, </BODY>, and </HTML>.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer .h> |
+-------------------------+--------------------+-----------------------------+

Nov 14 '05 #16
Keith Thompson <ks***@mib.or g> writes:
[...]
The first line of the html file is a "<pre>" directive. Apparently
the author mistakenly thought that a "<pre>" directive inhibits
special treatment of '<' characters (and didn't bother to check
how the pages is displayed).


I really need to proofread better before I post. That should be "how
the *page* is displayed".

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #17
Groovy hepcat Joona I Palaste was jivin' on 16 Sep 2004 19:53:00 GMT
in comp.lang.c.
Re: ping source code's a cool scene! Dig it!
wana <io*****@yahoo. com> scribbled the following:
main(argc, argv)
char *argv[];
{

That is how the main function starts. Is that legal?


It used to be, not any more. That's a pre-standard K&R style. It's
still accepted by some compilers.


Actually, Joona, apart from the lack of a return type required by
C99, this is perfectly legal code. Old K&R style declarations are
still legal (though obsolescent).

--

Dig the even newer still, yet more improved, sig!

http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technicall y correct" English; but since when was rock & roll "technicall y correct"?
Nov 14 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8407
by: Sean Cody | last post by:
Does anyone know of an ping module that will work with Windows? I'm currently using os.popen("ping -n1 host") but it's terribly slow when using it a few hundred times. After enumerating my domain of machines I'm trying to ping them to determine if they are active before connecting to them via WMI (which takes forever to timeout). --
8
4373
by: DCK | last post by:
Hello :) Into group-archive i found most e-mails, which touches PINGing. In my work i've used TELNET for testing if host is operational. Sometimes, for unknown reasons, workstation doesn't respond for PINGing. But in WinNT network, all hosts has a nbsession listening on port 139. I always use this script instead PING command (hope, will be usefull for someone :) ):
3
2267
by: Jason Rodman | last post by:
I have downloaded every example on how to create a ping utility in .Net in both VB and C#, but have been disappointed with the results. I have YET to find an example that returns consistent results that are even close the the actual ping command line utility. For example: If i would ping the same server over and over, some pings would come back in 0 milliseconds, others would come back in 15, but never in between. It would always jump...
0
1393
by: krisan | last post by:
Hi, i am writing a program for ping operation which supports both Ipv4 and IpV6 ..first i wrote for both of them individually , but i am unable to mix them such that they support both the versions ... i would be very thankful if anyone could come out with a complete program .. Ipv6 prog --------- #include<stdio.h> #include<winsock2.h>
0
7783
by: Ed | last post by:
I've attached some VB.NET code I've hacked together (some taken from MS examples & newsgroup postings) that will perform a ping or IcmpSendEcho using the icmp.dll (see this for more info: http://support.microsoft.com/default.aspx?scid=kb;en-us;170591 ). The problem I have is in order to perform a discovery/ping of an entire subnet (192.168.1.* for instance) I have to do a FOR loop to itterate through all of the addresses. That it seems...
7
7263
by: luvwknd | last post by:
Hi all, I am attempting to utilize MS's article I.D. #828993 found at: http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B828993 In an effort to create a GUI Ping utility that ultimately will show me via a green indicator if a system is pingable and a red indicator if a system is not pingable. In addition I want to be able to ping a range of addresses at one time and have the program return my indicators.
5
7407
by: Sonda | last post by:
how to ping ip address from c language ?
6
3459
by: Dave Marden | last post by:
I currently use this routine in vbscript to ping computers and get the status of ping to determine whether to try to backup a machine, I am trying to change it to work with vb2003.net I am wondering if anyone has a ping function they could share with me. I have done some searching on this but cannot find anything specifically for vb2003. Sub PingComputer If PingStatus(PCName) = "Success" Then
3
1244
by: jacob navia | last post by:
Mr Randy Howard has his views about C. C programmers that develop GUI applications are Neaderntals and (of course) he agrees with Mr Heathfield: Heathfield: Howard:
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9951
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.