onsdag den 29 september 2010 klockan 08:12 skrev Simon Josefsson detta: > Mats Erik Andersson <mats.anders...@gisladisker.se> writes: > > > tisdag den 28 september 2010 klockan 23:50 skrev Simon Josefsson detta: > >> Mats Erik Andersson <mats.anders...@gisladisker.se> writes: > >> > >> > My other suggested patching of the TFTP client presently adds > >> > > >> > NI_MAXSERV > >> > struct addrinfo > >> > getaddrinfo(3) > >> > gai_strerror(3) > >> > freeaddrinfo(3) > >> > strrchr(3) > >> > > >> > All these are fulfilled by any decent OS as far as I understand. > >> > >> And if they aren't, gnulib fixes that for us. > >> > >> However, why do you need NI_MAXSERV? I can't find it in POSIX nor in > >> the Glibc manual. I'm not sure it is portable. > > > > See getnameinfo(3). The constant ought to be present in <netdb.h> > > for every decent OS. > > Interesting, it is documented in RFC 2133/2553/4038 and from the man > page it appears to be intended as a GNU-extension, but it is not > mentioned in POSIX or the Glibc manual. I wonder how portable it is? > An old Solaris host I looked at had it. Maybe something for the Austin > group... > > NOTES > In order to assist the programmer in choosing reasonable sizes for the > supplied buffers, <netdb.h> defines the constants > > #define NI_MAXHOST 1025 > #define NI_MAXSERV 32 > > Since glibc 2.8, these definitions are exposed only if one of the > fea??? > ture test macros _BSD_SOURCE, _SVID_SOURCE, or _GNU_SOURCE is defined. > > The former is the constant MAXDNAME in recent versions of BIND's > <arpa/nameser.h> header file. The latter is a guess based on the > ser??? > vices listed in the current Assigned Numbers RFC.
Quoting from OpenBSD, i.e., their libc implementation, and getnameinfo(3): The maximum value for _hostlen_ is NI_MAXHOST and the maximum value for _servlen_ is NI_MAXSERV, as defined in <netdb.h>. Once someone begins commenting on the TFTP __client__ patch, I will also condition the use of NI_MAXHOST for that code, just to be safe. Anyway, the use of NI_MAXHOST and NI_MAXSERV is commonly considered as the portable way for OpenBSD and GNU/Linux as far as I understand things. Mats E A