LwIPInterface.cpp 1.9 KB

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