On 2006-12-04 14:45, [EMAIL PROTECTED] wrote:
> Is there a standard function converting four numbers to one 32-bit 
> IP address?
> 
> I mean a function like
> 
> f(i, j, k, l) {
>       return (((((i << 8) | j) << 8) | k) << 8) | l;
>       }

That's not even a complete, usable function, but if you are looking for
a 'standard' function as in "part of libc already", the answer is no.

Try something like the

    in_addr_t makeaddr(uint8_t, uint8_t, uint8_t, uint8_t);

function from this sample program:

    http://people.freebsd.org/~keramida/files/addr.tar.gz

which looks like this:

    #include <sys/types.h>
    
    #include <netinet/in.h>
    
    #include "addr.h"
    
    in_addr_t
    makeaddr(uint8_t a, uint8_t b, uint8_t c, uint8_t d)
    {
    
            return (htonl(((in_addr_t)a << 24) + ((in_addr_t)b << 16) +
                ((in_addr_t)c << 8) + (in_addr_t)d));
    }

_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to