Microchip® Advanced Software Framework

api.h File Reference
#include "lwip/opt.h"
#include <stddef.h>
#include "lwip/netbuf.h"
#include "lwip/sys.h"
#include "lwip/ip_addr.h"
#include "lwip/err.h"

Data Structures

struct  netconn
 A netconn descriptor. More...
 

Macros

#define API_EVENT(c, e, l)
 Register an Network connection event. More...
 
#define LWIP_NETCONN_SCOPE
 
#define netconn_addr(c, i, p)   netconn_getaddr(c,i,p,1)
 
#define netconn_bind_ip6(conn, ip6addr, port)
 
#define netconn_connect_ip6(conn, ip6addr, port)
 
#define NETCONN_COPY   0x01
 
#define NETCONN_DONTBLOCK   0x04
 
#define netconn_err(conn)   ((conn)->last_err)
 
#define NETCONN_FLAG_CHECK_WRITESPACE   0x10
 If a nonblocking write has been rejected before, poll_tcp needs to check if the netconn is writable again. More...
 
#define NETCONN_FLAG_IN_NONBLOCKING_CONNECT   0x04
 Was the last connect action a non-blocking one? More...
 
#define NETCONN_FLAG_IPV6_V6ONLY   0x20
 If this flag is set then only IPv6 communication is allowed on the netconn. More...
 
#define NETCONN_FLAG_NO_AUTO_RECVED   0x08
 If this is set, a TCP netconn must call netconn_recved() to update the TCP receive window (done automatically if not set). More...
 
#define NETCONN_FLAG_NON_BLOCKING   0x02
 Should this netconn avoid blocking? More...
 
#define NETCONN_FLAG_WRITE_DELAYED   0x01
 TCP: when data passed to netconn_write doesn't fit into the send buffer, this temporarily stores whether to wake up the original application task if data couldn't be sent in the first try. More...
 
#define netconn_get_noautorecved(conn)   (((conn)->flags & NETCONN_FLAG_NO_AUTO_RECVED) != 0)
 TCP: Get the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) More...
 
#define netconn_is_nonblocking(conn)   (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0)
 Get the blocking status of netconn calls (. More...
 
#define netconn_join_leave_group_ip6(conn, multiaddr, srcaddr, join_or_leave)
 
#define netconn_listen(conn)   netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG)
 
#define NETCONN_MORE   0x02
 
#define netconn_new(t)   netconn_new_with_proto_and_callback(t, 0, NULL)
 
#define netconn_new_with_callback(t, c)   netconn_new_with_proto_and_callback(t, 0, c)
 
#define NETCONN_NOCOPY   0x00 /* Only for source code compatibility */
 
#define NETCONN_NOFLAG   0x00
 
#define netconn_peer(c, i, p)   netconn_getaddr(c,i,p,0)
 
#define netconn_recv_bufsize(conn)   ((conn)->recv_bufsize)
 
#define netconn_sendto_ip6(conn, buf, ip6addr, port)
 
#define netconn_set_noautorecved(conn, val)
 TCP: Set the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) More...
 
