Core networking libraries including LwIP implementation

Dependencies:   DebugLib lwip_ppp_ethernet

Dependents:   EthernetNetworkLib

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LwIPInterface.cpp Source File

LwIPInterface.cpp

00001 /* LwIPInterface.cpp */
00002 /*
00003 Copyright (C) 2012 ARM Limited.
00004 
00005 Permission is hereby granted, free of charge, to any person obtaining a copy of
00006 this software and associated documentation files (the "Software"), to deal in
00007 the Software without restriction, including without limitation the rights to
00008 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
00009 of the Software, and to permit persons to whom the Software is furnished to do
00010 so, subject to the following conditions:
00011 
00012 The above copyright notice and this permission notice shall be included in all
00013 copies or substantial portions of the Software.
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00018 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00020 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
00021 SOFTWARE.
00022 */
00023 
00024 
00025 #include "core/fwk.h"
00026 
00027 #include "LwIPInterface.h"
00028 
00029 extern "C" {
00030 #include "lwip/init.h"
00031 #include "lwip/tcpip.h"
00032 }
00033 
00034 LwIPInterface::LwIPInterface() : IPInterface(), m_rdySphre(1)
00035 {
00036   m_rdySphre.wait();
00037 }
00038 
00039 /*virtual*/ LwIPInterface::~LwIPInterface()
00040 {
00041 
00042 }
00043 
00044 /*virtual*/ int LwIPInterface::init() //Init LwIP-specific stuff, create the right bindings, etc
00045 {
00046   //lwip_init(); //All LwIP initialisation functions called on a per-module basis (according to lwipopts.h)
00047   tcpip_init(LwIPInterface::tcpipRdyCb, this); //Start TCP/IP processing thread
00048   m_rdySphre.wait(); //Wait for callback to produce resource
00049   return OK;
00050 }
00051 
00052 /*static*/ void LwIPInterface::tcpipRdyCb(void* ctx) //Result of TCP/IP thread launch
00053 {
00054   LwIPInterface* pIf = (LwIPInterface*) ctx;
00055   pIf->m_rdySphre.release();
00056 }