Zephyr API Documentation 3.7.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Network Hostname Library

Network hostname configuration library . More...

Macros

#define NET_HOSTNAME_MAX_LEN
 Maximum hostname length.
 

Functions

static const char * net_hostname_get (void)
 Get the device hostname.
 
static int net_hostname_set (char *host, size_t len)
 Set the device hostname.
 
static void net_hostname_init (void)
 Initialize and set the device hostname.
 
static int net_hostname_set_postfix (const uint8_t *hostname_postfix, int postfix_len)
 Set the device hostname postfix.
 
static int net_hostname_set_postfix_str (const uint8_t *hostname_postfix, int postfix_len)
 Set the postfix string for the network hostname.
 

Detailed Description

Network hostname configuration library .

Since
1.10
Version
0.8.0

Macro Definition Documentation

◆ NET_HOSTNAME_MAX_LEN

#define NET_HOSTNAME_MAX_LEN

#include <zephyr/net/hostname.h>

Value:
(sizeof(CONFIG_NET_HOSTNAME) - 1 + \
(IS_ENABLED(CONFIG_NET_HOSTNAME_UNIQUE) ? sizeof("0011223344556677") - 1 : 0))
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:140

Maximum hostname length.

Function Documentation

◆ net_hostname_get()

static const char * net_hostname_get ( void )
inlinestatic

#include <zephyr/net/hostname.h>

Get the device hostname.

Return pointer to device hostname.

Returns
Pointer to hostname or NULL if not set.

◆ net_hostname_init()

static void net_hostname_init ( void )
inlinestatic

#include <zephyr/net/hostname.h>

Initialize and set the device hostname.

◆ net_hostname_set()

static int net_hostname_set ( char * host,
size_t len )
inlinestatic

#include <zephyr/net/hostname.h>

Set the device hostname.

Parameters
hostnew hostname as char array.
lenLength of the hostname array.
Returns
0 if ok, <0 on error

◆ net_hostname_set_postfix()

static int net_hostname_set_postfix ( const uint8_t * hostname_postfix,
int postfix_len )
inlinestatic

#include <zephyr/net/hostname.h>

Set the device hostname postfix.

Convert the hostname postfix to hexadecimal value and set the device hostname with the converted value. This is only used if CONFIG_NET_HOSTNAME_UNIQUE is set.

Parameters
hostname_postfixUsually link address. The function will convert this to a hexadecimal string.
postfix_lenLength of the hostname_postfix array.
Returns
0 if ok, <0 if error

◆ net_hostname_set_postfix_str()

static int net_hostname_set_postfix_str ( const uint8_t * hostname_postfix,
int postfix_len )
inlinestatic

#include <zephyr/net/hostname.h>

Set the postfix string for the network hostname.

Set the hostname postfix string for the network hostname as is, without any conversion. This is only used if CONFIG_NET_HOSTNAME_UNIQUE is set. The function checks if the combined length of the default hostname (defined by CONFIG_NET_HOSTNAME) and the postfix does not exceed NET_HOSTNAME_MAX_LEN. If the postfix is too long, the function returns an error.

Parameters
hostname_postfixPointer to the postfix string to be appended to the network hostname.
postfix_lenLength of the hostname_postfix array.
Returns
0 if ok, <0 if error