Zephyr API Documentation  3.6.0
A Scalable Open Source RTOS
3.6.0
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
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
31#define NET_HOSTNAME_MAX_LEN \
32 (sizeof(CONFIG_NET_HOSTNAME) - 1 + \
33 (IS_ENABLED(CONFIG_NET_HOSTNAME_UNIQUE) ? sizeof("0011223344556677") - 1 : 0))
34#endif
35
36#if defined(CONFIG_NET_HOSTNAME_ENABLE)
37#define NET_HOSTNAME_SIZE NET_HOSTNAME_MAX_LEN + 1
38#else
39#define NET_HOSTNAME_SIZE 1
40#endif
41
49#if defined(CONFIG_NET_HOSTNAME_ENABLE)
50const char *net_hostname_get(void);
51#else
52static inline const char *net_hostname_get(void)
53{
54 return "zephyr";
55}
56#endif /* CONFIG_NET_HOSTNAME_ENABLE */
57
66#if defined(CONFIG_NET_HOSTNAME_DYNAMIC)
67int net_hostname_set(char *host, size_t len);
68#else
69static inline int net_hostname_set(char *host, size_t len)
70{
71 return -ENOTSUP;
72}
73#endif
74
79#if defined(CONFIG_NET_HOSTNAME_ENABLE)
80void net_hostname_init(void);
81#else
82static inline void net_hostname_init(void)
83{
84}
85#endif /* CONFIG_NET_HOSTNAME_ENABLE */
86
99#if defined(CONFIG_NET_HOSTNAME_UNIQUE)
100int net_hostname_set_postfix(const uint8_t *hostname_postfix,
101 int postfix_len);
102#else
103static inline int net_hostname_set_postfix(const uint8_t *hostname_postfix,
104 int postfix_len)
105{
106 return -EMSGSIZE;
107}
108#endif /* CONFIG_NET_HOSTNAME_UNIQUE */
109
114#ifdef __cplusplus
115}
116#endif
117
118#endif /* ZEPHYR_INCLUDE_NET_HOSTNAME_H_ */
static int net_hostname_set(char *host, size_t len)
Set the device hostname.
Definition: hostname.h:69
static int net_hostname_set_postfix(const uint8_t *hostname_postfix, int postfix_len)
Set the device hostname postfix.
Definition: hostname.h:103
static const char * net_hostname_get(void)
Get the device hostname.
Definition: hostname.h:52
static void net_hostname_init(void)
Initialize and set the device hostname.
Definition: hostname.h:82
#define ENOTSUP
Unsupported value.
Definition: errno.h:115
#define EMSGSIZE
Message size.
Definition: errno.h:107
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88