Skip to content

Commit 4332d72

Browse files
committed
extmod/modlwip: Add lwip->POSIX error map for lwIP 1.4.0.
Between 1.4.0 and 1.4.1, lwIP errors were renumbered.
1 parent de0c84e commit 4332d72

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

extmod/modlwip.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ STATIC const mp_obj_type_t lwip_slip_type = {
158158

159159
// Extension to lwIP error codes
160160
#define _ERR_BADF -16
161+
// TODO: We just know that change happened somewhere between 1.4.0 and 1.4.1,
162+
// investigate in more detail.
163+
#if LWIP_VERSION < 0x01040100
161164
static const int error_lookup_table[] = {
162165
0, /* ERR_OK 0 No error, everything OK. */
163166
ENOMEM, /* ERR_MEM -1 Out of memory error. */
@@ -167,6 +170,28 @@ static const int error_lookup_table[] = {
167170
EINPROGRESS, /* ERR_INPROGRESS -5 Operation in progress */
168171
EINVAL, /* ERR_VAL -6 Illegal value. */
169172
EWOULDBLOCK, /* ERR_WOULDBLOCK -7 Operation would block. */
173+
174+
ECONNABORTED, /* ERR_ABRT -8 Connection aborted. */
175+
ECONNRESET, /* ERR_RST -9 Connection reset. */
176+
ENOTCONN, /* ERR_CLSD -10 Connection closed. */
177+
ENOTCONN, /* ERR_CONN -11 Not connected. */
178+
EIO, /* ERR_ARG -12 Illegal argument. */
179+
EADDRINUSE, /* ERR_USE -13 Address in use. */
180+
-1, /* ERR_IF -14 Low-level netif error */
181+
EALREADY, /* ERR_ISCONN -15 Already connected. */
182+
EBADF, /* _ERR_BADF -16 Closed socket (null pcb) */
183+
};
184+
#else
185+
static const int error_lookup_table[] = {
186+
0, /* ERR_OK 0 No error, everything OK. */
187+
ENOMEM, /* ERR_MEM -1 Out of memory error. */
188+
ENOBUFS, /* ERR_BUF -2 Buffer error. */
189+
EWOULDBLOCK, /* ERR_TIMEOUT -3 Timeout */
190+
EHOSTUNREACH, /* ERR_RTE -4 Routing problem. */
191+
EINPROGRESS, /* ERR_INPROGRESS -5 Operation in progress */
192+
EINVAL, /* ERR_VAL -6 Illegal value. */
193+
EWOULDBLOCK, /* ERR_WOULDBLOCK -7 Operation would block. */
194+
170195
EADDRINUSE, /* ERR_USE -8 Address in use. */
171196
EALREADY, /* ERR_ISCONN -9 Already connected. */
172197
ECONNABORTED, /* ERR_ABRT -10 Connection aborted. */
@@ -177,6 +202,7 @@ static const int error_lookup_table[] = {
177202
-1, /* ERR_IF -15 Low-level netif error */
178203
EBADF, /* _ERR_BADF -16 Closed socket (null pcb) */
179204
};
205+
#endif
180206

181207
/*******************************************************************************/
182208
// The socket object provided by lwip.socket.

0 commit comments

Comments
 (0)