diff packages/net/lwip_tcpip/current/src/api/api_lib.c @ 2174:d07decb23fa2

* Updated the complete lwIP source to the latest lwIP CVS version 1.1.1 * src/ecos/init.c Added call to netif_set_up(netif) in function lwip_set_addr() - this is required since lwIP version 1.0.0 * cdl/lwip_net.cdl Minor modifications for UDP configuration options. Renamed CYGNUM_LWIP_TCPIP_THREAD_PRIORITY to CYGNUM_LWIP_NETWORK_THREAD_PRIORITY and moved option outside CYGPKG_LWIP_TCPIP component because the network thread needs to run in all configurations. * tests/nc_slave.c * tests/tcpecho.c * tests/udpecho.c * tests/sockets.c * tests/httpd.c Added eCos test infrastructure to tests and made tests applicable depending on lwip configuration.
author asl
date Wed, 29 Mar 2006 10:33:28 +0000
parents 464189c3749b
children d6c0c0e0431c
line wrap: on
line diff
--- a/packages/net/lwip_tcpip/current/src/api/api_lib.c
+++ b/packages/net/lwip_tcpip/current/src/api/api_lib.c
@@ -165,7 +165,7 @@ netbuf_copy_partial(struct netbuf *buf, 
       offset -= p->len;
     } else {    
       for(i = offset; i < p->len; ++i) {
-  ((char *)dataptr)[left] = ((char *)p->payload)[i];
+  ((u8_t *)dataptr)[left] = ((u8_t *)p->payload)[i];
   if (++left >= len) {
     return;
   }
@@ -280,9 +280,10 @@ netconn_delete(struct netconn *conn)
   if (conn->recvmbox != SYS_MBOX_NULL) {
     while (sys_arch_mbox_fetch(conn->recvmbox, &mem, 1) != SYS_ARCH_TIMEOUT) {
       if (conn->type == NETCONN_TCP) {
-  pbuf_free((struct pbuf *)mem);
+        if(mem != NULL)
+          pbuf_free((struct pbuf *)mem);
       } else {
-  netbuf_delete((struct netbuf *)mem);
+        netbuf_delete((struct netbuf *)mem);
       }
     }
     sys_mbox_free(conn->recvmbox);
@@ -321,30 +322,29 @@ netconn_peer(struct netconn *conn, struc
        u16_t *port)
 {
   switch (conn->type) {
-#if LWIP_RAW
   case NETCONN_RAW:
     /* return an error as connecting is only a helper for upper layers */
     return ERR_CONN;
-#endif
-#if LWIP_UDP
   case NETCONN_UDPLITE:
   case NETCONN_UDPNOCHKSUM:
   case NETCONN_UDP:
+#if LWIP_UDP
     if (conn->pcb.udp == NULL ||
   ((conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0))
      return ERR_CONN;
     *addr = (conn->pcb.udp->remote_ip);
     *port = conn->pcb.udp->remote_port;
+#endif
     break;
-#endif
+    
+  case NETCONN_TCP:
 #if LWIP_TCP
-  case NETCONN_TCP:
     if (conn->pcb.tcp == NULL)
       return ERR_CONN;
     *addr = (conn->pcb.tcp->remote_ip);
     *port = conn->pcb.tcp->remote_port;
+#endif
     break;
-#endif
   }
   return (conn->err = ERR_OK);
 }
@@ -354,26 +354,27 @@ netconn_addr(struct netconn *conn, struc
        u16_t *port)
 {
   switch (conn->type) {
+  case NETCONN_RAW:
 #if LWIP_RAW
-  case NETCONN_RAW:
     *addr = &(conn->pcb.raw->local_ip);
     *port = conn->pcb.raw->protocol;
+#endif
     break;
-#endif
-#if LWIP_UDP
   case NETCONN_UDPLITE:
   case NETCONN_UDPNOCHKSUM:
   case NETCONN_UDP:
+#if LWIP_UDP
     *addr = &(conn->pcb.udp->local_ip);
     *port = conn->pcb.udp->local_port;
+#endif
     break;
-#endif
+    
+  case NETCONN_TCP:
 #if LWIP_TCP
-  case NETCONN_TCP:
     *addr = &(conn->pcb.tcp->local_ip);
     *port = conn->pcb.tcp->local_port;
+#endif
     break;
-#endif
   }
   return (conn->err = ERR_OK);
 }
@@ -684,7 +685,7 @@ netconn_write(struct netconn *conn, void
     api_msg_post(msg);
     sys_mbox_fetch(conn->mbox, NULL);    
     if (conn->err == ERR_OK) {
-      dataptr = (void *)((char *)dataptr + len);
+      dataptr = (void *)((u8_t *)dataptr + len);
       size -= len;
     } else if (conn->err == ERR_MEM) {
       conn->err = ERR_OK;