56 #ifndef LWIP_HDR_API_H 57 #define LWIP_HDR_API_H 61 #if LWIP_NETCONN || LWIP_SOCKET 80 #define NETCONN_NOFLAG 0x00 81 #define NETCONN_NOCOPY 0x00 82 #define NETCONN_COPY 0x01 83 #define NETCONN_MORE 0x02 84 #define NETCONN_DONTBLOCK 0x04 88 #define NETCONN_FLAG_NON_BLOCKING 0x02 90 #define NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04 93 #define NETCONN_FLAG_CHECK_WRITESPACE 0x10 98 #define NETCONN_FLAG_IPV6_V6ONLY 0x20 103 #define NETCONNTYPE_GROUP(t) ((t)&0xF0) 104 #define NETCONNTYPE_DATAGRAM(t) ((t)&0xE0) 106 #define NETCONN_TYPE_IPV6 0x08 107 #define NETCONNTYPE_ISIPV6(t) (((t)&NETCONN_TYPE_IPV6) != 0) 108 #define NETCONNTYPE_ISUDPLITE(t) (((t)&0xF3) == NETCONN_UDPLITE) 109 #define NETCONNTYPE_ISUDPNOCHKSUM(t) (((t)&0xF3) == NETCONN_UDPNOCHKSUM) 111 #define NETCONNTYPE_ISIPV6(t) (0) 112 #define NETCONNTYPE_ISUDPLITE(t) ((t) == NETCONN_UDPLITE) 113 #define NETCONNTYPE_ISUDPNOCHKSUM(t) ((t) == NETCONN_UDPNOCHKSUM) 125 NETCONN_TCP_IPV6 = NETCONN_TCP | NETCONN_TYPE_IPV6 ,
130 NETCONN_UDPLITE = 0x21,
132 NETCONN_UDPNOCHKSUM = 0x22,
136 NETCONN_UDP_IPV6 = NETCONN_UDP | NETCONN_TYPE_IPV6 ,
138 NETCONN_UDPLITE_IPV6 = NETCONN_UDPLITE | NETCONN_TYPE_IPV6 ,
140 NETCONN_UDPNOCHKSUM_IPV6 = NETCONN_UDPNOCHKSUM | NETCONN_TYPE_IPV6 ,
147 , NETCONN_RAW_IPV6 = NETCONN_RAW | NETCONN_TYPE_IPV6
189 NETCONN_EVT_RCVMINUS,
190 NETCONN_EVT_SENDPLUS,
191 NETCONN_EVT_SENDMINUS,
195 #if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) 205 #define NETCONN_DNS_DEFAULT NETCONN_DNS_IPV4_IPV6 206 #define NETCONN_DNS_IPV4 0 207 #define NETCONN_DNS_IPV6 1 208 #define NETCONN_DNS_IPV4_IPV6 2 209 #define NETCONN_DNS_IPV6_IPV4 3 221 typedef void (* netconn_callback)(
struct netconn *,
enum netconn_evt, u16_t len);
226 enum netconn_type type;
228 enum netconn_state state;
238 #if !LWIP_NETCONN_SEM_PER_THREAD 240 sys_sem_t op_completed;
286 struct api_msg *current_msg;
289 netconn_callback callback;
293 #define API_EVENT(c,e,l) if (c->callback) { \ 294 (*c->callback)(c, e, l); \ 298 #define NETCONN_SET_SAFE_ERR(conn, err) do { if ((conn) != NULL) { \ 299 SYS_ARCH_DECL_PROTECT(netconn_set_safe_err_lev); \ 300 SYS_ARCH_PROTECT(netconn_set_safe_err_lev); \ 301 if (!ERR_IS_FATAL((conn)->last_err)) { \ 302 (conn)->last_err = err; \ 304 SYS_ARCH_UNPROTECT(netconn_set_safe_err_lev); \ 312 #define netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL) 313 #define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c) 314 struct netconn *netconn_new_with_proto_and_callback(
enum netconn_type t, u8_t proto,
315 netconn_callback callback);
316 err_t netconn_delete(
struct netconn *conn);
318 #define netconn_type(conn) (conn->type) 320 err_t netconn_getaddr(
struct netconn *conn, ip_addr_t *addr,
321 u16_t *port, u8_t local);
323 #define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0) 325 #define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1) 327 err_t netconn_bind(
struct netconn *conn,
const ip_addr_t *addr, u16_t port);
328 err_t netconn_connect(
struct netconn *conn,
const ip_addr_t *addr, u16_t port);
329 err_t netconn_disconnect (
struct netconn *conn);
330 err_t netconn_listen_with_backlog(
struct netconn *conn, u8_t backlog);
332 #define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG) 333 err_t netconn_accept(
struct netconn *conn,
struct netconn **new_conn);
334 err_t netconn_recv(
struct netconn *conn,
struct netbuf **new_buf);
335 err_t netconn_recv_tcp_pbuf(
struct netconn *conn,
struct pbuf **new_buf);
336 err_t netconn_sendto(
struct netconn *conn,
struct netbuf *buf,
337 const ip_addr_t *addr, u16_t port);
338 err_t netconn_send(
struct netconn *conn,
struct netbuf *buf);
339 err_t netconn_write_partly(
struct netconn *conn,
const void *dataptr,
size_t size,
340 u8_t apiflags,
size_t *bytes_written);
342 #define netconn_write(conn, dataptr, size, apiflags) \ 343 netconn_write_partly(conn, dataptr, size, apiflags, NULL) 344 err_t netconn_close(
struct netconn *conn);
345 err_t netconn_shutdown(
struct netconn *conn, u8_t shut_rx, u8_t shut_tx);
347 #if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) 348 err_t netconn_join_leave_group(
struct netconn *conn,
const ip_addr_t *multiaddr,
349 const ip_addr_t *netif_addr,
enum netconn_igmp join_or_leave);
352 #if LWIP_IPV4 && LWIP_IPV6 353 err_t netconn_gethostbyname_addrtype(
const char *name, ip_addr_t *addr, u8_t dns_addrtype);
354 #define netconn_gethostbyname(name, addr) netconn_gethostbyname_addrtype(name, addr, NETCONN_DNS_DEFAULT) 356 err_t netconn_gethostbyname(
const char *name, ip_addr_t *addr);
357 #define netconn_gethostbyname_addrtype(name, addr, dns_addrtype) netconn_gethostbyname(name, addr) 361 #define netconn_err(conn) ((conn)->last_err) 362 #define netconn_recv_bufsize(conn) ((conn)->recv_bufsize) 365 #define netconn_set_nonblocking(conn, val) do { if(val) { \ 366 (conn)->flags |= NETCONN_FLAG_NON_BLOCKING; \ 368 (conn)->flags &= ~ NETCONN_FLAG_NON_BLOCKING; }} while(0) 370 #define netconn_is_nonblocking(conn) (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0) 376 #define netconn_set_ipv6only(conn, val) do { if(val) { \ 377 (conn)->flags |= NETCONN_FLAG_IPV6_V6ONLY; \ 379 (conn)->flags &= ~ NETCONN_FLAG_IPV6_V6ONLY; }} while(0) 383 #define netconn_get_ipv6only(conn) (((conn)->flags & NETCONN_FLAG_IPV6_V6ONLY) != 0) 388 #define netconn_set_sendtimeout(conn, timeout) ((conn)->send_timeout = (timeout)) 390 #define netconn_get_sendtimeout(conn) ((conn)->send_timeout) 394 #define netconn_set_recvtimeout(conn, timeout) ((conn)->recv_timeout = (timeout)) 396 #define netconn_get_recvtimeout(conn) ((conn)->recv_timeout) 400 #define netconn_set_recvbufsize(conn, recvbufsize) ((conn)->recv_bufsize = (recvbufsize)) 402 #define netconn_get_recvbufsize(conn) ((conn)->recv_bufsize) 405 #if LWIP_NETCONN_SEM_PER_THREAD 406 void netconn_thread_init(
void);
407 void netconn_thread_cleanup(
void);
409 #define netconn_thread_init() 410 #define netconn_thread_cleanup()