diff options
Diffstat (limited to 'libdhcp/include')
-rw-r--r-- | libdhcp/include/libdhcp/client.h | 87 |
1 files changed, 2 insertions, 85 deletions
diff --git a/libdhcp/include/libdhcp/client.h b/libdhcp/include/libdhcp/client.h index 6037a3b..b0eaa52 100644 --- a/libdhcp/include/libdhcp/client.h +++ b/libdhcp/include/libdhcp/client.h @@ -68,91 +68,8 @@ #define _LIBDHCP_DHCP_H_ #include <libhw/generic/net.h> -#include "hw/w5500.h" -enum dhcp_event { - DHCP_ASSIGN, - DHCP_UPDATE, - DHCP_CONFLICT, -}; - -typedef void (*dhcp_callback_t)(enum dhcp_event, struct dhcp_lease); - -/* Retry to processing DHCP */ -#define MAX_DHCP_RETRY 2 ///< Maximum retry count -#define DHCP_WAIT_TIME 10 ///< Wait Time 10s - -/* - * @brief return value of @ref DHCP_run() - */ -enum { - DHCP_RET_FAILED = 0, // Processing Fail - DHCP_RET_RUNNING, // Processing DHCP protocol - DHCP_RET_IP_ASSIGN, // First Occupy IP from DHPC server (if cbfunc == null, act as default default_ip_assign) - DHCP_RET_IP_CHANGED, // Change IP address by new ip from DHCP (if cbfunc == null, act as default default_ip_update) - DHCP_RET_IP_LEASED, // Stand by - DHCP_RET_STOPPED // Stop processing DHCP protocol -}; - -/* - * @brief DHCP client initialization (outside of the main loop) - * @param buf - buffer for processing DHCP message - */ -void DHCP_init(void *buf); - -/* - * @brief DHCP 1s Tick Timer handler - * @note SHOULD BE register to your system 1s Tick timer handler - */ -void DHCP_time_handler(void); - -/* - * @brief DHCP client in the main loop - * @return The value is as the follow \n - * @ref DHCP_FAILED \n - * @ref DHCP_RUNNING \n - * @ref DHCP_IP_ASSIGN \n - * @ref DHCP_IP_CHANGED \n - * @ref DHCP_IP_LEASED \n - * @ref DHCP_STOPPED \n - * - * @note This function is always called by you main task. - */ -uint8_t DHCP_run(struct w5500 *chip, uint8_t socknum, dhcp_callback_t cb); -//uint8_t DHCP_run(implements_net_packet_conn *sock, dhcp_callback_t cb); - -/* - * @brief Stop DHCP processing - * @note If you want to restart. call DHCP_init() and DHCP_run() - */ -void DHCP_stop(implements_net_packet_conn *sock); - -void xhandle(uint8_t opt_typ, uint8_t opt_len, uint8_t *opt_dat) { - switch (opt_typ) { - case DHCP_OPT_SUBNET_MASK: - if (opt_len != 4) - return; - global_lease.subnet_mask.octets[0] = opt_dat[0]; - global_lease.subnet_mask.octets[1] = opt_dat[1]; - global_lease.subnet_mask.octets[2] = opt_dat[2]; - global_lease.subnet_mask.octets[3] = opt_dat[3]; - case DHCP_OPT_ROUTER : - if (opt_len < 4) - return; - global_lease.gateway.octets[0] = opt_dat[0]; - global_lease.gateway.octets[1] = opt_dat[1]; - global_lease.gateway.octets[2] = opt_dat[2]; - global_lease.gateway.octets[3] = opt_dat[3]; - break; - case DHCP_OPT_DOMAIN_SERVER : - if (opt_len < 4) - return; - global_lease.dns.octets[0] = opt_dat[0]; - global_lease.dns.octets[1] = opt_dat[1]; - global_lease.dns.octets[2] = opt_dat[2]; - global_lease.dns.octets[3] = opt_dat[3]; - break; - } -} +__attribute__((noreturn)) void dhcp_client_main(implements_net_iface *iface, + char *self_hostname); #endif /* _LIBDHCP_DHCP_H_ */ |