it's not a piece of code but still may be helpful:

int pcap_lookupnet(char *device, bpf_u_int32 *netp,
               bpf_u_int32 *maskp, char *errbuf)

pcap_lookupnet() is used to determine the network number and mask
associated with the network device device.  Both netp and  maskp  are
bpf_u_int32 pointers.
A return  of -1 indicates an error in which case errbuf is filled in
with an appropriate error message.

for default gateway, i'd look what netstat -r code does.
:)

good luck!

-alexm
11:41 25/02/2005




On Fri, 25 Feb 2005, Ramsurrun Visham wrote:

> Hi to all,
>
> Does anyone know of some piece of C code that can allow me to get me the ip 
> addr, subnet mask and gateway ip addr of my machine itself (the one I'm 
> running the code on)?
>
> I got a code snippet for getting the mac addr of my NIC but concerning the 
> above info. that I require, I don't know how to do it.
>
> Regards,
> Visham
>
>
>
> This mail has been scanned for viruses by the UoM Antivirus Gateway.
> -
> This is the tcpdump-workers list.
> Visit https://lists.sandelman.ca/ to unsubscribe.
>


-
This is the tcpdump-workers list.
Visit https://lists.sandelman.ca/ to unsubscribe.

Reply via email to