提交 95d3982d 编写于 作者: C c00546070 提交者: Caoruihong

Description: move dhcps back to kernel

Reviewed-by: jianghan
上级 722ee45b
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
#define DHCP_MIN_REPLY_LEN 44 #define DHCP_MIN_REPLY_LEN 44
#define REBOOT_TRIES 2 #define REBOOT_TRIES 2
#if 0 /* The following codes are moved to dhcp.h for fixing it's todo, kept here just for notice */
#if LWIP_DNS && LWIP_DHCP_MAX_DNS_SERVERS #if LWIP_DNS && LWIP_DHCP_MAX_DNS_SERVERS
#if DNS_MAX_SERVERS > LWIP_DHCP_MAX_DNS_SERVERS #if DNS_MAX_SERVERS > LWIP_DHCP_MAX_DNS_SERVERS
#define LWIP_DHCP_PROVIDE_DNS_SERVERS LWIP_DHCP_MAX_DNS_SERVERS #define LWIP_DHCP_PROVIDE_DNS_SERVERS LWIP_DHCP_MAX_DNS_SERVERS
...@@ -159,7 +159,7 @@ u32_t dhcp_rx_options_val[DHCP_OPTION_IDX_MAX]; ...@@ -159,7 +159,7 @@ u32_t dhcp_rx_options_val[DHCP_OPTION_IDX_MAX];
only valid while in dhcp_recv. only valid while in dhcp_recv.
@todo: move this into struct dhcp? */ @todo: move this into struct dhcp? */
u8_t dhcp_rx_options_given[DHCP_OPTION_IDX_MAX]; u8_t dhcp_rx_options_given[DHCP_OPTION_IDX_MAX];
#endif
static u8_t dhcp_discover_request_options[] = { static u8_t dhcp_discover_request_options[] = {
DHCP_OPTION_SUBNET_MASK, DHCP_OPTION_SUBNET_MASK,
DHCP_OPTION_ROUTER, DHCP_OPTION_ROUTER,
...@@ -177,12 +177,12 @@ static u32_t xid; ...@@ -177,12 +177,12 @@ static u32_t xid;
static u8_t xid_initialised; static u8_t xid_initialised;
#endif /* DHCP_GLOBAL_XID */ #endif /* DHCP_GLOBAL_XID */
#define dhcp_option_given(dhcp, idx) (dhcp_rx_options_given[idx] != 0) #define dhcp_option_given(dhcp, idx) ((dhcp)->rx_options_given[idx] != 0)
#define dhcp_got_option(dhcp, idx) (dhcp_rx_options_given[idx] = 1) #define dhcp_got_option(dhcp, idx) ((dhcp)->rx_options_given[idx] = 1)
#define dhcp_clear_option(dhcp, idx) (dhcp_rx_options_given[idx] = 0) #define dhcp_clear_option(dhcp, idx) ((dhcp)->rx_options_given[idx] = 0)
#define dhcp_clear_all_options(dhcp) (memset(dhcp_rx_options_given, 0, sizeof(dhcp_rx_options_given))) #define dhcp_clear_all_options(dhcp) (memset((dhcp)->rx_options_given, 0, sizeof((dhcp)->rx_options_given)))
#define dhcp_get_option_value(dhcp, idx) (dhcp_rx_options_val[idx]) #define dhcp_get_option_value(dhcp, idx) ((dhcp)->rx_options_val[idx])
#define dhcp_set_option_value(dhcp, idx, val) (dhcp_rx_options_val[idx] = (val)) #define dhcp_set_option_value(dhcp, idx, val) ((dhcp)->rx_options_val[idx] = (val))
static struct udp_pcb *dhcp_pcb; static struct udp_pcb *dhcp_pcb;
static u8_t dhcp_pcb_refcount; static u8_t dhcp_pcb_refcount;
......
此差异已折叠。
...@@ -1689,7 +1689,7 @@ netif_get_by_index(u8_t idx) ...@@ -1689,7 +1689,7 @@ netif_get_by_index(u8_t idx)
return NULL; return NULL;
} }
#ifndef netif_find
/** /**
* @ingroup netif * @ingroup netif
* Find a network interface by searching for its name * Find a network interface by searching for its name
...@@ -1722,7 +1722,7 @@ netif_find(const char *name) ...@@ -1722,7 +1722,7 @@ netif_find(const char *name)
LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1])); LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1]));
return NULL; return NULL;
} }
#endif
#if LWIP_NETIF_EXT_STATUS_CALLBACK #if LWIP_NETIF_EXT_STATUS_CALLBACK
/** /**
* @ingroup netif * @ingroup netif
......
...@@ -58,6 +58,41 @@ extern "C" { ...@@ -58,6 +58,41 @@ extern "C" {
#define DHCP_BOOT_FILE_LEN 128U #define DHCP_BOOT_FILE_LEN 128U
#if LWIP_DNS && LWIP_DHCP_MAX_DNS_SERVERS
#if DNS_MAX_SERVERS > LWIP_DHCP_MAX_DNS_SERVERS
#define LWIP_DHCP_PROVIDE_DNS_SERVERS LWIP_DHCP_MAX_DNS_SERVERS
#else
#define LWIP_DHCP_PROVIDE_DNS_SERVERS DNS_MAX_SERVERS
#endif
#else
#define LWIP_DHCP_PROVIDE_DNS_SERVERS 0
#endif
/** Option handling: options are parsed in dhcp_parse_reply
* and saved in an array where other functions can load them from.
* This might be moved into the struct dhcp (not necessarily since
* lwIP is single-threaded and the array is only used while in recv
* callback). */
enum dhcp_option_idx {
DHCP_OPTION_IDX_OVERLOAD = 0,
DHCP_OPTION_IDX_MSG_TYPE,
DHCP_OPTION_IDX_SERVER_ID,
DHCP_OPTION_IDX_LEASE_TIME,
DHCP_OPTION_IDX_T1,
DHCP_OPTION_IDX_T2,
DHCP_OPTION_IDX_SUBNET_MASK,
DHCP_OPTION_IDX_ROUTER,
#if LWIP_DHCP_PROVIDE_DNS_SERVERS
DHCP_OPTION_IDX_DNS_SERVER,
DHCP_OPTION_IDX_DNS_SERVER_LAST = DHCP_OPTION_IDX_DNS_SERVER + LWIP_DHCP_PROVIDE_DNS_SERVERS - 1,
#endif /* LWIP_DHCP_PROVIDE_DNS_SERVERS */
#if LWIP_DHCP_GET_NTP_SRV
DHCP_OPTION_IDX_NTP_SERVER,
DHCP_OPTION_IDX_NTP_SERVER_LAST = DHCP_OPTION_IDX_NTP_SERVER + LWIP_DHCP_MAX_NTP_SERVERS - 1,
#endif /* LWIP_DHCP_GET_NTP_SRV */
DHCP_OPTION_IDX_MAX
};
/* AutoIP cooperation flags (struct dhcp.autoip_coop_state) */ /* AutoIP cooperation flags (struct dhcp.autoip_coop_state) */
typedef enum { typedef enum {
DHCP_AUTOIP_COOP_STATE_OFF = 0, DHCP_AUTOIP_COOP_STATE_OFF = 0,
...@@ -98,6 +133,10 @@ struct dhcp ...@@ -98,6 +133,10 @@ struct dhcp
ip4_addr_t offered_si_addr; ip4_addr_t offered_si_addr;
char boot_file_name[DHCP_BOOT_FILE_LEN]; char boot_file_name[DHCP_BOOT_FILE_LEN];
#endif /* LWIP_DHCP_BOOTPFILE */ #endif /* LWIP_DHCP_BOOTPFILE */
/** Holds the decoded option values, only valid while in dhcp_recv. */
u32_t rx_options_val[DHCP_OPTION_IDX_MAX];
/** Holds a flag which option was received and is contained in dhcp_rx_options_val, only valid while in dhcp_recv. */
u8_t rx_options_given[DHCP_OPTION_IDX_MAX];
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册