Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

api_msg.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
00003  * All rights reserved. 
00004  * 
00005  * Redistribution and use in source and binary forms, with or without modification, 
00006  * are permitted provided that the following conditions are met:
00007  *
00008  * 1. Redistributions of source code must retain the above copyright notice,
00009  *    this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright notice,
00011  *    this list of conditions and the following disclaimer in the documentation
00012  *    and/or other materials provided with the distribution.
00013  * 3. The name of the author may not be used to endorse or promote products
00014  *    derived from this software without specific prior written permission. 
00015  *
00016  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
00017  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00018  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
00019  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00020  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
00021  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
00024  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
00025  * OF SUCH DAMAGE.
00026  *
00027  * This file is part of the lwIP TCP/IP stack.
00028  * 
00029  * Author: Adam Dunkels <adam@sics.se>
00030  *
00031  * CHANGELOG: this file has been modified by Sergio Perez Alcañiz <serpeal@disca.upv.es> 
00032  *            Departamento de Informática de Sistemas y Computadores          
00033  *            Universidad Politécnica de Valencia                             
00034  *            Valencia (Spain)    
00035  *            Date: April 2003                                          
00036  *  
00037  */
00038 
00039 #include "lwip/opt.h"
00040 #include "lwip/arch.h"
00041 #include "lwip/api_msg.h"
00042 #include "lwip/memp.h"
00043 #include "lwip/sys.h"
00044 #include "lwip/tcpip.h"
00045 
00046 #if LWIP_UDP
00047 static void
00048 recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
00049          struct ip_addr *addr, u16_t port)
00050 {
00051   struct netbuf *buf;
00052   struct netconn *conn;
00053 
00054   conn = arg;
00055   
00056   if(conn == NULL) {
00057     pbuf_free(p);
00058     return;
00059   }
00060   if(conn->recvmbox != SYS_MBOX_NULL) {
00061     buf = memp_mallocp(MEMP_NETBUF);
00062     if(buf == NULL) {
00063       pbuf_free(p);
00064       return;
00065     } else {
00066       buf->p = p;
00067       buf->ptr = p;
00068       buf->fromaddr = addr;
00069       buf->fromport = port;
00070     }
00071 
00072         conn->recv_avail += p->tot_len;
00073     /* Register event with callback */
00074     if (conn->callback)
00075         (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, p->tot_len);
00076     sys_mbox_post(conn->recvmbox, buf);
00077   }
00078 }
00079 #endif /* LWIP_UDP */
00080 #if LWIP_TCP
00081 /*-----------------------------------------------------------------------------------*/
00082 static err_t
00083 recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
00084 {
00085   struct netconn *conn;
00086   u16_t len;
00087   
00088   conn = arg;
00089 
00090   if(conn == NULL) {
00091     pbuf_free(p);
00092     return ERR_VAL;
00093   }
00094 
00095   if(conn->recvmbox != SYS_MBOX_NULL) {
00096           
00097     conn->err = err;
00098     if (p != NULL) {
00099         len = p->tot_len;
00100         conn->recv_avail += len;
00101     }
00102     else
00103         len = 0;
00104     /* Register event with callback */
00105     if (conn->callback)
00106         (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, len);
00107     sys_mbox_post(conn->recvmbox, p);
00108   }  
00109   return ERR_OK;
00110 }
00111 
00112 /*-----------------------------------------------------------------------------------*/
00113 static err_t
00114 poll_tcp(void *arg, struct tcp_pcb *pcb)
00115 {
00116   struct netconn *conn;
00117 
00118   conn = arg;
00119   if(conn != NULL &&
00120      (conn->state == NETCONN_WRITE || conn->state == NETCONN_CLOSE) &&
00121      conn->sem != SYS_SEM_NULL) {
00122     sys_sem_signal(conn->sem);
00123   }
00124   return ERR_OK;
00125 }
00126 /*-----------------------------------------------------------------------------------*/
00127 static err_t
00128 sent_tcp(void *arg, struct tcp_pcb *pcb, u16_t len)
00129 {
00130   struct netconn *conn;
00131 
00132   conn = arg;
00133   if(conn != NULL && conn->sem != SYS_SEM_NULL) {
00134     sys_sem_signal(conn->sem);
00135   }
00136 
00137   if (conn && conn->callback)
00138       if (tcp_sndbuf(conn->pcb.tcp) > TCP_SNDLOWAT)
00139           (*conn->callback)(conn, NETCONN_EVT_SENDPLUS, len);
00140   
00141   return ERR_OK;
00142 }
00143 /*-----------------------------------------------------------------------------------*/
00144 static void
00145 err_tcp(void *arg, err_t err)
00146 {
00147   struct netconn *conn;
00148 
00149   conn = arg;
00150 
00151   conn->pcb.tcp = NULL;
00152 
00153   
00154   conn->err = err;
00155   if(conn->recvmbox != SYS_MBOX_NULL) {
00156     /* Register event with callback */
00157     if (conn->callback)
00158       (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, 0);
00159     sys_mbox_post(conn->recvmbox, NULL);
00160   }
00161   if(conn->mbox != SYS_MBOX_NULL) {
00162     sys_mbox_post(conn->mbox, NULL);
00163   }
00164   if(conn->acceptmbox != SYS_MBOX_NULL) {
00165      /* Register event with callback */
00166     if (conn->callback)
00167       (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, 0);
00168     sys_mbox_post(conn->acceptmbox, NULL);
00169   }
00170   if(conn->sem != SYS_SEM_NULL) {
00171     sys_sem_signal(conn->sem);
00172   }
00173 }
00174 /*-----------------------------------------------------------------------------------*/
00175 static void
00176 setup_tcp(struct netconn *conn)
00177 {
00178   struct tcp_pcb *pcb;
00179   
00180   pcb = conn->pcb.tcp;
00181   tcp_arg(pcb, conn);
00182   tcp_recv(pcb, recv_tcp);
00183   tcp_sent(pcb, sent_tcp);
00184   tcp_poll(pcb, poll_tcp, 4);
00185   tcp_err(pcb, err_tcp);
00186 }
00187 /*-----------------------------------------------------------------------------------*/
00188 static err_t
00189 accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
00190 {
00191   sys_mbox_t mbox;
00192   struct netconn *newconn;
00193   struct netconn *conn;
00194   
00195 #if API_MSG_DEBUG
00196 #if TCP_DEBUG
00197   tcp_debug_print_state(newpcb->state);
00198 #endif /* TCP_DEBUG */
00199 #endif /* API_MSG_DEBUG */
00200   conn = (struct netconn *)arg;
00201   mbox = conn->acceptmbox;
00202   newconn = memp_mallocp(MEMP_NETCONN);
00203   if(newconn == NULL) {
00204     return ERR_MEM;
00205   }
00206   newconn->type = NETCONN_TCP;
00207   newconn->pcb.tcp = newpcb;
00208   setup_tcp(newconn);
00209   newconn->recvmbox = sys_mbox_new();
00210   if(newconn->recvmbox == SYS_MBOX_NULL) {
00211     memp_free(MEMP_NETCONN, newconn);
00212     return ERR_MEM;
00213   }
00214   newconn->mbox = sys_mbox_new();
00215   if(newconn->mbox == SYS_MBOX_NULL) {
00216     sys_mbox_free(newconn->recvmbox);
00217     memp_free(MEMP_NETCONN, newconn);
00218     return ERR_MEM;
00219   }
00220   newconn->sem = sys_sem_new(0);
00221   if(newconn->sem == SYS_SEM_NULL) {
00222     sys_mbox_free(newconn->recvmbox);
00223     sys_mbox_free(newconn->mbox);
00224     memp_free(MEMP_NETCONN, newconn);
00225     return ERR_MEM;
00226   }
00227   newconn->acceptmbox = SYS_MBOX_NULL;
00228   newconn->err = err;
00229   /* Register event with callback */
00230   if (conn->callback)
00231   {
00232     (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, 0);
00233     /* We have to set the callback here even though
00234      * the new socket is unknown. Mark the socket as -1. */
00235     newconn->callback = conn->callback;
00236     newconn->socket = -1;
00237   }
00238   
00239   sys_mbox_post(mbox, newconn);
00240   return ERR_OK;
00241 }
00242 #endif /* LWIP_TCP */
00243 /*-----------------------------------------------------------------------------------*/
00244 static void
00245 do_newconn(struct api_msg_msg *msg)
00246 {
00247 }
00248 /*-----------------------------------------------------------------------------------*/
00249 static void
00250 do_delconn(struct api_msg_msg *msg)
00251 {
00252   if(msg->conn->pcb.tcp != NULL) {
00253     switch(msg->conn->type) {
00254 #if LWIP_UDP
00255     case NETCONN_UDPLITE:
00256       /* FALLTHROUGH */
00257     case NETCONN_UDPNOCHKSUM:
00258       /* FALLTHROUGH */
00259     case NETCONN_UDP:
00260       msg->conn->pcb.udp->recv_arg = NULL;
00261       udp_remove(msg->conn->pcb.udp);
00262       break;
00263 #endif /* LWIP_UDP */
00264 #if LWIP_TCP      
00265     case NETCONN_TCP:
00266       if(msg->conn->pcb.tcp->state == LISTEN) {
00267         tcp_arg(msg->conn->pcb.tcp, NULL);
00268         tcp_accept(msg->conn->pcb.tcp, NULL);   
00269         tcp_close(msg->conn->pcb.tcp);
00270       } else {
00271         tcp_arg(msg->conn->pcb.tcp, NULL);
00272         tcp_sent(msg->conn->pcb.tcp, NULL);
00273         tcp_recv(msg->conn->pcb.tcp, NULL);     
00274         tcp_poll(msg->conn->pcb.tcp, NULL, 0);
00275         tcp_err(msg->conn->pcb.tcp, NULL);
00276         if(tcp_close(msg->conn->pcb.tcp) != ERR_OK) {
00277           tcp_abort(msg->conn->pcb.tcp);
00278         }
00279       }
00280 #endif
00281     default:  
00282     break;
00283     }
00284   }
00285   /* Trigger select() in socket layer */
00286   if (msg->conn->callback)
00287   {
00288       (*msg->conn->callback)(msg->conn, NETCONN_EVT_RCVPLUS, 0);
00289       (*msg->conn->callback)(msg->conn, NETCONN_EVT_SENDPLUS, 0);
00290   }
00291   
00292   if(msg->conn->mbox != SYS_MBOX_NULL) {
00293     sys_mbox_post(msg->conn->mbox, NULL);
00294   }
00295 }
00296 /*-----------------------------------------------------------------------------------*/
00297 static void
00298 do_bind(struct api_msg_msg *msg)
00299 {
00300   if(msg->conn->pcb.tcp == NULL) {
00301     switch(msg->conn->type) {
00302 #if LWIP_UDP
00303     case NETCONN_UDPLITE:
00304       msg->conn->pcb.udp = udp_new();
00305       udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE);
00306       udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
00307       break;
00308     case NETCONN_UDPNOCHKSUM:
00309       msg->conn->pcb.udp = udp_new();
00310       udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM);
00311       udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
00312       break;
00313     case NETCONN_UDP:
00314       msg->conn->pcb.udp = udp_new();
00315       udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
00316       break;
00317 #endif /* LWIP_UDP */
00318 #if LWIP_TCP      
00319     case NETCONN_TCP:
00320       msg->conn->pcb.tcp = tcp_new();
00321       setup_tcp(msg->conn);
00322 #endif /* LWIP_TCP */
00323     default:  
00324     break;
00325     }
00326   }
00327   switch(msg->conn->type) {
00328 #if LWIP_UDP
00329   case NETCONN_UDPLITE:
00330     /* FALLTHROUGH */
00331   case NETCONN_UDPNOCHKSUM:
00332     /* FALLTHROUGH */
00333   case NETCONN_UDP:
00334     msg->conn->err = udp_bind(msg->conn->pcb.udp, msg->msg.bc.ipaddr, msg->msg.bc.port);
00335     break;
00336 #endif /* LWIP_UDP */
00337 #if LWIP_TCP
00338   case NETCONN_TCP:
00339     msg->conn->err = tcp_bind(msg->conn->pcb.tcp,
00340                               msg->msg.bc.ipaddr, msg->msg.bc.port);
00341 #endif /* LWIP_TCP */
00342   default:
00343     break;
00344   }
00345   sys_mbox_post(msg->conn->mbox, NULL);
00346 }
00347 #if LWIP_TCP
00348 /*-----------------------------------------------------------------------------------*/
00349 static err_t
00350 do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
00351 {
00352   struct netconn *conn;
00353 
00354   conn = arg;
00355 
00356   if(conn == NULL) {
00357     return ERR_VAL;
00358   }
00359   
00360   conn->err = err;
00361   if(conn->type == NETCONN_TCP && err == ERR_OK) {
00362     setup_tcp(conn);
00363   }    
00364   sys_mbox_post(conn->mbox, NULL);
00365   return ERR_OK;
00366 }
00367 #endif  
00368 /*-----------------------------------------------------------------------------------*/
00369 static void
00370 do_connect(struct api_msg_msg *msg)
00371 {
00372   if(msg->conn->pcb.tcp == NULL) {
00373     switch(msg->conn->type) {
00374 #if LWIP_UDP
00375     case NETCONN_UDPLITE:
00376       msg->conn->pcb.udp = udp_new();
00377       if(msg->conn->pcb.udp == NULL) {
00378         msg->conn->err = ERR_MEM;
00379         sys_mbox_post(msg->conn->mbox, NULL);
00380         return;
00381       }
00382       udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE);
00383       udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
00384       break;
00385     case NETCONN_UDPNOCHKSUM:
00386       msg->conn->pcb.udp = udp_new();
00387       if(msg->conn->pcb.udp == NULL) {
00388         msg->conn->err = ERR_MEM;
00389         sys_mbox_post(msg->conn->mbox, NULL);
00390         return;
00391       }
00392       udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM);
00393       udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
00394       break;
00395     case NETCONN_UDP:
00396       msg->conn->pcb.udp = udp_new();
00397       if(msg->conn->pcb.udp == NULL) {
00398         msg->conn->err = ERR_MEM;
00399         sys_mbox_post(msg->conn->mbox, NULL);
00400         return;
00401       }
00402       udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
00403       break;
00404 #endif /* LWIP_UDP */
00405 #if LWIP_TCP      
00406     case NETCONN_TCP:
00407       msg->conn->pcb.tcp = tcp_new();      
00408       if(msg->conn->pcb.tcp == NULL) {
00409         msg->conn->err = ERR_MEM;
00410         sys_mbox_post(msg->conn->mbox, NULL);
00411         return;
00412       }
00413 #endif
00414     default:
00415       break;
00416     }
00417   }
00418   switch(msg->conn->type) {
00419 #if LWIP_UDP
00420   case NETCONN_UDPLITE:
00421     /* FALLTHROUGH */
00422   case NETCONN_UDPNOCHKSUM:
00423     /* FALLTHROUGH */
00424   case NETCONN_UDP:
00425     udp_connect(msg->conn->pcb.udp, msg->msg.bc.ipaddr, msg->msg.bc.port);
00426     sys_mbox_post(msg->conn->mbox, NULL);
00427     break;
00428 #endif 
00429 #if LWIP_TCP      
00430   case NETCONN_TCP:
00431     /*    tcp_arg(msg->conn->pcb.tcp, msg->conn);*/
00432     setup_tcp(msg->conn);
00433     tcp_connect(msg->conn->pcb.tcp, msg->msg.bc.ipaddr, msg->msg.bc.port,
00434                 do_connected);
00435     /*tcp_output(msg->conn->pcb.tcp);*/
00436 #endif
00437   default:
00438     break;
00439   }
00440 }
00441 
00442 static void
00443 do_disconnect(struct api_msg_msg *msg)
00444 {
00445 
00446   switch(msg->conn->type) {
00447 #if LWIP_UDP
00448   case NETCONN_UDPLITE:
00449     /* FALLTHROUGH */
00450   case NETCONN_UDPNOCHKSUM:
00451     /* FALLTHROUGH */
00452   case NETCONN_UDP:
00453     udp_disconnect(msg->conn->pcb.udp);
00454     break;
00455 #endif 
00456   case NETCONN_TCP:
00457     break;
00458   }
00459   sys_mbox_post(msg->conn->mbox, NULL);
00460 }
00461 
00462 /*-----------------------------------------------------------------------------------*/
00463 static void
00464 do_listen(struct api_msg_msg *msg)
00465 {
00466   if(msg->conn->pcb.tcp != NULL) {
00467     switch(msg->conn->type) {
00468 #if LWIP_UDP
00469     case NETCONN_UDPLITE:
00470       /* FALLTHROUGH */
00471     case NETCONN_UDPNOCHKSUM:
00472       /* FALLTHROUGH */
00473     case NETCONN_UDP:
00474       DEBUGF(API_MSG_DEBUG, ("api_msg: listen UDP: cannot listen for UDP.\n"));
00475       break;
00476 #endif /* LWIP_UDP */
00477 #if LWIP_TCP      
00478     case NETCONN_TCP:
00479       msg->conn->pcb.tcp = tcp_listen(msg->conn->pcb.tcp);
00480       if(msg->conn->pcb.tcp == NULL) {
00481         msg->conn->err = ERR_MEM;
00482       } else {
00483         if(msg->conn->acceptmbox == SYS_MBOX_NULL) {
00484           msg->conn->acceptmbox = sys_mbox_new();
00485           if(msg->conn->acceptmbox == SYS_MBOX_NULL) {
00486             msg->conn->err = ERR_MEM;
00487             break;
00488           }
00489         }
00490         tcp_arg(msg->conn->pcb.tcp, msg->conn);
00491         tcp_accept(msg->conn->pcb.tcp, accept_function);
00492       }
00493 #endif
00494     default:
00495       break;
00496     }
00497   }
00498   sys_mbox_post(msg->conn->mbox, NULL);
00499 }
00500 /*-----------------------------------------------------------------------------------*/
00501 static void
00502 do_accept(struct api_msg_msg *msg)
00503 {
00504   if(msg->conn->pcb.tcp != NULL) {
00505     switch(msg->conn->type) {
00506 #if LWIP_UDP
00507     case NETCONN_UDPLITE:
00508       /* FALLTHROUGH */
00509     case NETCONN_UDPNOCHKSUM:
00510       /* FALLTHROUGH */
00511     case NETCONN_UDP:    
00512       DEBUGF(API_MSG_DEBUG, ("api_msg: accept UDP: cannot accept for UDP.\n"));
00513       break;
00514 #endif /* LWIP_UDP */
00515     case NETCONN_TCP:
00516       break;
00517     }
00518   }
00519 }
00520 /*-----------------------------------------------------------------------------------*/
00521 static void
00522 do_send(struct api_msg_msg *msg)
00523 {
00524   if(msg->conn->pcb.tcp != NULL) {
00525     switch(msg->conn->type) {
00526 #if LWIP_UDP
00527     case NETCONN_UDPLITE:
00528       /* FALLTHROUGH */
00529     case NETCONN_UDPNOCHKSUM:
00530       /* FALLTHROUGH */
00531     case NETCONN_UDP:
00532       udp_send(msg->conn->pcb.udp, msg->msg.p);
00533       break;
00534 #endif /* LWIP_UDP */
00535     case NETCONN_TCP:
00536       break;
00537     }
00538   }
00539   sys_mbox_post(msg->conn->mbox, NULL);
00540 }
00541 /*-----------------------------------------------------------------------------------*/
00542 static void
00543 do_recv(struct api_msg_msg *msg)
00544 {
00545 #if LWIP_TCP
00546   if(msg->conn->pcb.tcp != NULL) {
00547     if(msg->conn->type == NETCONN_TCP) {
00548       tcp_recved(msg->conn->pcb.tcp, msg->msg.len);
00549     }
00550   }
00551 #endif  
00552   sys_mbox_post(msg->conn->mbox, NULL);
00553 }
00554 /*-----------------------------------------------------------------------------------*/
00555 static void
00556 do_write(struct api_msg_msg *msg)
00557 {
00558 #if LWIP_TCP    
00559   err_t err;
00560 #endif  
00561   if(msg->conn->pcb.tcp != NULL) {
00562     switch(msg->conn->type) {
00563 #if LWIP_UDP 
00564     case NETCONN_UDPLITE:
00565       /* FALLTHROUGH */
00566     case NETCONN_UDPNOCHKSUM:
00567       /* FALLTHROUGH */
00568     case NETCONN_UDP:
00569       msg->conn->err = ERR_VAL;
00570       break;
00571 #endif /* LWIP_UDP */
00572 #if LWIP_TCP 
00573     case NETCONN_TCP:      
00574       err = tcp_write(msg->conn->pcb.tcp, msg->msg.w.dataptr,
00575                       msg->msg.w.len, msg->msg.w.copy);
00576       /* This is the Nagle algorithm: inhibit the sending of new TCP
00577          segments when new outgoing data arrives from the user if any
00578          previously transmitted data on the connection remains
00579          unacknowledged. */
00580       if(err == ERR_OK && msg->conn->pcb.tcp->unacked == NULL) {
00581         tcp_output(msg->conn->pcb.tcp);
00582       }
00583       msg->conn->err = err;
00584       if (msg->conn->callback)
00585           if (err == ERR_OK)
00586           {
00587               if (tcp_sndbuf(msg->conn->pcb.tcp) <= TCP_SNDLOWAT)
00588                   (*msg->conn->callback)(msg->conn, NETCONN_EVT_SENDMINUS, msg->msg.w.len);
00589           }
00590 #endif
00591     default:
00592       break;
00593     }
00594   }
00595   sys_mbox_post(msg->conn->mbox, NULL);
00596 }
00597 /*-----------------------------------------------------------------------------------*/
00598 static void
00599 do_close(struct api_msg_msg *msg)
00600 {
00601   err_t err;
00602 
00603   err = ERR_OK;
00604 
00605   if(msg->conn->pcb.tcp != NULL) {
00606     switch(msg->conn->type) {
00607 #if LWIP_UDP
00608     case NETCONN_UDPLITE:
00609       /* FALLTHROUGH */
00610     case NETCONN_UDPNOCHKSUM:
00611       /* FALLTHROUGH */
00612     case NETCONN_UDP:
00613       break;
00614 #endif /* LWIP_UDP */
00615 #if LWIP_TCP
00616     case NETCONN_TCP:
00617       if(msg->conn->pcb.tcp->state == LISTEN) {
00618         err = tcp_close(msg->conn->pcb.tcp);
00619       }
00620       msg->conn->err = err;      
00621 #endif
00622     default:      
00623       break;
00624     }
00625   }
00626   sys_mbox_post(msg->conn->mbox, NULL);
00627 }
00628 /*-----------------------------------------------------------------------------------*/
00629 typedef void (* api_msg_decode)(struct api_msg_msg *msg);
00630 static api_msg_decode decode[API_MSG_MAX] = {
00631   do_newconn,
00632   do_delconn,
00633   do_bind,
00634   do_connect,
00635   do_disconnect,
00636   do_listen,
00637   do_accept,
00638   do_send,
00639   do_recv,
00640   do_write,
00641   do_close
00642   };
00643 void
00644 api_msg_input(struct api_msg *msg)
00645 {  
00646   decode[msg->type](&(msg->msg));
00647 }
00648 /*-----------------------------------------------------------------------------------*/
00649 void
00650 api_msg_post(struct api_msg *msg)
00651 {
00652   tcpip_apimsg(msg);
00653 }
00654 /*-----------------------------------------------------------------------------------*/
00655 
00656 

Generated on Wed Jan 14 12:58:55 2004 for RTL-lwIP-0.4 by doxygen 1.3.4