Official mbed lwIP library (version 1.4.0)

Dependents:   LwIPNetworking NetServicesMin EthernetInterface EthernetInterface_RSF ... more

Legacy Networking Libraries

This is an mbed 2 networking library. For mbed OS 5, lwip has been integrated with built-in networking interfaces. The networking libraries have been revised to better support additional network stacks and thread safety here.

This library is based on the code of lwIP v1.4.0

Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
All rights reserved. 

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
   this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
   derived from this software without specific prior written permission. 

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.

Files at this revision

API Documentation at this revision

Comitter:
donatien
Date:
Fri Jun 22 15:08:59 2012 +0000
Parent:
3:9a63dd787415
Child:
5:89eb903836af
Commit message:
Put PPP Buffers in AHBSRAM1; pppOverSerialOpen() thread leak removed; Does not fail if remote end does not advertise its IP address

Changed in this revision

netif/ppp/ipcp.c Show annotated file Show diff for this revision Revisions of this file
netif/ppp/lcp.c Show annotated file Show diff for this revision Revisions of this file
netif/ppp/ppp.c Show annotated file Show diff for this revision Revisions of this file
--- a/netif/ppp/ipcp.c	Fri Jun 22 13:39:39 2012 +0000
+++ b/netif/ppp/ipcp.c	Fri Jun 22 15:08:59 2012 +0000
@@ -1235,9 +1235,13 @@
   }
 
   if (ho->hisaddr == 0) {
+#if 0
     IPCPDEBUG(LOG_ERR, ("Could not determine remote IP address\n"));
     ipcp_close(f->unit, "Could not determine remote IP address");
     return;
+#else //Kludge
+    ho->hisaddr = 0; //Set remote IP to 0.0.0.0, this is needed as most 3g providers do not advertise the remote IP to the user
+#endif
   }
   if (go->ouraddr == 0) {
     IPCPDEBUG(LOG_ERR, ("Could not determine local IP address\n"));
--- a/netif/ppp/lcp.c	Fri Jun 22 13:39:39 2012 +0000
+++ b/netif/ppp/lcp.c	Fri Jun 22 15:08:59 2012 +0000
@@ -107,7 +107,7 @@
 static u32_t lcp_echo_timer_running = 0;                /* TRUE if a timer is running */
 
 /* @todo: do we really need such a large buffer? The typical 1500 bytes seem too much. */
-static u_char nak_buffer[PPP_MRU]; /* where we construct a nak packet */ 
+static u_char nak_buffer[PPP_MRU] __attribute((section("AHBSRAM1"))); /* where we construct a nak packet */
 
 /*
  * Callbacks for fsm code.  (CI = Configuration Information)
--- a/netif/ppp/ppp.c	Fri Jun 22 13:39:39 2012 +0000
+++ b/netif/ppp/ppp.c	Fri Jun 22 15:08:59 2012 +0000
@@ -249,7 +249,9 @@
 /******************************/
 u_long subnetMask;
 
-static PPPControl pppControl[NUM_PPP]; /* The PPP interface control blocks. */
+static PPPControl pppControl[NUM_PPP] __attribute((section("AHBSRAM1"))); /* The PPP interface control blocks. */
+
+sys_mbox_t pppMbox; //Used to signal PPP thread that a PPP session begins
 
 /*
  * PPP Data Link Layer "protocol" table.
@@ -279,7 +281,7 @@
  * Buffers for outgoing packets.  This must be accessed only from the appropriate
  * PPP task so that it doesn't need to be protected to avoid collisions.
  */
-u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN];
+u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN] __attribute((section("AHBSRAM1")));
 
 
 /*****************************/
@@ -448,6 +450,9 @@
       (*protp->init)(i);
     }
   }
+
+  sys_mbox_new(&pppMbox, 1);
+  sys_thread_new(PPP_THREAD_NAME, pppInputThread, (void*)NULL, PPP_THREAD_STACKSIZE, PPP_THREAD_PRIO); //Create PPP thread here
 }
 
 void
@@ -573,7 +578,7 @@
     PPPDEBUG(LOG_INFO, ("pppOverSerialOpen: unit %d: Connecting\n", pd));
     pppStart(pd);
 #if PPP_INPROC_OWNTHREAD
-    sys_thread_new(PPP_THREAD_NAME, pppInputThread, (void*)&pc->rx, PPP_THREAD_STACKSIZE, PPP_THREAD_PRIO);
+    sys_mbox_post(&pppMbox, (void*)&pc->rx);
 #endif
   }
 
@@ -1508,6 +1513,10 @@
   int count;
   PPPControlRx *pcrx = arg;
 
+  do
+  {
+  sys_arch_mbox_fetch(&pppMbox, (void**)&pcrx, 0); //Wait indefinitely
+
   while (lcp_phase[pcrx->pd] != PHASE_DEAD) {
     count = sio_read(pcrx->fd, pcrx->rxbuf, PPPOS_RX_BUFSIZE);
     if(count > 0) {
@@ -1517,6 +1526,7 @@
       sys_msleep(1);
     }
   }
+  } while(1); //Never terminates
 }
 #endif /* PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD */