altcp_tcp: some fixes

- expose `altcp_tcp_setup()` so we can wrap altcp over existing tcp pcb.
- avoid calling tcp_close() with NULL pcb.
- free altcp_pcb struct when error callback called.

According to `mqtt_tcp_err_cb()` in src/apps/mqtt/mqtt.c, altcp socket should
work the same way than raw tcp socket. So freeing altcp_pcb ensure this.
This commit is contained in:
David Girault
2017-08-07 15:43:58 +02:00
committed by goldsimon
parent 9d120c59ea
commit ee89d906ec
2 changed files with 27 additions and 6 deletions

View File

@@ -53,6 +53,10 @@
extern "C" {
#endif
/* setup a newly allocated altcp_pcb with existing tcp_pcb */
struct tcp_pcb;
void altcp_tcp_setup(struct altcp_pcb *conn, struct tcp_pcb *tpcb);
struct altcp_pcb *altcp_tcp_new_ip_type(u8_t ip_type);
#define altcp_tcp_new() altcp_tcp_new_ip_type(IPADDR_TYPE_V4)