#define netconn_set_nonblocking(conn, val)
 Set the blocking status of netconn calls (. More...
 
#define NETCONN_SET_SAFE_ERR(conn, err)
 Set conn->last_err to err but don't overwrite fatal errors. More...
 
#define netconn_thread_cleanup()
 
#define netconn_thread_init()
 
#define netconn_type(conn)   (conn->type)
 Get the type of a netconn (as enum netconn_type). More...
 
#define NETCONN_TYPE_IPV6   0x08
 
#define netconn_write(conn, dataptr, size, apiflags)   netconn_write_partly(conn, dataptr, size, apiflags, NULL)
 
#define NETCONNTYPE_DATAGRAM(t)   ((t)&0xE0)
 
#define NETCONNTYPE_GROUP(t)   ((t)&0xF0)
 
#define NETCONNTYPE_ISIPV6(t)   ((t)&0x08)
 
#define NETCONNTYPE_ISUDPLITE(t)   (((t)&0xF7) == NETCONN_UDPLITE)
 
#define NETCONNTYPE_ISUDPNOCHKSUM(t)   (((t)&0xF7) == NETCONN_UDPNOCHKSUM)
 

Typedefs

typedef void(* netconn_callback )(struct netconn *, enum netconn_evt, u16_t len)
 A callback prototype to inform about events for a netconn. More...
 

Enumerations

enum  netconn_evt {
  NETCONN_EVT_RCVPLUS,
  NETCONN_EVT_RCVMINUS,
  NETCONN_EVT_SENDPLUS,
  NETCONN_EVT_SENDMINUS,
  NETCONN_EVT_ERROR
}
 Use to inform the callback function about changes. More...
 
enum  netconn_igmp {
  NETCONN_JOIN,
  NETCONN_LEAVE
}
 Used for netconn_join_leave_group() More...
 
enum  netconn_state {
  NETCONN_NONE,
  NETCONN_WRITE,
  NETCONN_LISTEN,
  NETCONN_CONNECT,
  NETCONN_CLOSE
}
 Current state of the netconn. More...
 
enum  netconn_type {
  NETCONN_INVALID = 0,
  NETCONN_TCP = 0x10,
  NETCONN_TCP_IPV6 = NETCONN_TCP | NETCONN_TYPE_IPV6,
  NETCONN_UDP = 0x20,
  NETCONN_UDPLITE = 0x21,
  NETCONN_UDPNOCHKSUM = 0x22,
  NETCONN_UDP_IPV6 = NETCONN_UDP | NETCONN_TYPE_IPV6,
  NETCONN_UDPLITE_IPV6 = NETCONN_UDPLITE | NETCONN_TYPE_IPV6,
  NETCONN_UDPNOCHKSUM_IPV6 = NETCONN_UDPNOCHKSUM | NETCONN_TYPE_IPV6,
  NETCONN_RAW = 0x40,
  NETCONN_RAW_IPV6 = NETCONN_RAW | NETCONN_TYPE_IPV6
}
 Protocol family and type of the netconn. More...
 

Functions

LWIP_NETCONN_SCOPE err_t netconn_accept (struct netconn *conn, struct netconn **new_conn)
 Accept a new connection on a TCP listening netconn. More...
 
LWIP_NETCONN_SCOPE err_t netconn_bind (struct netconn *conn, ip_addr_t *addr, u16_t port)
 Bind a netconn to a specific local IP address and port. More...
 
LWIP_NETCONN_SCOPE err_t netconn_close (struct netconn *conn)
 Close a TCP netconn (doesn't delete it). More...
 
LWIP_NETCONN_SCOPE err_t netconn_connect (struct netconn *conn, ip_addr_t *addr, u16_t port)
 Connect a netconn to a specific remote IP address and port. More...
 
LWIP_NETCONN_SCOPE err_t netconn_delete (struct netconn *conn)
 Close a netconn 'connection' and free its resources. More...
 
LWIP_NETCONN_SCOPE err_t netconn_disconnect (struct netconn *conn)
 Disconnect a netconn from its current peer (only valid for UDP netconns). More...
 
LWIP_NETCONN_SCOPE err_t netconn_getaddr (struct netconn *conn, ip_addr_t *addr, u16_t *port, u8_t local)
 Get the local or remote IP address and port of a netconn. More...
 
err_t netconn_gethostbyname (const char *name, ip_addr_t *addr)
 Execute a DNS query, only one IP address is returned. More...
 
LWIP_NETCONN_SCOPE err_t netconn_join_leave_group (struct netconn *conn, ip_addr_t *multiaddr, ip_addr_t *netif_addr, enum netconn_igmp join_or_leave)
 Join multicast groups for UDP netconns. More...
 
LWIP_NETCONN_SCOPE err_t netconn_listen_with_backlog (struct netconn *conn, u8_t backlog)
 Set a TCP netconn into listen mode. More...
 
LWIP_NETCONN_SCOPE struct netconnnetconn_new_with_proto_and_callback (enum netconn_type t, u8_t proto, netconn_callback callback)
 Create a new netconn (of a specific type) that has a callback function. More...
 
LWIP_NETCONN_SCOPE err_t netconn_recv (struct netconn *conn, struct netbuf **new_buf)
 Receive data (in form of a netbuf containing a packet buffer) from a netconn. More...
 
LWIP_NETCONN_SCOPE err_t netconn_recv_tcp_pbuf (struct netconn *conn, struct pbuf **new_buf)
 Receive data (in form of a pbuf) from a TCP netconn. More...
 
LWIP_NETCONN_SCOPE void netconn_recved (struct netconn *conn, u32_t length)
 TCP: update the receive window: by calling this, the application tells the stack that it has processed data and is able to accept new data. More...
 
LWIP_NETCONN_SCOPE err_t netconn_send (struct netconn *conn, struct netbuf *buf)
 Send data over a UDP or RAW netconn (that is already connected). More...
 
LWIP_NETCONN_SCOPE err_t netconn_sendto (struct netconn *conn, struct netbuf *buf, ip_addr_t *addr, u16_t port)
 Send data (in form of a netbuf) to a specific remote IP address and port. More...
 
LWIP_NETCONN_SCOPE err_t netconn_shutdown (struct netconn *conn, u8_t shut_rx, u8_t shut_tx)
 Shut down one or both sides of a TCP netconn (doesn't delete it). More...
 
LWIP_NETCONN_SCOPE err_t netconn_write_partly (struct netconn *conn, const void *dataptr, size_t size, u8_t apiflags, size_t *bytes_written)
 Send data over a TCP netconn. More...
 

#define API_EVENT (   c,
  e,
 
)
#define LWIP_NETCONN_SCOPE
#define netconn_addr (   c,
  i,
 
)    netconn_getaddr(c,i,p,1)
#define netconn_bind_ip6 (   conn,
  ip6addr,
  port 
)
Value:
netconn_bind(conn, ip6_2_ip(ip6addr), port) : ERR_VAL)
#define NETCONNTYPE_ISIPV6(t)
Definition: api.h:96
#define ERR_VAL
Definition: err.h:58
#define ip6_2_ip(ip6addr)
Definition: ip_addr.h:65
u8_t type
pbuf_type as u8_t instead of enum to save space
Definition: pbuf.h:108
err_t netconn_bind(struct netconn *conn, ip_addr_t *addr, u16_t port)
Bind a netconn to a specific local IP address and port.
Definition: api_lib.c:189
#define netconn_connect_ip6 (   conn,
  ip6addr,
  port 
)
Value:
netconn_connect(conn, ip6_2_ip(ip6addr), port) : ERR_VAL)
#define NETCONNTYPE_ISIPV6(t)
Definition: api.h:96
#define ERR_VAL
Definition: err.h:58
err_t netconn_connect(struct netconn *conn, ip_addr_t *addr, u16_t port)
Connect a netconn to a specific remote IP address and port.
Definition: api_lib.c:221
#define ip6_2_ip(ip6addr)
Definition: ip_addr.h:65
u8_t type
pbuf_type as u8_t instead of enum to save space
Definition: pbuf.h:108
#define NETCONN_COPY   0x01

