/[lwip]/lwip/src/api/api_msg.c
ViewVC logotype

Diff of /lwip/src/api/api_msg.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by likewise, Thu May 1 13:24:01 2003 UTC revision 1.14 by likewise, Mon Jun 9 21:14:47 2003 UTC
# Line 40  Line 40 
40  #if LWIP_UDP  #if LWIP_UDP
41  static void  static void
42  recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,  recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
43           struct ip_addr *addr, u16_t port)     struct ip_addr *addr, u16_t port)
44  {  {
45    struct netbuf *buf;    struct netbuf *buf;
46    struct netconn *conn;    struct netconn *conn;
# Line 63  recv_udp(void *arg, struct udp_pcb *pcb, Line 63  recv_udp(void *arg, struct udp_pcb *pcb,
63        buf->fromport = port;        buf->fromport = port;
64      }      }
65    
66          conn->recv_avail += p->tot_len;    conn->recv_avail += p->tot_len;
67      /* Register event with callback */      /* Register event with callback */
68      if (conn->callback)      if (conn->callback)
69          (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, p->tot_len);          (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, p->tot_len);
# Line 87  recv_tcp(void *arg, struct tcp_pcb *pcb, Line 87  recv_tcp(void *arg, struct tcp_pcb *pcb,
87    }    }
88    
89    if (conn->recvmbox != SYS_MBOX_NULL) {    if (conn->recvmbox != SYS_MBOX_NULL) {
90                      
91      conn->err = err;      conn->err = err;
92      if (p != NULL) {      if (p != NULL) {
93          len = p->tot_len;          len = p->tot_len;
# Line 258  do_delconn(struct api_msg_msg *msg) Line 258  do_delconn(struct api_msg_msg *msg)
258  #if LWIP_TCP        #if LWIP_TCP      
259      case NETCONN_TCP:      case NETCONN_TCP:
260        if (msg->conn->pcb.tcp->state == LISTEN) {        if (msg->conn->pcb.tcp->state == LISTEN) {
261          tcp_arg(msg->conn->pcb.tcp, NULL);    tcp_arg(msg->conn->pcb.tcp, NULL);
262          tcp_accept(msg->conn->pcb.tcp, NULL);      tcp_accept(msg->conn->pcb.tcp, NULL);  
263          tcp_close(msg->conn->pcb.tcp);    tcp_close(msg->conn->pcb.tcp);
264        } else {        } else {
265          tcp_arg(msg->conn->pcb.tcp, NULL);    tcp_arg(msg->conn->pcb.tcp, NULL);
266          tcp_sent(msg->conn->pcb.tcp, NULL);    tcp_sent(msg->conn->pcb.tcp, NULL);
267          tcp_recv(msg->conn->pcb.tcp, NULL);        tcp_recv(msg->conn->pcb.tcp, NULL);  
268          tcp_poll(msg->conn->pcb.tcp, NULL, 0);    tcp_poll(msg->conn->pcb.tcp, NULL, 0);
269          tcp_err(msg->conn->pcb.tcp, NULL);    tcp_err(msg->conn->pcb.tcp, NULL);
270          if (tcp_close(msg->conn->pcb.tcp) != ERR_OK) {    if (tcp_close(msg->conn->pcb.tcp) != ERR_OK) {
271            tcp_abort(msg->conn->pcb.tcp);      tcp_abort(msg->conn->pcb.tcp);
272          }    }
273        }        }
274  #endif  #endif
275      default:        default:  
# Line 331  do_bind(struct api_msg_msg *msg) Line 331  do_bind(struct api_msg_msg *msg)
331  #if LWIP_TCP  #if LWIP_TCP
332    case NETCONN_TCP:    case NETCONN_TCP:
333      msg->conn->err = tcp_bind(msg->conn->pcb.tcp,      msg->conn->err = tcp_bind(msg->conn->pcb.tcp,
334                                msg->msg.bc.ipaddr, msg->msg.bc.port);              msg->msg.bc.ipaddr, msg->msg.bc.port);
335  #endif /* LWIP_TCP */  #endif /* LWIP_TCP */
336    default:    default:
337      break;      break;
# Line 369  do_connect(struct api_msg_msg *msg) Line 369  do_connect(struct api_msg_msg *msg)
369      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
370        msg->conn->pcb.udp = udp_new();        msg->conn->pcb.udp = udp_new();
371        if (msg->conn->pcb.udp == NULL) {        if (msg->conn->pcb.udp == NULL) {
372          msg->conn->err = ERR_MEM;    msg->conn->err = ERR_MEM;
373          sys_mbox_post(msg->conn->mbox, NULL);    sys_mbox_post(msg->conn->mbox, NULL);
374          return;    return;
375        }        }
376        udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE);        udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE);
377        udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);        udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
# Line 379  do_connect(struct api_msg_msg *msg) Line 379  do_connect(struct api_msg_msg *msg)
379      case NETCONN_UDPNOCHKSUM:      case NETCONN_UDPNOCHKSUM:
380        msg->conn->pcb.udp = udp_new();        msg->conn->pcb.udp = udp_new();
381        if (msg->conn->pcb.udp == NULL) {        if (msg->conn->pcb.udp == NULL) {
382          msg->conn->err = ERR_MEM;    msg->conn->err = ERR_MEM;
383          sys_mbox_post(msg->conn->mbox, NULL);    sys_mbox_post(msg->conn->mbox, NULL);
384          return;    return;
385        }        }
386        udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM);        udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM);
387        udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);        udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
# Line 389  do_connect(struct api_msg_msg *msg) Line 389  do_connect(struct api_msg_msg *msg)
389      case NETCONN_UDP:      case NETCONN_UDP:
390        msg->conn->pcb.udp = udp_new();        msg->conn->pcb.udp = udp_new();
391        if (msg->conn->pcb.udp == NULL) {        if (msg->conn->pcb.udp == NULL) {
392          msg->conn->err = ERR_MEM;    msg->conn->err = ERR_MEM;
393          sys_mbox_post(msg->conn->mbox, NULL);    sys_mbox_post(msg->conn->mbox, NULL);
394          return;    return;
395        }        }
396        udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);        udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
397        break;        break;
# Line 400  do_connect(struct api_msg_msg *msg) Line 400  do_connect(struct api_msg_msg *msg)
400      case NETCONN_TCP:      case NETCONN_TCP:
401        msg->conn->pcb.tcp = tcp_new();              msg->conn->pcb.tcp = tcp_new();      
402        if (msg->conn->pcb.tcp == NULL) {        if (msg->conn->pcb.tcp == NULL) {
403          msg->conn->err = ERR_MEM;    msg->conn->err = ERR_MEM;
404          sys_mbox_post(msg->conn->mbox, NULL);    sys_mbox_post(msg->conn->mbox, NULL);
405          return;    return;
406        }        }
407  #endif  #endif
408      default:      default:
# Line 425  do_connect(struct api_msg_msg *msg) Line 425  do_connect(struct api_msg_msg *msg)
425      /*    tcp_arg(msg->conn->pcb.tcp, msg->conn);*/      /*    tcp_arg(msg->conn->pcb.tcp, msg->conn);*/
426      setup_tcp(msg->conn);      setup_tcp(msg->conn);
427      tcp_connect(msg->conn->pcb.tcp, msg->msg.bc.ipaddr, msg->msg.bc.port,      tcp_connect(msg->conn->pcb.tcp, msg->msg.bc.ipaddr, msg->msg.bc.port,
428                  do_connected);      do_connected);
429      /*tcp_output(msg->conn->pcb.tcp);*/      /*tcp_output(msg->conn->pcb.tcp);*/
430  #endif  #endif
431    default:    default:
# Line 472  do_listen(struct api_msg_msg *msg) Line 472  do_listen(struct api_msg_msg *msg)
472      case NETCONN_TCP:      case NETCONN_TCP:
473        msg->conn->pcb.tcp = tcp_listen(msg->conn->pcb.tcp);        msg->conn->pcb.tcp = tcp_listen(msg->conn->pcb.tcp);
474        if (msg->conn->pcb.tcp == NULL) {        if (msg->conn->pcb.tcp == NULL) {
475          msg->conn->err = ERR_MEM;    msg->conn->err = ERR_MEM;
476        } else {        } else {
477          if (msg->conn->acceptmbox == SYS_MBOX_NULL) {    if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
478            msg->conn->acceptmbox = sys_mbox_new();      msg->conn->acceptmbox = sys_mbox_new();
479            if (msg->conn->acceptmbox == SYS_MBOX_NULL) {      if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
480              msg->conn->err = ERR_MEM;        msg->conn->err = ERR_MEM;
481              break;        break;
482            }      }
483          }    }
484          tcp_arg(msg->conn->pcb.tcp, msg->conn);    tcp_arg(msg->conn->pcb.tcp, msg->conn);
485          tcp_accept(msg->conn->pcb.tcp, accept_function);    tcp_accept(msg->conn->pcb.tcp, accept_function);
486        }        }
487  #endif  #endif
488      default:      default:
# Line 549  do_recv(struct api_msg_msg *msg) Line 549  do_recv(struct api_msg_msg *msg)
549  static void  static void
550  do_write(struct api_msg_msg *msg)  do_write(struct api_msg_msg *msg)
551  {  {
552  #if LWIP_TCP      #if LWIP_TCP  
553    err_t err;    err_t err;
554  #endif    #endif  
555    if (msg->conn->pcb.tcp != NULL) {    if (msg->conn->pcb.tcp != NULL) {
# Line 568  do_write(struct api_msg_msg *msg) Line 568  do_write(struct api_msg_msg *msg)
568        err = tcp_write(msg->conn->pcb.tcp, msg->msg.w.dataptr,        err = tcp_write(msg->conn->pcb.tcp, msg->msg.w.dataptr,
569                        msg->msg.w.len, msg->msg.w.copy);                        msg->msg.w.len, msg->msg.w.copy);
570        /* This is the Nagle algorithm: inhibit the sending of new TCP        /* This is the Nagle algorithm: inhibit the sending of new TCP
571           segments when new outgoing data arrives from the user if any     segments when new outgoing data arrives from the user if any
572           previously transmitted data on the connection remains     previously transmitted data on the connection remains
573           unacknowledged. */     unacknowledged. */
574        if (err == ERR_OK && msg->conn->pcb.tcp->unacked == NULL) {        if (err == ERR_OK && msg->conn->pcb.tcp->unacked == NULL) {
575          tcp_output(msg->conn->pcb.tcp);    tcp_output(msg->conn->pcb.tcp);
576        }        }
577        msg->conn->err = err;        msg->conn->err = err;
578        if (msg->conn->callback)        if (msg->conn->callback)
# Line 609  do_close(struct api_msg_msg *msg) Line 609  do_close(struct api_msg_msg *msg)
609  #if LWIP_TCP  #if LWIP_TCP
610      case NETCONN_TCP:      case NETCONN_TCP:
611        if (msg->conn->pcb.tcp->state == LISTEN) {        if (msg->conn->pcb.tcp->state == LISTEN) {
612          err = tcp_close(msg->conn->pcb.tcp);    err = tcp_close(msg->conn->pcb.tcp);
613        }        }
614        msg->conn->err = err;              msg->conn->err = err;      
615  #endif  #endif

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26