1105 |
|
|
1106 |
|
|
1107 |
/** |
/** |
1108 |
* If an incoming DHCP message is in response to use, then trigger the state machine |
* If an incoming DHCP message is in response to us, then trigger the state machine |
1109 |
*/ |
*/ |
1110 |
static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port) |
static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port) |
1111 |
{ |
{ |
1116 |
u8_t msg_type; |
u8_t msg_type; |
1117 |
u8_t i; |
u8_t i; |
1118 |
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_recv(pbuf = %p) from DHCP server %u.%u.%u.%u port %u\n", p, |
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_recv(pbuf = %p) from DHCP server %u.%u.%u.%u port %u\n", p, |
1119 |
(u8_t)(ntohl(addr->addr) >> 24 & 0xff), |
(u8_t)(ntohl(addr->addr) >> 24 & 0xff), (u8_t)(ntohl(addr->addr) >> 16 & 0xff), |
1120 |
(u8_t)(ntohl(addr->addr) >> 16 & 0xff), |
(u8_t)(ntohl(addr->addr) >> 8 & 0xff), (u8_t)(ntohl(addr->addr) & 0xff), port)); |
|
(u8_t)(ntohl(addr->addr) >> 8 & 0xff), |
|
|
(u8_t)(ntohl(addr->addr) & 0xff), port)); |
|
1121 |
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->len = %u\n", p->len)); |
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->len = %u\n", p->len)); |
1122 |
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->tot_len = %u\n", p->tot_len)); |
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->tot_len = %u\n", p->tot_len)); |
1123 |
/* prevent warning */ |
/* prevent warnings about unused arguments */ |
1124 |
if (pcb || addr || port); |
(void)pcb; (void)addr; (void)port; |
1125 |
dhcp->p = p; |
dhcp->p = p; |
1126 |
|
/* TODO: check packet length before reading them */ |
1127 |
if (reply_msg->op != DHCP_BOOTREPLY) { |
if (reply_msg->op != DHCP_BOOTREPLY) { |
1128 |
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("not a DHCP reply message, but type %u\n", reply_msg->op)); |
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("not a DHCP reply message, but type %u\n", reply_msg->op)); |
1129 |
pbuf_free(p); |
pbuf_free(p); |