libnyoci icon indicating copy to clipboard operation
libnyoci copied to clipboard

Compatibility with lwIP and ESP-IDF

Open snej opened this issue 7 years ago • 5 comments

lwIP = Lightweight IP library http://savannah.nongnu.org/projects/lwip/

ESP-IDF = iOT Development Framework for Espressif's ESP32 chip https://github.com/espressif/esp-idf

New preprocessor flags for configuration:

  • NYOCI_LWIP -- define if compiling for lwIP. Will be automatically defined if ESP_PLATFORM is defined (i.e. building for ESP-IDF.)
  • NYOCI_CAN_POLL -- Indicates the poll system call is available and should be used instead of select. Defaults to 1 unless building for lwIP; explicitly define it as 0 to force use of select.
  • NYOCI_CAN_SENDMSG -- Indicates the sendmsg system call is available and should be used instead of send. Defaults to 1 unless building for lwIP; explicitly define it as 0 to force use of send. Note: send does not support setting the “from” address of the packet.

Fixes #8

(I also added a one-line commit that fixes a recent regression on the master branch that I discovered when rebasing just now.)

snej avatar Jul 02 '18 17:07 snej

I think a better approach would be to create a net platform rather than modifying the posix platform in-place, even if the new platform is based on posix.

Maybe call it plat-net/lwip-sockets?

darconeous avatar Jul 02 '18 18:07 darconeous

I think a better approach would be to create a net platform rather than modifying the posix platform in-place, even if the new platform is based on posix.

But that would mean duplicating ~1200 lines of code, which I couldn't bring myself to do (I'm pretty strict about DRY.)

Consider also that most of the changes aren't specific to lwIP; they'll add support for any other POSIX-like platform that's missing poll and/or sendmsg.

But it is of course your call. I may just keep my fork, err, forked. In that case, mind if I submit a smaller PR for just the ESP32-specific changes (e.g. to logging?)

snej avatar Jul 06 '18 16:07 snej

I'll take another look over the changes. If there are other POSIX platforms that your changes help make LibNyoci build on (Solaris? QNX? Minix?), then I'd be inclined to accept it. QNX in particular might benefit from it.

But I may end up just going ahead and implementing support for native LWIP.

Travis is failing here with these changes:

../../../../src/plat-net/posix/nyoci-plat-net.c:922:4: error: field designator 'sin6_len' does not refer to any field in type 'struct sockaddr_in6'
                .sin6_len = sizeof(struct sockaddr_in6),
                 ^

But let me review this stuff before you spend any significant amount of time trying to address that.

darconeous avatar Jul 07 '18 07:07 darconeous

Good news: It looks like I'll be adding real native support for LWIP at some point between now and the end of November. I'll also be adding support for bare-bones OpenThread.

darconeous avatar Jul 26 '18 18:07 darconeous

You've got some good changes in this PR, so I'm going to keep this open for now.

darconeous avatar Jul 26 '18 18:07 darconeous