Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
hostname.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2017 Intel Corporation
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10
11#ifndef ZEPHYR_INCLUDE_NET_HOSTNAME_H_
12#define ZEPHYR_INCLUDE_NET_HOSTNAME_H_
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
25#if defined(CONFIG_NET_HOSTNAME_MAX_LEN)
26#define NET_HOSTNAME_MAX_LEN \
27 MAX(CONFIG_NET_HOSTNAME_MAX_LEN, \
28 (sizeof(CONFIG_NET_HOSTNAME) - 1 + \
29 (IS_ENABLED(CONFIG_NET_HOSTNAME_UNIQUE) ? sizeof("0011223344556677") - 1 : 0)))
30#else
32#define NET_HOSTNAME_MAX_LEN \
33 (sizeof(CONFIG_NET_HOSTNAME) - 1 + \
34 (IS_ENABLED(CONFIG_NET_HOSTNAME_UNIQUE) ? sizeof("0011223344556677") - 1 : 0))
35#endif
36
39#if defined(CONFIG_NET_HOSTNAME_ENABLE)
40#define NET_HOSTNAME_SIZE NET_HOSTNAME_MAX_LEN + 1
41#else
42#define NET_HOSTNAME_SIZE 1
43#endif
44
54#if defined(CONFIG_NET_HOSTNAME_ENABLE)
55const char *net_hostname_get(void);
56#else
57static inline const char *net_hostname_get(void)
58{
59 return "zephyr";
60}
61#endif /* CONFIG_NET_HOSTNAME_ENABLE */
62
71#if defined(CONFIG_NET_HOSTNAME_DYNAMIC)
72int net_hostname_set(char *host, size_t len);
73#else
74static inline int net_hostname_set(char *host, size_t len)
75{
76 return -ENOTSUP;
77}
78#endif
79
84#if defined(CONFIG_NET_HOSTNAME_ENABLE)
85void net_hostname_init(void);
86#else
87static inline void net_hostname_init(void)
88{
89}
90#endif /* CONFIG_NET_HOSTNAME_ENABLE */
91
104#if defined(CONFIG_NET_HOSTNAME_UNIQUE)
105int net_hostname_set_postfix(const uint8_t *hostname_postfix,
106 int postfix_len);
107#else
108static inline int net_hostname_set_postfix(const uint8_t *hostname_postfix,
109 int postfix_len)
110{
111 ARG_UNUSED(hostname_postfix);
112 ARG_UNUSED(postfix_len);
113 return -EMSGSIZE;
114}
115#endif /* CONFIG_NET_HOSTNAME_UNIQUE */
116
121#ifdef __cplusplus
122}
123#endif
124
125#endif /* ZEPHYR_INCLUDE_NET_HOSTNAME_H_ */
static int net_hostname_set(char *host, size_t len)
Set the device hostname.
Definition: hostname.h:74
static int net_hostname_set_postfix(const uint8_t *hostname_postfix, int postfix_len)
Set the device hostname postfix.
Definition: hostname.h:108
static const char * net_hostname_get(void)
Get the device hostname.
Definition: hostname.h:57
static void net_hostname_init(void)
Initialize and set the device hostname.
Definition: hostname.h:87
#define ENOTSUP
Unsupported value.
Definition: errno.h:115
#define EMSGSIZE
Message size.
Definition: errno.h:107
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88