Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Network Configuration Library

Network configuration library. More...

Data Structures

struct  net_config_ssh_password_auth
 This contains configuration data for password authentication for sshd on the device. More...
struct  net_config_ssh_key
 This contains key configuration data for sshd on the device. More...

Macros

#define NET_CONFIG_NEED_ROUTER   0x00000001
 Application needs routers to be set so that connectivity to remote network is possible.
#define NET_CONFIG_NEED_IPV6   0x00000002
 Application needs IPv6 subsystem configured and initialized.
#define NET_CONFIG_NEED_IPV4   0x00000004
 Application needs IPv4 subsystem configured and initialized.
#define NET_CONFIG_SSH_KEY_BUF_DEFINE_STATIC(name, key_bits)
 Temporary key buffer needed for loading and saving keys.
#define NET_CONFIG_SSH_PASSWORD_AUTH_DEFINE_STATIC(name, user_name, pwd)
 Statically define a username and password for SSH server configuration.
#define NET_CONFIG_SSH_PRIV_KEY_DEFINE_STATIC(name, _key_buf_name, _key_buf_len, _key_name, _key_id, _key_type, _key_bits)
 Statically define a private key for SSH server configuration.
#define NET_CONFIG_SSH_PUB_KEY_DEFINE_STATIC(name, _key_buf_name, _key_buf_len, _key_name, _key_id)
 Statically define a public key for SSH server configuration.

Functions

int net_config_init (const char *app_info, uint32_t flags, int32_t timeout)
 Initialize this network application.
int net_config_init_by_iface (struct net_if *iface, const char *app_info, uint32_t flags, int32_t timeout)
 Initialize this network application using a specific network interface.
int net_config_init_app (const struct device *dev, const char *app_info)
 Initialize this network application.
static int net_config_init_sshd (struct net_if *iface, const struct net_config_ssh_key *priv_key_config, const struct net_config_ssh_key *pub_key_config, const struct net_config_ssh_password_auth *password_auth_config, int sshd_instance)
 Initialize SSH server on the device.

Detailed Description

Network configuration library.

Since
1.8
Version
0.8.0

Macro Definition Documentation

◆ NET_CONFIG_NEED_IPV4

#define NET_CONFIG_NEED_IPV4   0x00000004

#include <net_config.h>

Application needs IPv4 subsystem configured and initialized.

Typically this means that the device has IPv4 address set.

◆ NET_CONFIG_NEED_IPV6

#define NET_CONFIG_NEED_IPV6   0x00000002

#include <net_config.h>

Application needs IPv6 subsystem configured and initialized.

Typically this means that the device has IPv6 address set.

◆ NET_CONFIG_NEED_ROUTER

#define NET_CONFIG_NEED_ROUTER   0x00000001

#include <net_config.h>

Application needs routers to be set so that connectivity to remote network is possible.

For IPv6 networks, this means that the device should receive IPv6 router advertisement message before continuing.

◆ NET_CONFIG_SSH_KEY_BUF_DEFINE_STATIC

#define NET_CONFIG_SSH_KEY_BUF_DEFINE_STATIC ( name,
key_bits )

#include <net_config.h>

Value:
static uint8_t name[key_bits]
__UINT8_TYPE__ uint8_t
Definition stdint.h:88

Temporary key buffer needed for loading and saving keys.

Parameters
nameName of the SSH server configuration instance. This is used to identify the instance and must be unique if multiple instances are defined.
key_bitsSize of the SSH key in bits.

◆ NET_CONFIG_SSH_PASSWORD_AUTH_DEFINE_STATIC

#define NET_CONFIG_SSH_PASSWORD_AUTH_DEFINE_STATIC ( name,
user_name,
pwd )

#include <net_config.h>

Value:
static struct net_config_ssh_password_auth name = { \
.username = user_name, \
.password = pwd, \
}
This contains configuration data for password authentication for sshd on the device.
Definition net_config.h:106

Statically define a username and password for SSH server configuration.

Parameters
nameName of the SSH server configuration instance. This is used to identify the instance and must be unique if multiple instances are defined.
user_nameUsername to use for password authentication. If NULL or empty string, then username is not used. The username cannot contain spaces.
pwdPassword to use for password authentication. If NULL or empty string, password authentication will be disabled and only public key authentication will be allowed.

◆ NET_CONFIG_SSH_PRIV_KEY_DEFINE_STATIC

#define NET_CONFIG_SSH_PRIV_KEY_DEFINE_STATIC ( name,
_key_buf_name,
_key_buf_len,
_key_name,
_key_id,
_key_type,
_key_bits )

#include <net_config.h>

