1 /*
2  * Copyright (c) 2019 Linaro Limited
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <errno.h>
8 #include <zephyr/net/socket.h>
9 #include <zephyr/net/hostname.h>
10 #include <zephyr/internal/syscall_handler.h>
11 
z_impl_zsock_gethostname(char * buf,size_t len)12 int z_impl_zsock_gethostname(char *buf, size_t len)
13 {
14 	const char *p = net_hostname_get();
15 
16 	strncpy(buf, p, len);
17 
18 	return 0;
19 }
20 
21 #ifdef CONFIG_USERSPACE
z_vrfy_zsock_gethostname(char * buf,size_t len)22 static inline int z_vrfy_zsock_gethostname(char *buf, size_t len)
23 {
24 	K_OOPS(K_SYSCALL_MEMORY_WRITE(buf, len));
25 	return z_impl_zsock_gethostname(buf, len);
26 }
27 #include <zephyr/syscalls/zsock_gethostname_mrsh.c>
28 #endif
29