[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] pylwIP - problems compiling on ubuntu 10.04
From: |
Mason |
Subject: |
Re: [lwip-users] pylwIP - problems compiling on ubuntu 10.04 |
Date: |
Tue, 18 Oct 2011 15:03:44 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110928 Firefox/7.0.1 SeaMonkey/2.4.1 |
Mason wrote:
> Simon Goldschmidt wrote:
>
>> Amir Shalem wrote:
>>
>>> 3. missing ENSRNOTFOUND
>>> lwip/src/api/netdb.c:203: error: 'ENSRNOTFOUND' undeclared
>>
>> I think I remember this being reported on one of the lists.
>
> http://lists.gnu.org/archive/html/lwip-users/2011-08/msg00013.html
>
>> I guess there's an include missing on linux to the file that provides
>> this error code.
>
> It's not standard, as far as I could tell.
> So it should be defined by lwip headers.
> I can provide a patch this afternoon.
>
>> If not, you can just define the error codes
>> yourself. However, in this case, the correct solution would probably
>> be to split the definition of error codes in arch.h so that lwIP can
>> provide the 'h_errno' error codes (for DNS) while not providing the
>> 'errno' error codes.
>
> I'll look into it.
Of all the ENSR* definitions, only ENSRNOTFOUND is used, inside
lwip_gethostbyname_r
Before gethostbyname became obsolete in Issue 7 [1], POSIX had
this to say about netdb.h [2] and gethostbyname [3] in Issue 6.
[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netdb.h.html
[2] http://pubs.opengroup.org/onlinepubs/009695399/basedefs/netdb.h.html
[3] http://pubs.opengroup.org/onlinepubs/009695399/functions/gethostbyname.html
<quote>
ERRORS
These functions shall fail in the following cases.
The gethostbyaddr() and gethostbyname() functions shall set h_errno to
the value shown in the list below. Any changes to errno are unspecified.
[HOST_NOT_FOUND]
No such host is known.
[NO_DATA]
The server recognized the request and the name, but no address is
available. Another type of request to the name server for the domain might
return an answer.
[NO_RECOVERY]
An unexpected server failure occurred which cannot be recovered.
[TRY_AGAIN]
A temporary and possibly transient error occurred, such as a failure of a
server to respond.
When the <netdb.h> header is included, h_errno shall be available as
a modifiable lvalue of type int. It is unspecified whether h_errno is
a macro or an identifier declared with external linkage.
The <netdb.h> header shall define the following macros for use as
error values for gethostbyaddr() and gethostbyname():
HOST_NOT_FOUND
NO_DATA
NO_RECOVERY
TRY_AGAIN
</quote>
These error value are correctly defined in src/include/lwip/arch.h
#ifndef LWIP_DNS_API_DEFINE_ERRORS
#define LWIP_DNS_API_DEFINE_ERRORS 1
#endif
#if LWIP_DNS_API_DEFINE_ERRORS
/** Errors used by the DNS API functions, h_errno can be one of them */
#define EAI_NONAME 200
#define EAI_SERVICE 201
#define EAI_FAIL 202
#define EAI_MEMORY 203
#define HOST_NOT_FOUND 210
#define NO_DATA 211
#define NO_RECOVERY 212
#define TRY_AGAIN 213
#endif /* LWIP_DNS_API_DEFINE_ERRORS */
I propose simply using HOST_NOT_FOUND to fix the problem:
--- netdb.c.orig 2011-05-06 10:51:25.000000000 +0200
+++ netdb.c 2011-10-18 14:58:58.312500000 +0200
@@ -198,11 +198,11 @@
/* query host IP address */
err = netconn_gethostbyname(name, &(h->addr));
if (err != ERR_OK) {
LWIP_DEBUGF(DNS_DEBUG, ("lwip_gethostbyname(%s) failed, err=%d\n", name,
err));
- *h_errnop = ENSRNOTFOUND;
+ *h_errnop = HOST_NOT_FOUND;
return -1;
}
/* copy the hostname into buf */
MEMCPY(hostname, name, namelen);
--- arch.h.orig 2011-05-06 10:51:26.000000000 +0200
+++ arch.h 2011-10-18 15:00:20.828125000 +0200
@@ -202,31 +202,10 @@
#define EDQUOT 122 /* Quota exceeded */
#define ENOMEDIUM 123 /* No medium found */
#define EMEDIUMTYPE 124 /* Wrong medium type */
-
-#define ENSROK 0 /* DNS server returned answer with no data
*/
-#define ENSRNODATA 160 /* DNS server returned answer with no data
*/
-#define ENSRFORMERR 161 /* DNS server claims query was
misformatted */
-#define ENSRSERVFAIL 162 /* DNS server returned general failure */
-#define ENSRNOTFOUND 163 /* Domain name not found */
-#define ENSRNOTIMP 164 /* DNS server does not implement requested
operation */
-#define ENSRREFUSED 165 /* DNS server refused query */
-#define ENSRBADQUERY 166 /* Misformatted DNS query */
-#define ENSRBADNAME 167 /* Misformatted domain name */
-#define ENSRBADFAMILY 168 /* Unsupported address family */
-#define ENSRBADRESP 169 /* Misformatted DNS reply */
-#define ENSRCONNREFUSED 170 /* Could not contact DNS servers */
-#define ENSRTIMEOUT 171 /* Timeout while contacting DNS servers */
-#define ENSROF 172 /* End of file */
-#define ENSRFILE 173 /* Error reading file */
-#define ENSRNOMEM 174 /* Out of memory */
-#define ENSRDESTRUCTION 175 /* Application terminated lookup */
-#define ENSRQUERYDOMAINTOOLONG 176 /* Domain name is too long */
-#define ENSRCNAMELOOP 177 /* Domain name is too long */
-
#ifndef errno
extern int errno;
#endif
#endif /* LWIP_PROVIDE_ERRNO */
Simon, do you agree with the proposed fix?
--
Regards.