Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
fb7b715b
Commit
fb7b715b
authored
Dec 30, 2015
by
Paul Sokolovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extmod/modlwip: Use _ERR_BADF instead of magic number.
parent
bc25545f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
extmod/modlwip.c
extmod/modlwip.c
+8
-6
No files found.
extmod/modlwip.c
View file @
fb7b715b
...
...
@@ -150,6 +150,8 @@ STATIC const mp_obj_type_t lwip_slip_type = {
// Table to convert lwIP err_t codes to socket errno codes, from the lwIP
// socket API.
// Extension to lwIP error codes
#define _ERR_BADF -16
static
const
int
error_lookup_table
[]
=
{
0
,
/* ERR_OK 0 No error, everything OK. */
ENOMEM
,
/* ERR_MEM -1 Out of memory error. */
...
...
@@ -167,7 +169,7 @@ static const int error_lookup_table[] = {
ENOTCONN
,
/* ERR_CONN -13 Not connected. */
EIO
,
/* ERR_ARG -14 Illegal argument. */
-
1
,
/* ERR_IF -15 Low-level netif error */
EBADF
,
/*
Not an ERR
-16 Closed socket (null pcb) */
EBADF
,
/*
_ERR_BADF
-16 Closed socket (null pcb) */
};
/*******************************************************************************/
...
...
@@ -493,7 +495,7 @@ STATIC mp_obj_t lwip_socket_close(mp_obj_t self_in) {
//case MOD_NETWORK_SOCK_RAW: raw_remove(socket->pcb.raw); break;
}
socket
->
pcb
.
tcp
=
NULL
;
socket
->
state
=
-
16
;
// EBADF
socket
->
state
=
_ERR_BADF
;
if
(
socket
->
incoming
.
pbuf
!=
NULL
)
{
if
(
!
socket_is_listener
)
{
pbuf_free
(
socket
->
incoming
.
pbuf
);
...
...
@@ -699,7 +701,7 @@ STATIC mp_obj_t lwip_socket_send(mp_obj_t self_in, mp_obj_t buf_in) {
if
(
socket
->
pcb
.
tcp
==
NULL
)
{
// not connected
_errno
=
error_lookup_table
[
-
(
socket
->
state
)];
socket
->
state
=
-
16
;
socket
->
state
=
_ERR_BADF
;
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_OSError
,
MP_OBJ_NEW_SMALL_INT
(
_errno
)));
}
...
...
@@ -732,7 +734,7 @@ STATIC mp_obj_t lwip_socket_recv(mp_obj_t self_in, mp_obj_t len_in) {
if
(
socket
->
pcb
.
tcp
==
NULL
)
{
// not connected
_errno
=
error_lookup_table
[
-
(
socket
->
state
)];
socket
->
state
=
-
16
;
socket
->
state
=
_ERR_BADF
;
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_OSError
,
MP_OBJ_NEW_SMALL_INT
(
_errno
)));
}
...
...
@@ -770,7 +772,7 @@ STATIC mp_obj_t lwip_socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_obj_t
if
(
socket
->
pcb
.
tcp
==
NULL
)
{
// not connected
_errno
=
error_lookup_table
[
-
(
socket
->
state
)];
socket
->
state
=
-
16
;
socket
->
state
=
_ERR_BADF
;
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_OSError
,
MP_OBJ_NEW_SMALL_INT
(
_errno
)));
}
...
...
@@ -806,7 +808,7 @@ STATIC mp_obj_t lwip_socket_recvfrom(mp_obj_t self_in, mp_obj_t len_in) {
if
(
socket
->
pcb
.
tcp
==
NULL
)
{
// not connected
_errno
=
error_lookup_table
[
-
(
socket
->
state
)];
socket
->
state
=
-
16
;
socket
->
state
=
_ERR_BADF
;
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_OSError
,
MP_OBJ_NEW_SMALL_INT
(
_errno
)));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment