tech-net archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: sockaddr printing functions
On Mon, Dec 01, 2014 at 11:04:38AM -0500, Christos Zoulas wrote:
>
> Hi,
>
> We have a hodgepodge set of functions that print sockaddr_* and I wanted
> to try to clean that up:
Nice, thanks!
> 1. consistent api
> 2. don't use static storage
> 3. testable from userland (with unit tests added)
>
> For each socket type we have:
>
> int xx_print(char *buf, size_t len, const struct xxaddr *);
>
> and:
> int sxx_snprintf(char *buf, size_t len, void *sa, const char *fmt, ...);
>
> for xx [ "in" "in6" "at" "un" "dl" ]
> [the dl portion is slightly different, and the un portion I have
> not included in the patch]
A few questions:
1. the xx_print calls sxx_snprintf internally with a local (stack)
buffer, and then prints that out?
2. why have multiple sxx_snprintf functions, and then pass a void *sa in to
each? Is it one function with a void *sa, or many functions for each struct type?
3. why the format string?
4. return values are same as standard printf and snprintf?
> There are also constants that describe the max string length that xx_print
> needs:
> INET_ADDRSTRLEN, INET6_ADDRSTRLEN (existing)
> ATALK_ADDRSTRLEN, LINK_ADDRSTRNEL (new)
LINK_ADDRSTRLEN?
> UNIX_ADDRSTRLEN (should we add this?)
>
> The code is in:
>
> http://www.netbsd.org/~christos/net.tar.gz
Thanks,
Al
Home |
Main Index |
Thread Index |
Old Index