Merge branch 'master' into ppp-new

This commit is contained in:
Sylvain Rochet 2012-09-27 21:32:27 +02:00
commit 7fb874ad28
4 changed files with 1894 additions and 1761 deletions

View File

@ -145,6 +145,15 @@ HISTORY
++ Bugfixes:
2012-09-26: Simon Goldschmidt
* api_msg.c: fixed bug #37405 'err_tcp()' uses already freed 'netconn' object
2012-09-26: patch by Henrik Persson
* dhcp.c: patch #7843 Fix corner case with dhcp timeouts
2012-09-26: patch by Henrik Persson
* dhcp.c: patch #7840 Segfault in dhcp_parse_reply if no end marker in dhcp packet
2012-08-22: Simon Goldschmidt
* memp.c: fixed bug #37166: memp_sanity check loops itself

View File

@ -456,6 +456,14 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
if (sys_mbox_trypost(&conn->acceptmbox, newconn) != ERR_OK) {
/* When returning != ERR_OK, the pcb is aborted in tcp_process(),
so do nothing here! */
/* remove all references to this netconn from the pcb */
struct tcp_pcb* pcb = newconn->pcb.tcp;
tcp_arg(pcb, NULL);
tcp_recv(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_poll(pcb, NULL, 4);
tcp_err(pcb, NULL);
/* remove reference from to the pcb from this netconn */
newconn->pcb.tcp = NULL;
/* no need to drain since we know the recvmbox is empty. */
sys_mbox_free(&newconn->recvmbox);

File diff suppressed because it is too large Load Diff

View File

@ -118,6 +118,7 @@ static enum tcase {
TEST_LWIP_DHCP,
TEST_LWIP_DHCP_NAK,
TEST_LWIP_DHCP_RELAY,
TEST_LWIP_DHCP_NAK_NO_ENDMARKER,
} tcase;
static int debug = 0;
@ -796,6 +797,109 @@ START_TEST(test_dhcp_relayed)
}
END_TEST
START_TEST(test_dhcp_nak_no_endmarker)
{
struct ip_addr addr;
struct ip_addr netmask;
struct ip_addr gw;
u8_t dhcp_nack_no_endmarker[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x54, 0x75,
0xd0, 0x26, 0xd0, 0x0d, 0x08, 0x00, 0x45, 0x00,
0x01, 0x15, 0x38, 0x86, 0x00, 0x00, 0xff, 0x11,
0xc0, 0xa8, 0xc0, 0xa8, 0x01, 0x01, 0xff, 0xff,
0xff, 0xff, 0x00, 0x43, 0x00, 0x44, 0x01, 0x01,
0x00, 0x00, 0x02, 0x01, 0x06, 0x00, 0x7a, 0xcb,
0xba, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23,
0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82,
0x53, 0x63, 0x35, 0x01, 0x06, 0x36, 0x04, 0xc0,
0xa8, 0x01, 0x01, 0x31, 0xef, 0xad, 0x72, 0x31,
0x43, 0x4e, 0x44, 0x30, 0x32, 0x35, 0x30, 0x43,
0x52, 0x47, 0x44, 0x38, 0x35, 0x36, 0x3c, 0x08,
0x4d, 0x53, 0x46, 0x54, 0x20, 0x35, 0x2e, 0x30,
0x37, 0x0d, 0x01, 0x0f, 0x03, 0x06, 0x2c, 0x2e,
0x2f, 0x1f, 0x21, 0x79, 0xf9, 0x2b, 0xfc, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x71,
0xf3, 0x5b, 0xe2, 0x71, 0x2e, 0x01, 0x08, 0x03,
0x04, 0xc0, 0xa8, 0x01, 0x01, 0xff, 0xeb, 0x1e,
0x44, 0xec, 0xeb, 0x1e, 0x30, 0x37, 0x0c, 0x01,
0x0f, 0x03, 0x06, 0x2c, 0x2e, 0x2f, 0x1f, 0x21,
0x79, 0xf9, 0x2b, 0xff, 0x25, 0xc0, 0x09, 0xd6,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
tcase = TEST_LWIP_DHCP_NAK_NO_ENDMARKER;
setdebug(0);
IP4_ADDR(&addr, 0, 0, 0, 0);
IP4_ADDR(&netmask, 0, 0, 0, 0);
IP4_ADDR(&gw, 0, 0, 0, 0);
netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input);
dhcp_start(&net_test);
fail_unless(txpacket == 1); // DHCP discover sent
u32_t xid = net_test.dhcp->xid; // Write bad xid, not using htonl!
memcpy(&dhcp_offer[46], &xid, 4);
send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer));
// Interface down
fail_if(netif_is_up(&net_test));
// IP addresses should be zero
fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(struct ip_addr)));
fail_if(memcmp(&netmask, &net_test.netmask, sizeof(struct ip_addr)));
fail_if(memcmp(&gw, &net_test.gw, sizeof(struct ip_addr)));
fail_unless(txpacket == 1); // Nothing more sent
xid = htonl(net_test.dhcp->xid);
memcpy(&dhcp_offer[46], &xid, 4); // insert correct transaction id
send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer));
fail_unless(net_test.dhcp->state == DHCP_REQUESTING);
fail_unless(txpacket == 2); // No more sent
xid = htonl(net_test.dhcp->xid); // xid updated
memcpy(&dhcp_nack_no_endmarker[46], &xid, 4); // insert transaction id
send_pkt(&net_test, dhcp_nack_no_endmarker, sizeof(dhcp_nack_no_endmarker));
// NAK should put us in another state for a while, no other way detecting it
fail_unless(net_test.dhcp->state != DHCP_REQUESTING);
netif_remove(&net_test);
}
END_TEST
/** Create the suite including all tests for this module */
Suite *
dhcp_suite(void)
@ -803,7 +907,8 @@ dhcp_suite(void)
TFun tests[] = {
test_dhcp,
test_dhcp_nak,
test_dhcp_relayed
test_dhcp_relayed,
test_dhcp_nak_no_endmarker
};
return create_suite("DHCP", tests, sizeof(tests)/sizeof(TFun), dhcp_setup, dhcp_teardown);
}