68 netconn_new_with_proto_and_callback(
enum netconn_type t,
u8_t proto, netconn_callback callback)
73 conn = netconn_alloc(t, callback);
75 msg.function = do_newconn;
76 msg.msg.msg.n.proto = proto;
103 netconn_delete(
struct netconn *conn)
112 msg.function = do_delconn;
144 msg.function = do_getaddr;
146 msg.msg.msg.ad.ipaddr = addr;
147 msg.msg.msg.ad.port = port;
148 msg.msg.msg.ad.local = local;
151 NETCONN_SET_SAFE_ERR(conn, err);
173 msg.function = do_bind;
175 msg.msg.msg.bc.ipaddr = addr;
176 msg.msg.msg.bc.port = port;
179 NETCONN_SET_SAFE_ERR(conn, err);
192 netconn_connect(
struct netconn *conn,
ip_addr_t *addr,
u16_t port)
199 msg.function = do_connect;
201 msg.msg.msg.bc.ipaddr = addr;
202 msg.msg.msg.bc.port = port;
204 err = tcpip_apimsg(&msg);
206 NETCONN_SET_SAFE_ERR(conn, err);
217 netconn_disconnect(
struct netconn *conn)
224 msg.function = do_disconnect;
228 NETCONN_SET_SAFE_ERR(conn, err);
241 netconn_listen_with_backlog(
struct netconn *conn,
u8_t backlog)
252 msg.function = do_listen;
254 #if TCP_LISTEN_BACKLOG
255 msg.msg.msg.lb.backlog = backlog;
259 NETCONN_SET_SAFE_ERR(conn, err);
277 netconn_accept(
struct netconn *conn,
struct netconn **new_conn)
280 struct netconn *newconn;
282 #if TCP_LISTEN_BACKLOG
291 err = conn->last_err;
307 API_EVENT(conn, NETCONN_EVT_RCVMINUS, 0);
309 if (newconn ==
NULL) {
311 NETCONN_SET_SAFE_ERR(conn,
ERR_CLSD);
314 #if TCP_LISTEN_BACKLOG
316 msg.function = do_recv;
342 netconn_recv_data(
struct netconn *conn,
void **new_buf)
356 err = conn->last_err;
375 if (conn->type == NETCONN_TCP) {
376 if (!netconn_get_noautorecved(conn) || (buf ==
NULL)) {
380 msg.function = do_recv;
383 msg.msg.msg.r.len = ((
struct pbuf *)buf)->tot_len;
385 msg.msg.msg.r.len = 1;
393 API_EVENT(conn, NETCONN_EVT_RCVMINUS, 0);
395 NETCONN_SET_SAFE_ERR(conn,
ERR_CLSD);
398 len = ((
struct pbuf *)buf)->tot_len;
401 #if LWIP_TCP && (LWIP_UDP || LWIP_RAW)
404 #if (LWIP_UDP || LWIP_RAW)
415 API_EVENT(conn, NETCONN_EVT_RCVMINUS, len);
434 netconn_recv_tcp_pbuf(
struct netconn *conn,
struct pbuf **new_buf)
437 netconn_type(conn) == NETCONN_TCP,
return ERR_ARG;);
439 return netconn_recv_data(conn, (
void **)new_buf);
451 netconn_recv(
struct netconn *conn,
struct netbuf **new_buf)
464 if (conn->type == NETCONN_TCP) {
470 NETCONN_SET_SAFE_ERR(conn,
ERR_MEM);
474 err = netconn_recv_data(conn, (
void **)&p);
491 #if (LWIP_UDP || LWIP_RAW)
492 return netconn_recv_data(conn, (
void **)new_buf);
508 netconn_recved(
struct netconn *conn,
u32_t length)
511 if ((conn !=
NULL) && (conn->type == NETCONN_TCP) &&
512 (netconn_get_noautorecved(conn))) {
517 msg.function = do_recv;
519 msg.msg.msg.r.len = length;
545 return netconn_send(conn, buf);
558 netconn_send(
struct netconn *conn,
struct netbuf *buf)
566 msg.function = do_send;
571 NETCONN_SET_SAFE_ERR(conn, err);
588 netconn_write(
struct netconn *conn,
const void *dataptr,
size_t size,
u8_t apiflags)
594 LWIP_ERROR(
"netconn_write: invalid conn->type", (conn->type == NETCONN_TCP),
return ERR_VAL;);
601 msg.function = do_write;
603 msg.msg.msg.w.dataptr = dataptr;
604 msg.msg.msg.w.apiflags = apiflags;
605 msg.msg.msg.w.len = size;
611 NETCONN_SET_SAFE_ERR(conn, err);
623 netconn_close_shutdown(
struct netconn *conn,
u8_t how)
630 msg.function = do_close;
633 msg.msg.msg.sd.shut = how;
636 err = tcpip_apimsg(&msg);
638 NETCONN_SET_SAFE_ERR(conn, err);
649 netconn_close(
struct netconn *conn)
652 return netconn_close_shutdown(conn, NETCONN_SHUT_RDWR);
662 netconn_shutdown(
struct netconn *conn,
u8_t shut_rx,
u8_t shut_tx)
664 return netconn_close_shutdown(conn, (shut_rx ? NETCONN_SHUT_RD : 0) | (shut_tx ? NETCONN_SHUT_WR : 0));
679 netconn_join_leave_group(
struct netconn *conn,
682 enum netconn_igmp join_or_leave)
689 msg.function = do_join_leave_group;
691 msg.msg.msg.jl.multiaddr = multiaddr;
692 msg.msg.msg.jl.netif_addr = netif_addr;
693 msg.msg.msg.jl.join_or_leave = join_or_leave;
696 NETCONN_SET_SAFE_ERR(conn, err);
713 netconn_gethostbyname(
const char *name,
ip_addr_t *addr)
715 struct dns_api_msg msg;