Networking Forums

Networking Forums > Computer Networking > Linux Networking > how to programmatically get subnetmask

Reply
Thread Tools Display Modes

how to programmatically get subnetmask

 
 
Vinod Kumar P
Guest
Posts: n/a

 
      11-01-2003, 12:54 PM
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

Vinod Kumar P
 
Reply With Quote
 
 
 
 
Tauno Voipio
Guest
Posts: n/a

 
      11-01-2003, 03:06 PM

"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



 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
subnetmask and IP address prasi Linux Networking 4 10-24-2005 07:05 PM
Subnetmask Issues Poppen Windows Networking 4 09-06-2005 04:27 PM
win98se gets wrong subnetmask pi511 Windows Networking 2 06-03-2005 07:21 AM
how to programmatically get subnetmask Vinod Kumar P Windows Networking 1 11-01-2003 08:57 PM
Working out subnetmask HonkyDog Broadband 0 07-08-2003 09:37 AM



1 2 3 4 5 6 7 8 9 10 11