59 lines
1.3 KiB
C

#ifndef ETHERLIB_TEST_DHCP_H
#define ETHERLIB_TEST_DHCP_H
#include <stdint.h>
#include "../../eth_interface.h"
typedef struct {
uint8_t op; ///< Operations
uint8_t htype; ///< Hardware type
uint8_t hlen; ///< Hardware address length
uint8_t hops; ///< Number of network hops
uint32_t xid; ///< Transaction ID
uint16_t secs; ///< Seconds elapsed since client started trying to boot
uint16_t flags; ///< Flags
uint32_t ciaddr; ///< Client IP address (filled in DHCPREQUEST)
uint32_t yiaddr; ///< 'Your' client IP address
uint32_t siaddr; ///< DHCP server IP address
uint32_t giaddr; ///< Relay agent IP address
uint8_t chaddr[16]; ///< Client hardware address
char * sname; ///< Optional server host name
char * file; ///< Boot file name
} DhcpProps;
/**
* DHCP state.
*/
typedef enum {
DHCP_INIT_REBOOT,
DHCP_REBOOTING,
DHCP_INIT,
DHCP_REQUESTING,
DHCP_SELECTING,
DHCP_REBINDING,
DHCP_BOUND,
DHCP_RENEWING
} DhcpState;
/**
* DHCP id codes.
*/
typedef enum {
DHCP_BOOTREQUEST = 1,
DHCP_BOOTREPLY = 0
} DhcpOpCode;
#define DHCP_MIN_PACKET_SIZE (312)
#define DHCP_CLIENT_PORT (68)
#define DHCP_SERVER_PORT (67)
/**
* Initiate DHCP on interface
* @param intf interface
*/
void dhcp_initiate(EthInterface * intf);
void dhcp_start();
#endif //ETHERLIB_TEST_DHCP_H