summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-03-25 20:53:52 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-03-25 20:53:52 +0200
commit91031a75a1d3ece259ed7e02fd9396947abdbac0 (patch)
treeda44add04b1c25afd3b66d4d6e1b8649c4622ffe
parent4332d72fd8751a466a1e81116b4f52a522cddb11 (diff)
downloadmicropython-91031a75a1d3ece259ed7e02fd9396947abdbac0.tar.gz
micropython-91031a75a1d3ece259ed7e02fd9396947abdbac0.zip
extmod/modlwip: lwip_socket_setsockopt: Handle option value properly.
-rw-r--r--extmod/modlwip.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/extmod/modlwip.c b/extmod/modlwip.c
index 2df3fde9e5..84383516ff 100644
--- a/extmod/modlwip.c
+++ b/extmod/modlwip.c
@@ -48,6 +48,9 @@
#ifndef ip_set_option
#define ip_set_option(pcb, opt) ((pcb)->so_options |= (opt))
#endif
+#ifndef ip_reset_option
+#define ip_reset_option(pcb, opt) ((pcb)->so_options &= ~(opt))
+#endif
#ifdef MICROPY_PY_LWIP_SLIP
#include "netif/slipif.h"
@@ -941,8 +944,11 @@ STATIC mp_obj_t lwip_socket_setsockopt(mp_uint_t n_args, const mp_obj_t *args) {
switch (mp_obj_get_int(args[2])) {
case SOF_REUSEADDR:
// Options are common for UDP and TCP pcb's.
- // TODO: handle val
- ip_set_option(socket->pcb.tcp, SOF_REUSEADDR);
+ if (val) {
+ ip_set_option(socket->pcb.tcp, SOF_REUSEADDR);
+ } else {
+ ip_reset_option(socket->pcb.tcp, SOF_REUSEADDR);
+ }
break;
default:
printf("Warning: lwip.setsockopt() not implemented\n");