Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers tcp_helper.h Source File

tcp_helper.h

00001 #ifndef LWIP_HDR_TCP_HELPER_H
00002 #define LWIP_HDR_TCP_HELPER_H
00003 
00004 #include "../lwip_check.h"
00005 #include "lwip/arch.h"
00006 #include "lwip/tcp.h"
00007 #include "lwip/netif.h"
00008 
00009 /* counters used for test_tcp_counters_* callback functions */
00010 struct test_tcp_counters {
00011   u32_t recv_calls;
00012   u32_t recved_bytes;
00013   u32_t recv_calls_after_close;
00014   u32_t recved_bytes_after_close;
00015   u32_t close_calls;
00016   u32_t err_calls;
00017   err_t last_err;
00018   char* expected_data;
00019   u32_t expected_data_len;
00020 };
00021 
00022 struct test_tcp_txcounters {
00023   u32_t num_tx_calls;
00024   u32_t num_tx_bytes;
00025   u8_t  copy_tx_packets;
00026   struct pbuf *tx_packets;
00027 };
00028 
00029 extern const ip_addr_t test_local_ip;
00030 extern const ip_addr_t test_remote_ip;
00031 extern const ip_addr_t test_netmask;
00032 #define TEST_REMOTE_PORT    0x100
00033 #define TEST_LOCAL_PORT     0x101
00034 
00035 /* Helper functions */
00036 void tcp_remove_all(void);
00037 
00038 struct pbuf* tcp_create_segment(ip_addr_t* src_ip, ip_addr_t* dst_ip,
00039                    u16_t src_port, u16_t dst_port, void* data, size_t data_len,
00040                    u32_t seqno, u32_t ackno, u8_t headerflags);
00041 struct pbuf* tcp_create_rx_segment(struct tcp_pcb* pcb, void* data, size_t data_len,
00042                    u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags);
00043 struct pbuf* tcp_create_rx_segment_wnd(struct tcp_pcb* pcb, void* data, size_t data_len,
00044                    u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags, u16_t wnd);
00045 void tcp_set_state(struct tcp_pcb* pcb, enum tcp_state state, const ip_addr_t* local_ip,
00046                    const ip_addr_t* remote_ip, u16_t local_port, u16_t remote_port);
00047 void test_tcp_counters_err(void* arg, err_t err);
00048 err_t test_tcp_counters_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err);
00049 
00050 struct tcp_pcb* test_tcp_new_counters_pcb(struct test_tcp_counters* counters);
00051 
00052 void test_tcp_input(struct pbuf *p, struct netif *inp);
00053 
00054 void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcounters,
00055                          const ip_addr_t *ip_addr, const ip_addr_t *netmask);
00056 
00057 
00058 #endif