Home |
Function xn_dhcp |
Function xn_dhcpGets an IP address lease and/or network configuration parameters from a DHCP server. int xn_dhcp(int iface_no, DHCP_session * session, DHCP_conf * conf); Parametersiface_noInterface number returned by xn_interface_open or xn_attach. sessionPointer to struct DHCP_session in which server responses and outgoing packets will be stored. You need not fill in any of the fields in this structure before calling xn_dhcp. The variable pointer to by session must be a global or static variable and it must not be modified by the application after xn_dhcp has returned. A background processor of RTIP-32 will continue to use session to periodically extend leases. confPointer to struct DHCP_conf in which configuration info for this function is stored. Use xn_init_dhcp_conf to create a default DHCP_conf. The variable pointer to by conf must be a global or static variable and it must not be modified by the application after xn_dhcp has returned. A background processor of RTIP-32 will continue to use conf to periodically extend leases. return valueReturns 0 if successful, otherwise SOCKET_ERROR. If an error occurred, call xn_getlasterror and xn_geterror_string to return the error value. In addition to the error values listed below, all errors returned by recvfrom and sendto may also be set. Section Error Codes further describes each error. Possible return values for this function are:
This routine implements a DHCP client over UDP and may be called after the interface has been initialized. The conf parameter of xn_dhcp determines how DHCP is to be used. If conf has been initialized with xn_init_dhcp_conf, the interface's IP address, subnet mask, and any other RTIP-32 standard DHCP parameters that were returned by the server will be set. Many applications can simply use default values for this parameter, but if this is not sufficient, a custom configuration will be needed. See section struct DHCP_conf for details. The *session parameter returns information to the caller, i.e. session->lease_time will contain the lease time returned by the server; session->client_ip will contain the IP address you were leased and session->server_ip will contain the server's IP address. The session->param field is a structure which contains pointers to any standard configuration parameters that were returned by the server.
|