Referenced by iperf_tcp_client_task().

#define NETCONN_DONTBLOCK   0x04
#define netconn_err (   conn)    ((conn)->last_err)
#define NETCONN_FLAG_CHECK_WRITESPACE   0x10

If a nonblocking write has been rejected before, poll_tcp needs to check if the netconn is writable again.

Referenced by lwip_netconn_do_writemore(), poll_tcp(), and sent_tcp().

#define NETCONN_FLAG_IN_NONBLOCKING_CONNECT   0x04

Was the last connect action a non-blocking one?

#define NETCONN_FLAG_IPV6_V6ONLY   0x20

If this flag is set then only IPv6 communication is allowed on the netconn.

As per RFC#3493 this features defaults to OFF allowing dual-stack usage by default.

Referenced by lwip_netconn_do_listen().

#define NETCONN_FLAG_NO_AUTO_RECVED   0x08

If this is set, a TCP netconn must call netconn_recved() to update the TCP receive window (done automatically if not set).

#define NETCONN_FLAG_NON_BLOCKING   0x02

Should this netconn avoid blocking?

#define NETCONN_FLAG_WRITE_DELAYED   0x01

TCP: when data passed to netconn_write doesn't fit into the send buffer, this temporarily stores whether to wake up the original application task if data couldn't be sent in the first try.

