Index | Thread | Search

From:
Vitaliy Makkoveev <otto@bsdbox.dev>
Subject:
Re: wg(4) logging enhancement - revised patch
To:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Cc:
Theo de Raadt <deraadt@openbsd.org>, Lloyd <ng2d68@proton.me>, Stuart Henderson <stu@spacehopper.org>, "tech@openbsd.org" <tech@openbsd.org>
Date:
Thu, 2 Jan 2025 18:46:26 +0300

Download raw body.

Thread
> On 2 Jan 2025, at 18:36, Claudio Jeker <cjeker@diehard.n-r-g.com> wrote:
> 
> On Thu, Jan 02, 2025 at 09:20:11AM +0300, Vitaliy Makkoveev wrote:
>>> On 2 Jan 2025, at 09:02, Theo de Raadt <deraadt@openbsd.org> wrote:
>>> 
>>> No, printf should not print IP addresses.  Create a helper function
>>> that returns a static string, and print it with %.  Yes that means
>>> you can'to do two of them nicely in one call.  That's not terribly
>>> rough.  That is how this is done in userland.
>> 
>> This helper could use external buffer to printf. This allows
>> simultaneous runs. I mean:
>> 
>> char *
>> print_ip(struct sockaddr_in *sin, char *buf, size_t buf_sz)
>> {
>> 	/* do printf */
>> 	return buf;
>> }
>> 
> 
> Please open /sys/netinet/inet_ntop.c and have a look. That function
> already exists. sockaddr_ntop() and inet_ntop() are exactly used for that.

Thanks for pointing.