RetroArch
Classes | Macros | Functions | Variables
dhcp.h File Reference
#include "lwip/opt.h"
#include "lwip/netif.h"
#include "lwip/udp.h"
Include dependency graph for dhcp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  dhcp
 
struct  dhcp_msg
 

Macros

#define DHCP_COARSE_TIMER_SECS   60
 
#define DHCP_FINE_TIMER_MSECS   500
 
#define DHCP_MAX_DNS   2
 
#define DHCP_CHADDR_LEN   16U
 
#define DHCP_SNAME_LEN   64U
 
#define DHCP_FILE_LEN   128U
 
#define DHCP_MIN_OPTIONS_LEN   68U
 
#define DHCP_OPTIONS_LEN   DHCP_MIN_OPTIONS_LEN
 
#define DHCP_MSG_OFS   (UDP_DATA_OFS)
 
#define DHCP_OP_OFS   (DHCP_MSG_OFS + 0)
 
#define DHCP_HTYPE_OFS   (DHCP_MSG_OFS + 1)
 
#define DHCP_HLEN_OFS   (DHCP_MSG_OFS + 2)
 
#define DHCP_HOPS_OFS   (DHCP_MSG_OFS + 3)
 
#define DHCP_XID_OFS   (DHCP_MSG_OFS + 4)
 
#define DHCP_SECS_OFS   (DHCP_MSG_OFS + 8)
 
#define DHCP_FLAGS_OFS   (DHCP_MSG_OFS + 10)
 
#define DHCP_CIADDR_OFS   (DHCP_MSG_OFS + 12)
 
#define DHCP_YIADDR_OFS   (DHCP_MSG_OFS + 16)
 
#define DHCP_SIADDR_OFS   (DHCP_MSG_OFS + 20)
 
#define DHCP_GIADDR_OFS   (DHCP_MSG_OFS + 24)
 
#define DHCP_CHADDR_OFS   (DHCP_MSG_OFS + 28)
 
#define DHCP_SNAME_OFS   (DHCP_MSG_OFS + 44)
 
#define DHCP_FILE_OFS   (DHCP_MSG_OFS + 108)
 
#define DHCP_MSG_LEN   236
 
#define DHCP_COOKIE_OFS   (DHCP_MSG_OFS + DHCP_MSG_LEN)
 
#define DHCP_OPTIONS_OFS   (DHCP_MSG_OFS + DHCP_MSG_LEN + 4)
 
#define DHCP_CLIENT_PORT   68
 
#define DHCP_SERVER_PORT   67
 
#define DHCP_REQUESTING   1
 
#define DHCP_INIT   2
 
#define DHCP_REBOOTING   3
 
#define DHCP_REBINDING   4
 
#define DHCP_RENEWING   5
 
#define DHCP_SELECTING   6
 
#define DHCP_INFORMING   7
 
#define DHCP_CHECKING   8
 
#define DHCP_PERMANENT   9
 
#define DHCP_BOUND   10
 
#define DHCP_BACKING_OFF   12
 
#define DHCP_OFF   13
 
#define DHCP_BOOTREQUEST   1
 
#define DHCP_BOOTREPLY   2
 
#define DHCP_DISCOVER   1
 
#define DHCP_OFFER   2
 
#define DHCP_REQUEST   3
 
#define DHCP_DECLINE   4
 
#define DHCP_ACK   5
 
#define DHCP_NAK   6
 
#define DHCP_RELEASE   7
 
#define DHCP_INFORM   8
 
#define DHCP_HTYPE_ETH   1
 
#define DHCP_HLEN_ETH   6
 
#define DHCP_BROADCAST_FLAG   15
 
#define DHCP_BROADCAST_MASK   (1 << DHCP_FLAG_BROADCAST)
 
#define DHCP_OPTION_PAD   0
 
#define DHCP_OPTION_SUBNET_MASK   1 /* RFC 2132 3.3 */
 
#define DHCP_OPTION_ROUTER   3
 
#define DHCP_OPTION_DNS_SERVER   6
 
#define DHCP_OPTION_HOSTNAME   12
 
#define DHCP_OPTION_IP_TTL   23
 
#define DHCP_OPTION_MTU   26
 
#define DHCP_OPTION_BROADCAST   28
 
#define DHCP_OPTION_TCP_TTL   37
 
