mirror of
https://github.com/openharmony/device_soc_winnermicro.git
synced 2026-07-19 17:08:15 -04:00
@@ -18,13 +18,13 @@
|
||||
#include "wm_type_def.h"
|
||||
#include "wm_netif.h"
|
||||
|
||||
//socket state defination
|
||||
/* socket state defination */
|
||||
#define NETCONN_STATE_NONE 0
|
||||
#define NETCONN_STATE_WAITING 1
|
||||
#define NETCONN_STATE_CONNECTED 2
|
||||
#define NETCONN_STATE_CLOSED 3
|
||||
|
||||
//socket event defination
|
||||
/* socket event defination */
|
||||
#define NET_EVENT_TCP_JOINED 0
|
||||
#define NET_EVENT_TCP_DISCONNECT 1
|
||||
#define NET_EVENT_TCP_CONNECTED 2
|
||||
@@ -35,38 +35,38 @@
|
||||
#define TLS_MAX_SOCKET_NUM 4
|
||||
#define TLS_MAX_NETCONN_NUM 20
|
||||
|
||||
/** Main packet buffer struct */
|
||||
/** Main packet buffer struct */
|
||||
struct pbuf {
|
||||
/** next pbuf in singly linked pbuf chain */
|
||||
struct pbuf *next;
|
||||
/** next pbuf in singly linked pbuf chain */
|
||||
struct pbuf *next;
|
||||
|
||||
/** pointer to the actual data in the buffer */
|
||||
void *payload;
|
||||
/** pointer to the actual data in the buffer */
|
||||
void *payload;
|
||||
|
||||
/**
|
||||
* total length of this buffer and all next buffers in chain
|
||||
* belonging to the same packet.
|
||||
*
|
||||
* For non-queue packet chains this is the invariant:
|
||||
* p->tot_len == p->len + (p->next? p->next->tot_len: 0)
|
||||
*/
|
||||
u16_t tot_len;
|
||||
/**
|
||||
* total length of this buffer and all next buffers in chain
|
||||
* belonging to the same packet.
|
||||
*
|
||||
* For non-queue packet chains this is the invariant:
|
||||
* p->tot_len == p->len + (p->next? p->next->tot_len: 0)
|
||||
*/
|
||||
u16_t tot_len;
|
||||
|
||||
/** length of this buffer */
|
||||
u16_t len;
|
||||
/** length of this buffer */
|
||||
u16_t len;
|
||||
|
||||
/** pbuf_type as u8_t instead of enum to save space */
|
||||
u8_t /*pbuf_type*/ type;
|
||||
/** pbuf_type as u8_t instead of enum to save space */
|
||||
u8_t /*pbuf_type*/ type;
|
||||
|
||||
/** misc flags */
|
||||
u8_t flags;
|
||||
/** misc flags */
|
||||
u8_t flags;
|
||||
|
||||
/**
|
||||
* the reference count always equals the number of pointers
|
||||
* that refer to this pbuf. This can be pointers from an application,
|
||||
* the stack itself, or pbuf->next pointers from a chain.
|
||||
*/
|
||||
u16_t ref;
|
||||
/**
|
||||
* the reference count always equals the number of pointers
|
||||
* that refer to this pbuf. This can be pointers from an application,
|
||||
* the stack itself, or pbuf->next pointers from a chain.
|
||||
*/
|
||||
u16_t ref;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ struct pbuf {
|
||||
* callback functions
|
||||
* ERR_RST: the connection was reset by the remote host
|
||||
*/
|
||||
typedef void (*socket_err_fn)(u8 skt_num, err_t err);
|
||||
typedef void (*socket_err_fn)(u8 skt_num, err_t err);
|
||||
|
||||
/**
|
||||
* @brief This Function prototype for socket receive callback functions. Called when data has
|
||||
@@ -94,12 +94,12 @@ typedef void (*socket_err_fn)(u8 skt_num, err_t err);
|
||||
* @param[in] err An error code if there has been an error receiving, always be ERR_OK
|
||||
* when cs mode is udp.
|
||||
*
|
||||
* @retval The return value is only valid for tcp receive, for upd it means nothing.
|
||||
* @retval The return value is only valid for tcp receive, for upd it means nothing.
|
||||
* ERR_OK: Return this value after handling the received data.
|
||||
* ERR_ABRT: Only return ERR_ABRT if you want to abort the socket from within the
|
||||
* callback function!
|
||||
*/
|
||||
typedef err_t (*socket_recv_fn)(u8 skt_num, struct pbuf *p, err_t err);
|
||||
typedef err_t (*socket_recv_fn)(u8 skt_num, struct pbuf *p, err_t err);
|
||||
|
||||
/**
|
||||
* @brief This Function prototype for socket srce ip callback functions. Called when data has
|
||||
@@ -116,12 +116,12 @@ typedef err_t (*socket_recv_fn)(u8 skt_num, struct pbuf *p, err_t err);
|
||||
* @param[in] err An error code if there has been an error receiving, always be ERR_OK
|
||||
* when cs mode is udp.
|
||||
*
|
||||
* @retval The return value is only valid for UDP receive, for udp it means nothing.
|
||||
* @retval The return value is only valid for UDP receive, for udp it means nothing.
|
||||
* ERR_OK: Return this value after handling the received data.
|
||||
* ERR_ABRT: Only return ERR_ABRT if you want to abort the socket from within the
|
||||
* callback function!
|
||||
*/
|
||||
typedef err_t (*socket_recv_ip_rpt_fn)(u8 skt_num, u16 datalen, u8 *ipsrc, u16 port, err_t err);
|
||||
typedef err_t (*socket_recv_ip_rpt_fn)(u8 skt_num, u16 datalen, u8 *ipsrc, u16 port, err_t err);
|
||||
|
||||
/**
|
||||
* @brief This Function prototype for tcp connected callback functions. Called when
|
||||
@@ -135,7 +135,7 @@ typedef err_t (*socket_recv_ip_rpt_fn)(u8 skt_num, u16 datalen, u8 *ipsrc, u16
|
||||
* @retval ERR_ABRT: Only return ERR_ABRT if you want to abort the socket from within the
|
||||
* callback function!
|
||||
*/
|
||||
typedef err_t (*socket_connected_fn)(u8 skt_num, err_t err);
|
||||
typedef err_t (*socket_connected_fn)(u8 skt_num, err_t err);
|
||||
|
||||
/**
|
||||
* @brief This Function prototype for tcp poll callback functions. Called periodically.
|
||||
@@ -176,44 +176,43 @@ typedef void(*socket_state_changed_fn)(u8 skt_num, u8 event, u8 state);
|
||||
|
||||
/** Definitions for error constants. */
|
||||
typedef enum {
|
||||
/** No error, everything OK. */
|
||||
ERR_OK = 0,
|
||||
/** Out of memory error. */
|
||||
ERR_MEM = -1,
|
||||
/** Buffer error. */
|
||||
ERR_BUF = -2,
|
||||
/** Timeout. */
|
||||
ERR_TIMEOUT = -3,
|
||||
/** Routing problem. */
|
||||
ERR_RTE = -4,
|
||||
/** Operation in progress */
|
||||
ERR_INPROGRESS = -5,
|
||||
/** Illegal value. */
|
||||
ERR_VAL = -6,
|
||||
/** Operation would block. */
|
||||
ERR_WOULDBLOCK = -7,
|
||||
/** Address in use. */
|
||||
ERR_USE = -8,
|
||||
/** Already connecting. */
|
||||
ERR_ALREADY = -9,
|
||||
/** Conn already established.*/
|
||||
ERR_ISCONN = -10,
|
||||
/** Not connected. */
|
||||
ERR_CONN = -11,
|
||||
/** Low-level netif error */
|
||||
ERR_IF = -12,
|
||||
/** No error, everything OK. */
|
||||
ERR_OK = 0,
|
||||
/** Out of memory error. */
|
||||
ERR_MEM = -1,
|
||||
/** Buffer error. */
|
||||
ERR_BUF = -2,
|
||||
/** Timeout. */
|
||||
ERR_TIMEOUT = -3,
|
||||
/** Routing problem. */
|
||||
ERR_RTE = -4,
|
||||
/** Operation in progress */
|
||||
ERR_INPROGRESS = -5,
|
||||
/** Illegal value. */
|
||||
ERR_VAL = -6,
|
||||
/** Operation would block. */
|
||||
ERR_WOULDBLOCK = -7,
|
||||
/** Address in use. */
|
||||
ERR_USE = -8,
|
||||
/** Already connecting. */
|
||||
ERR_ALREADY = -9,
|
||||
/** Conn already established.*/
|
||||
ERR_ISCONN = -10,
|
||||
/** Not connected. */
|
||||
ERR_CONN = -11,
|
||||
/** Low-level netif error */
|
||||
ERR_IF = -12,
|
||||
/** Connection aborted. */
|
||||
ERR_ABRT = -13,
|
||||
/** Connection reset. */
|
||||
ERR_RST = -14,
|
||||
/** Connection closed. */
|
||||
ERR_CLSD = -15,
|
||||
/** Illegal argument. */
|
||||
ERR_ARG = -16
|
||||
}err_enum_t;
|
||||
|
||||
/** Connection aborted. */
|
||||
ERR_ABRT = -13,
|
||||
/** Connection reset. */
|
||||
ERR_RST = -14,
|
||||
/** Connection closed. */
|
||||
ERR_CLSD = -15,
|
||||
/** Illegal argument. */
|
||||
ERR_ARG = -16
|
||||
} err_enum_t;
|
||||
|
||||
enum tls_socket_protocol{
|
||||
enum tls_socket_protocol {
|
||||
SOCKET_PROTO_TCP, /* TCP Protocol */
|
||||
SOCKET_PROTO_UDP, /* UDP Protocol */
|
||||
};
|
||||
@@ -225,22 +224,22 @@ enum tls_socket_cs_mode{
|
||||
|
||||
struct tls_socket_desc {
|
||||
enum tls_socket_cs_mode cs_mode; /* Server mode or Client mode, Only for tcp protocol is valid */
|
||||
enum tls_socket_protocol protocol; /* TCP Protocol or UDP Protocol */
|
||||
ip_addr_t ip_addr; /* Remote ip address, for tcp client mode is remote server's ip address; for tcp server mode can be any address. */
|
||||
/* for udp is remote server's ip address */
|
||||
u16 port; /* port, for tcp client mode is remote server's port; for tcp server mode is local listen port .
|
||||
for udp is remote server's port */
|
||||
u16 localport; /* local port, for udp and tcp client is local listen port, for tcp server means nothing, tcp server always listen at port */
|
||||
char host_name[32]; /* remote host name, not support for now */
|
||||
u8 host_len; /* the length of host name */
|
||||
u32 timeout; /* poll timeout, not implemented for now */
|
||||
socket_err_fn errf; /* a pointer to socket_err_fn */
|
||||
socket_recv_fn recvf; /* a pointer to socket_recv_fn */
|
||||
socket_connected_fn connf; /* a pointer to socket_connected_fn */
|
||||
socket_poll_fn pollf; /* a pointer to socket_poll_fn */
|
||||
socket_accept_fn acceptf; /* a pointer to socket_accept_fn */
|
||||
socket_state_changed_fn state_changed; /* a pointer to socket_state_changed_fn */
|
||||
socket_recv_ip_rpt_fn recvwithipf; /*recv skt info report*/
|
||||
enum tls_socket_protocol protocol; /* TCP Protocol or UDP Protocol */
|
||||
ip_addr_t ip_addr; /* Remote ip address, for tcp client mode is remote server's ip address; for tcp server mode can be any address. */
|
||||
/* for udp is remote server's ip address */
|
||||
u16 port; /* port, for tcp client mode is remote server's port; for tcp server mode is local listen port .
|
||||
for udp is remote server's port */
|
||||
u16 localport; /* local port, for udp and tcp client is local listen port, for tcp server means nothing, tcp server always listen at port */
|
||||
char host_name[32]; /* remote host name, not support for now */
|
||||
u8 host_len; /* the length of host name */
|
||||
u32 timeout; /* poll timeout, not implemented for now */
|
||||
socket_err_fn errf; /* a pointer to socket_err_fn */
|
||||
socket_recv_fn recvf; /* a pointer to socket_recv_fn */
|
||||
socket_connected_fn connf; /* a pointer to socket_connected_fn */
|
||||
socket_poll_fn pollf; /* a pointer to socket_poll_fn */
|
||||
socket_accept_fn acceptf; /* a pointer to socket_accept_fn */
|
||||
socket_state_changed_fn state_changed; /* a pointer to socket_state_changed_fn */
|
||||
socket_recv_ip_rpt_fn recvwithipf; /*recv skt info report*/
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -248,7 +247,7 @@ struct tls_socket_desc {
|
||||
*
|
||||
* @param[in] skd Is a pointer to an tls_socket_desc.
|
||||
*
|
||||
* @retval ERR_OK If create socket successfully.
|
||||
* @retval ERR_OK If create socket successfully.
|
||||
* negative number If an error was detected.
|
||||
*/
|
||||
int tls_socket_create(struct tls_socket_desc * skd);
|
||||
@@ -262,7 +261,7 @@ int tls_socket_create(struct tls_socket_desc * skd);
|
||||
*
|
||||
* @param[in] len The data's length.
|
||||
*
|
||||
* @retval ERR_OK If send data successfully.
|
||||
* @retval ERR_OK If send data successfully.
|
||||
* negative number If an error was detected.
|
||||
*/
|
||||
int tls_socket_send(u8 skt_num, void *pdata, u16 len);
|
||||
@@ -272,7 +271,7 @@ int tls_socket_send(u8 skt_num, void *pdata, u16 len);
|
||||
*
|
||||
* @param[in] skt_num Is the socket number that returned by tls_socket_create function.
|
||||
*
|
||||
* @retval ERR_OK If close socket successfully.
|
||||
* @retval ERR_OK If close socket successfully.
|
||||
* negative number If an error was detected.
|
||||
*/
|
||||
int tls_socket_close(u8 skt_num);
|
||||
@@ -299,7 +298,7 @@ struct tls_skt_status_t {
|
||||
*
|
||||
* @param[in] len The buf's length. At least, the len should be bigger than sizeof(struct tls_skt_status_t).
|
||||
*
|
||||
* @retval ERR_OK If send data successfully.
|
||||
* @retval ERR_OK If send data successfully.
|
||||
* negative number If an error was detected.
|
||||
*/
|
||||
int tls_socket_get_status(u8 skt_num, u8 *buf, u32 bufsize);
|
||||
@@ -317,68 +316,68 @@ int tls_socket_get_status(u8 skt_num, u8 *buf, u32 bufsize);
|
||||
* @param[in] pdata Is a pointer to the data which need to be send by the socket.
|
||||
*
|
||||
* @param[in] len The data's length.
|
||||
* @retval ERR_OK If send data successfully.
|
||||
* @retval ERR_OK If send data successfully.
|
||||
* negative number If an error was detected.
|
||||
*/
|
||||
int tls_socket_udp_sendto(u16 localport, u8 *ip_addr, u16 port, void *pdata, u16 len);
|
||||
int tls_socket_udp_sendto(u16 localport, u8 *ip_addr, u16 port, void *pdata, u16 len);
|
||||
|
||||
/**
|
||||
* @ingroup pbuf
|
||||
* Enumeration of pbuf layers
|
||||
*/
|
||||
typedef enum {
|
||||
/** Includes spare room for transport layer header, e.g. UDP header.
|
||||
* Use this if you intend to pass the pbuf to functions like udp_send().
|
||||
*/
|
||||
PBUF_TRANSPORT,
|
||||
/** Includes spare room for IP header.
|
||||
* Use this if you intend to pass the pbuf to functions like raw_send().
|
||||
*/
|
||||
PBUF_IP,
|
||||
/** Includes spare room for link layer header (ethernet header).
|
||||
* Use this if you intend to pass the pbuf to functions like ethernet_output().
|
||||
* @see PBUF_LINK_HLEN
|
||||
*/
|
||||
PBUF_LINK,
|
||||
/** Includes spare room for additional encapsulation header before ethernet
|
||||
* headers (e.g. 802.11).
|
||||
* Use this if you intend to pass the pbuf to functions like netif->linkoutput().
|
||||
* @see PBUF_LINK_ENCAPSULATION_HLEN
|
||||
*/
|
||||
PBUF_RAW_TX,
|
||||
/** Use this for input packets in a netif driver when calling netif->input()
|
||||
* in the most common case - ethernet-layer netif driver. */
|
||||
PBUF_RAW
|
||||
} pbuf_layer;
|
||||
/** Includes spare room for transport layer header, e.g. UDP header.
|
||||
* Use this if you intend to pass the pbuf to functions like udp_send().
|
||||
*/
|
||||
PBUF_TRANSPORT,
|
||||
/** Includes spare room for IP header.
|
||||
* Use this if you intend to pass the pbuf to functions like raw_send().
|
||||
*/
|
||||
PBUF_IP,
|
||||
/** Includes spare room for link layer header (ethernet header).
|
||||
* Use this if you intend to pass the pbuf to functions like ethernet_output().
|
||||
* @see PBUF_LINK_HLEN
|
||||
*/
|
||||
PBUF_LINK,
|
||||
/** Includes spare room for additional encapsulation header before ethernet
|
||||
* headers (e.g. 802.11).
|
||||
* Use this if you intend to pass the pbuf to functions like netif->linkoutput().
|
||||
* @see PBUF_LINK_ENCAPSULATION_HLEN
|
||||
*/
|
||||
PBUF_RAW_TX,
|
||||
/** Use this for input packets in a netif driver when calling netif->input()
|
||||
* in the most common case - ethernet-layer netif driver. */
|
||||
PBUF_RAW
|
||||
}pbuf_layer;
|
||||
|
||||
/**
|
||||
* @ingroup pbuf
|
||||
* Enumeration of pbuf types
|
||||
*/
|
||||
typedef enum {
|
||||
/** pbuf data is stored in RAM, used for TX mostly, struct pbuf and its payload
|
||||
/** pbuf data is stored in RAM, used for TX mostly, struct pbuf and its payload
|
||||
are allocated in one piece of contiguous memory (so the first payload byte
|
||||
can be calculated from struct pbuf).
|
||||
pbuf_alloc() allocates PBUF_RAM pbufs as unchained pbufs (although that might
|
||||
change in future versions).
|
||||
This should be used for all OUTGOING packets (TX).*/
|
||||
PBUF_RAM,
|
||||
/** pbuf data is stored in ROM, i.e. struct pbuf and its payload are located in
|
||||
PBUF_RAM,
|
||||
/** pbuf data is stored in ROM, i.e. struct pbuf and its payload are located in
|
||||
totally different memory areas. Since it points to ROM, payload does not
|
||||
have to be copied when queued for transmission. */
|
||||
PBUF_ROM,
|
||||
/** pbuf comes from the pbuf pool. Much like PBUF_ROM but payload might change
|
||||
so it has to be duplicated when queued before transmitting, depending on
|
||||
who has a 'ref' to it. */
|
||||
PBUF_REF,
|
||||
/** pbuf payload refers to RAM. This one comes from a pool and should be used
|
||||
PBUF_REF,
|
||||
/** pbuf payload refers to RAM. This one comes from a pool and should be used
|
||||
for RX. Payload can be chained (scatter-gather RX) but like PBUF_RAM, struct
|
||||
pbuf and its payload are allocated in one piece of contiguous memory (so
|
||||
the first payload byte can be calculated from struct pbuf).
|
||||
Don't use this for TX, if the pool becomes empty e.g. because of TCP queuing,
|
||||
you are unable to receive TCP acks! */
|
||||
PBUF_POOL
|
||||
} pbuf_type;
|
||||
PBUF_POOL
|
||||
}pbuf_type;
|
||||
|
||||
/**
|
||||
* @brief This Function allocates a pbuf of the given type (possibly a chain for PBUF_POOL type).
|
||||
|
||||
@@ -41,15 +41,15 @@ typedef u32_t in_addr_t;
|
||||
#endif
|
||||
|
||||
struct in_addr {
|
||||
in_addr_t s_addr;
|
||||
in_addr_t s_addr;
|
||||
};
|
||||
|
||||
struct in6_addr {
|
||||
union {
|
||||
u32_t u32_addr[4];
|
||||
u8_t u8_addr[16];
|
||||
} un;
|
||||
#define s6_addr un.u8_addr
|
||||
union {
|
||||
u32_t u32_addr[4];
|
||||
u8_t u8_addr[16];
|
||||
}un;
|
||||
#define s6_addr un.u8_addr
|
||||
};
|
||||
|
||||
/** 255.255.255.255 */
|
||||
@@ -82,39 +82,39 @@ extern const struct in6_addr in6addr_any;
|
||||
#if TLS_CONFIG_IPV4
|
||||
/** members are in network byte order */
|
||||
struct sockaddr_in {
|
||||
u8_t sin_len;
|
||||
sa_family_t sin_family;
|
||||
in_port_t sin_port;
|
||||
struct in_addr sin_addr;
|
||||
u8_t sin_len;
|
||||
sa_family_t sin_family;
|
||||
in_port_t sin_port;
|
||||
struct in_addr sin_addr;
|
||||
#define SIN_ZERO_LEN 8
|
||||
char sin_zero[SIN_ZERO_LEN];
|
||||
char sin_zero[SIN_ZERO_LEN];
|
||||
};
|
||||
#endif /* TLS_CONFIG_IPV4 */
|
||||
|
||||
#if TLS_CONFIG_IPV6
|
||||
struct sockaddr_in6 {
|
||||
u8_t sin6_len; /* length of this structure */
|
||||
sa_family_t sin6_family; /* AF_INET6 */
|
||||
in_port_t sin6_port; /* Transport layer port # */
|
||||
u32_t sin6_flowinfo; /* IPv6 flow information */
|
||||
struct in6_addr sin6_addr; /* IPv6 address */
|
||||
u32_t sin6_scope_id; /* Set of interfaces for scope */
|
||||
u8_t sin6_len; /* length of this structure */
|
||||
sa_family_t sin6_family; /* AF_INET6 */
|
||||
in_port_t sin6_port; /* Transport layer port # */
|
||||
u32_t sin6_flowinfo; /* IPv6 flow information */
|
||||
struct in6_addr sin6_addr; /* IPv6 address */
|
||||
u32_t sin6_scope_id; /* Set of interfaces for scope */
|
||||
};
|
||||
#endif /* TLS_CONFIG_IPV6 */
|
||||
|
||||
struct sockaddr {
|
||||
u8_t sa_len;
|
||||
sa_family_t sa_family;
|
||||
char sa_data[14];
|
||||
u8_t sa_len;
|
||||
sa_family_t sa_family;
|
||||
char sa_data[14];
|
||||
};
|
||||
|
||||
struct sockaddr_storage {
|
||||
u8_t s2_len;
|
||||
sa_family_t ss_family;
|
||||
char s2_data1[2];
|
||||
u32_t s2_data2[3];
|
||||
u8_t s2_len;
|
||||
sa_family_t ss_family;
|
||||
char s2_data1[2];
|
||||
u32_t s2_data2[3];
|
||||
#if TLS_CONFIG_IPV6
|
||||
u32_t s2_data3[3];
|
||||
u32_t s2_data3[3];
|
||||
#endif /* TLS_CONFIG_IPV6 */
|
||||
};
|
||||
|
||||
@@ -130,12 +130,12 @@ struct hostent {
|
||||
};
|
||||
|
||||
struct sockaddr_store {
|
||||
u8_t s2_len;
|
||||
sa_family_t ss_family;
|
||||
char s2_data1[2];
|
||||
u32_t s2_data2[3];
|
||||
u8_t s2_len;
|
||||
sa_family_t ss_family;
|
||||
char s2_data1[2];
|
||||
u32_t s2_data2[3];
|
||||
#if TLS_CONFIG_IPV6
|
||||
u32_t s2_data3[3];
|
||||
u32_t s2_data3[3];
|
||||
#endif /* TLS_CONFIG_IPV6 */
|
||||
};
|
||||
|
||||
@@ -276,7 +276,7 @@ struct linger {
|
||||
typedef struct ip_mreq {
|
||||
struct in_addr imr_multiaddr; /* IP multicast address of group */
|
||||
struct in_addr imr_interface; /* local IP address of interface */
|
||||
} ip_mreq;
|
||||
}ip_mreq;
|
||||
|
||||
#if TLS_CONFIG_IPV6
|
||||
#define IPV6_JOIN_GROUP 38
|
||||
@@ -284,7 +284,7 @@ typedef struct ip_mreq {
|
||||
typedef struct ipv6_mreq {
|
||||
struct in6_addr ipv6mr_multiaddr; /* IP multicast address of group */
|
||||
int ipv6mr_interface; /* index of interface */
|
||||
} ipv6_mreq;
|
||||
}ipv6_mreq;
|
||||
#endif
|
||||
#endif /* TLS_CONFIG_IGMP */
|
||||
|
||||
@@ -348,9 +348,6 @@ typedef struct ipv6_mreq {
|
||||
#define IOC_OUT 0x40000000UL /* copy out parameters */
|
||||
#define IOC_IN 0x80000000UL /* copy in parameters */
|
||||
#define IOC_INOUT (IOC_IN | IOC_OUT) /* 0x20000000 distinguishes new & old ioctl's */
|
||||
#define _IO(x, y) (IOC_VOID|((x) << 8) | (y))
|
||||
#define _IOR(x, y, t) (IOC_OUT|(((long)sizeof(t) & IOCPARM_MASK) << 16)|((x) << 8) | (y))
|
||||
#define _IOW(x, y, t) (IOC_IN|(((long)sizeof(t) & IOCPARM_MASK) << 16)|((x) << 8) | (y))
|
||||
#endif /* !defined(FIONREAD) || !defined(FIONBIO) */
|
||||
|
||||
#ifndef FIONREAD
|
||||
@@ -387,9 +384,9 @@ typedef struct ipv6_mreq {
|
||||
#endif
|
||||
|
||||
#ifndef SHUT_RD
|
||||
#define SHUT_RD 0
|
||||
#define SHUT_WR 1
|
||||
#define SHUT_RDWR 2
|
||||
#define SHUT_RD 0
|
||||
#define SHUT_WR 1
|
||||
#define SHUT_RDWR 2
|
||||
#endif
|
||||
|
||||
/** FD_SET used for lwip_select */
|
||||
@@ -407,8 +404,8 @@ typedef struct ipv6_mreq {
|
||||
/** Make FD_SETSIZE match NUM_SOCKETS in socket.c */
|
||||
#define FD_SETSIZE MEMP_NUM_NETCONN
|
||||
#define FDSETSAFESET(n, code) do { \
|
||||
if (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \
|
||||
code; }} while(0)
|
||||
if (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \
|
||||
code; }} while(0)
|
||||
#define FDSETSAFEGET(n, code) (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && \
|
||||
(((int)(n) - LWIP_SOCKET_OFFSET) >= 0) ? (code) : 0)
|
||||
|
||||
@@ -424,8 +421,8 @@ typedef struct ipv6_mreq {
|
||||
#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
|
||||
|
||||
typedef struct fd_set {
|
||||
unsigned char fd_bits [(FD_SETSIZE + 7) / 8];
|
||||
} fd_set;
|
||||
unsigned char fd_bits [(FD_SETSIZE + 7) / 8];
|
||||
}fd_set;
|
||||
|
||||
#elif LWIP_SOCKET_OFFSET
|
||||
#error LWIP_SOCKET_OFFSET does not work with external FD_SET!
|
||||
@@ -439,8 +436,8 @@ typedef struct fd_set {
|
||||
|
||||
#if LWIP_TIMEVAL_PRIVATE
|
||||
struct timeval {
|
||||
long tv_sec; /* seconds */
|
||||
long tv_usec; /* and microseconds */
|
||||
long tv_sec; /* seconds */
|
||||
long tv_usec; /* and microseconds */
|
||||
};
|
||||
#endif /* LWIP_TIMEVAL_PRIVATE */
|
||||
|
||||
@@ -535,7 +532,7 @@ u32_t ipaddr_addr(const char *cp);
|
||||
/** This is the aligned version of ip4_addr_t,
|
||||
used as local variable, on the stack, etc. */
|
||||
struct ip4_addr {
|
||||
u32_t addr;
|
||||
u32_t addr;
|
||||
};
|
||||
|
||||
/** ip4_addr_t uses a struct for convenience only, so that the same defines can
|
||||
@@ -608,13 +605,13 @@ u8_t ip4_addr_netmask_valid(u32_t netmask);
|
||||
#define ip4_addr_debug_print_parts(debug, a, b, c, d) \
|
||||
LWIP_DEBUGF(debug, ("%" U16_F ".%" U16_F ".%" U16_F ".%" U16_F, a, b, c, d))
|
||||
#define ip4_addr_debug_print(debug, ipaddr) \
|
||||
ip4_addr_debug_print_parts(debug, \
|
||||
ip4_addr_debug_print_parts(debug, \
|
||||
(u16_t)((ipaddr) != NULL ? ip4_addr1_16(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? ip4_addr2_16(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? ip4_addr3_16(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? ip4_addr4_16(ipaddr) : 0))
|
||||
#define ip4_addr_debug_print_val(debug, ipaddr) \
|
||||
ip4_addr_debug_print_parts(debug, \
|
||||
ip4_addr_debug_print_parts(debug, \
|
||||
ip4_addr1_16(&(ipaddr)), \
|
||||
ip4_addr2_16(&(ipaddr)), \
|
||||
ip4_addr3_16(&(ipaddr)), \
|
||||
@@ -657,7 +654,7 @@ char *ip4addr_ntoa_r(const ip4_addr_t *addr, char *buf, int buflen);
|
||||
/** This is the aligned version of ip6_addr_t,
|
||||
used as local variable, on the stack, etc. */
|
||||
struct ip6_addr {
|
||||
u32_t addr[4];
|
||||
u32_t addr[4];
|
||||
};
|
||||
|
||||
/** IPv6 address */
|
||||
@@ -665,15 +662,15 @@ typedef struct ip6_addr ip6_addr_t;
|
||||
|
||||
/** Set an IPv6 partial address given by byte-parts */
|
||||
#define IP6_ADDR_PART(ip6addr, index, a, b, c, d) \
|
||||
(ip6addr)->addr[index] = PP_HTONL(LWIP_MAKEU32(a, b, c, d))
|
||||
(ip6addr)->addr[index] = PP_HTONL(LWIP_MAKEU32(a, b, c, d))
|
||||
|
||||
/** Set a full IPv6 address by passing the 4 u32_t indices in network byte order
|
||||
(use PP_HTONL() for constants) */
|
||||
#define IP6_ADDR(ip6addr, idx0, idx1, idx2, idx3) do { \
|
||||
(ip6addr)->addr[0] = idx0; \
|
||||
(ip6addr)->addr[1] = idx1; \
|
||||
(ip6addr)->addr[2] = idx2; \
|
||||
(ip6addr)->addr[3] = idx3; } while(0)
|
||||
(ip6addr)->addr[0] = idx0; \
|
||||
(ip6addr)->addr[1] = idx1; \
|
||||
(ip6addr)->addr[2] = idx2; \
|
||||
(ip6addr)->addr[3] = idx3; } while(0)
|
||||
|
||||
/** Access address in 16-bit block */
|
||||
#define IP6_ADDR_BLOCK1(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[0]) >> 16) & 0xffff))
|
||||
@@ -808,9 +805,9 @@ typedef struct ip6_addr ip6_addr_t;
|
||||
((ip6addr)->addr[3] == PP_HTONL(0x00000001UL)))
|
||||
|
||||
#define ip6_addr_set_allnodes_linklocal(ip6addr) do {(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \
|
||||
(ip6addr)->addr[1] = 0; \
|
||||
(ip6addr)->addr[2] = 0; \
|
||||
(ip6addr)->addr[3] = PP_HTONL(0x00000001UL);} while(0)
|
||||
(ip6addr)->addr[1] = 0; \
|
||||
(ip6addr)->addr[2] = 0; \
|
||||
(ip6addr)->addr[3] = PP_HTONL(0x00000001UL);} while(0)
|
||||
|
||||
#define ip6_addr_isallrouters_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
|
||||
((ip6addr)->addr[1] == 0UL) && \
|
||||
@@ -818,23 +815,23 @@ typedef struct ip6_addr ip6_addr_t;
|
||||
((ip6addr)->addr[3] == PP_HTONL(0x00000002UL)))
|
||||
|
||||
#define ip6_addr_set_allrouters_linklocal(ip6addr) do {(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \
|
||||
(ip6addr)->addr[1] = 0; \
|
||||
(ip6addr)->addr[2] = 0; \
|
||||
(ip6addr)->addr[3] = PP_HTONL(0x00000002UL);} while(0)
|
||||
(ip6addr)->addr[1] = 0; \
|
||||
(ip6addr)->addr[2] = 0; \
|
||||
(ip6addr)->addr[3] = PP_HTONL(0x00000002UL);} while(0)
|
||||
|
||||
#define ip6_addr_issolicitednode(ip6addr) ( ((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
|
||||
((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \
|
||||
(((ip6addr)->addr[3] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL)) )
|
||||
((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \
|
||||
(((ip6addr)->addr[3] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL)) )
|
||||
|
||||
#define ip6_addr_set_solicitednode(ip6addr, if_id) do {(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \
|
||||
(ip6addr)->addr[1] = 0; \
|
||||
(ip6addr)->addr[2] = PP_HTONL(0x00000001UL); \
|
||||
(ip6addr)->addr[3] = (PP_HTONL(0xff000000UL) | (if_id));} while(0)
|
||||
(ip6addr)->addr[1] = 0; \
|
||||
(ip6addr)->addr[2] = PP_HTONL(0x00000001UL); \
|
||||
(ip6addr)->addr[3] = (PP_HTONL(0xff000000UL) | (if_id));} while(0)
|
||||
|
||||
#define ip6_addr_cmp_solicitednode(ip6addr, sn_addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
|
||||
((ip6addr)->addr[1] == 0) && \
|
||||
((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \
|
||||
((ip6addr)->addr[3] == (PP_HTONL(0xff000000UL) | (sn_addr)->addr[3])))
|
||||
((ip6addr)->addr[1] == 0) && \
|
||||
((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \
|
||||
((ip6addr)->addr[3] == (PP_HTONL(0xff000000UL) | (sn_addr)->addr[3])))
|
||||
|
||||
/* IPv6 address states. */
|
||||
#define IP6_ADDR_INVALID 0x00
|
||||
@@ -859,10 +856,10 @@ typedef struct ip6_addr ip6_addr_t;
|
||||
#define ip6_addr_isdeprecated(addr_state) (addr_state == IP6_ADDR_DEPRECATED)
|
||||
|
||||
#define ip6_addr_debug_print_parts(debug, a, b, c, d, e, f, g, h) \
|
||||
LWIP_DEBUGF(debug, ("%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F, \
|
||||
LWIP_DEBUGF(debug, ("%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F, \
|
||||
a, b, c, d, e, f, g, h))
|
||||
#define ip6_addr_debug_print(debug, ipaddr) \
|
||||
ip6_addr_debug_print_parts(debug, \
|
||||
ip6_addr_debug_print_parts(debug, \
|
||||
(u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK1(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK2(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK3(ipaddr) : 0), \
|
||||
@@ -872,7 +869,7 @@ typedef struct ip6_addr ip6_addr_t;
|
||||
(u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK7(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK8(ipaddr) : 0))
|
||||
#define ip6_addr_debug_print_val(debug, ipaddr) \
|
||||
ip6_addr_debug_print_parts(debug, \
|
||||
ip6_addr_debug_print_parts(debug, \
|
||||
IP6_ADDR_BLOCK1(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK2(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK3(&(ipaddr)), \
|
||||
@@ -888,7 +885,7 @@ int ip6addr_aton(const char *cp, ip6_addr_t *addr);
|
||||
/** returns ptr to static buffer; not reentrant! */
|
||||
char *ip6addr_ntoa(const ip6_addr_t *addr);
|
||||
char *ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/** @ingroup ipaddr
|
||||
@@ -896,12 +893,12 @@ char *ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen);
|
||||
* @see tcp_new_ip_type(), udp_new_ip_type(), raw_new_ip_type().
|
||||
*/
|
||||
enum lwip_ip_addr_type {
|
||||
/** IPv4 */
|
||||
IPADDR_TYPE_V4 = 0U,
|
||||
/** IPv6 */
|
||||
IPADDR_TYPE_V6 = 6U,
|
||||
/** IPv4+IPv6 ("dual-stack") */
|
||||
IPADDR_TYPE_ANY = 46U
|
||||
/** IPv4 */
|
||||
IPADDR_TYPE_V4 = 0U,
|
||||
/** IPv6 */
|
||||
IPADDR_TYPE_V6 = 6U,
|
||||
/** IPv4+IPv6 ("dual-stack") */
|
||||
IPADDR_TYPE_ANY = 46U
|
||||
};
|
||||
|
||||
#if TLS_CONFIG_IPV4&&TLS_CONFIG_IPV6
|
||||
@@ -911,13 +908,13 @@ enum lwip_ip_addr_type {
|
||||
* ATTENTION: watch out for its size when adding IPv6 address scope!
|
||||
*/
|
||||
typedef struct ip_addr {
|
||||
union {
|
||||
ip6_addr_t ip6;
|
||||
ip4_addr_t ip4;
|
||||
} u_addr;
|
||||
/** @ref lwip_ip_addr_type */
|
||||
u8_t type;
|
||||
} ip_addr_t;
|
||||
union {
|
||||
ip6_addr_t ip6;
|
||||
ip4_addr_t ip4;
|
||||
}u_addr;
|
||||
/** @ref lwip_ip_addr_type */
|
||||
u8_t type;
|
||||
}ip_addr_t;
|
||||
|
||||
extern const ip_addr_t ip_addr_any_type;
|
||||
|
||||
@@ -949,7 +946,8 @@ extern const ip_addr_t ip_addr_any_type;
|
||||
#define IP_GET_TYPE(ipaddr) ((ipaddr)->type)
|
||||
|
||||
#define IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr) (IP_GET_TYPE(&pcb->local_ip) == IP_GET_TYPE(ipaddr))
|
||||
#define IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr) (IP_IS_ANY_TYPE_VAL(pcb->local_ip) || IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr))
|
||||
#define IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr) (IP_IS_ANY_TYPE_VAL(pcb->local_ip) || \
|
||||
IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr))
|
||||
|
||||
/** @ingroup ip6addr
|
||||
* Convert generic ip address to specific protocol version
|
||||
@@ -971,96 +969,94 @@ extern const ip_addr_t ip_addr_any_type;
|
||||
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_copy(dest, src) do { IP_SET_TYPE_VAL(dest, IP_GET_TYPE(&src)); if(IP_IS_V6_VAL(src)){ \
|
||||
ip6_addr_copy(*ip_2_ip6(&(dest)), *ip_2_ip6(&(src))); } else { \
|
||||
ip4_addr_copy(*ip_2_ip4(&(dest)), *ip_2_ip4(&(src))); }} while(0)
|
||||
ip6_addr_copy(*ip_2_ip6(&(dest)), *ip_2_ip6(&(src))); } else { \
|
||||
ip4_addr_copy(*ip_2_ip4(&(dest)), *ip_2_ip4(&(src))); }} while(0)
|
||||
/** @ingroup ip6addr */
|
||||
#define ip_addr_copy_from_ip6(dest, src) do { \
|
||||
ip6_addr_copy(*ip_2_ip6(&(dest)), src); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V6);} while(0)
|
||||
ip6_addr_copy(*ip_2_ip6(&(dest)), src); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V6);} while(0)
|
||||
/** @ingroup ip4addr */
|
||||
#define ip_addr_copy_from_ip4(dest, src) do { \
|
||||
ip4_addr_copy(*ip_2_ip4(&(dest)), src); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V4);} while(0)
|
||||
ip4_addr_copy(*ip_2_ip4(&(dest)), src); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V4);} while(0)
|
||||
/** @ingroup ip4addr */
|
||||
#define ip_addr_set_ip4_u32(ipaddr, val) do {if(ipaddr){ip4_addr_set_u32(ip_2_ip4(ipaddr), val); \
|
||||
IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }} while(0)
|
||||
IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }} while(0)
|
||||
/** @ingroup ip4addr */
|
||||
#define ip_addr_get_ip4_u32(ipaddr) (((ipaddr) && IP_IS_V4(ipaddr)) ? \
|
||||
ip4_addr_get_u32(ip_2_ip4(ipaddr)) : 0)
|
||||
ip4_addr_get_u32(ip_2_ip4(ipaddr)) : 0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_set(dest, src) do { IP_SET_TYPE(dest, IP_GET_TYPE(src)); if(IP_IS_V6(src)){ \
|
||||
ip6_addr_set(ip_2_ip6(dest), ip_2_ip6(src)); } else { \
|
||||
ip4_addr_set(ip_2_ip4(dest), ip_2_ip4(src)); }} while(0)
|
||||
ip6_addr_set(ip_2_ip6(dest), ip_2_ip6(src)); } else { \
|
||||
ip4_addr_set(ip_2_ip4(dest), ip_2_ip4(src)); }} while(0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_set_ipaddr(dest, src) ip_addr_set(dest, src)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_set_zero(ipaddr) do { \
|
||||
ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, 0); } while(0)
|
||||
ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, 0); } while(0)
|
||||
/** @ingroup ip5addr */
|
||||
#define ip_addr_set_zero_ip4(ipaddr) do { \
|
||||
ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); } while(0)
|
||||
ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); } while(0)
|
||||
/** @ingroup ip6addr */
|
||||
#define ip_addr_set_zero_ip6(ipaddr) do { \
|
||||
ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); } while(0)
|
||||
ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); } while(0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_set_any(is_ipv6, ipaddr) do {if(is_ipv6){ \
|
||||
ip6_addr_set_any(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); } else { \
|
||||
ip4_addr_set_any(ip_2_ip4(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }} while(0)
|
||||
ip6_addr_set_any(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); } else { \
|
||||
ip4_addr_set_any(ip_2_ip4(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }} while(0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_set_loopback(is_ipv6, ipaddr) do {if(is_ipv6){ \
|
||||
ip6_addr_set_loopback(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); } else { \
|
||||
ip4_addr_set_loopback(ip_2_ip4(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }} while(0)
|
||||
ip6_addr_set_loopback(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); } else { \
|
||||
ip4_addr_set_loopback(ip_2_ip4(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }} while(0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_set_hton(dest, src) do {if (IP_IS_V6(src)){ \
|
||||
ip6_addr_set_hton(ip_2_ip6(ipaddr), (src)); IP_SET_TYPE(dest, IPADDR_TYPE_V6); } else { \
|
||||
ip4_addr_set_hton(ip_2_ip4(ipaddr), (src)); IP_SET_TYPE(dest, IPADDR_TYPE_V4); }} while(0)
|
||||
ip6_addr_set_hton(ip_2_ip6(ipaddr), (src)); IP_SET_TYPE(dest, IPADDR_TYPE_V6); } else { \
|
||||
ip4_addr_set_hton(ip_2_ip4(ipaddr), (src)); IP_SET_TYPE(dest, IPADDR_TYPE_V4); }} while(0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_get_network(target, host, netmask) do {if (IP_IS_V6(host)){ \
|
||||
ip4_addr_set_zero(ip_2_ip4(target)); IP_SET_TYPE(target, IPADDR_TYPE_V6); } else { \
|
||||
ip4_addr_get_network(ip_2_ip4(target), ip_2_ip4(host), ip_2_ip4(netmask)); \
|
||||
IP_SET_TYPE(target, IPADDR_TYPE_V4); }} while(0)
|
||||
ip4_addr_set_zero(ip_2_ip4(target)); IP_SET_TYPE(target, IPADDR_TYPE_V6); } else { \
|
||||
ip4_addr_get_network(ip_2_ip4(target), ip_2_ip4(host), ip_2_ip4(netmask)); \
|
||||
IP_SET_TYPE(target, IPADDR_TYPE_V4); }} while(0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_netcmp(addr1, addr2, mask) ((IP_IS_V6(addr1) && IP_IS_V6(addr2)) ? \
|
||||
0 : \
|
||||
ip4_addr_netcmp(ip_2_ip4(addr1), ip_2_ip4(addr2), mask))
|
||||
0 : ip4_addr_netcmp(ip_2_ip4(addr1), ip_2_ip4(addr2), mask))
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_cmp(addr1, addr2) ((IP_GET_TYPE(addr1) != IP_GET_TYPE(addr2)) ? 0 : (IP_IS_V6_VAL(*(addr1)) ? \
|
||||
ip6_addr_cmp(ip_2_ip6(addr1), ip_2_ip6(addr2)) : \
|
||||
ip4_addr_cmp(ip_2_ip4(addr1), ip_2_ip4(addr2))))
|
||||
ip6_addr_cmp(ip_2_ip6(addr1), ip_2_ip6(addr2)) : \
|
||||
ip4_addr_cmp(ip_2_ip4(addr1), ip_2_ip4(addr2))))
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_isany(ipaddr) ((IP_IS_V6(ipaddr)) ? \
|
||||
ip6_addr_isany(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_isany(ip_2_ip4(ipaddr)))
|
||||
ip6_addr_isany(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_isany(ip_2_ip4(ipaddr)))
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_isany_val(ipaddr) ((IP_IS_V6_VAL(ipaddr)) ? \
|
||||
ip6_addr_isany_val(*ip_2_ip6(&(ipaddr))) : \
|
||||
ip4_addr_isany_val(*ip_2_ip4(&(ipaddr))))
|
||||
ip6_addr_isany_val(*ip_2_ip6(&(ipaddr))) : \
|
||||
ip4_addr_isany_val(*ip_2_ip4(&(ipaddr))))
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_isbroadcast(ipaddr, netif) ((IP_IS_V6(ipaddr)) ? \
|
||||
0 : \
|
||||
ip4_addr_isbroadcast(ip_2_ip4(ipaddr), netif))
|
||||
0 : ip4_addr_isbroadcast(ip_2_ip4(ipaddr), netif))
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_ismulticast(ipaddr) ((IP_IS_V6(ipaddr)) ? \
|
||||
ip6_addr_ismulticast(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_ismulticast(ip_2_ip4(ipaddr)))
|
||||
ip6_addr_ismulticast(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_ismulticast(ip_2_ip4(ipaddr)))
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_isloopback(ipaddr) ((IP_IS_V6(ipaddr)) ? \
|
||||
ip6_addr_isloopback(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_isloopback(ip_2_ip4(ipaddr)))
|
||||
ip6_addr_isloopback(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_isloopback(ip_2_ip4(ipaddr)))
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_islinklocal(ipaddr) ((IP_IS_V6(ipaddr)) ? \
|
||||
ip6_addr_islinklocal(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_islinklocal(ip_2_ip4(ipaddr)))
|
||||
ip6_addr_islinklocal(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_islinklocal(ip_2_ip4(ipaddr)))
|
||||
#define ip_addr_debug_print(debug, ipaddr) do { if(IP_IS_V6(ipaddr)) { \
|
||||
ip6_addr_debug_print(debug, ip_2_ip6(ipaddr)); } else { \
|
||||
ip4_addr_debug_print(debug, ip_2_ip4(ipaddr)); }} while(0)
|
||||
ip6_addr_debug_print(debug, ip_2_ip6(ipaddr)); } else { \
|
||||
ip4_addr_debug_print(debug, ip_2_ip4(ipaddr)); }} while(0)
|
||||
#define ip_addr_debug_print_val(debug, ipaddr) do {if (IP_IS_V6_VAL(ipaddr)) { \
|
||||
ip6_addr_debug_print_val(debug, *ip_2_ip6(&(ipaddr))); } else { \
|
||||
ip4_addr_debug_print_val(debug, *ip_2_ip4(&(ipaddr))); }} while(0)
|
||||
ip6_addr_debug_print_val(debug, *ip_2_ip6(&(ipaddr))); } else { \
|
||||
ip4_addr_debug_print_val(debug, *ip_2_ip4(&(ipaddr))); }} while(0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ipaddr_ntoa(addr) (((addr) == NULL) ? "NULL" : \
|
||||
((IP_IS_V6(addr)) ? ip6addr_ntoa(ip_2_ip6(addr)) : ip4addr_ntoa(ip_2_ip4(addr))))
|
||||
((IP_IS_V6(addr)) ? ip6addr_ntoa(ip_2_ip6(addr)) : ip4addr_ntoa(ip_2_ip4(addr))))
|
||||
/** @ingroup ipaddr */
|
||||
#define ipaddr_ntoa_r(addr, buf, buflen) (((addr) == NULL) ? "NULL" : \
|
||||
((IP_IS_V6(addr)) ? ip6addr_ntoa_r(ip_2_ip6(addr), buf, buflen) : ip4addr_ntoa_r(ip_2_ip4(addr), buf, buflen)))
|
||||
((IP_IS_V6(addr)) ? ip6addr_ntoa_r(ip_2_ip6(addr), buf, buflen) : ip4addr_ntoa_r(ip_2_ip4(addr), buf, buflen)))
|
||||
int ipaddr_aton(const char *cp, ip_addr_t *addr);
|
||||
|
||||
/** @ingroup ipaddr */
|
||||
@@ -1068,14 +1064,14 @@ int ipaddr_aton(const char *cp, ip_addr_t *addr);
|
||||
|
||||
/** @ingroup ipaddr */
|
||||
#define ip4_2_ipv4_mapped_ipv6(ip6addr, ip4addr) do { \
|
||||
(ip6addr)->addr[3] = (ip4addr)->addr; \
|
||||
(ip6addr)->addr[2] = PP_HTONL(0x0000FFFFUL); \
|
||||
(ip6addr)->addr[1] = 0; \
|
||||
(ip6addr)->addr[0] = 0; } while(0);
|
||||
(ip6addr)->addr[3] = (ip4addr)->addr; \
|
||||
(ip6addr)->addr[2] = PP_HTONL(0x0000FFFFUL); \
|
||||
(ip6addr)->addr[1] = 0; \
|
||||
(ip6addr)->addr[0] = 0; } while(0);
|
||||
|
||||
/** @ingroup ipaddr */
|
||||
#define unmap_ipv4_mapped_ipv6(ip4addr, ip6addr) \
|
||||
(ip4addr)->addr = (ip6addr)->addr[3];
|
||||
(ip4addr)->addr = (ip6addr)->addr[3];
|
||||
|
||||
#define IP46_ADDR_ANY(type) (((type) == IPADDR_TYPE_V6) ? IP6_ADDR_ANY : IP4_ADDR_ANY)
|
||||
|
||||
@@ -1189,11 +1185,11 @@ typedef ip6_addr_t ip_addr_t;
|
||||
/** @ingroup socket */
|
||||
#define inet_ntop(af, src, dst, size) \
|
||||
(((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src), (dst), (size)) \
|
||||
: (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src), (dst), (size)) : NULL))
|
||||
: (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src), (dst), (size)) : NULL))
|
||||
/** @ingroup socket */
|
||||
#define inet_pton(af, src, dst) \
|
||||
(((af) == AF_INET6) ? ip6addr_aton((src), (ip6_addr_t*)(dst)) \
|
||||
: (((af) == AF_INET) ? ip4addr_aton((src), (ip4_addr_t*)(dst)) : 0))
|
||||
: (((af) == AF_INET) ? ip4addr_aton((src), (ip4_addr_t*)(dst)) : 0))
|
||||
#elif TLS_CONFIG_IPV4 /* TLS_CONFIG_IPV4 && TLS_CONFIG_IPV6 */
|
||||
#define inet_ntop(af, src, dst, size) \
|
||||
(((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src), (dst), (size)) : NULL)
|
||||
@@ -1212,11 +1208,11 @@ typedef ip6_addr_t ip_addr_t;
|
||||
/** @ingroup socket */
|
||||
#define inet_ntop(af, src, dst, size) \
|
||||
(((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src), (dst), (size)) \
|
||||
: (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src), (dst), (size)) : NULL))
|
||||
: (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src), (dst), (size)) : NULL))
|
||||
/** @ingroup socket */
|
||||
#define inet_pton(af, src, dst) \
|
||||
(((af) == AF_INET6) ? ip6addr_aton((src), (ip6_addr_t*)(dst)) \
|
||||
: (((af) == AF_INET) ? ip4addr_aton((src), (ip4_addr_t*)(dst)) : -1))
|
||||
: (((af) == AF_INET) ? ip4addr_aton((src), (ip4_addr_t*)(dst)) : -1))
|
||||
#elif TLS_CONFIG_IPV4 /* TLS_CONFIG_IPV4 && TLS_CONFIG_IPV6 */
|
||||
#define inet_ntop(af, src, dst, size) \
|
||||
(((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src), (dst), (size)) : NULL)
|
||||
|
||||
@@ -152,7 +152,7 @@ s8 tls_wl_task_untimeout(struct task_parameter *task_param, tls_timeout_handler
|
||||
if (tls_mbox_valid(task_mbox[task_param->mbox_id])) {
|
||||
msg = (struct task_msg *)tls_mem_alloc(sizeof(struct task_msg));
|
||||
if (msg == NULL) {
|
||||
return TLS_OS_ERROR;
|
||||
return TLS_OS_ERROR;
|
||||
}
|
||||
|
||||
msg->type = TASK_MSG_UNTIMEOUT;
|
||||
@@ -161,7 +161,7 @@ s8 tls_wl_task_untimeout(struct task_parameter *task_param, tls_timeout_handler
|
||||
tls_mbox_post(task_mbox[task_param->mbox_id], msg);
|
||||
return TLS_OS_SUCCESS;
|
||||
}
|
||||
return TLS_OS_ERROR;
|
||||
return TLS_OS_ERROR;
|
||||
}
|
||||
|
||||
s8 tls_wl_task_init(void)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <ctype.h>
|
||||
#include "wm_config.h"
|
||||
#include "wm_cmdp.h"
|
||||
#if (GCC_COMPILE==1)
|
||||
#if (GCC_COMPILE == 1)
|
||||
#include "wm_cmdp_hostif_gcc.h"
|
||||
#else
|
||||
#include "wm_cmdp_hostif.h"
|
||||
@@ -53,7 +53,8 @@ extern const char HwVer[TEN];
|
||||
tls_os_timer_t *RSTTIMER = NULL;
|
||||
|
||||
u8 gfwupdatemode = 0;
|
||||
u8 tls_get_fwup_mode(void) {
|
||||
u8 tls_get_fwup_mode(void)
|
||||
{
|
||||
return gfwupdatemode;
|
||||
}
|
||||
|
||||
@@ -308,7 +309,7 @@ int tls_cmd_create_net(void)
|
||||
|
||||
int tls_cmd_create_ibss_net(void)
|
||||
{
|
||||
int ret=CMD_ERR_UNSUPP;
|
||||
int ret = CMD_ERR_UNSUPP;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -381,8 +382,8 @@ int tls_cmd_get_wireless_mode(u8 *mode)
|
||||
int err = 0;
|
||||
u8 wmode = 0;
|
||||
|
||||
tls_param_get(TLS_PARAM_ID_WPROTOCOL, (void* )&wmode, TRUE);
|
||||
/* set WPAS_MODE to do*/
|
||||
tls_param_get(TLS_PARAM_ID_WPROTOCOL, (void *)&wmode, TRUE);
|
||||
/* set WPAS_MODE to do */
|
||||
switch (wmode) {
|
||||
case IEEE80211_MODE_INFRA:
|
||||
*mode = 0;
|
||||
@@ -544,8 +545,8 @@ int tls_cmd_get_original_ssid(struct tls_param_ssid *original_ssid)
|
||||
{
|
||||
tls_param_get(TLS_PARAM_ID_ORIGIN_SSID, (void *)original_ssid, 1);
|
||||
if (original_ssid->ssid_len > THIRTY_TWO) {
|
||||
original_ssid->ssid_len = 0;
|
||||
original_ssid->ssid[0] = '\0';
|
||||
original_ssid->ssid_len = 0;
|
||||
original_ssid->ssid[0] = '\0';
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1019,7 +1020,7 @@ int tls_cmd_set_sha1(u8* psk, u8 update_flash)
|
||||
|
||||
int tls_cmd_get_sha1(u8 *psk)
|
||||
{
|
||||
tls_param_get(TLS_PARAM_ID_SHA1, (void *)psk,1);
|
||||
tls_param_get(TLS_PARAM_ID_SHA1, (void *)psk, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1032,7 +1033,7 @@ int tls_cmd_set_wps_pin(struct tls_param_wps* wps, u8 update_flash)
|
||||
|
||||
int tls_cmd_get_wps_pin(struct tls_param_wps *wps)
|
||||
{
|
||||
tls_param_get(TLS_PARAM_ID_WPS, (void *)wps,1);
|
||||
tls_param_get(TLS_PARAM_ID_WPS, (void *)wps, 1);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -1089,7 +1090,7 @@ int tls_cmd_wr_flash(struct tls_cmd_flash_t *wr_flash)
|
||||
{
|
||||
u8 data[TWENTY_FOUR];
|
||||
tls_fls_write(wr_flash->flash_addr, (u8 *)wr_flash->value,
|
||||
sizeof(u32) * wr_flash->word_cnt);
|
||||
sizeof(u32) * wr_flash->word_cnt);
|
||||
|
||||
memset(data, 0, TWENTY_FOUR);
|
||||
tls_fls_read(wr_flash->flash_addr, data, TWENTY_FOUR);
|
||||
@@ -1215,7 +1216,7 @@ int tls_cmd_set_softap_encrypt(u8 encrypt, u8 update_flash)
|
||||
{
|
||||
struct tls_param_key param_key;
|
||||
|
||||
if (0 == encrypt) {
|
||||
if (encrypt == 0) {
|
||||
memset(param_key.psk, 0, SIXTY_FOUR);
|
||||
param_key.key_format = 0;
|
||||
param_key.key_index = 0;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -59,7 +59,7 @@ struct tls_netconn *get_server_conn(struct tls_netconn *conn)
|
||||
do {
|
||||
server_conn = dl_list_first(&conn->list, struct tls_netconn, list);
|
||||
conn = server_conn;
|
||||
} while((server_conn != NULL) && server_conn->client);
|
||||
} while ((server_conn != NULL) && server_conn->client);
|
||||
|
||||
return server_conn;
|
||||
}
|
||||
@@ -70,8 +70,7 @@ static struct tls_netconn *net_alloc_socket(struct tls_netconn *conn)
|
||||
u32 cpu_sr;
|
||||
struct tls_netconn *conn_t = NULL;
|
||||
|
||||
for (i = 0; i < TLS_MAX_NETCONN_NUM; i++)
|
||||
{
|
||||
for (i = 0; i < TLS_MAX_NETCONN_NUM; i++) {
|
||||
if (p_net_conn[i] == NULL) {
|
||||
sock = i;
|
||||
break;
|
||||
@@ -98,7 +97,7 @@ static struct tls_netconn *net_alloc_socket(struct tls_netconn *conn)
|
||||
cpu_sr = tls_os_set_critical();
|
||||
conn_t = tls_mem_alloc(sizeof(struct tls_netconn));
|
||||
tls_os_release_critical(cpu_sr);
|
||||
if (NULL != conn_t) {
|
||||
if (conn_t != NULL) {
|
||||
p_net_conn[sock] = conn_t;
|
||||
memset(conn_t, 0, sizeof(struct tls_netconn));
|
||||
conn_t->used = true;
|
||||
@@ -200,11 +199,11 @@ static void net_tcp_err_cb(void *arg, err_t err)
|
||||
tcp_accept(pcb, NULL);
|
||||
}
|
||||
if (err == ERR_OK) {
|
||||
tcp_close(pcb);
|
||||
tcp_close(pcb);
|
||||
}
|
||||
if (conn->state != NETCONN_STATE_NONE) {
|
||||
conn->state = NETCONN_STATE_NONE;
|
||||
event = NET_EVENT_TCP_DISCONNECT;
|
||||
conn->state = NETCONN_STATE_NONE;
|
||||
event = NET_EVENT_TCP_DISCONNECT;
|
||||
}
|
||||
|
||||
net_send_event_to_hostif (conn, event);
|
||||
@@ -236,7 +235,7 @@ static void raw_sk_free_pbuf_custom_fn(struct pbuf *p)
|
||||
|
||||
if (p != NULL) {
|
||||
if (TRUE == ((struct tls_netconn *)pcr->conn)->used &&
|
||||
pcr->pcb == ((struct tls_netconn *)pcr->conn)->pcb.tcp) {
|
||||
pcr->pcb == ((struct tls_netconn *)pcr->conn)->pcb.tcp) {
|
||||
tcp_recved((struct tcp_pcb *)pcr->pcb, p->tot_len);
|
||||
}
|
||||
|
||||
@@ -279,7 +278,7 @@ static err_t net_tcp_connect_cb(void *arg, struct tcp_pcb *pcb, err_t err)
|
||||
net_send_event_to_hostif(conn, NET_EVENT_TCP_CONNECTED);
|
||||
} else {
|
||||
TLS_DBGPRT_INFO("the err is =%d\n", err);
|
||||
}
|
||||
}
|
||||
|
||||
if (conn->skd != NULL && conn->skd->connf != NULL) {
|
||||
err_ret = conn->skd->connf(conn->skt_num, err);
|
||||
@@ -315,7 +314,7 @@ static void net_udp_recv_cb(void *arg, struct udp_pcb *pcb,
|
||||
LWIP_ASSERT("recv_udp must have an argument", arg < 0);
|
||||
socketno = (int)arg;
|
||||
conn = tls_net_get_socket(socketno);
|
||||
if (conn == NULL || conn->used != TRUE || NULL == pcb) {
|
||||
if (conn == NULL || conn->used != TRUE || pcb == NULL) {
|
||||
TLS_DBGPRT_ERR("\nconn=%x,used=%d\n", (u32)conn, conn->used);
|
||||
if (p != NULL) {
|
||||
pbuf_free(p);
|
||||
@@ -325,8 +324,9 @@ static void net_udp_recv_cb(void *arg, struct udp_pcb *pcb,
|
||||
LWIP_ASSERT("recv_udp: recv for wrong pcb!", conn->pcb.udp == pcb);
|
||||
if (conn->skd->recvf != NULL) {
|
||||
datalen = p->tot_len;
|
||||
/*if Address is broadcast, update source IP according to source address and source port according to sender*/
|
||||
if ((ip_addr_get_ip4_u32(&conn->addr) == IPADDR_BROADCAST) || ((ip_addr_get_ip4_u32(&conn->addr) & 0xFF) == 0xFF)) {
|
||||
/* if Address is broadcast, update source IP according to source address and source port according to sender */
|
||||
if ((ip_addr_get_ip4_u32(&conn->addr) == IPADDR_BROADCAST) ||
|
||||
((ip_addr_get_ip4_u32(&conn->addr) & 0xFF) == 0xFF)) {
|
||||
tls_net_set_sourceip(ip_addr_get_ip4_u32(srcaddr));
|
||||
conn->port = port;
|
||||
} else {
|
||||
@@ -389,7 +389,7 @@ static err_t net_skt_tcp_send(struct tls_net_msg *net_msg)
|
||||
}
|
||||
|
||||
/**
|
||||
* Send data on a UDP pcb
|
||||
* Send data on a UDP pcb
|
||||
*/
|
||||
static void net_do_send(void *ctx)
|
||||
{
|
||||
@@ -522,7 +522,7 @@ static void do_create_connect(void *ctx)
|
||||
net_free_socket(socketno);
|
||||
} else {
|
||||
conn->state = NETCONN_STATE_CONNECTED;
|
||||
net_send_event_to_hostif (conn, NET_EVENT_UDP_START);
|
||||
net_send_event_to_hostif (conn, NET_EVENT_UDP_START);
|
||||
}
|
||||
break;
|
||||
case TLS_NETCONN_TCP:
|
||||
@@ -580,8 +580,7 @@ static void do_close_connect(void *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
while(i-->0)
|
||||
{
|
||||
while(i-- > 0) {
|
||||
net_tcp_close_connect(sktNums[i]);
|
||||
}
|
||||
}
|
||||
@@ -652,7 +651,6 @@ int tls_socket_udp_sendto(u16 localport, u8 *ip_addr, u16 port, void *pdata, u1
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int tls_socket_send(u8 skt_num, void *pdata, u16 len)
|
||||
{
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user