Core networking libraries including LwIP implementation

Dependencies:   DebugLib Socket lwip lwip-sys

Dependents:   EthernetInterface

Fork of NetworkingCoreLib by Donatien Garnier

Committer:
donatien
Date:
Fri Jun 22 16:18:09 2012 +0000
Revision:
15:cf5f669a30bc
Parent:
13:f7d8c8088289
DebugLib up

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 1:240e3322b87a 1 /* LwIPInterface.cpp */
donatien 13:f7d8c8088289 2 /* Copyright (C) 2012 mbed.org, MIT License
donatien 13:f7d8c8088289 3 *
donatien 13:f7d8c8088289 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
donatien 13:f7d8c8088289 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
donatien 13:f7d8c8088289 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
donatien 13:f7d8c8088289 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
donatien 13:f7d8c8088289 8 * furnished to do so, subject to the following conditions:
donatien 13:f7d8c8088289 9 *
donatien 13:f7d8c8088289 10 * The above copyright notice and this permission notice shall be included in all copies or
donatien 13:f7d8c8088289 11 * substantial portions of the Software.
donatien 13:f7d8c8088289 12 *
donatien 13:f7d8c8088289 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
donatien 13:f7d8c8088289 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
donatien 13:f7d8c8088289 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
donatien 13:f7d8c8088289 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien 13:f7d8c8088289 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
donatien 13:f7d8c8088289 18 */
donatien 1:240e3322b87a 19
donatien 1:240e3322b87a 20
donatien 1:240e3322b87a 21 #include "core/fwk.h"
donatien 1:240e3322b87a 22
donatien 1:240e3322b87a 23 #include "LwIPInterface.h"
donatien 1:240e3322b87a 24
donatien 1:240e3322b87a 25 extern "C" {
donatien 1:240e3322b87a 26 #include "lwip/init.h"
donatien 1:240e3322b87a 27 #include "lwip/tcpip.h"
donatien 1:240e3322b87a 28 }
donatien 1:240e3322b87a 29
donatien 1:240e3322b87a 30 LwIPInterface::LwIPInterface() : IPInterface(), m_rdySphre(1)
donatien 1:240e3322b87a 31 {
donatien 1:240e3322b87a 32 m_rdySphre.wait();
donatien 1:240e3322b87a 33 }
donatien 1:240e3322b87a 34
donatien 8:387f573a6813 35 LwIPInterface::~LwIPInterface()
donatien 1:240e3322b87a 36 {
donatien 1:240e3322b87a 37
donatien 1:240e3322b87a 38 }
donatien 1:240e3322b87a 39
donatien 8:387f573a6813 40 int LwIPInterface::init() //Init LwIP-specific stuff, create the right bindings, etc
donatien 1:240e3322b87a 41 {
donatien 1:240e3322b87a 42 //lwip_init(); //All LwIP initialisation functions called on a per-module basis (according to lwipopts.h)
donatien 1:240e3322b87a 43 tcpip_init(LwIPInterface::tcpipRdyCb, this); //Start TCP/IP processing thread
donatien 1:240e3322b87a 44 m_rdySphre.wait(); //Wait for callback to produce resource
donatien 1:240e3322b87a 45 return OK;
donatien 1:240e3322b87a 46 }
donatien 1:240e3322b87a 47
donatien 1:240e3322b87a 48 /*static*/ void LwIPInterface::tcpipRdyCb(void* ctx) //Result of TCP/IP thread launch
donatien 1:240e3322b87a 49 {
donatien 1:240e3322b87a 50 LwIPInterface* pIf = (LwIPInterface*) ctx;
donatien 1:240e3322b87a 51 pIf->m_rdySphre.release();
donatien 1:240e3322b87a 52 }