Closed edwin-oetelaar closed 8 years ago
very serious bugs in socket.c (that have been there a long long time) The socket.c has major problems, one of them is not having break statements in the right places. This leads to very serious bugs. Completely wrong responses from ctlsocket() and getsockopt() See attached patch with fixes. I personally think this codebase needs major review. diff -r e377caf76636 W7500P/W7500P_FW/ioLibrary/Ethernet/socket.c --- a/W7500P/W7500P_FW/ioLibrary/Ethernet/socket.c Tue Apr 05 21:28:05 2016 +0200 +++ b/W7500P/W7500P_FW/ioLibrary/Ethernet/socket.c Sun Apr 10 17:20:23 2016 +0200 @@ -52,12 +52,12 @@ #include "socket.h" #include "W7500x_wztoe.h" -#define SOCK_ANY_PORT_NUM 0xC000; +#define SOCK_ANY_PORT_NUM (0xC000) static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; static uint16_t sock_io_mode = 0; static uint16_t sock_is_sending = 0; -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; +static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,}; static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; #if _WIZCHIP_ == 5200 @@ -589,6 +589,7 @@ int8_t ctlsocket(uint8_t sn, ctlsock_ty break; case CS_GET_INTMASK: *((uint8_t*)arg) = getSn_IMR(sn); + break; default: return SOCKERR_ARG; } @@ -664,6 +665,7 @@ int8_t getsockopt(uint8_t sn, sockopt_t break; case SO_MSS: *(uint8_t*) arg = getSn_MSSR(sn); + break; case SO_DESTIP: getSn_DIPR(sn, (uint8_t*)arg); break; @@ -678,8 +680,10 @@ int8_t getsockopt(uint8_t sn, sockopt_t #endif case SO_SENDBUF: *(uint16_t*) arg = getSn_TX_FSR(sn); + break; case SO_RECVBUF: *(uint16_t*) arg = getSn_RX_RSR(sn); + break; case SO_STATUS: *(uint8_t*) arg = getSn_SR(sn); break;
Sorry... we made a mistake. I will upload repaired for that part. thank you for fixed code :)
The code appears to be fixed. I will close the issue now.