test_tcp: de-duplicate test IP addresses, netmask, and ports

This creates a single version of test IP addresses, netmasks, and ports.
All tests were using the same values, but duplicated in each test

This also adds const to some functions so we can use a const version
of addresses
This commit is contained in:
Joel Cunningham
2017-03-23 16:57:40 -05:00
parent 648b2b6f2b
commit 6fe66771cb
4 changed files with 43 additions and 98 deletions

View File

@@ -10,6 +10,10 @@
#error "This tests needs TCP- and MEMP-statistics enabled"
#endif
const ip_addr_t test_local_ip = IPADDR4_INIT_BYTES(192, 168, 1, 1);
const ip_addr_t test_remote_ip = IPADDR4_INIT_BYTES(192, 168, 1, 2);
const ip_addr_t test_netmask = IPADDR4_INIT_BYTES(255, 255, 255, 0);
/** Remove all pcbs on the given list. */
static void
tcp_remove(struct tcp_pcb* pcb_list)
@@ -138,8 +142,8 @@ struct pbuf* tcp_create_rx_segment_wnd(struct tcp_pcb* pcb, void* data, size_t d
/** Safely bring a tcp_pcb into the requested state */
void
tcp_set_state(struct tcp_pcb* pcb, enum tcp_state state, ip_addr_t* local_ip,
ip_addr_t* remote_ip, u16_t local_port, u16_t remote_port)
tcp_set_state(struct tcp_pcb* pcb, enum tcp_state state, const ip_addr_t* local_ip,
const ip_addr_t* remote_ip, u16_t local_port, u16_t remote_port)
{
u32_t iss;
@@ -292,7 +296,7 @@ static err_t test_tcp_netif_output(struct netif *netif, struct pbuf *p,
}
void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcounters,
ip_addr_t *ip_addr, ip_addr_t *netmask)
const ip_addr_t *ip_addr, const ip_addr_t *netmask)
{
struct netif *n;
memset(netif, 0, sizeof(struct netif));