Networking_DhcpServer_Start Function

Header: #include <applibs/networking.h>

Registers, configures, and starts the DHCP server for a network interface. The configuration specified by this function call overwrites the existing configuration.

int Networking_DhcpServer_Start(const char *networkInterfaceName, const Networking_DhcpServerConfig *dhcpServerConfig);

Parameters

  • networkInterfaceName The name of the network interface to configure.

  • dhcpServerConfig A pointer to the Networking_DhcpServerConfig struct that represents the DHCP server configuration.

Errors

Returns -1 if an error is encountered and sets errno to the error value.

  • EACCES: the application manifest does not include the DhcpService capability.

  • ENOENT: the networkInterfaceName parameter refers to an interface that does not exist.

  • EPERM: this operation is not allowed on the network interface.

  • EFAULT: the networkInterfaceName parameter is NULL.

  • EFAULT: the dhcpServerConfig parameter is NULL.

  • EAGAIN: the networking stack isn't ready.

  • EINVAL: the configuration struct has invalid parameters.

Any other errno may also be specified; such errors aren't deterministic and the same behavior might not be retained through system updates.

Return value

Returns 0 for success, or -1 for failure, in which case errno will be set to the error value.

Remarks

If the network interface is up when this function is called, the DHCP server will be shut down, configured, and started. If the interface is down, the server will start when the interface is up.

The interface must be configured with a static IP address before this function is called; otherwise, the EPERM error is returned.

Application manifest requirements

The application manifest must include the DhcpService capability.

Concepts and samples