Network Configuration Library

Overview

The network configuration library sets up networking devices in a semi-automatic way during the system boot, based on user-supplied Kconfig options.

The following Kconfig options affect how configuration library will setup the system:

Kconfig options for network configuration library
Option name Description
CONFIG_NET_CONFIG_SETTINGS This option controls whether the network system is configured or initialized at all. If not set, then the config library is not used for initialization and the application needs to do all the network related configuration itself. If this option is set, then the user can optionally configure static IP addresses to be set to the first network interface in the system. Typically setting static IP addresses is only usable in testing and should not be used in production code. See the config library Kconfig file subsys/net/lib/config/Kconfig for specific options to set the static IP addresses.
CONFIG_NET_CONFIG_AUTO_INIT The networking system is automatically configured when the device is started.
CONFIG_NET_CONFIG_INIT_TIMEOUT This tells how long to wait for the networking to be ready and available. If for example IPv4 address from DHCPv4 is not received within this limit, then a call to net_config_init() will return error during the device startup.
CONFIG_NET_CONFIG_NEED_IPV4 The network application needs IPv4 support to function properly. This option makes sure the network application is initialized properly in order to use IPv4. If CONFIG_NET_IPV4 is not enabled, then setting this option will automatically enable IPv4.
CONFIG_NET_CONFIG_NEED_IPV6 The network application needs IPv6 support to function properly. This option makes sure the network application is initialized properly in order to use IPv6. If CONFIG_NET_IPV6 is not enabled, then setting this option will automatically enable IPv6.
CONFIG_NET_CONFIG_NEED_IPV6_ROUTER If IPv6 is enabled, then this option tells that the network application needs IPv6 router to exists before continuing. This means in practice that the application wants to wait until it receives IPv6 router advertisement message before continuing.
CONFIG_NET_CONFIG_BT_NODE Enables application to operate in Bluetooth node mode which requires GATT service to be registered and start advertising as peripheral.

Sample usage

If CONFIG_NET_CONFIG_AUTO_INIT is set, then the configuration library is automatically enabled and run during the device boot. In this case, the library will call net_config_init() automatically and the application does not need to do any network configuration.

If you want to use the network configuration library but without automatic initialization, you can call net_config_init() manually. The flags parameter can be used to give hints to the library about what kind of functionality the application wishes to have before the actual application starts.

API Reference

group net_config

Network configuration library.

Defines

NET_CONFIG_NEED_ROUTER

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_NEED_IPV6

Application needs IPv6 subsystem configured and initialized. Typically this means that the device has IPv6 address set.

NET_CONFIG_NEED_IPV4

Application needs IPv4 subsystem configured and initialized. Typically this means that the device has IPv4 address set.

Functions

int net_config_init(const char *app_info, u32_t flags, s32_t timeout)

Initialize this network application.

Return
0 if ok, <0 if error.
Parameters
  • app_info: String describing this application.
  • flags: Flags related to services needed by the client.
  • timeout: How long to wait the network setup before continuing the startup.