Node and Host Name Sizes on HP-UX: Using the Expanded Capabilities of HP-UX

17
APPENDIX B: HP-UX Node and Host Name Interfaces
This appendix provides additional information about how the OS interfaces that directly manipulate
the node and host name are affected by the support of expanded names. In some cases, the changes
were effective in 11i v2 September 2004 Update. In all cases, the default configuration environment
will be compatible with that of HP-UX releases and updates prior to the 11i v2 September 2004
Update (8-byte node names and 64-byte host names).
Functional Program Interfaces
sethostname(2)
This function accepts up to 255 bytes (plus null terminator) for the host name if the
expanded_node_host_names tunable is 1 (on). Otherwise, it accepts up to 64 bytes (plus
null terminator).
gethostname(2)
This function returns up to 255 bytes (plus null terminator) of the host name previously set via
sethostname(2) on the 11i v2 September 2004 Update and succeeding
updates/versions. Otherwise, it returns up to 64 bytes (plus null terminator) on prior versions
of 11i.
setuname(2)
This function accepts up to 255 bytes (plus null terminator) for the node name if the
expanded_node_host_names tunable is 1 (on). Otherwise accepts up to 8 bytes (plus null
terminator). Other capabilities are unchanged.
uname(2)
This function returns an utsname structure. Two versions of this function and corresponding
structure are available. The nonexpanded version is consistent and compatible with that of
previous HP-UX releases. All fields are 9 bytes except for one which is 15 bytes. The
expanded version, with 257-byte fields, is available on the 11i v2 September 2004 Update
and succeeding updates/versions. It is used if the program is compiled with
_HPUX_API_LEVEL set to 20040821.
For the nonexpanded version, if the system node name is set to more than 9 bytes (including
null terminator) it returns an EOVERFLOW error if the uname_eoverflow system tunable is
set to 1 (the default). Otherwise, the error is not reported and the value is truncated to 8
bytes (plus null terminator). In a future release, no data will be returned if EOVERFLOW is
reported.
sysconf(_SC_HOST_NAME_MAX)
This function returns the value of the system variable HOST_NAME_MAX. This is the maximum
size of a host name that the OS configuration can support. Programs can use this function to
provide a size for buffers to hold the host name. It returns 255 (not including null terminator)
on 11i v3 and on 11i v2 if the optional NodeHostNameXpnd product bundle has been
installed; otherwise, it returns 63. This sysconf(2) variable is not available prior to 11i v2
September 2004 Update. Programs receive an EINVAL error if used on earlier versions.