13#if !LWIP_IPV4 || !IP_REASSEMBLY || !MIB2_STATS || !IPFRAG_STATS
14#error "This tests needs LWIP_IPV4, IP_REASSEMBLY; MIB2- and IPFRAG-statistics enabled"
30 fail_unless(
p !=
NULL);
43 netif->output = etharp_output;
53 IP4_ADDR(&
test_gw, 192,168,0,1);
78 fail_unless((
start & 7) == 0);
79 fail_unless(((
len & 7) == 0) ||
last);
80 fail_unless(input_netif !=
NULL);
83 fail_unless(
p !=
NULL);
99 ip4_addr_copy(iphdr->src, *netif_ip4_addr(input_netif));
101 ip4_addr_copy(iphdr->dest, *netif_ip4_addr(input_netif));
104 err = ip4_input(
p, input_netif);
113 const ip4_addr_t *ipaddr) {
135 tcpip_thread_poll_one();
145 ip_addr_t peer_ip = IPADDR4_INIT_BYTES(192,168,0,5);
167 const u16_t ip_id = 128;
170 memset(&lwip_stats.mib2, 0,
sizeof(lwip_stats.mib2));
173 fail_unless(lwip_stats.ip_frag.recv == 1);
174 fail_unless(lwip_stats.ip_frag.err == 0);
175 fail_unless(lwip_stats.ip_frag.memerr == 0);
176 fail_unless(lwip_stats.ip_frag.drop == 0);
177 fail_unless(lwip_stats.mib2.ipreasmoks == 0);
180 fail_unless(lwip_stats.ip_frag.recv == 2);
181 fail_unless(lwip_stats.ip_frag.err == 0);
182 fail_unless(lwip_stats.ip_frag.memerr == 0);
183 fail_unless(lwip_stats.ip_frag.drop == 0);
184 fail_unless(lwip_stats.mib2.ipreasmoks == 0);
187 fail_unless(lwip_stats.ip_frag.recv == 3);
188 fail_unless(lwip_stats.ip_frag.err == 0);
189 fail_unless(lwip_stats.ip_frag.memerr == 0);
190 fail_unless(lwip_stats.ip_frag.drop == 0);
191 fail_unless(lwip_stats.mib2.ipreasmoks == 0);
194 fail_unless(lwip_stats.ip_frag.recv == 4);
195 fail_unless(lwip_stats.ip_frag.err == 0);
196 fail_unless(lwip_stats.ip_frag.memerr == 0);
197 fail_unless(lwip_stats.ip_frag.drop == 0);
198 fail_unless(lwip_stats.mib2.ipreasmoks == 0);
201 fail_unless(lwip_stats.ip_frag.recv == 5);
202 fail_unless(lwip_stats.ip_frag.err == 0);
203 fail_unless(lwip_stats.ip_frag.memerr == 0);
204 fail_unless(lwip_stats.ip_frag.drop == 0);
205 fail_unless(lwip_stats.mib2.ipreasmoks == 0);
208 fail_unless(lwip_stats.ip_frag.recv == 6);
209 fail_unless(lwip_stats.ip_frag.err == 0);
210 fail_unless(lwip_stats.ip_frag.memerr == 0);
211 fail_unless(lwip_stats.ip_frag.drop == 0);
212 fail_unless(lwip_stats.mib2.ipreasmoks == 0);
215 fail_unless(lwip_stats.ip_frag.recv == 7);
216 fail_unless(lwip_stats.ip_frag.err == 0);
217 fail_unless(lwip_stats.ip_frag.memerr == 0);
218 fail_unless(lwip_stats.ip_frag.drop == 0);
219 fail_unless(lwip_stats.mib2.ipreasmoks == 0);
222 fail_unless(lwip_stats.ip_frag.recv == 8);
223 fail_unless(lwip_stats.ip_frag.err == 0);
224 fail_unless(lwip_stats.ip_frag.memerr == 0);
225 fail_unless(lwip_stats.ip_frag.drop == 0);
226 fail_unless(lwip_stats.mib2.ipreasmoks == 0);
229 fail_unless(lwip_stats.ip_frag.recv == 9);
230 fail_unless(lwip_stats.ip_frag.err == 0);
231 fail_unless(lwip_stats.ip_frag.memerr == 0);
232 fail_unless(lwip_stats.ip_frag.drop == 0);
233 fail_unless(lwip_stats.mib2.ipreasmoks == 1);
265 fail_unless(ip4addr_aton(
"192.168.0.1", &ip_addr) == 1);
266 fail_unless(ip4addr_aton(
"192.168.0.0001", &ip_addr) == 1);
267 fail_unless(ip4addr_aton(
"192.168.0.zzz", &ip_addr) == 0);
268 fail_unless(ip4addr_aton(
"192.168.1", &ip_addr) == 1);
269 fail_unless(ip4addr_aton(
"192.168.0xd3", &ip_addr) == 1);
270 fail_unless(ip4addr_aton(
"192.168.0xz5", &ip_addr) == 0);
271 fail_unless(ip4addr_aton(
"192.168.095", &ip_addr) == 0);
279 const u8_t unknown_proto[] = {
280 0x45, 0x00, 0x00, 0x15, 0xd4, 0x31, 0x00, 0x00, 0xff, 0x22,
281 0x66, 0x41, 0xc0, 0xa8, 0x00, 0x02, 0xc0, 0xa8, 0x00, 0x01,
292 pbuf_take(
p, unknown_proto,
sizeof(unknown_proto));
305 const u8_t unknown_proto[] = {
306 0x45, 0x00, 0x00, 0x1f, 0xd4, 0x31, 0x00, 0x00, 0xff, 0x22,
307 0x66, 0x37, 0xc0, 0xa8, 0x00, 0x02, 0xc0, 0xa8, 0x00, 0x01,
308 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9,
312 const int unreach_len =
IP_HLEN + 8;
320 pbuf_take(
p, unknown_proto,
sizeof(unknown_proto));
338 TESTFUNC(test_ip4_icmp_replylen_short),
339 TESTFUNC(test_ip4_icmp_replylen_first_8),
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
#define LWIP_UNUSED_ARG(x)
#define NETIF_FLAG_LINK_UP
#define NETIF_FLAG_ETHARP
#define NETIF_FLAG_BROADCAST
void netif_set_down(struct netif *netif)
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)
u16_t pbuf_copy_partial(const struct pbuf *buf, void *dataptr, u16_t len, u16_t offset)
err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len)
u16_t inet_chksum(const void *dataptr, u16_t len)
#define ETHARP_HWADDR_LEN
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[]
static const BYTE localhost[]
struct netif * netif_list
struct netif * netif_default
#define IPH_VHL_SET(hdr, v, hl)
#define IPH_LEN_SET(hdr, len)
#define IPH_ID_SET(hdr, id)
#define IPH_PROTO_SET(hdr, proto)
#define IPH_OFFSET_SET(hdr, off)
#define IPH_TTL_SET(hdr, ttl)
#define IPH_CHKSUM_SET(hdr, chksum)
#define IPH_TOS_SET(hdr, tos)
netif_linkoutput_fn linkoutput
static ip4_addr_t test_netmask
static void ip4_setup(void)
static u16_t linkoutput_pkt_len
static ip4_addr_t test_gw
static err_t test_netif_linkoutput(struct netif *netif, struct pbuf *p)
static struct netif test_netif
static void test_netif_add(void)
static void create_ip4_input_fragment(u16_t ip_id, u16_t start, u16_t len, int last)
END_TEST Suite * ip4_suite(void)
static err_t arpless_output(struct netif *netif, struct pbuf *p, const ip4_addr_t *ipaddr)
static u8_t linkoutput_pkt[100]
static err_t test_netif_init(struct netif *netif)
static ip4_addr_t test_ipaddr
static void ip4_teardown(void)
static void test_netif_remove(void)
static int linkoutput_ctr
static int linkoutput_byte_ctr