Value:
static struct net_config_ssh_key name = { \
.key_buf = _key_buf_name, \
.key_buf_len = _key_buf_len, \
.key_name = _key_name, \
.key_id = _key_id, \
.key_type = _key_type, \
.key_bits = _key_bits, \
.is_private = true, \
}
This contains key configuration data for sshd on the device.
Definition net_config.h:122

Statically define a private key for SSH server configuration.

Parameters
nameName of the SSH server configuration instance. This is used to identify the instance and must be unique if multiple instances are defined.
_key_buf_nameName of the temporary key buffer defined with NET_CONFIG_SSH_KEY_BUF_DEFINE_STATIC() macro. This buffer is needed for loading and saving keys. The buffer can be shared between private and public key configurations if needed, but it must be big enough to hold the key data for both configurations.
_key_nameSSH key name. This is used when saving or loading keys to identify them. The key name cannot contain spaces.
_key_idKey id. This is used to identify the key.
_key_typeType of the SSH key. For example RSA key etc.
_key_bitsSize of the SSH key in bits. This is used to determine the size of the buffer needed for loading and saving keys.

◆ NET_CONFIG_SSH_PUB_KEY_DEFINE_STATIC

#define NET_CONFIG_SSH_PUB_KEY_DEFINE_STATIC ( name,
_key_buf_name,
_key_buf_len,
_key_name,
_key_id )

#include <net_config.h>

Value:
static struct net_config_ssh_key name = { \
.key_buf = _key_buf_name, \
.key_buf_len = _key_buf_len, \
.key_name = _key_name, \
.key_id = _key_id, \
.key_bits = 0, \
.is_private = false, \
}

Statically define a public key for SSH server configuration.

Parameters
nameName of the SSH server configuration instance. This is used to identify the instance and must be unique if multiple instances are defined.
_key_buf_nameName of the temporary key buffer defined with NET_CONFIG_SSH_KEY_BUF_DEFINE_STATIC() macro. This buffer is needed for loading and saving keys. The buffer can be shared between private and public key configurations if needed, but it must be big enough to hold the key data for both configurations.
_key_nameSSH key name. This is used when saving or loading keys to identify them. The key name cannot contain spaces.
_key_idKey id. This is used to identify the key.

Function Documentation

◆ net_config_init()

int net_config_init ( const char * app_info,
uint32_t flags,
int32_t timeout )

#include <net_config.h>

Initialize this network application.

This will call net_config_init_by_iface() with NULL network interface.

Parameters
app_infoString describing this application.
flagsFlags related to services needed by the client.
timeoutHow long to wait the network setup before continuing the startup.
Returns
0 if ok, <0 if error.

◆ net_config_init_app()

int net_config_init_app ( const struct device * dev,
const char * app_info )

#include <net_config.h>

Initialize this network application.

If CONFIG_NET_CONFIG_AUTO_INIT is set, then this function is called automatically when the device boots. If that is not desired, unset the config option and call the function manually when the application starts.

Parameters
devNetwork device to use. The function will figure out what network interface to use based on the device. If the device is NULL, then default network interface is used by the function.
app_infoString describing this application.
Returns
0 if ok, <0 if error.

◆ net_config_init_by_iface()

int net_config_init_by_iface ( struct net_if * iface,
const char * app_info,
uint32_t flags,
int32_t timeout )

#include <net_config.h>

Initialize this network application using a specific network interface.

If network interface is set to NULL, then the default one is used in the configuration.

Parameters
ifaceInitialize networking using this network interface.
app_infoString describing this application.
flagsFlags related to services needed by the client.
timeoutHow long to wait the network setup before continuing the startup.
Returns
0 if ok, <0 if error.

◆ net_config_init_sshd()

int net_config_init_sshd ( struct net_if * iface,
const struct net_config_ssh_key * priv_key_config,
const struct net_config_ssh_key * pub_key_config,
const struct net_config_ssh_password_auth * password_auth_config,
int sshd_instance )
inlinestatic

#include <net_config.h>

Initialize SSH server on the device.

Parameters
ifaceNetwork interface to use for the SSH server. If NULL, the SSH server will bind to the wildcard address and be reachable through all network interfaces.
priv_key_configPrivate key configuration for the SSH server.
pub_key_configPublic key configuration for the SSH server.
password_auth_configPassword authentication configuration for the SSH server. If using public key authetication, then this can be left as NULL or with NULL username and password. The public key authentication will have higher priority than password authentication, so if both are configured, then password authentication will only be used if public key authentication fails. If you want to specify a username for public key authentication, then set the username in the password_auth_config struct, even if password authentication is not used. This is because the SSH server needs to know the username to associate it with the public key.
sshd_instanceSSH server instance number. This is used to identify the SSH server instance and must be unique if multiple instances are defined.
Returns
0 if the SSH server was initialized successfully, <0 if there was an error.