extmod/modlwip: lwip_socket_setsockopt: Handle option value properly.

pull/1936/head
Paul Sokolovsky 2016-03-25 20:53:52 +02:00
rodzic 4332d72fd8
commit 91031a75a1
1 zmienionych plików z 8 dodań i 2 usunięć

Wyświetl plik

@ -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");