zephyr/subsys/net/lib/sockets/sockets_misc.c
Andrew Boie ce6b80470d net: add missing syscall for gethostname()
We need all the socket APIs to work from user mode.
tests/net/socket/misc now runs in userspace.

Fixes: #15227

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00

27 lines
467 B
C

/*
* Copyright (c) 2019 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <errno.h>
#include <net/socket.h>
#include <syscall_handler.h>
int z_impl_zsock_gethostname(char *buf, size_t len)
{
const char *p = net_hostname_get();
strncpy(buf, p, len);
return 0;
}
#ifdef CONFIG_USERSPACE
Z_SYSCALL_HANDLER(zsock_gethostname, buf, len)
{
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(buf, len));
return z_impl_zsock_gethostname((char *)buf, len);
}
#endif