Add non-blocking support for connect (partly from patch #6860) plus many cleanups in socket & netconn API
This commit is contained in:
@@ -61,6 +61,7 @@ extern "C" {
|
||||
#define NETCONNTYPE_GROUP(t) (t&0xF0)
|
||||
#define NETCONNTYPE_DATAGRAM(t) (t&0xE0)
|
||||
|
||||
/** Protocol family and type of the netconn */
|
||||
enum netconn_type {
|
||||
NETCONN_INVALID = 0,
|
||||
/* NETCONN_TCP Group */
|
||||
@@ -73,6 +74,8 @@ enum netconn_type {
|
||||
NETCONN_RAW = 0x40
|
||||
};
|
||||
|
||||
/** Current state of the netconn. Non-TCP netconns are always
|
||||
* in state NETCONN_NONE! */
|
||||
enum netconn_state {
|
||||
NETCONN_NONE,
|
||||
NETCONN_WRITE,
|
||||
@@ -81,6 +84,7 @@ enum netconn_state {
|
||||
NETCONN_CLOSE
|
||||
};
|
||||
|
||||
/** Use to inform the callback function about changes */
|
||||
enum netconn_evt {
|
||||
NETCONN_EVT_RCVPLUS,
|
||||
NETCONN_EVT_RCVMINUS,
|
||||
@@ -89,6 +93,7 @@ enum netconn_evt {
|
||||
};
|
||||
|
||||
#if LWIP_IGMP
|
||||
/** Used for netconn_join_leave_group() */
|
||||
enum netconn_igmp {
|
||||
NETCONN_JOIN,
|
||||
NETCONN_LEAVE
|
||||
@@ -152,10 +157,14 @@ struct netconn {
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
|
||||
this temporarily stores whether to wake up the original application task
|
||||
if data couldn't be sent in the first try. */
|
||||
if data couldn't be sent in the first try. @todo: combine in 'flags' */
|
||||
u8_t write_delayed;
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#endif /* LWIP_TCP */
|
||||
/** Should this netconn avoid blocking? @todo: combine in 'flags' */
|
||||
u8_t non_blocking;
|
||||
/** Was the last connect action a non-blocking one? @todo: combine in 'flags' */
|
||||
u8_t in_non_blocking_connect;
|
||||
/** A callback function that is informed about events for this netconn */
|
||||
netconn_callback callback;
|
||||
};
|
||||
|
||||
@@ -54,24 +54,22 @@ typedef LWIP_ERR_T err_t;
|
||||
#define ERR_BUF -2 /* Buffer error. */
|
||||
#define ERR_TIMEOUT -3 /* Timeout. */
|
||||
#define ERR_RTE -4 /* Routing problem. */
|
||||
#define ERR_INPROGRESS -5 /* Operation in progress */
|
||||
#define ERR_VAL -6 /* Illegal value. */
|
||||
|
||||
#define ERR_IS_FATAL(e) ((e) < ERR_RTE)
|
||||
#define ERR_IS_FATAL(e) ((e) < ERR_VAL)
|
||||
|
||||
#define ERR_ABRT -5 /* Connection aborted. */
|
||||
#define ERR_RST -6 /* Connection reset. */
|
||||
#define ERR_CLSD -7 /* Connection closed. */
|
||||
#define ERR_CONN -8 /* Not connected. */
|
||||
#define ERR_ABRT -7 /* Connection aborted. */
|
||||
#define ERR_RST -8 /* Connection reset. */
|
||||
#define ERR_CLSD -9 /* Connection closed. */
|
||||
#define ERR_CONN -10 /* Not connected. */
|
||||
|
||||
#define ERR_VAL -9 /* Illegal value. */
|
||||
#define ERR_ARG -11 /* Illegal argument. */
|
||||
|
||||
#define ERR_ARG -10 /* Illegal argument. */
|
||||
#define ERR_USE -12 /* Address in use. */
|
||||
|
||||
#define ERR_USE -11 /* Address in use. */
|
||||
|
||||
#define ERR_IF -12 /* Low-level netif error */
|
||||
#define ERR_ISCONN -13 /* Already connected. */
|
||||
|
||||
#define ERR_INPROGRESS -14 /* Operation in progress */
|
||||
#define ERR_IF -13 /* Low-level netif error */
|
||||
#define ERR_ISCONN -14 /* Already connected. */
|
||||
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
|
||||
@@ -262,10 +262,6 @@ typedef struct ip_mreq {
|
||||
#define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */
|
||||
#endif
|
||||
|
||||
/* Socket flags: */
|
||||
#ifndef O_NONBLOCK
|
||||
#define O_NONBLOCK 04000U
|
||||
#endif
|
||||
|
||||
/* FD_SET used for lwip_select */
|
||||
#ifndef FD_SET
|
||||
|
||||
Reference in New Issue
Block a user