Implemented via Zephyr's net_hostname_get(). As support for that call is configurable and by default off, while many POSIX applications assume that hostname is always available, we need a default value in case CONFIG_NET_HOSTNAME_ENABLE is "n". Initial version of this patch added that on the level of gethostname() call, but of was suggested to move that down to net_hostname_get() instead. Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
18 lines
253 B
C
18 lines
253 B
C
/*
|
|
* Copyright (c) 2019 Linaro Limited
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <errno.h>
|
|
#include <net/socket.h>
|
|
|
|
int zsock_gethostname(char *buf, size_t len)
|
|
{
|
|
const char *p = net_hostname_get();
|
|
|
|
strncpy(buf, p, len);
|
|
|
|
return 0;
|
|
}
|