37 #ifndef LWIP_HDR_API_H
38 #define LWIP_HDR_API_H
42 #if LWIP_NETCONN || LWIP_SOCKET
61 #define NETCONN_NOFLAG 0x00
62 #define NETCONN_NOCOPY 0x00
63 #define NETCONN_COPY 0x01
64 #define NETCONN_MORE 0x02
65 #define NETCONN_DONTBLOCK 0x04
66 #define NETCONN_NOAUTORCVD 0x08
67 #define NETCONN_NOFIN 0x10
71 #define NETCONN_FLAG_MBOXCLOSED 0x01
73 #define NETCONN_FLAG_NON_BLOCKING 0x02
75 #define NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04
76 #if LWIP_NETCONN_FULLDUPLEX
78 #define NETCONN_FLAG_MBOXINVALID 0x08
82 #define NETCONN_FLAG_CHECK_WRITESPACE 0x10
87 #define NETCONN_FLAG_IPV6_V6ONLY 0x20
89 #if LWIP_NETBUF_RECVINFO
91 #define NETCONN_FLAG_PKTINFO 0x40
94 #define NETCONN_FIN_RX_PENDING 0x80
97 #define NETCONNTYPE_GROUP(t) ((t)&0xF0)
98 #define NETCONNTYPE_DATAGRAM(t) ((t)&0xE0)
100 #define NETCONN_TYPE_IPV6 0x08
101 #define NETCONNTYPE_ISIPV6(t) (((t)&NETCONN_TYPE_IPV6) != 0)
102 #define NETCONNTYPE_ISUDPLITE(t) (((t)&0xF3) == NETCONN_UDPLITE)
103 #define NETCONNTYPE_ISUDPNOCHKSUM(t) (((t)&0xF3) == NETCONN_UDPNOCHKSUM)
105 #define NETCONNTYPE_ISIPV6(t) (0)
106 #define NETCONNTYPE_ISUDPLITE(t) ((t) == NETCONN_UDPLITE)
107 #define NETCONNTYPE_ISUDPNOCHKSUM(t) ((t) == NETCONN_UDPNOCHKSUM)
119 NETCONN_TCP_IPV6 = NETCONN_TCP | NETCONN_TYPE_IPV6 ,
124 NETCONN_UDPLITE = 0x21,
126 NETCONN_UDPNOCHKSUM = 0x22,
130 NETCONN_UDP_IPV6 = NETCONN_UDP | NETCONN_TYPE_IPV6 ,
132 NETCONN_UDPLITE_IPV6 = NETCONN_UDPLITE | NETCONN_TYPE_IPV6 ,
134 NETCONN_UDPNOCHKSUM_IPV6 = NETCONN_UDPNOCHKSUM | NETCONN_TYPE_IPV6 ,
141 , NETCONN_RAW_IPV6 = NETCONN_RAW | NETCONN_TYPE_IPV6
183 NETCONN_EVT_RCVMINUS,
184 NETCONN_EVT_SENDPLUS,
185 NETCONN_EVT_SENDMINUS,
189 #if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
199 #define NETCONN_DNS_DEFAULT NETCONN_DNS_IPV4_IPV6
200 #define NETCONN_DNS_IPV4 0
201 #define NETCONN_DNS_IPV6 1
202 #define NETCONN_DNS_IPV4_IPV6 2
203 #define NETCONN_DNS_IPV6_IPV4 3
215 typedef void (* netconn_callback)(
struct netconn *,
enum netconn_evt,
u16_t len);
220 enum netconn_type type;
222 enum netconn_state state;
232 #if !LWIP_NETCONN_SEM_PER_THREAD
244 #if LWIP_NETCONN_FULLDUPLEX
247 int mbox_threads_waiting;
282 struct api_msg *current_msg;
285 netconn_callback callback;
301 #define API_EVENT(c,e,l) if (c->callback) { \
302 (*c->callback)(c, e, l); \
310 #define netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL)
311 #define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c)
312 struct netconn *netconn_new_with_proto_and_callback(
enum netconn_type t,
u8_t proto,
313 netconn_callback callback);
314 err_t netconn_prepare_delete(
struct netconn *conn);
315 err_t netconn_delete(
struct netconn *conn);
317 #define netconn_type(conn) (conn->type)
322 #define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0)
324 #define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1)
327 err_t netconn_bind_if(
struct netconn *conn,
u8_t if_idx);
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_udp_raw_netbuf(
struct netconn *conn,
struct netbuf **new_buf);
336 err_t netconn_recv_udp_raw_netbuf_flags(
struct netconn *conn,
struct netbuf **new_buf,
u8_t apiflags);
337 err_t netconn_recv_tcp_pbuf(
struct netconn *conn,
struct pbuf **new_buf);
338 err_t netconn_recv_tcp_pbuf_flags(
struct netconn *conn,
struct pbuf **new_buf,
u8_t apiflags);
339 err_t netconn_tcp_recvd(
struct netconn *conn,
size_t len);
340 err_t netconn_sendto(
struct netconn *conn,
struct netbuf *buf,
342 err_t netconn_send(
struct netconn *conn,
struct netbuf *buf);
343 err_t netconn_write_partly(
struct netconn *conn,
const void *dataptr,
size_t size,
344 u8_t apiflags,
size_t *bytes_written);
345 err_t netconn_write_vectors_partly(
struct netconn *conn,
struct netvector *vectors,
u16_t vectorcnt,
346 u8_t apiflags,
size_t *bytes_written);
348 #define netconn_write(conn, dataptr, size, apiflags) \
349 netconn_write_partly(conn, dataptr, size, apiflags, NULL)
350 err_t netconn_close(
struct netconn *conn);
351 err_t netconn_shutdown(
struct netconn *conn,
u8_t shut_rx,
u8_t shut_tx);
353 #if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
354 err_t netconn_join_leave_group(
struct netconn *conn,
const ip_addr_t *multiaddr,
355 const ip_addr_t *netif_addr,
enum netconn_igmp join_or_leave);
356 err_t netconn_join_leave_group_netif(
struct netconn *conn,
const ip_addr_t *multiaddr,
357 u8_t if_idx,
enum netconn_igmp join_or_leave);
360 #if LWIP_IPV4 && LWIP_IPV6
361 err_t netconn_gethostbyname_addrtype(
const char *name,
ip_addr_t *addr,
u8_t dns_addrtype);
362 #define netconn_gethostbyname(name, addr) netconn_gethostbyname_addrtype(name, addr, NETCONN_DNS_DEFAULT)
365 #define netconn_gethostbyname_addrtype(name, addr, dns_addrtype) netconn_gethostbyname(name, addr)
369 err_t netconn_err(
struct netconn *conn);
370 #define netconn_recv_bufsize(conn) ((conn)->recv_bufsize)
372 #define netconn_set_flags(conn, set_flags) do { (conn)->flags = (u8_t)((conn)->flags | (set_flags)); } while(0)
373 #define netconn_clear_flags(conn, clr_flags) do { (conn)->flags = (u8_t)((conn)->flags & (u8_t)(~(clr_flags) & 0xff)); } while(0)
374 #define netconn_is_flag_set(conn, flag) (((conn)->flags & (flag)) != 0)
377 #define netconn_set_nonblocking(conn, val) do { if(val) { \
378 netconn_set_flags(conn, NETCONN_FLAG_NON_BLOCKING); \
380 netconn_clear_flags(conn, NETCONN_FLAG_NON_BLOCKING); }} while(0)
382 #define netconn_is_nonblocking(conn) (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0)
388 #define netconn_set_ipv6only(conn, val) do { if(val) { \
389 netconn_set_flags(conn, NETCONN_FLAG_IPV6_V6ONLY); \
391 netconn_clear_flags(conn, NETCONN_FLAG_IPV6_V6ONLY); }} while(0)
395 #define netconn_get_ipv6only(conn) (((conn)->flags & NETCONN_FLAG_IPV6_V6ONLY) != 0)
400 #define netconn_set_sendtimeout(conn, timeout) ((conn)->send_timeout = (timeout))
402 #define netconn_get_sendtimeout(conn) ((conn)->send_timeout)
406 #define netconn_set_recvtimeout(conn, timeout) ((conn)->recv_timeout = (timeout))
408 #define netconn_get_recvtimeout(conn) ((conn)->recv_timeout)
412 #define netconn_set_recvbufsize(conn, recvbufsize) ((conn)->recv_bufsize = (recvbufsize))
414 #define netconn_get_recvbufsize(conn) ((conn)->recv_bufsize)
417 #if LWIP_NETCONN_SEM_PER_THREAD
418 void netconn_thread_init(
void);
419 void netconn_thread_cleanup(
void);
421 #define netconn_thread_init()
422 #define netconn_thread_cleanup()
int32_t s32_t
Definition: arch.h:130
uint32_t u32_t
Definition: arch.h:129
uint8_t u8_t
Definition: arch.h:125
uint16_t u16_t
Definition: arch.h:127
int16_t s16_t
Definition: arch.h:128
s8_t err_t
Definition: err.h:96
ip6_addr_t ip_addr_t
Definition: ip_addr.h:318
osMessageQId sys_mbox_t
Definition: sys_arch.h:54
osSemaphoreId sys_sem_t
Definition: sys_arch.h:52