Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LwIPInterface.cpp@1:fbf17fb09581, 2015-02-20 (annotated)
- Committer:
- clemounet
- Date:
- Fri Feb 20 17:15:55 2015 +0000
- Revision:
- 1:fbf17fb09581
Add PPP networking
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| clemounet | 1:fbf17fb09581 | 1 | /* LwIPInterface.cpp */ |
| clemounet | 1:fbf17fb09581 | 2 | /* Copyright (C) 2012 mbed.org, MIT License |
| clemounet | 1:fbf17fb09581 | 3 | * |
| clemounet | 1:fbf17fb09581 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
| clemounet | 1:fbf17fb09581 | 5 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
| clemounet | 1:fbf17fb09581 | 6 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
| clemounet | 1:fbf17fb09581 | 7 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
| clemounet | 1:fbf17fb09581 | 8 | * furnished to do so, subject to the following conditions: |
| clemounet | 1:fbf17fb09581 | 9 | * |
| clemounet | 1:fbf17fb09581 | 10 | * The above copyright notice and this permission notice shall be included in all copies or |
| clemounet | 1:fbf17fb09581 | 11 | * substantial portions of the Software. |
| clemounet | 1:fbf17fb09581 | 12 | * |
| clemounet | 1:fbf17fb09581 | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
| clemounet | 1:fbf17fb09581 | 14 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| clemounet | 1:fbf17fb09581 | 15 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| clemounet | 1:fbf17fb09581 | 16 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| clemounet | 1:fbf17fb09581 | 17 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| clemounet | 1:fbf17fb09581 | 18 | */ |
| clemounet | 1:fbf17fb09581 | 19 | |
| clemounet | 1:fbf17fb09581 | 20 | |
| clemounet | 1:fbf17fb09581 | 21 | #include "core/fwk.h" |
| clemounet | 1:fbf17fb09581 | 22 | |
| clemounet | 1:fbf17fb09581 | 23 | #include "LwIPInterface.h" |
| clemounet | 1:fbf17fb09581 | 24 | |
| clemounet | 1:fbf17fb09581 | 25 | extern "C" { |
| clemounet | 1:fbf17fb09581 | 26 | #include "lwip/init.h" |
| clemounet | 1:fbf17fb09581 | 27 | #include "lwip/tcpip.h" |
| clemounet | 1:fbf17fb09581 | 28 | } |
| clemounet | 1:fbf17fb09581 | 29 | |
| clemounet | 1:fbf17fb09581 | 30 | LwIPInterface::LwIPInterface() : IPInterface(), m_rdySphre(1) |
| clemounet | 1:fbf17fb09581 | 31 | { |
| clemounet | 1:fbf17fb09581 | 32 | m_rdySphre.wait(); |
| clemounet | 1:fbf17fb09581 | 33 | } |
| clemounet | 1:fbf17fb09581 | 34 | |
| clemounet | 1:fbf17fb09581 | 35 | LwIPInterface::~LwIPInterface() |
| clemounet | 1:fbf17fb09581 | 36 | { |
| clemounet | 1:fbf17fb09581 | 37 | |
| clemounet | 1:fbf17fb09581 | 38 | } |
| clemounet | 1:fbf17fb09581 | 39 | |
| clemounet | 1:fbf17fb09581 | 40 | int LwIPInterface::init() //Init LwIP-specific stuff, create the right bindings, etc |
| clemounet | 1:fbf17fb09581 | 41 | { |
| clemounet | 1:fbf17fb09581 | 42 | //lwip_init(); //All LwIP initialisation functions called on a per-module basis (according to lwipopts.h) |
| clemounet | 1:fbf17fb09581 | 43 | tcpip_init(LwIPInterface::tcpipRdyCb, this); //Start TCP/IP processing thread |
| clemounet | 1:fbf17fb09581 | 44 | m_rdySphre.wait(); //Wait for callback to produce resource |
| clemounet | 1:fbf17fb09581 | 45 | return OK; |
| clemounet | 1:fbf17fb09581 | 46 | } |
| clemounet | 1:fbf17fb09581 | 47 | |
| clemounet | 1:fbf17fb09581 | 48 | /*static*/ void LwIPInterface::tcpipRdyCb(void* ctx) //Result of TCP/IP thread launch |
| clemounet | 1:fbf17fb09581 | 49 | { |
| clemounet | 1:fbf17fb09581 | 50 | LwIPInterface* pIf = (LwIPInterface*) ctx; |
| clemounet | 1:fbf17fb09581 | 51 | pIf->m_rdySphre.release(); |
| clemounet | 1:fbf17fb09581 | 52 | } |