[RFC] solution for the inet_ntoa problem, buffer allocator

From: Stephen Lee (unknown@domain.x.cig.nml.mot.com)
Date: Thu Jul 06 2000 - 01:18:21 EST


>From: Olaf Titz <olaf@bigred.inka.de>
>
>Ideally, we would be able to do something like:
>printk(KERN_DEBUG "foo: src=%s dst=%s\n", inet_ntoa(src), inet_ntoa(dst));
>but the inet_ntoa() API doesn't work that way. Providing a buffer to
>that function needs additional code over and over again, and that is
>exactly what such library functions should eliminate.
>The NIPQUAD solution is (a) cumbersome to handle, (b) conceptually
>wrong since an IP address is _one_ item to print, not four, and (c)
>even worse when dealing with IPv6 addresses.

How about letting the user passing in their own buffer?

char *my_inet_ntoa(__u32 a, char result[])
{
   /* Do whatever [...] */

   return result;
}

Then you can call it with

char s1[16], s2[16];
printk("a1=%s, a2=%s\n", my_inet_ntoa(a1, s1), my_inet_ntoa(a2, s2));

Stephen

-
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 : Fri Jul 07 2000 - 21:00:18 EST