BOOTP Client

Jump to: navigation, search

Table of Contents >> Optional Protocols

BOOTP Automatic Configuration

Description

The BOOTP user interface allows the user to query directly a BOOTP server, for IP addresses that the user can use. The Treck stack allows the user to retrieve the BOOTP addresses automatically. When the user configures an interface/multihome, the Treck stack automatically queries a BOOTP server for an IP address and parameters, and finishes configuring the interface/multihome with the IP address, and default router given by the BOOTP server. Up to TM_MAX_IPS_PER_IF multihomes per interface can be configured that way.

In that case, the following steps are needed (after having called linkLayerHandle = tfUseEthernet()):

interfaceHandle = tfAddInterface(namePtr, linkLayerHandle, ...);

errorCode = tfUseBootp(interfaceHandle, myNotifyFunction);

errorCode = tfOpenInterface(interfaceHandle,
                            0UL,
                            0UL,
                            TM_DEV_IP_BOOTP,
                            1);

Note that we have called tfOpenInterface() with the TM_DEV_IP_BOOTP flag set. (Note other flags such as TM_DEV_IP_FORW_ENB could be OR'ed to TM_DEV_IP_BOOTP as needed.)


Note Note: The user must wait for the BOOTP configuration to complete. During the wait, ensure tfTimerUpdate() (or tfTimerUpdateIsr()), and tfTimerExecute() are called.

ARP probes sent by the BOOTP client

If the TM_USE_AUTO_IP macro is defined in <trsystem.h>, and the AUTO IP option has been purchased, then the BOOTP client will send several ARP Probes (i.e. ARP request with a sender net address set to 0) to make sure that no other node has been configured with the same IP address. If a node responds, then the BOOTP would notify the user with a TM_EADDRINUSE error code.


Checking on completion of a BOOTP configuration

  • Synchronous check: The user can make multiple calls to tfOpenInterface() to determine when the configuration has completed. Additional calls to tfOpenInterface() will return TM_EINPROGRESS as long as the BOOTP server has not replied. tfOpenInterface will return TM_ENOERROR if the BOOTP server has replied and the configuration has completed.
  • Asynchronous check: To avoid this synchronous poll, the user can provide a user call back function to tfUseBootp() as shown above. This function will be called upon completion of tfOpenInterface(). The notifyFunc is called when the interface/multi home index is configured or if the BOOTP request timed out as follows:
myNotifyFunction(interfaceHandle, errorCode);
where errorCode is 0 if the configuration was successful, or TM_ETIMEDOUT if the BOOTP request timed out.

BOOTP Configuration parameters

When the BOOTP configuration has completed successfully as shown above, the user can retrieve the BOOTP configuration parameters by calling:

userBtEntryPtr = tfConfGetBootEntry(ethernetInterfaceHandle, multiHomeIndex);

If the BOOTP configuration has been successful, this function will return a pointer to a boot structure (null otherwise).

The userBtEntryPtr is a pointer to a structure defined in <trsocket.h>. In particular, the userBtEntryPtr will contain:

  • The allocated IP address in the field userBtEntryPtr->btuYiaddr.
  • The subnet mask in the field userBtEntryPtr->btuNetMask.
  • Default router entry in the field userBtEntryPtr->btuDefRouter.

Configuring additional BOOTP IP addresses on the same interface

To configure additional BOOTP IP addresses on the same interface (multi homing), use tfConfigInterface() instead of tfOpenInterface().


Function Calls

BOOTP User Controlled Configuration

Description

The BOOTP User Controlled Configuration API allows the user to query a BOOTP server direction without automatically configurating an interface. This is useful if the user wants to have more control and wants to acquire the IP address prior to configuring the interface. The following sections describe this procedure. Subsequent sections describe each new interface.

Initializing the Interfaces

1. Call tfInitTreck().
2. Call tfInitTreckOptions() before calling tfStartTreck(). This reserves numberSerialLines BOOTP or DHCP user entries:
errorCode = tfInitTreckOptions(TM_OPTION_DHCP_MAX_ENTRIES,
                               (unsigned long)numberSerialLines);
3. If this succeeds (errorCode == TM_ENOERROR):
errorCode = tfStartTreck();
4. Add all required link layers and interfaces. For Ethernet, call:
ethernetLinkLayerHandle = tfUseEthernet();
ethernetInterfaceHandle = tfAddInterface(namePtr, ethernetLinkLayerhandle, ...);

Starting the Configuration

  1. To start the configuration, the user needs to all tfOpenInterface() or tfConfigInterface() using a zero IP address, zero IP netmask and flags = TM_DEV_IP_USER_BOOT.
  2. Ask for a BOOTP address on the Ethernet interface:

User controlled configuration parameters

tfBootpUserSet() is provided to allow the user to set the host name option. tfBootpUserSet() must be called before tfBootpUserStart().

User controlled BOOTP options

The BOOTP User Controlled API has been extended to support options that are not natively supported by the pre-existing BOOTP client with the following new functions:

tfBootpUserSetOption() needs to be called before tfBootpUserStart().

ARP probes sent by the BOOTP client

If TM_USE_AUTO_IP is defined in trsystem.h, the BOOTP client will send several ARP Probes (i.e. ARP request with a sender net address set to 0) to make sure that no other node has been configured with the same IP address. If a node responds, the BOOTP client will decline the IP address and restart the discovery process in the INIT state after 10 seconds have elapsed.

Retrieving configuration parameters

When the BOOTP request is successful, the user can retrieve the IP address and parameters given by the BOOTP server:

 userBtEntryPtr = tfBootpUserGetBootEntry(ethernetInterfaceHandle,
                                            userIndex );

If the BOOTP request succeeds, this function returns a pointer to a boot structure (else NULL). The userBtEntryPtr (see Section 4) is a pointer to a structure defined in trsocket.h which will contain the following elements:

  • btuYiaddr
    This is the allocated IP address.
  • btuNetMask
    This is the network subnet mask.
  • btuDefRouter
    This is the default router entry.
  • btuDns1ServerIpAddress
    This is the Primary Domain Name Server.
  • btuDns2ServerIpAddress
    This is the Secondary Domain Name Server.


Finishing the interface configuration

The user can finish configuring the interface by calling tfFinishOpenInterface() with this IP address for its interface, or by calling tfFinishConfigInterface() for another multihome index. The user can also add the retrieved default gateway.

Function Calls

Table of Contents >> Optional Protocols