test_pppos.c 1.6 KB

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