Zephyr Project API 4.0.0
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
27#if defined(CONFIG_NET_HOSTNAME_MAX_LEN)
28#define NET_HOSTNAME_MAX_LEN \
29 MAX(CONFIG_NET_HOSTNAME_MAX_LEN, \
30 (sizeof(CONFIG_NET_HOSTNAME) - 1 + \
31 (IS_ENABLED(CONFIG_NET_HOSTNAME_UNIQUE) ? sizeof("0011223344556677") - 1 : 0)))
32#else
34#define NET_HOSTNAME_MAX_LEN \
35 (sizeof(CONFIG_NET_HOSTNAME) - 1 + \
36 (IS_ENABLED(CONFIG_NET_HOSTNAME_UNIQUE) ? sizeof("0011223344556677") - 1 : 0))
37#endif
38
41#if defined(CONFIG_NET_HOSTNAME_ENABLE)
42#define NET_HOSTNAME_SIZE NET_HOSTNAME_MAX_LEN + 1
43#else
44#define NET_HOSTNAME_SIZE 1
45#endif
46
56#if defined(CONFIG_NET_HOSTNAME_ENABLE)
57const char *net_hostname_get(void);
58#else
59static inline const char *net_hostname_get(void)
60{
61 return "zephyr";
62}
63#endif /* CONFIG_NET_HOSTNAME_ENABLE */
64
73#if defined(CONFIG_NET_HOSTNAME_DYNAMIC)
74int net_hostname_set(char *host, size_t len);
75#else
76static inline int net_hostname_set(char *host, size_t len)
77{
78 return -ENOTSUP;
79}
80#endif
81
86#if defined(CONFIG_NET_HOSTNAME_ENABLE)
87void net_hostname_init(void);
88#else
89static inline void net_hostname_init(void)
90{
91}
92#endif /* CONFIG_NET_HOSTNAME_ENABLE */
93
107#if defined(CONFIG_NET_HOSTNAME_UNIQUE)
108int net_hostname_set_postfix(const uint8_t *hostname_postfix,
109 int postfix_len);
110#else
111static inline int net_hostname_set_postfix(const uint8_t *hostname_postfix,
112 int postfix_len)
113{
114 ARG_UNUSED(hostname_postfix);
115 ARG_UNUSED(postfix_len);
116 return -EMSGSIZE;
117}
118#endif /* CONFIG_NET_HOSTNAME_UNIQUE */
119
134#if defined(CONFIG_NET_HOSTNAME_UNIQUE)
135int net_hostname_set_postfix_str(const uint8_t *hostname_postfix,
136 int postfix_len);
137#else
138static inline int net_hostname_set_postfix_str(const uint8_t *hostname_postfix,
139 int postfix_len)
140{
141 ARG_UNUSED(hostname_postfix);
142 ARG_UNUSED(postfix_len);
143 return -EMSGSIZE;
144}
145#endif /* CONFIG_NET_HOSTNAME_UNIQUE */
146
151#ifdef __cplusplus
152}
153#endif
154
155#endif /* ZEPHYR_INCLUDE_NET_HOSTNAME_H_ */
static int net_hostname_set(char *host, size_t len)
Set the device hostname.
Definition hostname.h:76
static int net_hostname_set_postfix_str(const uint8_t *hostname_postfix, int postfix_len)
Set the postfix string for the network hostname.
Definition hostname.h:138
static int net_hostname_set_postfix(const uint8_t *hostname_postfix, int postfix_len)
Set the device hostname postfix.
Definition hostname.h:111
static const char * net_hostname_get(void)
Get the device hostname.
Definition hostname.h:59
static void net_hostname_init(void)
Initialize and set the device hostname.
Definition hostname.h:89
#define ENOTSUP
Unsupported value.
Definition errno.h:114
#define EMSGSIZE
Message size.
Definition errno.h:106
__UINT8_TYPE__ uint8_t
Definition stdint.h:88