#define DHCP_OPTION_END   255
 
#define DHCP_OPTION_REQUESTED_IP   50 /* RFC 2132 9.1, requested IP address */
 
#define DHCP_OPTION_LEASE_TIME   51 /* RFC 2132 9.2, time in seconds, in 4 bytes */
 
#define DHCP_OPTION_OVERLOAD   52 /* RFC2132 9.3, use file and/or sname field for options */
 
#define DHCP_OPTION_MESSAGE_TYPE   53 /* RFC 2132 9.6, important for DHCP */
 
#define DHCP_OPTION_MESSAGE_TYPE_LEN   1
 
#define DHCP_OPTION_SERVER_ID   54 /* RFC 2132 9.7, server IP address */
 
#define DHCP_OPTION_PARAMETER_REQUEST_LIST   55 /* RFC 2132 9.8, requested option types */
 
#define DHCP_OPTION_MAX_MSG_SIZE   57 /* RFC 2132 9.10, message size accepted >= 576 */
 
#define DHCP_OPTION_MAX_MSG_SIZE_LEN   2
 
#define DHCP_OPTION_T1   58 /* T1 renewal time */
 
#define DHCP_OPTION_T2   59 /* T2 rebinding time */
 
#define DHCP_OPTION_CLIENT_ID   61
 
#define DHCP_OPTION_TFTP_SERVERNAME   66
 
#define DHCP_OPTION_BOOTFILE   67
 
#define DHCP_OVERLOAD_NONE   0
 
#define DHCP_OVERLOAD_FILE   1
 
#define DHCP_OVERLOAD_SNAME   2
 
#define DHCP_OVERLOAD_SNAME_FILE   3
 

Functions

PACK_STRUCT_END err_t dhcp_start (struct netif *netif)
 
err_t dhcp_renew (struct netif *netif)
 
err_t dhcp_release (struct netif *netif)
 
void dhcp_stop (struct netif *netif)
 
void dhcp_inform (struct netif *netif)
 
void dhcp_coarse_tmr (void)
 
void dhcp_fine_tmr (void)
 

Variables

PACK_STRUCT_BEGIN struct dhcp_msg PACK_STRUCT_STRUCT
 

Macro Definition Documentation

◆ DHCP_ACK

#define DHCP_ACK   5

◆ DHCP_BACKING_OFF

#define DHCP_BACKING_OFF   12

not yet implemented #define DHCP_RELEASING 11

◆ DHCP_BOOTREPLY

#define DHCP_BOOTREPLY   2

◆ DHCP_BOOTREQUEST

#define DHCP_BOOTREQUEST   1

◆ DHCP_BOUND

#define DHCP_BOUND   10

◆ DHCP_BROADCAST_FLAG

#define DHCP_BROADCAST_FLAG   15

◆ DHCP_BROADCAST_MASK

#define DHCP_BROADCAST_MASK   (1 << DHCP_FLAG_BROADCAST)

◆ DHCP_CHADDR_LEN

#define DHCP_CHADDR_LEN   16U

◆ DHCP_CHADDR_OFS

#define DHCP_CHADDR_OFS   (DHCP_MSG_OFS + 28)

◆ DHCP_CHECKING

#define DHCP_CHECKING   8

◆ DHCP_CIADDR_OFS

#define DHCP_CIADDR_OFS   (DHCP_MSG_OFS + 12)

◆ DHCP_CLIENT_PORT

#define DHCP_CLIENT_PORT   68

◆ DHCP_COARSE_TIMER_SECS

#define DHCP_COARSE_TIMER_SECS   60

period (in seconds) of the application calling dhcp_coarse_tmr()

◆ DHCP_COOKIE_OFS

#define DHCP_COOKIE_OFS   (DHCP_MSG_OFS + DHCP_MSG_LEN)

◆ DHCP_DECLINE

#define DHCP_DECLINE   4

◆ DHCP_DISCOVER

#define DHCP_DISCOVER   1

◆ DHCP_FILE_LEN

#define DHCP_FILE_LEN   128U

◆ DHCP_FILE_OFS

#define DHCP_FILE_OFS   (DHCP_MSG_OFS + 108)

◆ DHCP_FINE_TIMER_MSECS

#define DHCP_FINE_TIMER_MSECS   500

