[Select]

Networking


Index

 

DHCPClient documentation

Introduction

The DHCPClient module provides an implementation of the 'Dynamic Host Configuration Protocol'. This allows a server to allocate addresses to a client based on its internal ethernet 'MAC' address.

The module is able to control multiple interfaces simultaneously. Information about the DHCP configuration process is recorded to the DHCP log.

*Commands

*DHCP [-|+]<interface>

Modify the DHCP control of an interface.

If no prefix is applied to the interface name the interface will be added to the list of those controlled by the DHCP module.

If a '-' prefix is used, the interface name will be removed from those controlled by the DHCP module and any address which is in use will be removed.

If a '+' prefix is used, an existing DHCP lease on that interface will be renewed, or a new attempt to obtain a lease will be made.

*DHCPStatus

Display information on DHCP controlled interfaces.

SWIs

SWI DHCPClient_Control (&55E00)
On entry
   R0 = reason code :
         0 = Add interface
         1 = Remove interface
         2 = Renew lease/re-try obtaining a lease.
   R1 = pointer to interface name
On exit
   R0, R1 preserved

This SWI is used to add or remove an interface from the DHCPClient's control. Once placed under the control of the DHCPClient the interface will continue to operate according to the DHCP protocol until either the interface is configured manually or it is removed from the module's control by being reconfigured.

SWI DHCPClient_State (&55E01)
On entry
   R0 = pointer to interface name
   R1 = pointer to list of information types, terminated by -1
         0 = Interface state (1 word)
                     0 = sleeping
                     1 = initreboot
                     2 = init
                     3 = rebooting
                     4 = selecting
                     5 = requesting
                     6 = bound
                     7 = renewing
                     8 = rebinding
         1 = Bound address - yiaddr (1 word)
         2 = Server address - siaddr (1 word)
         3 = Gateway address - giaddr (1 word)
         4 = lease period in centiseconds (1 word)
         5 = T1 period in centiseconds (1 word)
         6 = T2 period in centiseconds (1 word)
         7 = dhcp start (8 bytes; 5 bytes time, 3 bytes padding)
         8 = lease start (8 bytes; 5 bytes time, 3 bytes padding)
         9 = lease end (8 bytes; 5 bytes time, 3 bytes padding)
         10= T1 end (8 bytes; 5 bytes time, 3 bytes padding)
         11= T2 end (8 bytes; 5 bytes time, 3 bytes padding)
         Others = reserved 
   R2 = pointer to output block R3 = output block length
On exit
   R0 preserved
   R1 = pointer to invalid option, -1 if all types valid
   R2 = pointer to first free space in output block
   R3 = space left, or -ve space needed if data would not fit

This SWI is used to read the current DHCP client state for an interface. R1 points to a list of types which will be returned in the output buffer in the order in which they were supplied. If the block was not large enough, a 'Buffer overflow' error will be returned, with R3 set to the -ve size required. If the type of information requested was invalid, an error will return and R1 will point to the invalid entry.

SWI DHCPClient_Enumerate (&55E02)
On entry
   R0 = pointer to last interface name, or 0 to read initial interface
   R1 = pointer to buffer to return next name in to (may be same as R0)
   R2 = buffer size
On exit
   R0 = number of state transitions
   R1 = pointer to buffer on entry, or NULL if no interfaces left
   R2 = space left, or -ve space needed if data would not fit.

This SWI enumerates the interfaces under DHCPClient control.

Services

Service_InternetStatus 4 (Service Call &B0)
On entry
   R0 = 4 (subreason code)
   R1 = &B0 (reason code)
   R2 = pointer to interface name (eg "ea0")
   R3 = pointer to Driver Information Block for interface
   R4 = pointer to DHCP reply message buffer
   R5 = size of buffer pointed to by R4
On exit
   R0,R2-R5 preserved
   R1 = 0 to claim service call, else preserved

This service call is issued by the Internet module (version 5.28 or later) when a BOOTP/DHCP reply is received. Clients may inspect the contents of the buffer to extract any configuration information.

If you want to alter information in the buffer you may do so, but you must then claim the service call by setting R1 to zero on exit. If the service call is claimed the Internet module will reprocess the buffer as if it had just arrived from the network. Another Service_InternetStatus 4 will arrive in due course.

You should not normally claim this service call.

Service_InternetStatus 5 (Service Call &B0)
On entry
   R0 = 5 (subreason code)
   R1 = &B0 (reason code)
   R2 = pointer to interface name (eg "ea0")
   R3 = pointer to Driver Information Block for interface
   R4 = pointer to DHCPOFFER message buffer
   R5 = size of buffer pointed to by R4
On exit
   R0,R2-R5 preserved
   R1 = 0 to claim service call, else preserved

This service call is issued by the DHCPClient module whenever it receives an offer of an IP address lease which is better than its current best choice (or if it is the first acceptable offer). You may inspect the buffer, but it must not be modified.

If clients choose to retain information about offers they MUST use the value of OPTION_SERVERIDENTIFIER as an opaque key to identify which offer has been chosen.

If you claim this service the DHCPClient module will not accept the offer, but will wait for another offer to be made.

You should not normally claim this service call.

Service_InternetStatus &30 (Service Call &B0)
On entry
   R0 = &30 (subreason code)
   R1 = &B0 (reason code)
   R2 = pointer to interface name (eg "ea0")
   R3 = IP address assigned to interface
On exit
   R0-R3 preserved

This service call is issued by the DHCPClient module (after 0.37) when it has successfully configured an interface with an address leased from a DHCP server. If the interface is reconfigured, the server releases the lease, the server fails to renew the lease, a duplicate address is identified, or the network stack is stopped, the lease will be lost and InternetStatus_DHCPLeaseLost will be issued. This service will not be reissued for renewals of the lease.

This service should never be claimed.

Service_InternetStatus &31 (Service Call &B0)
On entry
   R0 = &31 (subreason code)
   R1 = &B0 (reason code)
   R2 = pointer to interface name (eg "ea0")
   R3 = IP address that was assigned to interface
On exit
   R0-R3 preserved

This service call is issued by the DHCPClient module (after 0.37) when it has lost the DHCP server leased address allocated to an interface. A new address may be established by the DHCPClient if the server responds, or the interface may be manually reconfigured (however, this service may have been issued because of a manual reconfiguration).

See InternetStatus_DHCPLeaseGained for details of circumstances in which this service will be issued.

This service should never be claimed.


This documentation is copyright 3QD Developments Ltd 2013 and may not be reproduced or published in any form without the copyright holders permission. RISC OS is subject to continuous development and improvement as such all information is reproduced by 3QD Developments Ltd in good faith and is believed to be correct at the time of publication E&OE. 3QD Developments Ltd cannot accept any liability for any loss or damage arising from the use of any information provided as part of the RISC OS Documentation.

HTML document version 1.03 3rd November 2015