diff --git a/test/unit/dhcp/test_dhcp.c b/test/unit/dhcp/test_dhcp.c index 850c213f..61471e2e 100644 --- a/test/unit/dhcp/test_dhcp.c +++ b/test/unit/dhcp/test_dhcp.c @@ -125,6 +125,8 @@ static enum tcase { static int debug = 0; static void setdebug(int a) {debug = a;} +#define netif_dhcp_data(netif) ((struct dhcp*)(netif)->client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP]) + static int tick = 0; static void tick_lwip(void) { @@ -448,7 +450,7 @@ START_TEST(test_dhcp) dhcp_start(&net_test); fail_unless(txpacket == 1); /* DHCP discover sent */ - xid = ((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->xid; /* Write bad xid, not using htonl! */ + xid = netif_dhcp_data(&net_test)->xid; /* Write bad xid, not using htonl! */ memcpy(&dhcp_offer[46], &xid, 4); send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); @@ -458,17 +460,17 @@ START_TEST(test_dhcp) fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t))); fail_unless(txpacket == 1, "TX %d packets, expected 1", txpacket); /* Nothing more sent */ - xid = htonl(((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->xid); + xid = htonl(netif_dhcp_data(&net_test)->xid); memcpy(&dhcp_offer[46], &xid, 4); /* insert correct transaction id */ send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); fail_unless(txpacket == 2, "TX %d packets, expected 2", txpacket); /* DHCP request sent */ - xid = ((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->xid; /* Write bad xid, not using htonl! */ + xid = netif_dhcp_data(&net_test)->xid; /* Write bad xid, not using htonl! */ memcpy(&dhcp_ack[46], &xid, 4); send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack)); fail_unless(txpacket == 2, "TX %d packets, still expected 2", txpacket); /* No more sent */ - xid = htonl(((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->xid); /* xid updated */ + xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */ memcpy(&dhcp_ack[46], &xid, 4); /* insert transaction id */ send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack)); @@ -517,7 +519,7 @@ START_TEST(test_dhcp_nak) dhcp_start(&net_test); fail_unless(txpacket == 1); /* DHCP discover sent */ - xid = ((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->xid; /* Write bad xid, not using htonl! */ + xid = netif_dhcp_data(&net_test)->xid; /* Write bad xid, not using htonl! */ memcpy(&dhcp_offer[46], &xid, 4); send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); @@ -527,17 +529,17 @@ START_TEST(test_dhcp_nak) fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t))); fail_unless(txpacket == 1); /* Nothing more sent */ - xid = htonl(((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->xid); + xid = htonl(netif_dhcp_data(&net_test)->xid); memcpy(&dhcp_offer[46], &xid, 4); /* insert correct transaction id */ send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); fail_unless(txpacket == 2); /* DHCP request sent */ - xid = ((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->xid; /* Write bad xid, not using htonl! */ + xid = netif_dhcp_data(&net_test)->xid; /* Write bad xid, not using htonl! */ memcpy(&dhcp_ack[46], &xid, 4); send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack)); fail_unless(txpacket == 2); /* No more sent */ - xid = htonl(((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->xid); /* xid updated */ + xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */ memcpy(&dhcp_ack[46], &xid, 4); /* insert transaction id */ send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack)); @@ -742,13 +744,13 @@ START_TEST(test_dhcp_relayed) fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t))); fail_unless(txpacket == 1); /* Nothing more sent */ - xid = htonl(((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->xid); + xid = htonl(netif_dhcp_data(&net_test)->xid); memcpy(&relay_offer[46], &xid, 4); /* insert correct transaction id */ send_pkt(&net_test, relay_offer, sizeof(relay_offer)); /* request sent? */ fail_unless(txpacket == 2, "txpkt = %d, should be 2", txpacket); - xid = htonl(((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->xid); /* xid updated */ + xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */ memcpy(&relay_ack1[46], &xid, 4); /* insert transaction id */ send_pkt(&net_test, relay_ack1, sizeof(relay_ack1)); @@ -784,7 +786,7 @@ START_TEST(test_dhcp_relayed) fail_unless(txpacket == 7, "txpacket = %d", txpacket); fail_unless(netif_is_up(&net_test)); - xid = htonl(((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->xid); /* xid updated */ + xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */ memcpy(&relay_ack2[46], &xid, 4); /* insert transaction id */ send_pkt(&net_test, relay_ack2, sizeof(relay_ack2)); @@ -873,7 +875,7 @@ START_TEST(test_dhcp_nak_no_endmarker) dhcp_start(&net_test); fail_unless(txpacket == 1); /* DHCP discover sent */ - xid = ((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->xid; /* Write bad xid, not using htonl! */ + xid = netif_dhcp_data(&net_test)->xid; /* Write bad xid, not using htonl! */ memcpy(&dhcp_offer[46], &xid, 4); send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); @@ -883,19 +885,19 @@ START_TEST(test_dhcp_nak_no_endmarker) fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t))); fail_unless(txpacket == 1); /* Nothing more sent */ - xid = htonl(((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->xid); + xid = htonl(netif_dhcp_data(&net_test)->xid); memcpy(&dhcp_offer[46], &xid, 4); /* insert correct transaction id */ send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); - fail_unless(((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->state == DHCP_STATE_REQUESTING); + fail_unless(netif_dhcp_data(&net_test)->state == DHCP_STATE_REQUESTING); fail_unless(txpacket == 2); /* No more sent */ - xid = htonl(((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->xid); /* xid updated */ + xid = htonl(netif_dhcp_data(&net_test)->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(((struct dhcp*)net_test.client_data[LWIP_NETIF_CLIENT_DATA_INDEX_DHCP])->state != DHCP_STATE_REQUESTING); + fail_unless(netif_dhcp_data(&net_test)->state != DHCP_STATE_REQUESTING); netif_remove(&net_test); } diff --git a/test/unit/mdns/test_mdns.c b/test/unit/mdns/test_mdns.c index c9a6bc3f..d1d2cb71 100644 --- a/test/unit/mdns/test_mdns.c +++ b/test/unit/mdns/test_mdns.c @@ -382,7 +382,7 @@ START_TEST(add_label_long_label) memset(&domain, 0, sizeof(domain)); res = mdns_domain_add_label(&domain, "multi", 5); fail_unless(res == ERR_OK); - res = mdns_domain_add_label(&domain, toolong, strlen(toolong)); + res = mdns_domain_add_label(&domain, toolong, (u8_t)strlen(toolong)); fail_unless(res == ERR_VAL); } END_TEST @@ -394,28 +394,28 @@ START_TEST(add_label_full) err_t res; memset(&domain, 0, sizeof(domain)); - res = mdns_domain_add_label(&domain, label, strlen(label)); + res = mdns_domain_add_label(&domain, label, (u8_t)strlen(label)); fail_unless(res == ERR_OK); fail_unless(domain.length == 33); - res = mdns_domain_add_label(&domain, label, strlen(label)); + res = mdns_domain_add_label(&domain, label, (u8_t)strlen(label)); fail_unless(res == ERR_OK); fail_unless(domain.length == 66); - res = mdns_domain_add_label(&domain, label, strlen(label)); + res = mdns_domain_add_label(&domain, label, (u8_t)strlen(label)); fail_unless(res == ERR_OK); fail_unless(domain.length == 99); - res = mdns_domain_add_label(&domain, label, strlen(label)); + res = mdns_domain_add_label(&domain, label, (u8_t)strlen(label)); fail_unless(res == ERR_OK); fail_unless(domain.length == 132); - res = mdns_domain_add_label(&domain, label, strlen(label)); + res = mdns_domain_add_label(&domain, label, (u8_t)strlen(label)); fail_unless(res == ERR_OK); fail_unless(domain.length == 165); - res = mdns_domain_add_label(&domain, label, strlen(label)); + res = mdns_domain_add_label(&domain, label, (u8_t)strlen(label)); fail_unless(res == ERR_OK); fail_unless(domain.length == 198); - res = mdns_domain_add_label(&domain, label, strlen(label)); + res = mdns_domain_add_label(&domain, label, (u8_t)strlen(label)); fail_unless(res == ERR_OK); fail_unless(domain.length == 231); - res = mdns_domain_add_label(&domain, label, strlen(label)); + res = mdns_domain_add_label(&domain, label, (u8_t)strlen(label)); fail_unless(res == ERR_VAL); fail_unless(domain.length == 231); res = mdns_domain_add_label(&domain, label, 25); @@ -517,27 +517,27 @@ END_TEST START_TEST(domain_eq_anydata) { - static const char data1[] = { 0x05, (char)0xcc, (char)0xdc, 0x00, (char)0xa0 }; - static const char data2[] = { 0x7f, (char)0x8c, 0x01, (char)0xff, (char)0xcf }; + static const u8_t data1[] = { 0x05, 0xcc, 0xdc, 0x00, 0xa0 }; + static const u8_t data2[] = { 0x7f, 0x8c, 0x01, 0xff, 0xcf }; struct mdns_domain domain1, domain2; err_t res; memset(&domain1, 0, sizeof(domain1)); - res = mdns_domain_add_label(&domain1, data1, sizeof(data1)); + res = mdns_domain_add_label(&domain1, (char*)data1, sizeof(data1)); fail_unless(res == ERR_OK); res = mdns_domain_add_label(&domain1, "cast", 4); fail_unless(res == ERR_OK); - res = mdns_domain_add_label(&domain1, data2, sizeof(data2)); + res = mdns_domain_add_label(&domain1, (char*)data2, sizeof(data2)); fail_unless(res == ERR_OK); res = mdns_domain_add_label(&domain1, NULL, 0); fail_unless(res == ERR_OK); memset(&domain2, 0, sizeof(domain2)); - res = mdns_domain_add_label(&domain2, data1, sizeof(data1)); + res = mdns_domain_add_label(&domain2, (char*)data1, sizeof(data1)); fail_unless(res == ERR_OK); res = mdns_domain_add_label(&domain2, "casT", 4); fail_unless(res == ERR_OK); - res = mdns_domain_add_label(&domain2, data2, sizeof(data2)); + res = mdns_domain_add_label(&domain2, (char*)data2, sizeof(data2)); fail_unless(res == ERR_OK); res = mdns_domain_add_label(&domain2, NULL, 0); fail_unless(res == ERR_OK); @@ -578,7 +578,7 @@ START_TEST(compress_full_match) struct pbuf *p; struct mdns_domain domain; u16_t offset; - u8_t length; + u16_t length; err_t res; p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM); @@ -612,7 +612,7 @@ START_TEST(compress_full_match_subset) struct pbuf *p; struct mdns_domain domain; u16_t offset; - u8_t length; + u16_t length; err_t res; p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM); @@ -648,7 +648,7 @@ START_TEST(compress_full_match_jump) struct pbuf *p; struct mdns_domain domain; u16_t offset; - u8_t length; + u16_t length; err_t res; p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM); @@ -682,7 +682,7 @@ START_TEST(compress_no_match) struct pbuf *p; struct mdns_domain domain; u16_t offset; - u8_t length; + u16_t length; err_t res; p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM); @@ -715,7 +715,7 @@ START_TEST(compress_2nd_label) struct pbuf *p; struct mdns_domain domain; u16_t offset; - u8_t length; + u16_t length; err_t res; p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM); @@ -749,7 +749,7 @@ START_TEST(compress_2nd_label_short) struct pbuf *p; struct mdns_domain domain; u16_t offset; - u8_t length; + u16_t length; err_t res; p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM); @@ -785,7 +785,7 @@ START_TEST(compress_jump_to_jump) struct pbuf *p; struct mdns_domain domain; u16_t offset; - u8_t length; + u16_t length; err_t res; p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM); @@ -824,7 +824,7 @@ START_TEST(compress_long_match) struct pbuf *p; struct mdns_domain domain; u16_t offset; - u8_t length; + u16_t length; err_t res; p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);