Referenced by lwip_netconn_do_write(), and lwip_netconn_do_writemore().

#define netconn_get_noautorecved (   conn)    (((conn)->flags & NETCONN_FLAG_NO_AUTO_RECVED) != 0)

TCP: Get the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED)

Referenced by netconn_recv_data(), and netconn_recved().

#define netconn_is_nonblocking (   conn)    (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0)

Get the blocking status of netconn calls (.

Todo:
: write/send is missing)

Referenced by lwip_netconn_do_connect(), lwip_netconn_do_writemore(), and netconn_write_partly().

#define netconn_join_leave_group_ip6 (   conn,
  multiaddr,
  srcaddr,
  join_or_leave 
)
Value:
netconn_join_leave_group(conn, ip6_2_ip(multiaddr), ip6_2_ip(srcaddr), join_or_leave) :\
#define NETCONNTYPE_ISIPV6(t)
Definition: api.h:96
err_t netconn_join_leave_group(struct netconn *conn, ip_addr_t *multiaddr, ip_addr_t *netif_addr, enum netconn_igmp join_or_leave)
Join multicast groups for UDP netconns.
Definition: api_lib.c:781
#define ERR_VAL
Definition: err.h:58
#define ip6_2_ip(ip6addr)
Definition: ip_addr.h:65
u8_t type
pbuf_type as u8_t instead of enum to save space
Definition: pbuf.h:108
#define netconn_listen (   conn)    netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG)

Referenced by iperf_tcp_task().

#define NETCONN_MORE   0x02
#define netconn_new_with_callback (   t,
 
)    netconn_new_with_proto_and_callback(t, 0, c)
#define NETCONN_NOCOPY   0x00 /* Only for source code compatibility */
#define NETCONN_NOFLAG   0x00
#define netconn_peer (   c,
  i,
 
)    netconn_getaddr(c,i,p,0)
#define netconn_recv_bufsize (   conn)    ((conn)->recv_bufsize)
#define netconn_sendto_ip6 (   conn,
  buf,
  ip6addr,
  port 
)
Value:
netconn_sendto(conn, buf, ip6_2_ip(ip6addr), port) : ERR_VAL)
#define NETCONNTYPE_ISIPV6(t)
Definition: api.h:96
err_t netconn_sendto(struct netconn *conn, struct netbuf *buf, ip_addr_t *addr, u16_t port)
Send data (in form of a netbuf) to a specific remote IP address and port.
Definition: api_lib.c:607
#define ERR_VAL
Definition: err.h:58
#define ip6_2_ip(ip6addr)
Definition: ip_addr.h:65
u8_t type
pbuf_type as u8_t instead of enum to save space
Definition: pbuf.h:108
#define netconn_set_noautorecved (   conn,
  val 
)
Value:
do { if(val) { \
} else { \
(conn)->flags &= ~ NETCONN_FLAG_NO_AUTO_RECVED; }} while(0)
#define NETCONN_FLAG_NO_AUTO_RECVED
If this is set, a TCP netconn must call netconn_recved() to update the TCP receive window (done autom...
Definition: api.h:79
static u8_t flags
Definition: tcp_in.c:76

TCP: Set the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED)

#define netconn_set_nonblocking (   conn,
  val 
)
Value:
do { if(val) { \
} else { \
(conn)->flags &= ~ NETCONN_FLAG_NON_BLOCKING; }} while(0)
#define NETCONN_FLAG_NON_BLOCKING
Should this netconn avoid blocking?
Definition: api.h:74
static u8_t flags
Definition: tcp_in.c:76

