Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
 4.1.99
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 ARG_UNUSED(host);
79 ARG_UNUSED(len);
80 return -ENOTSUP;
81}
82#endif
83
88#if defined(CONFIG_NET_HOSTNAME_ENABLE)
89void net_hostname_init(void);
90#else
91static inline void net_hostname_init(void)
92{
93}
94#endif /* CONFIG_NET_HOSTNAME_ENABLE */
95
109#if defined(CONFIG_NET_HOSTNAME_UNIQUE)
110int net_hostname_set_postfix(const uint8_t *hostname_postfix,
111 int postfix_len);
112#else
113static inline int net_hostname_set_postfix(const uint8_t *hostname_postfix,
114 int postfix_len)
115{
116 ARG_UNUSED(hostname_postfix);
117 ARG_UNUSED(postfix_len);
118 return -EMSGSIZE;
119}
120#endif /* CONFIG_NET_HOSTNAME_UNIQUE */
121
136#if defined(CONFIG_NET_HOSTNAME_UNIQUE)
137int net_hostname_set_postfix_str(const uint8_t *hostname_postfix,
138 int postfix_len);
139#else
140static inline int net_hostname_set_postfix_str(const uint8_t *hostname_postfix,
141 int postfix_len)
142{
143 ARG_UNUSED(hostname_postfix);
144 ARG_UNUSED(postfix_len);
145 return -EMSGSIZE;
146}
147#endif /* CONFIG_NET_HOSTNAME_UNIQUE */
148
153#ifdef __cplusplus
154}
155#endif
156
157#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:140
static int net_hostname_set_postfix(const uint8_t *hostname_postfix, int postfix_len)
Set the device hostname postfix.
Definition hostname.h:113
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:91
#define ENOTSUP
Unsupported value.
Definition errno.h:114
#define EMSGSIZE
Message size.
Definition errno.h:106
__UINT8_TYPE__ uint8_t
Definition stdint.h:88