mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-12 16:50:21 +00:00
Introduce MG_NET_IF var, replaces MG_NET_IF_*
Possible values:
MG_NET_IF_SOCKET (1) - traditional BSD socket API
MG_NET_IF_SIMPLELINK (2) - TI's SimpleLink socket interface
MG_NET_IF_LWIP_LOW_LEVEL - a net_if implementation that uses LWIP's
low-level API, when LWIP_SOCKET is not available.
PUBLISHED_FROM=a5c0aebb7b6bdb1f1f4cb3210763d16f3ab5e133
This commit is contained in:
1 parent
31c5ef1bc3
commit
4ef3a778c1
3 files changed
+57
-38
No files matched your search
+33
-14
@@ -75,6 +75,10 @@
|
||||
|
||||
#endif /* !defined(CS_PLATFORM) */
|
||||
|
||||
#define MG_NET_IF_SOCKET 1
|
||||
#define MG_NET_IF_SIMPLELINK 2
|
||||
#define MG_NET_IF_LWIP_LOW_LEVEL 3
|
||||
|
||||
/* Amalgamated: #include "common/platforms/platform_unix.h" */
|
||||
/* Amalgamated: #include "common/platforms/platform_windows.h" */
|
||||
/* Amalgamated: #include "common/platforms/platform_esp_lwip.h" */
|
||||
@@ -270,6 +274,10 @@ typedef struct _stati64 cs_stat_t;
|
||||
#define MG_ENABLE_HTTP_CGI 1
|
||||
#endif
|
||||
|
||||
#ifndef MG_NET_IF
|
||||
#define MG_NET_IF MG_NET_IF_SOCKET
|
||||
#endif
|
||||
|
||||
#endif /* CS_PLATFORM == CS_P_WINDOWS */
|
||||
#endif /* CS_COMMON_PLATFORMS_PLATFORM_WINDOWS_H_ */
|
||||
#ifdef MG_MODULE_LINES
|
||||
@@ -392,6 +400,10 @@ typedef struct stat cs_stat_t;
|
||||
#define MG_ENABLE_HTTP_CGI 1
|
||||
#endif
|
||||
|
||||
#ifndef MG_NET_IF
|
||||
#define MG_NET_IF MG_NET_IF_SOCKET
|
||||
#endif
|
||||
|
||||
#endif /* CS_PLATFORM == CS_P_UNIX */
|
||||
#endif /* CS_COMMON_PLATFORMS_PLATFORM_UNIX_H_ */
|
||||
#ifdef MG_MODULE_LINES
|
||||
@@ -448,12 +460,14 @@ unsigned long os_random(void);
|
||||
#define random os_random
|
||||
|
||||
#ifndef RTOS_SDK
|
||||
#define MG_NET_IF_LWIP
|
||||
#define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL
|
||||
struct mg_mgr;
|
||||
struct mg_connection;
|
||||
uint32_t mg_lwip_get_poll_delay_ms(struct mg_mgr *mgr);
|
||||
void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle,
|
||||
int interval, int count);
|
||||
#else
|
||||
#define MG_NET_IF MG_NET_IF_SOCKET
|
||||
#endif
|
||||
|
||||
#ifndef CS_ENABLE_STDIO
|
||||
@@ -482,7 +496,7 @@ void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle,
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#define MG_SOCKET_SIMPLELINK 1
|
||||
#define MG_NET_IF MG_NET_IF_SIMPLELINK
|
||||
#define MG_DISABLE_SYNC_RESOLVER 1
|
||||
|
||||
/*
|
||||
@@ -536,7 +550,7 @@ int inet_pton(int af, const char *src, void *dst);
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#define MG_SOCKET_SIMPLELINK 1
|
||||
#define MG_NET_IF MG_NET_IF_SIMPLELINK
|
||||
#define MG_DISABLE_SYNC_RESOLVER 1
|
||||
|
||||
/* Only SPIFFS supports directories, SLFS does not. */
|
||||
@@ -671,7 +685,7 @@ struct dirent *readdir(DIR *dir);
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#define MG_SOCKET_SIMPLELINK 1
|
||||
#define MG_NET_IF MG_NET_IF_SIMPLELINK
|
||||
#define MG_DISABLE_SYNC_RESOLVER 1
|
||||
|
||||
/* Amalgamated: #include "common/platforms/simplelink/cs_simplelink.h" */
|
||||
@@ -785,7 +799,7 @@ int _stat(const char *pathname, struct stat *st);
|
||||
#define CS_COMMON_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_
|
||||
|
||||
/* If simplelink.h is already included, all bets are off. */
|
||||
#if defined(MG_SOCKET_SIMPLELINK) && !defined(__SIMPLELINK_H__)
|
||||
#if MG_NET_IF == MG_NET_IF_SIMPLELINK && !defined(__SIMPLELINK_H__)
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
@@ -876,7 +890,7 @@ int sl_set_ssl_opts(struct mg_connection *nc);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* defined(MG_SOCKET_SIMPLELINK) && !defined(__SIMPLELINK_H__) */
|
||||
#endif /* MG_NET_IF == MG_NET_IF_SIMPLELINK && !defined(__SIMPLELINK_H__) */
|
||||
|
||||
#endif /* CS_COMMON_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_ */
|
||||
#ifdef MG_MODULE_LINES
|
||||
@@ -1032,6 +1046,10 @@ typedef unsigned int* uintptr_t;
|
||||
#define MG_ENABLE_FILESYSTEM 1
|
||||
#endif
|
||||
|
||||
#ifndef MG_NET_IF
|
||||
#define MG_NET_IF MG_NET_IF_SOCKET
|
||||
#endif
|
||||
|
||||
typedef struct _stati64 {
|
||||
uint32_t st_mtime;
|
||||
uint32_t st_size;
|
||||
@@ -1423,10 +1441,6 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
|
||||
#define MG_DISABLE_RESOLVER 0
|
||||
#endif
|
||||
|
||||
#ifndef MG_DISABLE_SOCKET_IF
|
||||
#define MG_DISABLE_SOCKET_IF 0
|
||||
#endif
|
||||
|
||||
#ifndef MG_DISABLE_SYNC_RESOLVER
|
||||
#define MG_DISABLE_SYNC_RESOLVER 0
|
||||
#endif
|
||||
@@ -1523,6 +1537,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
|
||||
#define MG_ENABLE_STDIO CS_ENABLE_STDIO
|
||||
#endif
|
||||
|
||||
#ifndef MG_NET_IF
|
||||
#define MG_NET_IF MG_NET_IF_SOCKET
|
||||
#endif
|
||||
|
||||
#ifndef MG_ENABLE_THREADS /* ifdef-ok */
|
||||
#ifdef _WIN32
|
||||
#define MG_ENABLE_THREADS 1
|
||||
@@ -1592,7 +1610,7 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
|
||||
#ifdef __APPLE__
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
#if !defined(MG_SOCKET_SIMPLELINK)
|
||||
#if MG_NET_IF != MG_NET_IF_SIMPLELINK
|
||||
#include <openssl/ssl.h>
|
||||
#endif
|
||||
#endif /* MG_ENABLE_SSL */
|
||||
@@ -1673,7 +1691,7 @@ struct mg_connection {
|
||||
struct mbuf recv_mbuf; /* Received data */
|
||||
struct mbuf send_mbuf; /* Data scheduled for sending */
|
||||
#if MG_ENABLE_SSL
|
||||
#if !defined(MG_SOCKET_SIMPLELINK)
|
||||
#if MG_NET_IF != MG_NET_IF_SIMPLELINK
|
||||
SSL *ssl;
|
||||
SSL_CTX *ssl_ctx;
|
||||
#else
|
||||
@@ -1950,7 +1968,7 @@ struct mg_connection *mg_connect_opt(struct mg_mgr *mgr, const char *address,
|
||||
mg_event_handler_t handler,
|
||||
struct mg_connect_opts opts);
|
||||
|
||||
#if MG_ENABLE_SSL && !defined(MG_SOCKET_SIMPLELINK)
|
||||
#if MG_ENABLE_SSL && MG_NET_IF != MG_NET_IF_SIMPLELINK
|
||||
/*
|
||||
* Note: This function is deprecated. Please, use SSL options in
|
||||
* mg_connect_opt.
|
||||
@@ -2376,7 +2394,8 @@ void mg_set_close_on_exec(sock_t);
|
||||
*/
|
||||
void mg_conn_addr_to_str(struct mg_connection *nc, char *buf, size_t len,
|
||||
int flags);
|
||||
#if !MG_DISABLE_SOCKET_IF /* Legacy interface. */
|
||||
#if MG_NET_IF == MG_NET_IF_SOCKET
|
||||
/* Legacy interface. */
|
||||
void mg_sock_to_str(sock_t sock, char *buf, size_t len, int flags);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in new issue
Block a user