[Swan-dev] [PATCH] ikev2_ipsec: include limits.h for HOST_NAME_MAX
timo.teras at iki.fi
Tue Aug 15 06:41:57 UTC 2017
On Mon, 14 Aug 2017 21:20:52 +0200
Antony Antony <antony at phenome.org> wrote:
> could you please try the attached patch?
Seems to work too, thanks.
> It should be consistent with the use id.c and whack. The comment
> there suggested unistd.h.
> #ifndef HOST_NAME_MAX /* POSIX 1003.1-2001 says <unistd.h> defines
> this */
> Now I think the comment is for OpenBSD. Linux it is in limits.h
> which should come via sysdep.h
> #include <limits.h>
> /* POSIX 1003.1-2001 says <unistd.h> defines this */
> Here is my proposed patch.
That's weird. It's always been in limits.h in POSIX IIRC. See e.g.:
However, gethostname() / sethostname() to which this define is
associated, comes from unistd.h.
> Actually, we may have to use another constant. Now it is 64, which is
> probably short, I was thinking it is 255.
In musl it seems to be 255. Probably because that's what POSIX gives as
the upper bound. Linux kernel likely enforces 64.
But yes, it seems you want to use something different. HOST_NAME_MAX is
the max. length for the hostname [that is, the current device's name].
I guess the linux 64 bytes comes from the fact that single dns label
cannot exceed 63 octets.
Sounds like you are looking for something like arpa/nameser.h's
NS_MAXCDNAME or NS_MAXDNAME. But maybe just better define something in
libreswan for this purpose, not sure if there's good standardized
#define for this.
More information about the Swan-dev