|
|
|
@ -22,10 +22,16 @@ extern "C" {
@@ -22,10 +22,16 @@ extern "C" {
|
|
|
|
|
* @{ |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#define NET_HOSTNAME_MAX_LEN \ |
|
|
|
|
(sizeof(CONFIG_NET_HOSTNAME) - 1 + \ |
|
|
|
|
(IS_ENABLED(CONFIG_NET_HOSTNAME_UNIQUE) ? \ |
|
|
|
|
sizeof("0011223344556677") - 1 : 0)) |
|
|
|
|
#if defined(CONFIG_NET_HOSTNAME_MAX_LEN) |
|
|
|
|
#define NET_HOSTNAME_MAX_LEN \ |
|
|
|
|
MAX(CONFIG_NET_HOSTNAME_MAX_LEN, \ |
|
|
|
|
(sizeof(CONFIG_NET_HOSTNAME) - 1 + \ |
|
|
|
|
(IS_ENABLED(CONFIG_NET_HOSTNAME_UNIQUE) ? sizeof("0011223344556677") - 1 : 0))) |
|
|
|
|
#else |
|
|
|
|
#define NET_HOSTNAME_MAX_LEN \ |
|
|
|
|
(sizeof(CONFIG_NET_HOSTNAME) - 1 + \ |
|
|
|
|
(IS_ENABLED(CONFIG_NET_HOSTNAME_UNIQUE) ? sizeof("0011223344556677") - 1 : 0)) |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#if defined(CONFIG_NET_HOSTNAME_ENABLE) |
|
|
|
|
#define NET_HOSTNAME_SIZE NET_HOSTNAME_MAX_LEN + 1 |
|
|
|
@ -49,6 +55,23 @@ static inline const char *net_hostname_get(void)
@@ -49,6 +55,23 @@ static inline const char *net_hostname_get(void)
|
|
|
|
|
} |
|
|
|
|
#endif /* CONFIG_NET_HOSTNAME_ENABLE */ |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Set the device hostname |
|
|
|
|
* |
|
|
|
|
* @param host new hostname as char array. |
|
|
|
|
* @param len Length of the hostname array. |
|
|
|
|
* |
|
|
|
|
* @return 0 if ok, <0 on error |
|
|
|
|
*/ |
|
|
|
|
#if defined(CONFIG_NET_HOSTNAME_DYNAMIC) |
|
|
|
|
int net_hostname_set(char *host, size_t len); |
|
|
|
|
#else |
|
|
|
|
static inline int net_hostname_set(char *host, size_t len) |
|
|
|
|
{ |
|
|
|
|
return -ENOTSUP; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Initialize and set the device hostname. |
|
|
|
|
* |
|
|
|
|