tcp_helper.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef LWIP_HDR_TCP_HELPER_H
  2. #define LWIP_HDR_TCP_HELPER_H
  3. #include "../lwip_check.h"
  4. #include "lwip/arch.h"
  5. #include "lwip/tcp.h"
  6. #include "lwip/netif.h"
  7. /* counters used for test_tcp_counters_* callback functions */
  8. struct test_tcp_counters {
  9. u32_t recv_calls;
  10. u32_t recved_bytes;
  11. u32_t recv_calls_after_close;
  12. u32_t recved_bytes_after_close;
  13. u32_t close_calls;
  14. u32_t err_calls;
  15. err_t last_err;
  16. char* expected_data;
  17. u32_t expected_data_len;
  18. };
  19. struct test_tcp_txcounters {
  20. u32_t num_tx_calls;
  21. u32_t num_tx_bytes;
  22. u8_t copy_tx_packets;
  23. struct pbuf *tx_packets;
  24. };
  25. /* Helper functions */
  26. void tcp_remove_all(void);
  27. struct pbuf* tcp_create_segment(ip_addr_t* src_ip, ip_addr_t* dst_ip,
  28. u16_t src_port, u16_t dst_port, void* data, size_t data_len,
  29. u32_t seqno, u32_t ackno, u8_t headerflags);
  30. struct pbuf* tcp_create_rx_segment(struct tcp_pcb* pcb, void* data, size_t data_len,
  31. u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags);
  32. struct pbuf* tcp_create_rx_segment_wnd(struct tcp_pcb* pcb, void* data, size_t data_len,
  33. u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags, u16_t wnd);
  34. void tcp_set_state(struct tcp_pcb* pcb, enum tcp_state state, ip_addr_t* local_ip,
  35. ip_addr_t* remote_ip, u16_t local_port, u16_t remote_port);
  36. void test_tcp_counters_err(void* arg, err_t err);
  37. err_t test_tcp_counters_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err);
  38. struct tcp_pcb* test_tcp_new_counters_pcb(struct test_tcp_counters* counters);
  39. void test_tcp_input(struct pbuf *p, struct netif *inp);
  40. void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcounters,
  41. ip_addr_t *ip_addr, ip_addr_t *netmask);
  42. #endif