Functions | |
void | wlp_set_ipaddr_cb (void(*addr_cb)(void *ctx, const struct ip_addr *addr), void *ctx) |
Register a callback that will be invoked when an IP address is set. | |
int | wlp_set_ipaddr (const struct ip_addr *ip, const struct ip_addr *netmask, const struct ip_addr *gw, const struct ip_addr *dns) |
Set a static IP address. | |
int | wlp_get_ipaddr (struct ip_addr *ip, struct ip_addr *netmask, struct ip_addr *gw, struct ip_addr *dns) |
Get the current IP address parameters. | |
int | wlp_set_dhcp (int enable) |
Request or release IP address through DHCP. | |
int | wlp_get_dhcp (int *enabled) |
Get the current DHCP configuration. |
These functions manage the network address configuration.
int wlp_get_dhcp | ( | int * | enabled | ) |
Get the current DHCP configuration.
Get information on whether DHCP is enabled or not. Note that wlp_get_dhcp() will not indicate whether an actual IP address has been obtained through DHCP or not. See wlp_set_ipaddr_cb() for information about IP address notifications.
enabled | will hold the DHCP configuration upon successful return. Not used if NULL. |
int wlp_get_ipaddr | ( | struct ip_addr * | ip, | |
struct ip_addr * | netmask, | |||
struct ip_addr * | gw, | |||
struct ip_addr * | dns | |||
) |
Get the current IP address parameters.
The currently assigned IP address setttings for the wifi device will be fetched. If DHCP is enabled (through wlp_set_dhcp()) and the IP configuration has not yet been assigned, all IP address values will be IP_ADDR_ANY. If DHCP is disabled the statically assigned IP addresses will be fetched.
ip | will hold the current IP address upon successful return. Not used if NULL. | |
netmask | will hold the current netmask upon successful return. Not used if NULL. | |
gw | will hold the current default gateway address upon successful return. Not used if NULL. | |
dns | will hold the current dns server address upon successful return. return. Not used if NULL. |
int wlp_set_dhcp | ( | int | enable | ) |
Request or release IP address through DHCP.
Enable or disable DHCP for IP address configuration. If this function is called when the wifi link is up, an IP address will be requested or released upon successful return, depending on the value of the enable parameter. See wlp_set_ipaddr_cb() on how to get notified when the IP address configuration is set or removed.
wlp_set_dhcp() can be invoked either before or after the wifi link is up. If this function is called when the wifi link is down, any DHCP requests will be performed when the wifi link comes up.
If DHCP is enabled through this function, any configuration set through wl_set_ipaddr() will not be used.
Note that the current IP address settings can be obtained through wl_get_ipaddr() at any time.
enable | determines if DHCP should be enabled or disabled. |
int wlp_set_ipaddr | ( | const struct ip_addr * | ip, | |
const struct ip_addr * | netmask, | |||
const struct ip_addr * | gw, | |||
const struct ip_addr * | dns | |||
) |
Set a static IP address.
Disable DHCP and configure the device static IP address settings. wlp_set_ipaddr() can be invoked either before or after the wifi link is up.
If a static IP address is configured using this function, any callback registered with wlp_set_ipaddr_cb() will be invoked as soon as the wifi link status changes (see wlp_linkup()).
ip | is the IP address to set, e.g. 192.168.1.100. Not used if NULL. | |
mask | is the network mask, e.g. 255.255.255.0. Not used if NULL. | |
gw | is the gateway to use, e.g. 192.168.1.1. Not used if NULL. | |
dns | is the dns server to use, e.g. 192.168.1.1. Not used if NULL. |
void wlp_set_ipaddr_cb | ( | void(*)(void *ctx, const struct ip_addr *addr) | addr_cb, | |
void * | ctx | |||
) |
Register a callback that will be invoked when an IP address is set.
The provided callback will be invoked when an IP address is set or removed. Every time wlp_poll() is invoked, the callback condition will be evaluated and any registered callback will be invoked from same context as the call to wlp_poll().
If a static IP address is configured (through wlp_set_ipaddr()), this function will be called at the same time as the link callback registered in wlp_set_link_cb().
If a dynamic IP address is configured (through wlp_set_dhcp()) this function will be called when the link is up and an address has been successfully obatined through DHCP. It will also be called when the wifi link goes down (since the IP address will be removed at that time) or if the IP address is relesed through a call to set_dhcp() with argument 0.
Note that the connection status will also be indicated by any wlp_api that performs socket communication (e.g. wlp_send() and wlp_recv()) through their return values, even though wlp_set_ipaddr_cb() has not been called.
addr_cb | is called when the IP address is set or removed. If the address is set, the current address will be provided in the addr parameter. If the address is removed, the addr parameter will be NULL. | |
ctx | is an opaque context parameter that will be passed back to the addr_cb. |