lwip: define LWIP_POSIX_SOCKETS_IO_NAMES as zero (#457)
This patch gets the newlib standard stream descriptors playing well with the lwip socket descriptors and the spiffs file descriptors. The LWIP_SOCKET_OFFSET is now defined to be 3, rather than zero, to avoid clashing with the standard stream descriptors, and the SPIFFS_FILEHDL_OFFSET is bumped up to start after the lwip descriptors.
This commit is contained in:
		
							parent
							
								
									87a3503f93
								
							
						
					
					
						commit
						ebdd2f983b
					
				
					 12 changed files with 102 additions and 13 deletions
				
			
		|  | @ -21,6 +21,7 @@ | |||
|  *  This file is part of mbed TLS (https://tls.mbed.org)
 | ||||
|  */ | ||||
| 
 | ||||
| #include <fcntl.h> | ||||
| #if !defined(MBEDTLS_CONFIG_FILE) | ||||
| #include "mbedtls/config.h" | ||||
| #else | ||||
|  |  | |||
|  | @ -20,6 +20,7 @@ | |||
|   */ | ||||
| 
 | ||||
| #include <espressif/esp_common.h> | ||||
| #include <unistd.h> | ||||
| #include <lwip/sockets.h> | ||||
| #include <lwip/inet.h> | ||||
| #include <lwip/netdb.h> | ||||
|  |  | |||
|  | @ -149,7 +149,8 @@ int _open_r(struct _reent *r, const char *pathname, int flags, int mode) | |||
|     return SPIFFS_open(&fs, pathname, spiffs_flags, mode); | ||||
| } | ||||
| 
 | ||||
| int _close_r(struct _reent *r, int fd) | ||||
| // This implementation replaces implementation in core/newlib_syscals.c
 | ||||
| int _close_filesystem_r(struct _reent *r, int fd) | ||||
| { | ||||
|     return SPIFFS_close(&fs, (spiffs_file)fd); | ||||
| } | ||||
|  |  | |||
|  | @ -198,7 +198,15 @@ typedef unsigned char u8_t; | |||
| // NB: This adds config field fh_ix_offset in the configuration struct when
 | ||||
| // mounting, which must be defined.
 | ||||
| #ifndef SPIFFS_FILEHDL_OFFSET | ||||
| #define SPIFFS_FILEHDL_OFFSET                 1 | ||||
| #define SPIFFS_FILEHDL_OFFSET                 17 | ||||
| // Not ideal having to use a literal above, which is necessary because this file
 | ||||
| // is also included by tools that run on the host, but at least do some checks
 | ||||
| // when building the target code.
 | ||||
| #ifdef LWIP_SOCKET_OFFSET | ||||
| #if SPIFFS_FILEHDL_OFFSET < (LWIP_SOCKET_OFFSET + MEMP_NUM_NETCONN) | ||||
| #error SPIFFS_FILEHDL_OFFSET clashes with lwip sockets range. | ||||
| #endif | ||||
| #endif | ||||
| #endif | ||||
| 
 | ||||
| // Enable this to compile a read only version of spiffs.
 | ||||
|  |  | |||
|  | @ -21,6 +21,7 @@ | |||
| 
 | ||||
| #include <string.h> | ||||
| #include <ctype.h> | ||||
| #include <unistd.h> | ||||
| 
 | ||||
| #include <espressif/esp_common.h> | ||||
| #include <espressif/user_interface.h> | ||||
|  | @ -1722,9 +1723,9 @@ static void dns_task(void *pvParameters) | |||
| 
 | ||||
|     const struct ifreq ifreq0 = { "en0" }; | ||||
|     const struct ifreq ifreq1 = { "en1" }; | ||||
|     lwip_setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, | ||||
|                     sdk_wifi_get_opmode() == STATIONAP_MODE ? &ifreq1 : &ifreq0, | ||||
|                     sizeof(ifreq0)); | ||||
|     setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, | ||||
|                sdk_wifi_get_opmode() == STATIONAP_MODE ? &ifreq1 : &ifreq0, | ||||
|                sizeof(ifreq0)); | ||||
| 
 | ||||
|     for (;;) { | ||||
|         char buffer[96]; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue