1 #include "test_pppos.h"
2
3 #include "lwip/netif.h"
4 #include "netif/ppp/pppos.h"
5 #include "netif/ppp/ppp.h"
6
7 #if PPP_SUPPORT && PPPOS_SUPPORT
8 static struct netif pppos_netif;
9 static ppp_pcb *ppp;
10
ppp_output_cb(ppp_pcb * pcb,const void * data,u32_t len,void * ctx)11 static u32_t ppp_output_cb(ppp_pcb *pcb, const void *data, u32_t len, void *ctx)
12 {
13 LWIP_UNUSED_ARG(pcb);
14 LWIP_UNUSED_ARG(data);
15 LWIP_UNUSED_ARG(len);
16 LWIP_UNUSED_ARG(ctx);
17
18 return 0;
19 }
20
ppp_link_status_cb(ppp_pcb * pcb,int err_code,void * ctx)21 static void ppp_link_status_cb(ppp_pcb *pcb, int err_code, void *ctx)
22 {
23 LWIP_UNUSED_ARG(pcb);
24 LWIP_UNUSED_ARG(err_code);
25 LWIP_UNUSED_ARG(ctx);
26 }
27
pppos_setup(void)28 static void pppos_setup(void)
29 {
30 ppp = pppos_create(&pppos_netif, ppp_output_cb, ppp_link_status_cb, NULL);
31 fail_if(ppp == NULL);
32 ppp_connect(ppp, 0);
33 }
34
pppos_teardown(void)35 static void pppos_teardown(void)
36 {
37 }
38
START_TEST(test_pppos_empty_packet_with_valid_fcs)39 START_TEST(test_pppos_empty_packet_with_valid_fcs)
40 {
41 u8_t two_breaks[] = { 0x7e, 0, 0, 0x7e };
42 u8_t other_packet[] = { 0x7e, 0x7d, 0x20, 0x00, 0x7e };
43 /* Set internal states of the underlying pcb */
44 pppos_pcb *pppos = (pppos_pcb *)ppp->link_ctx_cb;
45
46 LWIP_UNUSED_ARG(_i);
47
48 pppos->open = 1; /* Pretend the connection is open already */
49 pppos->in_accm[0] = 0xf0; /* Make sure 0x0's are not escaped chars */
50
51 pppos_input(ppp, two_breaks, sizeof(two_breaks));
52 pppos_input(ppp, other_packet, sizeof(other_packet));
53
54 }
55 END_TEST
56
57 /** Create the suite including all tests for this module */
58 Suite *
pppos_suite(void)59 pppos_suite(void)
60 {
61 testfunc tests[] = {
62 TESTFUNC(test_pppos_empty_packet_with_valid_fcs)
63 };
64 return create_suite("PPPOS", tests, sizeof(tests)/sizeof(testfunc), pppos_setup, pppos_teardown);
65 }
66
67 #endif /* PPP_SUPPORT && PPPOS_SUPPORT */
68