32 #ifndef LWIP_HDR_API_H 33 #define LWIP_HDR_API_H 37 #if LWIP_NETCONN || LWIP_SOCKET 57 #define NETCONN_NOFLAG 0x00 58 #define NETCONN_NOCOPY 0x00 59 #define NETCONN_COPY 0x01 60 #define NETCONN_MORE 0x02 61 #define NETCONN_DONTBLOCK 0x04 65 #define NETCONN_FLAG_NON_BLOCKING 0x02 67 #define NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04 70 #define NETCONN_FLAG_NO_AUTO_RECVED 0x08 73 #define NETCONN_FLAG_CHECK_WRITESPACE 0x10 78 #define NETCONN_FLAG_IPV6_V6ONLY 0x20 83 #define NETCONNTYPE_GROUP(t) ((t)&0xF0) 84 #define NETCONNTYPE_DATAGRAM(t) ((t)&0xE0) 86 #define NETCONN_TYPE_IPV6 0x08 87 #define NETCONNTYPE_ISIPV6(t) ((t)&0x08) 88 #define NETCONNTYPE_ISUDPLITE(t) (((t)&0xF7) == NETCONN_UDPLITE) 89 #define NETCONNTYPE_ISUDPNOCHKSUM(t) (((t)&0xF7) == NETCONN_UDPNOCHKSUM) 91 #define NETCONNTYPE_ISUDPLITE(t) ((t) == NETCONN_UDPLITE) 92 #define NETCONNTYPE_ISUDPNOCHKSUM(t) ((t) == NETCONN_UDPNOCHKSUM) 101 NETCONN_TCP_IPV6 = NETCONN_TCP | NETCONN_TYPE_IPV6 ,
105 NETCONN_UDPLITE = 0x21,
106 NETCONN_UDPNOCHKSUM = 0x22,
108 NETCONN_UDP_IPV6 = NETCONN_UDP | NETCONN_TYPE_IPV6 ,
109 NETCONN_UDPLITE_IPV6 = NETCONN_UDPLITE | NETCONN_TYPE_IPV6 ,
110 NETCONN_UDPNOCHKSUM_IPV6 = NETCONN_UDPNOCHKSUM | NETCONN_TYPE_IPV6 ,
116 NETCONN_RAW_IPV6 = NETCONN_RAW | NETCONN_TYPE_IPV6
133 NETCONN_EVT_RCVMINUS,
134 NETCONN_EVT_SENDPLUS,
135 NETCONN_EVT_SENDMINUS,
139 #if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) 149 #define NETCONN_DNS_DEFAULT NETCONN_DNS_IPV4_IPV6 150 #define NETCONN_DNS_IPV4 0 151 #define NETCONN_DNS_IPV6 1 152 #define NETCONN_DNS_IPV4_IPV6 2 153 #define NETCONN_DNS_IPV6_IPV4 3 165 typedef void (* netconn_callback)(
struct netconn *,
enum netconn_evt,
u16_t len);
170 enum netconn_type type;
172 enum netconn_state state;
182 #if !LWIP_NETCONN_SEM_PER_THREAD 230 struct api_msg_msg *current_msg;
233 netconn_callback callback;
237 #define API_EVENT(c,e,l) if (c->callback) { \ 238 (*c->callback)(c, e, l); \ 242 #define NETCONN_SET_SAFE_ERR(conn, err) do { if ((conn) != NULL) { \ 243 SYS_ARCH_DECL_PROTECT(netconn_set_safe_err_lev); \ 244 SYS_ARCH_PROTECT(netconn_set_safe_err_lev); \ 245 if (!ERR_IS_FATAL((conn)->last_err)) { \ 246 (conn)->last_err = err; \ 248 SYS_ARCH_UNPROTECT(netconn_set_safe_err_lev); \ 252 #define netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL) 253 #define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c) 254 struct netconn *netconn_new_with_proto_and_callback(
enum netconn_type t,
u8_t proto,
255 netconn_callback callback);
256 err_t netconn_delete(
struct netconn *conn);
258 #define netconn_type(conn) (conn->type) 262 #define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0) 263 #define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1) 267 err_t netconn_disconnect (
struct netconn *conn);
268 err_t netconn_listen_with_backlog(
struct netconn *conn,
u8_t backlog);
269 #define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG) 270 err_t netconn_accept(
struct netconn *conn,
struct netconn **new_conn);
271 err_t netconn_recv(
struct netconn *conn,
struct netbuf **new_buf);
272 err_t netconn_recv_tcp_pbuf(
struct netconn *conn,
struct pbuf **new_buf);
273 void netconn_recved(
struct netconn *conn,
u32_t length);
274 err_t netconn_sendto(
struct netconn *conn,
struct netbuf *buf,
276 err_t netconn_send(
struct netconn *conn,
struct netbuf *buf);
277 err_t netconn_write_partly(
struct netconn *conn,
const void *dataptr,
size_t size,
278 u8_t apiflags,
size_t *bytes_written);
279 #define netconn_write(conn, dataptr, size, apiflags) \ 280 netconn_write_partly(conn, dataptr, size, apiflags, NULL) 281 err_t netconn_close(
struct netconn *conn);
282 err_t netconn_shutdown(
struct netconn *conn,
u8_t shut_rx,
u8_t shut_tx);
284 #if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) 285 err_t netconn_join_leave_group(
struct netconn *conn,
const ip_addr_t *multiaddr,
286 const ip_addr_t *netif_addr,
enum netconn_igmp join_or_leave);
289 #if LWIP_IPV4 && LWIP_IPV6 290 err_t netconn_gethostbyname_addrtype(
const char *name,
ip_addr_t *addr,
u8_t dns_addrtype);
291 #define netconn_gethostbyname(name, addr) netconn_gethostbyname_addrtype(name, addr, NETCONN_DNS_DEFAULT) 294 #define netconn_gethostbyname_addrtype(name, addr, dns_addrtype) netconn_gethostbyname(name, addr) 298 #define netconn_err(conn) ((conn)->last_err) 299 #define netconn_recv_bufsize(conn) ((conn)->recv_bufsize) 302 #define netconn_set_nonblocking(conn, val) do { if(val) { \ 303 (conn)->flags |= NETCONN_FLAG_NON_BLOCKING; \ 305 (conn)->flags &= ~ NETCONN_FLAG_NON_BLOCKING; }} while(0) 307 #define netconn_is_nonblocking(conn) (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0) 310 #define netconn_set_noautorecved(conn, val) do { if(val) { \ 311 (conn)->flags |= NETCONN_FLAG_NO_AUTO_RECVED; \ 313 (conn)->flags &= ~ NETCONN_FLAG_NO_AUTO_RECVED; }} while(0) 315 #define netconn_get_noautorecved(conn) (((conn)->flags & NETCONN_FLAG_NO_AUTO_RECVED) != 0) 319 #define netconn_set_sendtimeout(conn, timeout) ((conn)->send_timeout = (timeout)) 321 #define netconn_get_sendtimeout(conn) ((conn)->send_timeout) 325 #define netconn_set_recvtimeout(conn, timeout) ((conn)->recv_timeout = (timeout)) 327 #define netconn_get_recvtimeout(conn) ((conn)->recv_timeout) 331 #define netconn_set_recvbufsize(conn, recvbufsize) ((conn)->recv_bufsize = (recvbufsize)) 333 #define netconn_get_recvbufsize(conn) ((conn)->recv_bufsize) 336 #if LWIP_NETCONN_SEM_PER_THREAD 337 void netconn_thread_init(
void);
338 void netconn_thread_cleanup(
void);
340 #define netconn_thread_init() 341 #define netconn_thread_cleanup()