on_sys_dhcp_ok Event

Function:

Informs of the successful procurement of configuration parameters from the DHCP server.

Declaration:

on_sys_dhcp_ok(renew as no_yes, interface as pl_sock_interfaces, dhcp_obtained_ip as string(16), dhcp_obtained_gateway as string(16), dhcp_obtained_netmask as string(16), dhcp_obtained_lease_time as dword)

See Also:

wln.autodhcp, wln.dhcp


Parameter

Description

renew

0 — NO: this is an initial configuration of the IP, etc.

1 — YES: this is a lease renewal (watch out for IP changes!).

interface

Network interface on which the DHCP configuration has completed successfully:

1 — PL_SOCK_INTERFACE_NET: Ethernet (net.) interface.

2 — PL_SOCK_INTERFACE_WLN: Wi-Fi (wln.) interface.

dhcp_obtained_ip

Obtained IP address in the human-readable form, i.e. "192.168.1.40".

dhcp_obtained_gateway

Obtained gateway IP address in the human-readable form, i.e. "192.168.1.1".

dhcp_obtained_netmask

Obtained netmask in the human-readable form, i.e. "255.255.255.0".

dhcp_obtained_lease_time

Obtained lease time expressed as the number of seconds.

Details

This event handler is generated when the DHCP negotiation is completed successfully. This event handler is currently supported only on the WM2000.

Sample code

** Tibbo Basic **


on_sys_dhcp_ok(renew as no_yes, interface as pl_sock_interfaces, ip as string(16), 
     gateway as string(16), netmask as string(16), lease_time as dword)

     if renew=YES and wln.ip<>ip then
          'This is a lease renewal in which the DHCP server has issued a new IP.
          'Depending on your application, you may want to clean up socket resources
          'before switching to the new IP address. Alternatively, you can also reboot
          'to avoid the implications of a changed IP address.
     end if

     wln.ip=ip
     wln.gatewayip=dhcp_obtained_gateway
     wln.netmask=netmask

end sub