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