Set the blocking status of netconn calls (.

Todo:
: write/send is missing)
#define NETCONN_SET_SAFE_ERR (   conn,
  err 
)
Value:
do { \
if (!ERR_IS_FATAL((conn)->last_err)) { \
(conn)->last_err = err; \
} \
} while(0);
#define ERR_IS_FATAL(e)
Definition: err.h:63
void * SYS_ARCH_DECL_PROTECT(old_level)
Get an element from a specific pool.
if(memp!=NULL)
Definition: memp.c:426
SYS_ARCH_UNPROTECT(old_level)
SYS_ARCH_PROTECT(old_level)

Set conn->last_err to err but don't overwrite fatal errors.

Referenced by lwip_netconn_do_connected(), netconn_accept(), netconn_bind(), netconn_close_shutdown(), netconn_connect(), netconn_disconnect(), netconn_getaddr(), netconn_join_leave_group(), netconn_listen_with_backlog(), netconn_recv(), netconn_recv_data(), netconn_send(), netconn_write_partly(), and recv_tcp().

#define netconn_thread_cleanup ( )
#define netconn_thread_init ( )
#define netconn_type (   conn)    (conn->type)

Get the type of a netconn (as enum netconn_type).

#define NETCONN_TYPE_IPV6   0x08
#define netconn_write (   conn,
  dataptr,
  size,
  apiflags 
)    netconn_write_partly(conn, dataptr, size, apiflags, NULL)
#define NETCONNTYPE_DATAGRAM (   t)    ((t)&0xE0)
#define NETCONNTYPE_ISIPV6 (   t)    ((t)&0x08)

Referenced by pcb_new().

#define NETCONNTYPE_ISUDPLITE (   t)    (((t)&0xF7) == NETCONN_UDPLITE)

Referenced by pcb_new().

#define NETCONNTYPE_ISUDPNOCHKSUM (   t)    (((t)&0xF7) == NETCONN_UDPNOCHKSUM)

Referenced by pcb_new().

typedef void(* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len)

A callback prototype to inform about events for a netconn.

Use to inform the callback function about changes.

Enumerator
NETCONN_EVT_RCVPLUS 
NETCONN_EVT_RCVMINUS 
NETCONN_EVT_SENDPLUS 
NETCONN_EVT_SENDMINUS 
NETCONN_EVT_ERROR 

Used for netconn_join_leave_group()

Enumerator
NETCONN_JOIN 
NETCONN_LEAVE 

Current state of the netconn.

Non-TCP netconns are always in state NETCONN_NONE!

Enumerator
NETCONN_NONE 
NETCONN_WRITE 
NETCONN_LISTEN 
NETCONN_CONNECT 
NETCONN_CLOSE 

Protocol family and type of the netconn.

Enumerator
NETCONN_INVALID 
NETCONN_TCP 
NETCONN_TCP_IPV6 
NETCONN_UDP 
NETCONN_UDPLITE 
NETCONN_UDPNOCHKSUM 
NETCONN_UDP_IPV6 
NETCONN_UDPLITE_IPV6 
NETCONN_UDPNOCHKSUM_IPV6 
NETCONN_RAW 
NETCONN_RAW_IPV6 

LWIP_NETCONN_SCOPE err_t netconn_accept ( struct netconn conn,
struct netconn **  new_conn 
)

Accept a new connection on a TCP listening netconn.

Parameters
connthe TCP listen netconn
new_connpointer where the new connection is stored
Returns
ERR_OK if a new connection has been received or an error code otherwise

References netconn::acceptmbox, API_EVENT, API_MSG_VAR_ALLOC_DONTFAIL, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ABRT, ERR_ARG, ERR_IS_FATAL, ERR_OK, ERR_TIMEOUT, netconn::last_err, LWIP_ERROR(), lwip_netconn_do_recv(), NETCONN_EVT_RCVMINUS, NETCONN_SET_SAFE_ERR, NULL, sys_arch_mbox_fetch(), SYS_ARCH_TIMEOUT, sys_mbox_valid(), and TCPIP_APIMSG_NOERR.

Referenced by iperf_tcp_task().

