summaryrefslogtreecommitdiff
path: root/extmod/modlwip.c
AgeCommit message (Collapse)Author
2017-08-13all: Raise exceptions via mp_raise_XXXJavier Candeira
- Changed: ValueError, TypeError, NotImplementedError - OSError invocations unchanged, because the corresponding utility function takes ints, not strings like the long form invocation. - OverflowError, IndexError and RuntimeError etc. not changed for now until we decide whether to add new utility functions.
2017-07-31extmod/modlwip: Implement setsockopt(IP_ADD_MEMBERSHIP).Paul Sokolovsky
Allows to join multicast groups.
2017-07-31extmod: Use MP_ROM_INT for int values in an mp_rom_map_elem_t.Damien George
2017-07-29extmod/mod{lwip,onewire,webrepl}: Convert to mp_rom_map_elem_t.Paul Sokolovsky
2017-06-04extmod/modlwip: accept: Fix error code for non-blocking mode.Paul Sokolovsky
In non-blocking mode, if no pending connection available, should return EAGAIN, not ETIMEDOUT.
2017-06-04extmod/modlwip: Fix error codes for duplicate calls to connect().Paul Sokolovsky
If socket is already connected, POSIX requires returning EISCONN. If connection was requested, but not yet complete (for non-blocking socket), error code is EALREADY. http://pubs.opengroup.org/onlinepubs/7908799/xns/connect.html
2017-06-03extmod/modlwip: connect: For non-blocking mode, return EINPROGRESS.Paul Sokolovsky
Instead of ETIMEDOUT. This is consistent with POSIX: http://pubs.opengroup.org/onlinepubs/7908799/xns/connect.html
2017-05-29various: Spelling fixesVille Skyttä
2017-05-01extmod/modlwip: ioctl POLL: Fix handling of peer closed socket.Paul Sokolovsky
Peer-closed socket is both readable and writable: read will return EOF, write - error. Without this poll will hang on such socket. Note that we don't return POLLHUP, based on argumentation in http://www.greenend.org.uk/rjk/tech/poll.html that it should apply to deeper disconnects, for example for networking, that would be link layer disconnect (e.g. WiFi went down).
2017-04-29extmod/modlwip: getaddrinfo: Allow to accept all 6 standard params.Paul Sokolovsky
But warn if anything else but host/port is passed.
2017-03-31all: Use full path name when including mp-readline/timeutils/netutils.Damien George
This follows the pattern of how all other headers are now included, and makes it explicit where the header file comes from. This patch also removes -I options from Makefile's that specify the mp-readline/timeutils/ netutils directories, which are no longer needed.
2017-03-26extmod/modlwip: Use mp_obj_str_get_str instead of mp_obj_str_get_data.Damien George
2017-02-15extmod/modlwip: Add my copyright.Paul Sokolovsky
Per: $ git log modlwip.c |grep ^Auth | sort | uniq -c 9 Author: Damien George 2 Author: Galen Hazelwood 43 Author: Paul Sokolovsky
2017-01-27extmod/modlwip: Add socket.readinto() method.Damien George
2017-01-04all: Consistently update signatures of .make_new and .call methods.Paul Sokolovsky
Otherwise, they serve reoccurring source of copy-paste mistakes and breaking nanbox build.
2016-12-02extmod/modlwip: Add ioctl method to socket, with poll implementation.Damien George
Implementation of polling may need further fine tuning, but basic functionality works (tested on esp8266).
2016-10-07extmod/modlwip: Use mp_raise_OSError helper function.Damien George
Reduces esp8266 code size by about 230 bytes.
2016-09-22all: Remove 'name' member from mp_obj_module_t struct.Damien George
One can instead lookup __name__ in the modules dict to get the value.
2016-06-19extmod/modlwip: Store a chain of incoming pbufs, instead of only one.Paul Sokolovsky
Storing a chain of pbuf was an original design of @pfalcon's lwIP socket module. The problem with storing just one, like modlwip does is that "peer closed connection" notification is completely asynchronous and out of band. So, there may be following sequence of actions: 1. pbuf #1 arrives, and stored in a socket. 2. pbuf #2 arrives, and rejected, which causes lwIP to put it into a queue to re-deliver later. 3. "Peer closed connection" is signaled, and socket is set at such status. 4. pbuf #1 is processed. 5. There's no stored pbufs in teh socket, and socket status is "peer closed connection", so EOF is returned to a client. 6. pbuf #2 gets redelivered. Apparently, there's no easy workaround for this, except to queue all incoming pbufs in a socket. This may lead to increased memory pressure, as number of pending packets would be regulated only by TCP/IP flow control, whereas with previous setup lwIP had a global overlook of number packets waiting for redelivery and could regulate them centrally.
2016-06-18all: Rename mp_obj_type_t::stream_p to protocol.Paul Sokolovsky
It's now used for more than just stream protocol (e.g. pin protocol), so don't use false names.
2016-05-15extmod/modlwip: Rework how Python accept callback is called.Paul Sokolovsky
Calling it from lwIP accept callback will lead incorrect functioning and/or packet leaks if Python callback has any networking calls, due to lwIP non-reentrancy. So, instead schedule "poll" callback to do that, which will be called by lwIP when it does not perform networking activities. "Poll" callback is called infrequently though (docs say every 0.5s by default), so for better performance, lwIP needs to be patched to call poll callback soon after accept callback, but when current packet is already processed.
2016-05-12extmod/modlwip: Convert errno's to use MP_Exxx symbols.Damien George
2016-05-03extmod/modlwip: Implement sendall() method for TCP sockets.Paul Sokolovsky
2016-04-26extmod/modlwip: Add print_pcbs() debug function.Paul Sokolovsky
This requires lwIP built with LWIP_DEBUG (or it will be no-op).
2016-04-26extmod/modlwip: Workaround esp8266 sendto issue where 1 is returned.Damien George
2016-04-26extmod, stmhal: Fix typo of macro that detects if float is enabled.Damien George
2016-04-25extmod/modlwip: Protect recv/accept Python callback against exceptions.Paul Sokolovsky
Using usual call_function_*_protected() helper, to avoid NLR jump crashes.
2016-04-17extmod/modlwip: Add ability to run callback on "recv" and "accept" events.Paul Sokolovsky
To use: .setsockopt(SOL_SOCKET, 20, lambda sock: print(sock)). There's a single underlying callback slot. For normal sockets, it serves as data received callback, for listening sockets - connection arrived callback.
2016-04-17extmod/modlwip: lwip_tcp_receive(): Full error handling.Paul Sokolovsky
2016-04-17extmod/modlwip: lwip_tcp_send(): Full error handling.Paul Sokolovsky
2016-04-15extmod/modlwip: More debug messages for various edge conditions.Paul Sokolovsky
2016-04-14extmod/modlwip: Start adding debug output.Paul Sokolovsky
2016-04-14extmod/modlwip: lwip_tcp_receive(): Properly handle EOF for non-blocking sock.Paul Sokolovsky
2016-04-11extmod/modlwip: Fix for loss of data in unaccepted incoming sockets.Paul Sokolovsky
When lwIP creates a incoming connection socket of a listen socket, it sets its recv callback to one which discards incoming data. We set proper callback only in accept() call, when we allocate Python-level socket where we can queue incoming data. So, in lwIP accept callback be sure to set recv callback to one which tells lwIP to not discard incoming data.
2016-03-25extmod/modlwip: lwip_socket_setsockopt: Handle option value properly.Paul Sokolovsky
2016-03-25extmod/modlwip: Add lwip->POSIX error map for lwIP 1.4.0.Paul Sokolovsky
Between 1.4.0 and 1.4.1, lwIP errors were renumbered.
2016-03-25extmod/modlwip: lwip_tcp_send: Handle properly send buffer full condition.Paul Sokolovsky
Per POSIX http://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html : "If space is not available at the sending socket to hold the message to be transmitted, and the socket file descriptor does not have O_NONBLOCK set, send() shall block until space is available. If space is not available at the sending socket to hold the message to be transmitted, and the socket file descriptor does have O_NONBLOCK set, send() shall fail [with EAGAIN]."
2016-03-25extmod/modlwip: Implement setsocketopt(SO_REUSEADDR).Paul Sokolovsky
2016-03-25extmod/modlwip: Add SOL_SOCKET and SO_REUSEADDR constants for setsockopt().Paul Sokolovsky
2016-03-12extmod/modlwip: lwip_tcp_receive: Properly map lwIP error to POSIX errno.Paul Sokolovsky
2016-03-12extmod/modlwip: Add socket.setblocking() method.Paul Sokolovsky
2016-03-12extmod/modlwip: Rework getaddrinfo() data passing.Paul Sokolovsky
The code is based on Damien George's implementation for esp8266 port, avoids use of global variables and associated re-entrancy issues, and fixes returning stale data in some cases.
2016-03-11extmod/modlwip: Use MICROPY_EVENT_POLL_HOOK for event polling if defined.Paul Sokolovsky
Instead of just delaying 100ms if event isn't yet ready. So far applies only to default, "infinite" socket timeout.
2016-03-09extmod/modlwip: Factor out "socket connected" check to a function.Paul Sokolovsky
Same code repeated for each send*() and recv*() function.
2016-03-09extmod/modlwip: Support non-blocking recv().Paul Sokolovsky
2016-03-09extmod/modlwip: Add .write() stream method.Paul Sokolovsky
2016-03-09extmod/modlwip: Still process remaining incoming data of a closed socket.Damien George
It can happen that a socket gets closed while the pbuf is not completely drained by the application. It can also happen that a new pbuf comes in via the recv callback, and then a "peer closed" event comes via the same callback (pbuf=NULL) before the previous event has been handled. In both cases the socket is closed but there is remaining data. This patch makes sure such data is passed to the application.
2016-03-09extmod/modlwip: Check for state change during recv busy-wait loop.Damien George
For example, the peer may close the connection while recv is waiting for incoming data.
2016-03-09extmod/modlwip: Add stream .read() and .readline() methods.Paul Sokolovsky
2016-03-09extmod/modlwip: Add dummy .makefile() method.Paul Sokolovsky