period (in milliseconds) of the application calling dhcp_fine_tmr()

◆ DHCP_FLAGS_OFS

#define DHCP_FLAGS_OFS   (DHCP_MSG_OFS + 10)

◆ DHCP_GIADDR_OFS

#define DHCP_GIADDR_OFS   (DHCP_MSG_OFS + 24)

◆ DHCP_HLEN_ETH

#define DHCP_HLEN_ETH   6

◆ DHCP_HLEN_OFS

#define DHCP_HLEN_OFS   (DHCP_MSG_OFS + 2)

◆ DHCP_HOPS_OFS

#define DHCP_HOPS_OFS   (DHCP_MSG_OFS + 3)

◆ DHCP_HTYPE_ETH

#define DHCP_HTYPE_ETH   1

◆ DHCP_HTYPE_OFS

#define DHCP_HTYPE_OFS   (DHCP_MSG_OFS + 1)

◆ DHCP_INFORM

#define DHCP_INFORM   8

◆ DHCP_INFORMING

#define DHCP_INFORMING   7

◆ DHCP_INIT

#define DHCP_INIT   2

◆ DHCP_MAX_DNS

#define DHCP_MAX_DNS   2

◆ DHCP_MIN_OPTIONS_LEN

#define DHCP_MIN_OPTIONS_LEN   68U

◆ DHCP_MSG_LEN

#define DHCP_MSG_LEN   236

◆ DHCP_MSG_OFS

#define DHCP_MSG_OFS   (UDP_DATA_OFS)

DHCP message item offsets and length

◆ DHCP_NAK

#define DHCP_NAK   6

◆ DHCP_OFF

#define DHCP_OFF   13

◆ DHCP_OFFER

#define DHCP_OFFER   2

◆ DHCP_OP_OFS

#define DHCP_OP_OFS   (DHCP_MSG_OFS + 0)

◆ DHCP_OPTION_BOOTFILE

#define DHCP_OPTION_BOOTFILE   67

◆ DHCP_OPTION_BROADCAST

#define DHCP_OPTION_BROADCAST   28

◆ DHCP_OPTION_CLIENT_ID

#define DHCP_OPTION_CLIENT_ID   61

◆ DHCP_OPTION_DNS_SERVER

#define DHCP_OPTION_DNS_SERVER   6

◆ DHCP_OPTION_END

#define DHCP_OPTION_END   255

◆ DHCP_OPTION_HOSTNAME

#define DHCP_OPTION_HOSTNAME   12

◆ DHCP_OPTION_IP_TTL

#define DHCP_OPTION_IP_TTL   23

◆ DHCP_OPTION_LEASE_TIME

#define DHCP_OPTION_LEASE_TIME   51 /* RFC 2132 9.2, time in seconds, in 4 bytes */

◆ DHCP_OPTION_MAX_MSG_SIZE

#define DHCP_OPTION_MAX_MSG_SIZE   57 /* RFC 2132 9.10, message size accepted >= 576 */

◆ DHCP_OPTION_MAX_MSG_SIZE_LEN

#define DHCP_OPTION_MAX_MSG_SIZE_LEN   2

◆ DHCP_OPTION_MESSAGE_TYPE

#define DHCP_OPTION_MESSAGE_TYPE   53 /* RFC 2132 9.6, important for DHCP */

◆ DHCP_OPTION_MESSAGE_TYPE_LEN

#define DHCP_OPTION_MESSAGE_TYPE_LEN   1

◆ DHCP_OPTION_MTU

#define DHCP_OPTION_MTU   26

◆ DHCP_OPTION_OVERLOAD

#define DHCP_OPTION_OVERLOAD   52 /* RFC2132 9.3, use file and/or sname field for options */

◆ DHCP_OPTION_PAD

#define DHCP_OPTION_PAD   0

BootP options

◆ DHCP_OPTION_PARAMETER_REQUEST_LIST

#define DHCP_OPTION_PARAMETER_REQUEST_LIST   55 /* RFC 2132 9.8, requested option types */

◆ DHCP_OPTION_REQUESTED_IP

#define DHCP_OPTION_REQUESTED_IP   50 /* RFC 2132 9.1, requested IP address */

DHCP options

◆ DHCP_OPTION_ROUTER

#define DHCP_OPTION_ROUTER   3

◆ DHCP_OPTION_SERVER_ID

#define DHCP_OPTION_SERVER_ID   54 /* RFC 2132 9.7, server IP address */

◆ DHCP_OPTION_SUBNET_MASK

#define DHCP_OPTION_SUBNET_MASK   1 /* RFC 2132 3.3 */

◆ DHCP_OPTION_T1

#define DHCP_OPTION_T1   58 /* T1 renewal time */

◆ DHCP_OPTION_T2

#define DHCP_OPTION_T2   59 /* T2 rebinding time */

◆ DHCP_OPTION_TCP_TTL

#define DHCP_OPTION_TCP_TTL   37

◆ DHCP_OPTION_TFTP_SERVERNAME

#define DHCP_OPTION_TFTP_SERVERNAME   66

◆ DHCP_OPTIONS_LEN

#define DHCP_OPTIONS_LEN   DHCP_MIN_OPTIONS_LEN

make sure user does not configure this too small allow this to be configured in lwipopts.h, but not too small set this to be sufficient for your options in outgoing DHCP msgs

◆ DHCP_OPTIONS_OFS

#define DHCP_OPTIONS_OFS   (DHCP_MSG_OFS + DHCP_MSG_LEN + 4)

◆ DHCP_OVERLOAD_FILE

#define DHCP_OVERLOAD_FILE   1

◆ DHCP_OVERLOAD_NONE

#define DHCP_OVERLOAD_NONE   0

possible combinations of overloading the file and sname fields with options

◆ DHCP_OVERLOAD_SNAME

#define DHCP_OVERLOAD_SNAME   2

◆ DHCP_OVERLOAD_SNAME_FILE

#define DHCP_OVERLOAD_SNAME_FILE   3

◆ DHCP_PERMANENT

#define DHCP_PERMANENT   9

◆ DHCP_REBINDING

#define DHCP_REBINDING   4

◆ DHCP_REBOOTING

#define DHCP_REBOOTING   3

◆ DHCP_RELEASE

#define DHCP_RELEASE   7

◆ DHCP_RENEWING

#define DHCP_RENEWING   5

◆ DHCP_REQUEST

#define DHCP_REQUEST   3

◆ DHCP_REQUESTING

#define DHCP_REQUESTING   1

DHCP client states

◆ DHCP_SECS_OFS

#define DHCP_SECS_OFS   (DHCP_MSG_OFS + 8)

◆ DHCP_SELECTING

#define DHCP_SELECTING   6

◆ DHCP_SERVER_PORT

#define DHCP_SERVER_PORT   67

◆ DHCP_SIADDR_OFS

#define DHCP_SIADDR_OFS   (DHCP_MSG_OFS + 20)

◆ DHCP_SNAME_LEN

#define DHCP_SNAME_LEN   64U

◆ DHCP_SNAME_OFS

#define DHCP_SNAME_OFS   (DHCP_MSG_OFS + 44)

◆ DHCP_XID_OFS

#define DHCP_XID_OFS   (DHCP_MSG_OFS + 4)

◆ DHCP_YIADDR_OFS

#define DHCP_YIADDR_OFS   (DHCP_MSG_OFS + 16)

Function Documentation

◆ dhcp_coarse_tmr()

void dhcp_coarse_tmr ( void  )

if enabled, check whether the offered IP address is not in use, using ARP to be called every minute

Here is the caller graph for this function:

◆ dhcp_fine_tmr()

void dhcp_fine_tmr ( void  )

to be called every half second

Here is the caller graph for this function:

◆ dhcp_inform()

void dhcp_inform ( struct netif netif)

inform server of our manual IP address

◆ dhcp_release()

err_t dhcp_release ( struct netif netif)

release the DHCP lease, usually called before dhcp_stop()

◆ dhcp_renew()

err_t dhcp_renew ( struct netif netif)

enforce early lease renewal (not needed normally)

◆ dhcp_start()

PACK_STRUCT_END err_t dhcp_start ( struct netif netif)

start DHCP configuration

Here is the caller graph for this function:

◆ dhcp_stop()

void dhcp_stop ( struct netif netif)

stop DHCP configuration

Variable Documentation

◆ PACK_STRUCT_STRUCT

PACK_STRUCT_BEGIN struct dhcp_msg PACK_STRUCT_STRUCT