Re: [patch] repost of netfilter/NIPQUAD patches

From: Olaf Titz (olaf@bigred.inka.de)
Date: Fri Apr 14 2000 - 13:52:59 EST


> How about changing printk() so it knows how to output ipv4 dotted quads?

Either that, or make a kernel version of inet_ntoa().
I'm already using the latter approach in CIPE:

static char cipe_ntoa_buf[2][16];
const char *cipe_ntoa(int b, const __u32 addr)
{
    const unsigned char *x=(const unsigned char *)&addr;
    char *p=cipe_ntoa_buf[b];
    int i;
    for (i=0; i<4; ++i) {
        int k=x[i]/100;
        if (k)
            *p++=k+'0';
        k=(x[i]/10)%10;
        if (k)
            *p++=k+'0';
        *p++=(x[i]%10)+'0';
        if (i<3)
            *p++='.';
    }
    *p='\0';
    return cipe_ntoa_buf[b];
}

This can even be used twice in a single printk(), with the first
argument 0 and 1 respectively.

Olaf

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Apr 15 2000 - 21:00:24 EST