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/syscall_handler.h> 10 z_impl_zsock_gethostname(char * buf,size_t len)11int z_impl_zsock_gethostname(char *buf, size_t len) 12 { 13 const char *p = net_hostname_get(); 14 15 strncpy(buf, p, len); 16 17 return 0; 18 } 19 20 #ifdef CONFIG_USERSPACE z_vrfy_zsock_gethostname(char * buf,size_t len)21static inline int z_vrfy_zsock_gethostname(char *buf, size_t len) 22 { 23 Z_OOPS(Z_SYSCALL_MEMORY_WRITE(buf, len)); 24 return z_impl_zsock_gethostname(buf, len); 25 } 26 #include <syscalls/zsock_gethostname_mrsh.c> 27 #endif 28