"Vinod Kumar P" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Dear all
> How can I programmatically get the subnet mask of the network
> associated with my machine's one of the NICs? ( my machine has to
> NICs.) Do we have some C function for that? Or else is there any other
> way to get it from my machine inside my C program. This is to
> eliminate a packet coming from another network.
>
> I am working on redhat linux 7.2 with packages gcc version 2.96,
> glibc2.2.4-13 and glibc-devel-2.2.4-13.
>
> Thanks for all your advices
> Reply if any clarifications needed
Use the standard library functions:
- create a network socket
- ioctl() to that socket for all network interface names
- ioctl() network interfaces for network specifics
- repeat previous till the proper network information is obtained.
For details, see e.g. Unix Network Programming by W. Richard Stevens.
HTH
Tauno Voipio
tauno voipio @ iki fi
|