netmask access from a c program

Eljay Love-Jensen eljay@adobe.com
Fri May 16 20:00:00 GMT 2008


Hi Vardhan,

Your inquiry is off topic for this forum.

You may be able to use these commands:
ping -c 1 -t 1 -M mask <ipaddr>
ping -c 1 -t 1 -R <ipaddr>

The ping command uses the ICMP (RFC 792).  ICMP stands for "Internet Control
Message Protocol".

You can either shell out to the command line and use ping directly, or
create your own ICMP API.

The first will send a ICMP_MASKREQ to the remote IP address.  If the remote
IP address is configured to respond to a ping, and is configured to respond
to ICMP_MASKREQ, you should get back what you want.

The second will get the routing information.

The only use for querying for the netmask that I can imagine is for auditing
purposes.  (Diagnostic purposes wouldn't be useful, because if it is not set
up right, you probably can't ping it.)

I recommend the "TCP/IP Illustrated" books by (the late, and much missed)
Dr. Richard Stevens:
http://www.amazon.com/dp/0201633469/
http://www.amazon.com/dp/020163354X/
http://www.amazon.com/dp/0201634953/

I don't have my books on hand to confirm that the ICMP / ping details are in
there.  But I'd be surprised if they weren't.

HTH,
--Eljay



More information about the Gcc-help mailing list