Improved integration with the lwip library#20441
Improved integration with the lwip library#20441MAntoniak wants to merge 1 commit intocurl:masterfrom
Conversation
| #ifdef HAVE_GETHOSTBYNAME_R_6 | ||
| #define CURL_GETHOSTBYNAME_R lwip_gethostbyname_r | ||
| #endif | ||
| #ifdef HAVE_GETPEERNAME | ||
| #define CURL_GETPEERNAME lwip_getpeername | ||
| #endif | ||
| #ifdef HAVE_GETSOCKNAME | ||
| #define CURL_GETSOCKNAME lwip_getsockname | ||
| #endif |
There was a problem hiding this comment.
In what cases are these these 3 functions unavailable when
USE_LWIPSOCK is defined? Why guard them like this?
There was a problem hiding this comment.
You're right, it's unnecessary. I can update it, but I'm waiting for a decision on the future of this PR.
| (curl_socklen_t)(size)) | ||
| #elif defined(USE_LWIPSOCK) | ||
| #define curlx_inet_ntop(af,addr,buf,size) \ | ||
| lwip_inet_ntop(af, addr, buf, (curl_socklen_t)(size)) |
There was a problem hiding this comment.
| lwip_inet_ntop(af, addr, buf, (curl_socklen_t)(size)) | |
| lwip_inet_ntop(af, addr, buf, (curl_socklen_t)(size)) |
(minor indent nit)
| #define CURL_LISTEN listen | ||
| #define CURL_SELECT select | ||
| #define CURL_SETSOCKOPT setsockopt | ||
| #endif |
There was a problem hiding this comment.
Wouldn't the new macros need to be used in test code too,
for consistency, and to allow building (and running) tests
with lwip enabled?
edit: also in src.
|
It seems strange that lwip provides a POSIX-like API but with different identifiers. Does it not have a compatibility mode that provides the standard names? Does it really expect every network application to adapt to its oddball names? |
|
The INSTALL.md file actually mentions lwip and talks about "BSD-style lwIP TCP/IP stack support" and that curl has been tested with lwip 1.4.0. Have you looked at that section of the document and make sure to abide by the prerequisites? |
And if they need oddball names, why not define them the other way around? In this style: |
|
Looking at lwip sources, it offers a macro to enable defining standard It also offers POSIX-compatible headers via: I wonder if there is a reason not using them. |
|
The main reason for these changes is the use of the lwip library without defining LWIP_COMPAT_SOCKETS. I was inspired by what has already been done for the close and fcntl functions in the curl_setup_once.h file. We use the curl and lwip libraries in the embedded system. Our main code is written in C++. The entire project is built by Visual Studio and gcc. When defining LWIP_COMPAT_SOCKETS, it is not possible to build the project because we use these function/method names in many places, even though they are often private class methods or functions written in a different namespace. Macros will always win over a method name because it runs before compilation. For this reason, we decided not to define LWIP_COMPAT_SOCKETS. |
Past cases required strong reasons, since they impact working with I'd expect |
Yes, I am building the project as a single piece to be programmed on a microcontroller. |
|
Yes, I am building the project as a single piece to be programmed on a
microcontroller.
Why not enable lwip BSD compatibility only when building the libcurl portion of
the project? Any build system that is capable of building libcurl would be
capable of building different parts independently. I'm still not sure exactly
what the problem is.
|
I also use the lwip library in other parts of project, such as the TCP server/client, UDP server, protocol SNTP etc. The lwip library is heavily integrated into the project and it is not easy to separate lwip from the rest. |
|
But, if the compatibility layer is just a set of macros, that could be enabled only when compiling libcurl, right?
|
I'm not sure if I understand correctly, but this could work if the macro set were defined in this file. However, these macros are defined in lwip/sockets.h. |
|
I'm not sure if I understand correctly, but this could work if the macro set
were defined in this file. However, these macros are defined in lwip/sockets.h.
That file is included in curl_setup.h, so it should be available to libcurl. If
that's the file that's causing issue in the rest of the application, just make
sure it's not being included there. Or, if the problem is macros within that
file, make sure that they're turned off in the rest of your application.
I don't know how you're building your application, but I'm pretty sure you can
make this to work without touching curl. We don't want to add hacks to curl
for particular application since it works fine already (apparently) with lwip.
|
|
Agreed this is better solved locally on the build side, by separating I tried building curl with lwIP, and found a number of issues. Also Further, Also lwIP support is missing from both cmake and autotools. [ Finally, lwIP itself did not produce a linkable library with mingw-w64, |
|
I have decided to close this PR. I am unable to address this issue at this time. Thank you for all your advice. |
Using the lwip_* function family.
Use of the inet_ntop and lwip_inet_pton functions.
I did not change references to functions if they appeared inside the linux or USE_WINSOCK definitions.