238 |
static void |
static void |
239 |
do_newconn(struct api_msg_msg *msg) |
do_newconn(struct api_msg_msg *msg) |
240 |
{ |
{ |
241 |
|
if(msg->conn->pcb.tcp != NULL) { |
242 |
|
/* This "new" connection already has a PCB allocated. */ |
243 |
|
/* Is this an error condition? Should it be deleted? |
244 |
|
We currently just are happy and return. */ |
245 |
|
sys_mbox_post(msg->conn->mbox, NULL); |
246 |
|
return; |
247 |
|
} |
248 |
|
|
249 |
|
msg->conn->err = ERR_OK; |
250 |
|
|
251 |
|
/* Allocate a PCB for this connection */ |
252 |
|
switch(msg->conn->type) { |
253 |
|
#if LWIP_UDP |
254 |
|
case NETCONN_UDPLITE: |
255 |
|
msg->conn->pcb.udp = udp_new(); |
256 |
|
if(msg->conn->pcb.udp == NULL) { |
257 |
|
msg->conn->err = ERR_MEM; |
258 |
|
break; |
259 |
|
} |
260 |
|
udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE); |
261 |
|
udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); |
262 |
|
break; |
263 |
|
case NETCONN_UDPNOCHKSUM: |
264 |
|
msg->conn->pcb.udp = udp_new(); |
265 |
|
if(msg->conn->pcb.udp == NULL) { |
266 |
|
msg->conn->err = ERR_MEM; |
267 |
|
break; |
268 |
|
} |
269 |
|
udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM); |
270 |
|
udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); |
271 |
|
break; |
272 |
|
case NETCONN_UDP: |
273 |
|
msg->conn->pcb.udp = udp_new(); |
274 |
|
if(msg->conn->pcb.udp == NULL) { |
275 |
|
msg->conn->err = ERR_MEM; |
276 |
|
break; |
277 |
|
} |
278 |
|
udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); |
279 |
|
break; |
280 |
|
#endif /* LWIP_UDP */ |
281 |
|
#if LWIP_TCP |
282 |
|
case NETCONN_TCP: |
283 |
|
msg->conn->pcb.tcp = tcp_new(); |
284 |
|
if(msg->conn->pcb.tcp == NULL) { |
285 |
|
msg->conn->err = ERR_MEM; |
286 |
|
break; |
287 |
|
} |
288 |
|
setup_tcp(msg->conn); |
289 |
|
break; |
290 |
|
#endif |
291 |
|
} |
292 |
|
|
293 |
|
|
294 |
|
sys_mbox_post(msg->conn->mbox, NULL); |
295 |
} |
} |
296 |
|
|
297 |
/*-----------------------------------------------------------------------------------*/ |
/*-----------------------------------------------------------------------------------*/ |
298 |
static void |
static void |
299 |
do_delconn(struct api_msg_msg *msg) |
do_delconn(struct api_msg_msg *msg) |
626 |
segments when new outgoing data arrives from the user if any |
segments when new outgoing data arrives from the user if any |
627 |
previously transmitted data on the connection remains |
previously transmitted data on the connection remains |
628 |
unacknowledged. */ |
unacknowledged. */ |
629 |
if (err == ERR_OK && msg->conn->pcb.tcp->unacked == NULL) { |
if(err == ERR_OK && (msg->conn->pcb.tcp->unacked == NULL || (msg->conn->pcb.tcp->flags & TF_NODELAY)) ) { |
630 |
tcp_output(msg->conn->pcb.tcp); |
tcp_output(msg->conn->pcb.tcp); |
631 |
} |
} |
632 |
msg->conn->err = err; |
msg->conn->err = err; |