LWIP_NETCONN_SCOPE err_t netconn_bind ( struct netconn conn,
ip_addr_t addr,
u16_t  port 
)

Bind a netconn to a specific local IP address and port.

Binding one netconn twice might not always be checked correctly!

Parameters
connthe netconn to bind
addrthe local IP address to bind the netconn to (use IP_ADDR_ANY to bind to all addresses)
portthe local port to bind the netconn to (not used for RAW)
Returns
ERR_OK if bound, any other err_t on failure

References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, IP_ADDR_ANY, LWIP_ERROR(), lwip_netconn_do_bind(), NETCONN_SET_SAFE_ERR, NULL, and TCPIP_APIMSG.

Referenced by iperf_tcp_client_task(), iperf_tcp_send(), iperf_tcp_task(), and iperf_udp_task().

LWIP_NETCONN_SCOPE err_t netconn_close ( struct netconn conn)

Close a TCP netconn (doesn't delete it).

Parameters
connthe TCP netconn to close
Returns
ERR_OK if the netconn was closed, any other err_t on error

References netconn_close_shutdown(), and NETCONN_SHUT_RDWR.

Referenced by iperf_tcp_client_task(), and iperf_tcp_send().

LWIP_NETCONN_SCOPE err_t netconn_connect ( struct netconn conn,
ip_addr_t addr,
u16_t  port 
)

Connect a netconn to a specific remote IP address and port.

Parameters
connthe netconn to connect
addrthe remote IP address to connect to
portthe remote port to connect to (no used for RAW)
Returns
ERR_OK if connected, return value of tcp_/udp_/raw_connect otherwise

References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, IP_ADDR_ANY, LWIP_ERROR(), lwip_netconn_do_connect(), NETCONN_SET_SAFE_ERR, NETCONN_TCP, NETCONNTYPE_GROUP, NULL, TCPIP_APIMSG, tcpip_apimsg(), and netconn::type.

Referenced by iperf_tcp_client_task(), and iperf_tcp_send().

LWIP_NETCONN_SCOPE err_t netconn_delete ( struct netconn conn)

Close a netconn 'connection' and free its resources.

UDP and RAW connection are completely closed, TCP pcbs might still be in a waitstate after this returns.

Parameters
connthe netconn to delete
Returns
ERR_OK if the connection was deleted

References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_OK, lwip_netconn_do_delconn(), netconn_free(), NULL, and tcpip_apimsg().

Referenced by iperf_tcp_client_task(), iperf_tcp_recv(), and iperf_tcp_send().

LWIP_NETCONN_SCOPE err_t netconn_disconnect ( struct netconn conn)

Disconnect a netconn from its current peer (only valid for UDP netconns).

Parameters
connthe netconn to disconnect
Returns
TODO: return value is not set here...

References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, LWIP_ERROR(), lwip_netconn_do_disconnect(), NETCONN_SET_SAFE_ERR, NULL, and TCPIP_APIMSG.

LWIP_NETCONN_SCOPE err_t netconn_getaddr ( struct netconn conn,
ip_addr_t addr,
u16_t port,
u8_t  local 
)

Get the local or remote IP address and port of a netconn.

For RAW netconns, this returns the protocol instead of a port!

Parameters
connthe netconn to query
addra pointer to which to save the IP address
porta pointer to which to save the port (or protocol for RAW)
local1 to get the local IP address, 0 to get the remote one
Returns
ERR_CONN for invalid connections ERR_OK if the information was retrieved

References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, ip_2_ipX, ipX_2_ip, LWIP_ERROR(), lwip_netconn_do_getaddr(), NETCONN_SET_SAFE_ERR, NULL, and TCPIP_APIMSG.

Referenced by iperf_tcp_task().

err_t netconn_gethostbyname ( const char *  name,
ip_addr_t addr 
)

Execute a DNS query, only one IP address is returned.

Parameters
namea string representation of the DNS host name to query
addra preallocated ip_addr_t where to store the resolved IP address
Returns
ERR_OK: resolving succeeded ERR_MEM: memory error, try again later ERR_ARG: dns client not initialized or invalid hostname ERR_VAL: dns server response was invalid

References API_EXPR_REF, API_VAR_ALLOC, API_VAR_DECLARE, API_VAR_FREE, API_VAR_REF, ERR_ARG, ERR_OK, LWIP_ERROR(), lwip_netconn_do_gethostbyname(), NULL, sys_sem_free(), sys_sem_new(), sys_sem_wait, and tcpip_callback.

LWIP_NETCONN_SCOPE err_t netconn_join_leave_group ( struct netconn conn,
ip_addr_t multiaddr,
ip_addr_t netif_addr,
enum netconn_igmp  join_or_leave 
)

Join multicast groups for UDP netconns.

Parameters
connthe UDP netconn for which to change multicast addresses
multiaddrIP address of the multicast group to join or leave
netif_addrthe IP address of the network interface on which to send the igmp message
join_or_leaveflag whether to send a join- or leave-message
Returns
ERR_OK if the action was taken, any err_t on error

References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, ip_2_ipX, IP_ADDR_ANY, LWIP_ERROR(), lwip_netconn_do_join_leave_group(), NETCONN_SET_SAFE_ERR, NULL, and TCPIP_APIMSG.

LWIP_NETCONN_SCOPE err_t netconn_listen_with_backlog ( struct netconn conn,
u8_t  backlog 
)

Set a TCP netconn into listen mode.

Parameters
connthe tcp netconn to set to listen mode
backlogthe listen backlog, only used if TCP_LISTEN_BACKLOG==1
Returns
ERR_OK if the netconn was set to listen (UDP and RAW netconns don't return any error (yet?))

References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, LWIP_ERROR(), lwip_netconn_do_listen(), NETCONN_SET_SAFE_ERR, NULL, and TCPIP_APIMSG.

LWIP_NETCONN_SCOPE struct netconn* netconn_new_with_proto_and_callback ( enum netconn_type  t,
u8_t  proto,
netconn_callback  callback 
)

Create a new netconn (of a specific type) that has a callback function.

The corresponding pcb is also created.

Parameters
tthe type of 'connection' to create (
See Also
enum netconn_type)
Parameters
protothe IP protocol for RAW IP pcbs
callbacka function to call on status changes (RX available, TX'ed)
Returns
a newly allocated struct netconn or NULL on memory error

References netconn::acceptmbox, API_MSG_VAR_ALLOC_DONTFAIL, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_OK, LWIP_ASSERT, lwip_netconn_do_newconn(), memp_free(), netconn_alloc(), NULL, netconn::op_completed, netconn::pcb, netconn::recvmbox, sys_mbox_free(), sys_mbox_valid(), sys_sem_free(), sys_sem_valid(), netconn::tcp, and TCPIP_APIMSG.

LWIP_NETCONN_SCOPE err_t netconn_recv ( struct netconn conn,
struct netbuf **  new_buf 
)

Receive data (in form of a netbuf containing a packet buffer) from a netconn.

Parameters
connthe netconn from which to receive data
new_bufpointer where a new netbuf is stored when received data
Returns
ERR_OK if data has been received, an error code otherwise (timeout, memory error or another error)

References ERR_ARG, ERR_CONN, ERR_MEM, ERR_OK, ipX_addr_set_any, LWIP_ASSERT, LWIP_ERROR(), LWIP_IPV6, memp_free(), memp_malloc(), netconn_recv_data(), NETCONN_SET_SAFE_ERR, NETCONN_TCP, NETCONNTYPE_GROUP, NULL, netconn::recvmbox, sys_mbox_valid(), and netconn::type.

Referenced by iperf_tcp_recv(), and iperf_udp_recv().

LWIP_NETCONN_SCOPE err_t netconn_recv_tcp_pbuf ( struct netconn conn,
struct pbuf **  new_buf 
)

Receive data (in form of a pbuf) from a TCP netconn.

Parameters
connthe netconn from which to receive data
new_bufpointer where a new pbuf is stored when received data
Returns
ERR_OK if data has been received, an error code otherwise (timeout, memory error or another error) ERR_ARG if conn is not a TCP netconn

References ERR_ARG, LWIP_ERROR(), netconn_recv_data(), NETCONN_TCP, NETCONNTYPE_GROUP, and NULL.

LWIP_NETCONN_SCOPE void netconn_recved ( struct netconn conn,
u32_t  length 
)

TCP: update the receive window: by calling this, the application tells the stack that it has processed data and is able to accept new data.

ATTENTION: use with care, this is mainly used for sockets! Can only be used when calling netconn_set_noautorecved(conn, 1) before.

Parameters
connthe netconn for which to update the receive window
lengthamount of data processed (ATTENTION: this must be accurate!)

References API_MSG_VAR_ALLOC_DONTFAIL, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, lwip_netconn_do_recv(), netconn_get_noautorecved, NETCONN_TCP, NETCONNTYPE_GROUP, NULL, TCPIP_APIMSG_NOERR, and netconn::type.

LWIP_NETCONN_SCOPE err_t netconn_send ( struct netconn conn,
struct netbuf *  buf 
)

Send data over a UDP or RAW netconn (that is already connected).

Parameters
connthe UDP or RAW netconn over which to send data
bufa netbuf containing the data to send
Returns
ERR_OK if data was sent, any other err_t on error

References API_LIB_DEBUG, API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, LWIP_DEBUGF, LWIP_ERROR(), lwip_netconn_do_send(), NETCONN_SET_SAFE_ERR, NULL, TCPIP_APIMSG, and U16_F.

Referenced by netconn_sendto().

LWIP_NETCONN_SCOPE err_t netconn_sendto ( struct netconn conn,
struct netbuf *  buf,
ip_addr_t addr,
u16_t  port 
)

Send data (in form of a netbuf) to a specific remote IP address and port.

Only to be used for UDP and RAW netconns (not TCP).

Parameters
connthe netconn over which to send data
bufa netbuf containing the data to send
addrthe remote IP address to which to send the data
portthe remote port to which to send the data
Returns
ERR_OK if data was sent, any other err_t on error

References ERR_VAL, netconn::ip, ipX_addr_set_ipaddr, netconn_send(), NULL, netconn::pcb, and PCB_ISIPV6.

Referenced by iperf_udp_recv(), and iperf_udp_send().

LWIP_NETCONN_SCOPE err_t netconn_shutdown ( struct netconn conn,
u8_t  shut_rx,
u8_t  shut_tx 
)

Shut down one or both sides of a TCP netconn (doesn't delete it).

Parameters
connthe TCP netconn to shut down
Returns
ERR_OK if the netconn was closed, any other err_t on error

References netconn_close_shutdown(), NETCONN_SHUT_RD, and NETCONN_SHUT_WR.

LWIP_NETCONN_SCOPE err_t netconn_write_partly ( struct netconn conn,
const void dataptr,
size_t  size,
u8_t  apiflags,
size_t *  bytes_written 
)

Send data over a TCP netconn.

Parameters
connthe TCP netconn over which to send data
dataptrpointer to the application buffer that contains the data to send
sizesize of the application data to send
apiflagscombination of following flags :
  • NETCONN_COPY: data will be copied into memory belonging to the stack
  • NETCONN_MORE: for TCP connection, PSH flag will be set on last segment sent
  • NETCONN_DONTBLOCK: only write the data if all data can be written at once
bytes_writtenpointer to a location that receives the number of written bytes
Returns
ERR_OK if data was sent, any other err_t on error

References API_MSG_VAR_ALLOC, API_MSG_VAR_DECLARE, API_MSG_VAR_FREE, API_MSG_VAR_REF, ERR_ARG, ERR_OK, ERR_VAL, LWIP_ERROR(), lwip_netconn_do_write(), NETCONN_DONTBLOCK, netconn_is_nonblocking, NETCONN_SET_SAFE_ERR, NETCONN_TCP, NETCONNTYPE_GROUP, NULL, sys_now(), TCPIP_APIMSG, and netconn::type.