File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 4444//#include "lwip/raw.h"
4545#include "lwip/dns.h"
4646
47+ // For compatibilily with older lwIP versions.
48+ #ifndef ip_set_option
49+ #define ip_set_option (pcb , opt ) ((pcb)->so_options |= (opt))
50+ #endif
51+
4752#ifdef MICROPY_PY_LWIP_SLIP
4853#include "netif/slipif.h"
4954#include "lwip/sio.h"
@@ -876,7 +881,17 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_setblocking_obj, lwip_socket_setblo
876881
877882STATIC mp_obj_t lwip_socket_setsockopt (mp_uint_t n_args , const mp_obj_t * args ) {
878883 (void )n_args ; // always 4
879- printf ("Warning: lwip.setsockopt() not implemented\n" );
884+ lwip_socket_obj_t * socket = args [0 ];
885+ mp_int_t val = mp_obj_get_int (args [3 ]);
886+ switch (mp_obj_get_int (args [2 ])) {
887+ case SOF_REUSEADDR :
888+ // Options are common for UDP and TCP pcb's.
889+ // TODO: handle val
890+ ip_set_option (socket -> pcb .tcp , SOF_REUSEADDR );
891+ break ;
892+ default :
893+ printf ("Warning: lwip.setsockopt() not implemented\n" );
894+ }
880895 return mp_const_none ;
881896}
882897STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (lwip_socket_setsockopt_obj , 4 , 4 , lwip_socket_setsockopt );
You can’t perform that action at this time.
0 commit comments