calculating ip subnet with netmask in C programming - BSD

This is a discussion on calculating ip subnet with netmask in C programming - BSD ; Hi, This is a C programming specific with TCP/IP relation. Supposed I have two string (char *) variables with the following assignment: ip_str = "10.1.2.3" netmask_str = "255.255.0.0" How can I use C programming technique to get the subnet 10.1.0.0? ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: calculating ip subnet with netmask in C programming

  1. calculating ip subnet with netmask in C programming

    Hi,

    This is a C programming specific with TCP/IP relation.
    Supposed I have two string (char *) variables with the following assignment:
    ip_str = "10.1.2.3"
    netmask_str = "255.255.0.0"

    How can I use C programming technique to get the subnet 10.1.0.0?

    I tried to use "struct in_addr", but not sure how to start writing a
    simple code for it?

    Is there any simple C code that I can follow in this regard?

    Thanks
    Sam

  2. Re: calculating ip subnet with netmask in C programming

    have a look at man 3 inet


  3. Re: calculating ip subnet with netmask in C programming

    tedu wrote:

    > have a look at man 3 inet
    >

    Thanks, what a great API.

    Sam

+ Reply to Thread