7#if !LWIP_STATS || !UDP_STATS || !MEMP_STATS
8#error "This tests needs UDP- and MEMP-statistics enabled"
26 struct udp_pcb *pcb = udp_pcbs;
41 fail_unless(
p !=
NULL);
42 fail_unless(ipaddr !=
NULL);
51 fail_unless(
p !=
NULL);
86 fail_unless(
n == &test_netif1);
143 fail_unless(pcb !=
NULL);
161 fail_unless(ctr->
pcb ==
pcb);
179 const u8_t test_data[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf};
182 fail_unless(
p !=
NULL);
186 fail_unless(
p->next ==
NULL);
200 ih = (
struct ip_hdr *)
p->payload;
201 memset(ih, 0,
sizeof(*ih));
202 ih->dest.addr = dst_addr;
215 struct udp_pcb *pcb1, *pcb2;
220 struct udp_pcb *pcb_any;
226 fail_unless(pcb1 !=
NULL);
228 fail_unless(pcb2 !=
NULL);
232 fail_unless(pcb_any !=
NULL);
240 memset(&ctr_any, 0,
sizeof(ctr_any));
241 ctr_any.
pcb = pcb_any;
245 err = udp_bind(pcb1, &test_netif1.ip_addr,
port);
250 memset(&ctr1, 0,
sizeof(ctr1));
252 memset(&ctr2, 0,
sizeof(ctr2));
261 err = ip4_input(
p, &test_netif1);
263 fail_unless(ctr1.
rx_cnt == 1);
265 fail_unless(ctr2.
rx_cnt == 0);
267 fail_unless(ctr_any.
rx_cnt == 0);
276 fail_unless(ctr2.
rx_cnt == 1);
278 fail_unless(ctr1.
rx_cnt == 0);
280 fail_unless(ctr_any.
rx_cnt == 0);
289 fail_unless(ctr1.
rx_cnt == 1);
291 fail_unless(ctr2.
rx_cnt == 0);
293 fail_unless(ctr_any.
rx_cnt == 0);
300 err = ip4_input(
p, &test_netif1);
302 fail_unless(ctr2.
rx_cnt == 1);
304 fail_unless(ctr1.
rx_cnt == 0);
306 fail_unless(ctr_any.
rx_cnt == 0);
313 err = ip4_input(
p, &test_netif1);
315 fail_unless(ctr1.
rx_cnt == 1);
317 fail_unless(ctr2.
rx_cnt == 0);
319 fail_unless(ctr_any.
rx_cnt == 0);
328 fail_unless(ctr2.
rx_cnt == 1);
330 fail_unless(ctr1.
rx_cnt == 0);
332 fail_unless(ctr_any.
rx_cnt == 0);
340 struct udp_pcb* pcb1;
341 struct udp_pcb* pcb2;
355 err1 = udp_bind(pcb1, &ip1, 2105);
356 err2 = udp_bind(pcb2, &ip2, 2105);
358 fail_unless(err1 ==
ERR_OK);
359 fail_unless(err2 ==
ERR_OK);
371 err1 = udp_bind(pcb1, &ip1, 2105);
372 err2 = udp_bind(pcb2, &ip2, 2105);
374 fail_unless(err1 ==
ERR_OK);
387 err1 = udp_bind(pcb1, &ip1, 2105);
388 err2 = udp_bind(pcb2, &ip2, 2105);
390 fail_unless(err1 ==
ERR_OK);
403 err1 = udp_bind(pcb1, &ip1, 2105);
404 err2 = udp_bind(pcb2, &ip2, 2105);
406 fail_unless(err1 ==
ERR_OK);
407 fail_unless(err2 ==
ERR_OK);
413 IP_ADDR4(&ip1, 1, 2, 3, 4);
414 IP_ADDR4(&ip2, 4, 3, 2, 1);
419 err1 = udp_bind(pcb1, &ip1, 2105);
420 err2 = udp_bind(pcb2, &ip2, 2105);
422 fail_unless(err1 ==
ERR_OK);
423 fail_unless(err2 ==
ERR_OK);
429 IP_ADDR4(&ip1, 1, 2, 3, 4);
430 IP_ADDR4(&ip2, 1, 2, 3, 4);
435 err1 = udp_bind(pcb1, &ip1, 2105);
436 err2 = udp_bind(pcb2, &ip2, 2105);
438 fail_unless(err1 ==
ERR_OK);
446 IP_ADDR4(&ip2, 1, 2, 3, 4);
451 err1 = udp_bind(pcb1, &ip1, 2105);
452 err2 = udp_bind(pcb2, &ip2, 2105);
454 fail_unless(err1 ==
ERR_OK);
468 TESTFUNC(test_udp_broadcast_rx_with_2_netifs),
#define ip_set_option(pcb, opt)
GLuint GLsizei GLsizei * length
GLenum const GLvoid * addr
#define LWIP_UNUSED_ARG(x)
#define NETIF_FLAG_LINK_UP
#define NETIF_FLAG_ETHARP
#define NETIF_FLAG_BROADCAST
void netif_remove(struct netif *netif)
struct netif * netif_add(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
void netif_set_default(struct netif *netif)
void netif_set_up(struct netif *netif)
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
u8_t pbuf_free(struct pbuf *p)
err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len)
u16_t inet_chksum(const void *dataptr, u16_t len)
#define ip_addr_set_any_val(is_ipv6, ipaddr)
Suite * create_suite(const char *name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown)
void lwip_check_ensure_no_alloc(unsigned int skip)
static struct test_info tests[]
struct netif * netif_list
struct netif * netif_default
u8_t pbuf_add_header(struct pbuf *p, size_t header_size_increment)
#define IPH_VHL_SET(hdr, v, hl)
#define IPH_CHKSUM_SET(hdr, chksum)
#define MEMP_STATS_GET(x, i)
netif_linkoutput_fn linkoutput
static ip4_addr_t test_gw2
static struct pbuf * test_udp_create_test_packet(u16_t length, u16_t port, u32_t dst_addr)
static err_t default_netif_linkoutput(struct netif *netif, struct pbuf *p)
static struct netif test_netif1 test_netif2
static void udp_setup(void)
static END_TEST void test_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
static err_t default_netif_init(struct netif *netif)
static ip4_addr_t test_netmask2
static ip4_addr_t test_ipaddr1
static void udp_teardown(void)
static void udp_remove_all(void)
static void default_netif_add(void)
static err_t default_netif_output(struct netif *netif, struct pbuf *p, const ip4_addr_t *ipaddr)
static ip4_addr_t test_gw1
static void default_netif_remove(void)
static ip4_addr_t test_netmask1
static ip4_addr_t test_ipaddr2
static int linkoutput_ctr
END_TEST Suite * udp_suite(void)