Documentation

Documentation

Includes

lwip/opt.h

#include "lwip/opt.h"
#include "lwip/opt.h"

lwip/arch.h

#include "lwip/arch.h"
#include "lwip/arch.h"

lwip/netbuf.h

#include "lwip/netbuf.h"
#include "lwip/netbuf.h"

lwip/sys.h

#include "lwip/sys.h"
#include "lwip/sys.h"

lwip/ip_addr.h

#include "lwip/ip_addr.h"
#include "lwip/ip_addr.h"

lwip/err.h

#include "lwip/err.h"
#include "lwip/err.h"

Macros

Marco LWIP_HDR_API_H

#define LWIP_HDR_API_H


      

Marco NETCONN_NOFLAG

#define NETCONN_NOFLAG     0
/* Flags for netconn_write (u8_t) */

Marco NETCONN_NOCOPY

#define NETCONN_NOCOPY     0 /* Only for source code compatibility */


      

Marco NETCONN_COPY

#define NETCONN_COPY       1


      

Marco NETCONN_MORE

#define NETCONN_MORE       2


      

Marco NETCONN_DONTBLOCK

#define NETCONN_DONTBLOCK  4


      

Marco NETCONN_NOAUTORCVD

#define NETCONN_NOAUTORCVD 8 /* prevent netconn_recv_data_tcp() from updating the tcp window - must be done manually via netconn_tcp_recvd() */


      

Marco NETCONN_NOFIN

#define NETCONN_NOFIN      16 /* upper layer already received data, leave FIN in queue until called again */


      

Marco NETCONN_FLAG_MBOXCLOSED

#define NETCONN_FLAG_MBOXCLOSED              1
/** This netconn had an error, don't block on recvmbox/acceptmbox any more */

Marco NETCONN_FLAG_NON_BLOCKING

#define NETCONN_FLAG_NON_BLOCKING            2
/** Should this netconn avoid blocking? */

Marco NETCONN_FLAG_IN_NONBLOCKING_CONNECT

#define NETCONN_FLAG_IN_NONBLOCKING_CONNECT  4
/** Was the last connect action a non-blocking one? */

Marco NETCONN_FLAG_MBOXINVALID

#define NETCONN_FLAG_MBOXINVALID             8
/** The mbox of this netconn is being deallocated, don't use it anymore */

Marco NETCONN_FLAG_CHECK_WRITESPACE

#define NETCONN_FLAG_CHECK_WRITESPACE        16
/** If a nonblocking write has been rejected before, poll_tcp needs to
    check if the netconn is writable again */

Marco NETCONN_FLAG_IPV6_V6ONLY

#define NETCONN_FLAG_IPV6_V6ONLY             32
/** 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. */

Marco NETCONN_FLAG_PKTINFO

#define NETCONN_FLAG_PKTINFO                 64
/** Received packet info will be recorded for this netconn */

Marco NETCONN_FIN_RX_PENDING

#define NETCONN_FIN_RX_PENDING               128
/** A FIN has been received but not passed to the application yet */

Marco NETCONNTYPE_GROUP(t)

#define NETCONNTYPE_GROUP(t)        ((t)&240)
/* Helpers to process several netconn_types by the same code */

Marco NETCONNTYPE_DATAGRAM(t)

#define NETCONNTYPE_DATAGRAM(t)     ((t)&0xE0)


      

Marco NETCONN_TYPE_IPV6

#define NETCONN_TYPE_IPV6           8


      

Marco NETCONNTYPE_ISIPV6(t)

#define NETCONNTYPE_ISIPV6(t)       (((t)&NETCONN_TYPE_IPV6) != 0)


      

Marco NETCONNTYPE_ISUDPLITE(t)

#define NETCONNTYPE_ISUDPLITE(t)    (((t)&243) == NETCONN_UDPLITE)


      

Marco NETCONNTYPE_ISUDPNOCHKSUM(t)

#define NETCONNTYPE_ISUDPNOCHKSUM(t) (((t)&243) == NETCONN_UDPNOCHKSUM)


      

Marco NETCONNTYPE_ISIPV6(t)

#define NETCONNTYPE_ISIPV6(t)       (0)


      

Marco NETCONNTYPE_ISUDPLITE(t)

#define NETCONNTYPE_ISUDPLITE(t)    ((t) == NETCONN_UDPLITE)


      

Marco NETCONNTYPE_ISUDPNOCHKSUM(t)

#define NETCONNTYPE_ISUDPNOCHKSUM(t) ((t) == NETCONN_UDPNOCHKSUM)


      

Marco NETCONN_DNS_DEFAULT

#define NETCONN_DNS_DEFAULT  NETCONN_DNS_IPV4_IPV6
/* Used for netconn_gethostbyname_addrtype(), these should match the DNS_ADDRTYPE defines in dns.h */

Marco NETCONN_DNS_IPV4

#define NETCONN_DNS_IPV4     0


      

Marco NETCONN_DNS_IPV6

#define NETCONN_DNS_IPV6     1


      

Marco NETCONN_DNS_IPV4_IPV6

#define NETCONN_DNS_IPV4_IPV6 2 /* try to resolve IPv4 first, try IPv6 if IPv4 fails only */


      

Marco NETCONN_DNS_IPV6_IPV4

#define NETCONN_DNS_IPV6_IPV4 3 /* try to resolve IPv6 first, try IPv4 if IPv6 fails only */


      

Marco API_EVENT(c,e,l)

#define API_EVENT(c,e,l) if (c->callback) {        \
                          (*c->callback)(c, e, l); \
                        }
/** Register an Network connection event */

Marco netconn_new(t)

#define netconn_new(t)                 netconn_new_with_proto_and_callback(t, 0, NULL)
/** @ingroup netconn_common
 * Create new netconn connection
 * @param t @ref netconn_type */

Marco netconn_new_with_callback(t, c)

#define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c)


      

Marco netconn_type(conn)

#define netconn_type(conn) (conn->type)
/** Get the type of a netconn (as enum netconn_type). */

Marco netconn_peer(c,i,p)

#define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0)
/** @ingroup netconn_common */

Marco netconn_addr(c,i,p)

#define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1)
/** @ingroup netconn_common */

Marco netconn_listen(conn)

#define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG)
/** @ingroup netconn_tcp */

Marco netconn_write(conn, dataptr, size, apiflags)

#define netconn_write(conn, dataptr, size, apiflags) \
         netconn_write_partly(conn, dataptr, size, apiflags, NULL)
/** @ingroup netconn_tcp */

Marco netconn_gethostbyname(name, addr)

#define netconn_gethostbyname(name, addr) netconn_gethostbyname_addrtype(name, addr, NETCONN_DNS_DEFAULT)


      

Marco netconn_gethostbyname_addrtype(name, addr, dns_addrtype)

#define netconn_gethostbyname_addrtype(name, addr, dns_addrtype) netconn_gethostbyname(name, addr)


      

Marco netconn_recv_bufsize(conn)

#define netconn_recv_bufsize(conn)     ((conn)->recv_bufsize)


      

Marco netconn_set_flags(conn, set_flags)

#define netconn_set_flags(conn, set_flags)    do { (conn)->flags = (u8_t)((conn)->flags | (set_flags)); } while(0)


      

Marco netconn_clear_flags(conn, clr_flags)

#define netconn_clear_flags(conn, clr_flags)  do { (conn)->flags = (u8_t)((conn)->flags & (u8_t)(~(clr_flags) & 255)); } while(0)


      

Marco netconn_is_flag_set(conn, flag)

#define netconn_is_flag_set(conn, flag)       (((conn)->flags & (flag)) != 0)


      

Marco netconn_set_nonblocking(conn, val)

#define netconn_set_nonblocking(conn, val) do { if(val) { \
 netconn_set_flags(conn, NETCONN_FLAG_NON_BLOCKING); \
} else { \
 netconn_clear_flags(conn, NETCONN_FLAG_NON_BLOCKING); }} while(0)
/** Set the blocking status of netconn calls (@todo: write/send is missing) */

Marco netconn_is_nonblocking(conn)

#define netconn_is_nonblocking(conn)       (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0)
/** Get the blocking status of netconn calls (@todo: write/send is missing) */

Marco netconn_set_ipv6only(conn, val)

#define netconn_set_ipv6only(conn, val) do { if(val) { \
 netconn_set_flags(conn, NETCONN_FLAG_IPV6_V6ONLY); \
} else { \
 netconn_clear_flags(conn, NETCONN_FLAG_IPV6_V6ONLY); }} while(0)
/** @ingroup netconn_common
 * TCP: Set the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY)
 */

Marco netconn_get_ipv6only(conn)

#define netconn_get_ipv6only(conn)       (((conn)->flags & NETCONN_FLAG_IPV6_V6ONLY) != 0)
/** @ingroup netconn_common
 * TCP: Get the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY)
 */

Marco netconn_set_sendtimeout(conn, timeout)

#define netconn_set_sendtimeout(conn, timeout)     ((conn)->send_timeout = (timeout))
/** Set the send timeout in milliseconds */

Marco netconn_get_sendtimeout(conn)

#define netconn_get_sendtimeout(conn)              ((conn)->send_timeout)
/** Get the send timeout in milliseconds */

Marco netconn_set_recvtimeout(conn, timeout)

#define netconn_set_recvtimeout(conn, timeout)     ((conn)->recv_timeout = (timeout))
/** Set the receive timeout in milliseconds */

Marco netconn_get_recvtimeout(conn)

#define netconn_get_recvtimeout(conn)              ((conn)->recv_timeout)
/** Get the receive timeout in milliseconds */

Marco netconn_set_recvbufsize(conn, recvbufsize)

#define netconn_set_recvbufsize(conn, recvbufsize) ((conn)->recv_bufsize = (recvbufsize))
/** Set the receive buffer in bytes */

Marco netconn_get_recvbufsize(conn)

#define netconn_get_recvbufsize(conn)              ((conn)->recv_bufsize)
/** Get the receive buffer in bytes */

Marco netconn_thread_init

#define netconn_thread_init 


      

Marco netconn_thread_cleanup

#define netconn_thread_cleanup 

      

Functions

Func netconn_prepare_delete

err_t  netconn_prepare_delete(struct netconn *conn);


      

Func netconn_delete

err_t  netconn_delete(struct netconn *conn);


      

Func netconn_getaddr

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


      

Func netconn_bind

err_t  netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port);


      

Func netconn_bind_if

err_t  netconn_bind_if(struct netconn *conn, u8_t if_idx);


      

Func netconn_connect

err_t  netconn_connect(struct netconn *conn, const ip_addr_t *addr, u16_t port);


      

Func netconn_disconnect

err_t  netconn_disconnect (struct netconn *conn);


      

Func netconn_listen_with_backlog

err_t  netconn_listen_with_backlog(struct netconn *conn, u8_t backlog);


      

Func netconn_accept

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


      

Func netconn_recv

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


      

Func netconn_recv_udp_raw_netbuf

err_t  netconn_recv_udp_raw_netbuf(struct netconn *conn, struct netbuf **new_buf);


      

Func netconn_recv_udp_raw_netbuf_flags

err_t  netconn_recv_udp_raw_netbuf_flags(struct netconn *conn, struct netbuf **new_buf, u8_t apiflags);


      

Func netconn_recv_tcp_pbuf

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


      

Func netconn_recv_tcp_pbuf_flags

err_t  netconn_recv_tcp_pbuf_flags(struct netconn *conn, struct pbuf **new_buf, u8_t apiflags);


      

Func netconn_tcp_recvd

err_t  netconn_tcp_recvd(struct netconn *conn, size_t len);


      

Func netconn_sendto

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


      

Func netconn_send

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


      

Func netconn_write_partly

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


      

Func netconn_write_vectors_partly

err_t  netconn_write_vectors_partly(struct netconn *conn, struct netvector *vectors, u16_t vectorcnt,
                                    u8_t apiflags, size_t *bytes_written);


      

Func netconn_close

err_t  netconn_close(struct netconn *conn);


      

Func netconn_shutdown

err_t  netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx);


      

Func netconn_join_leave_group

err_t  netconn_join_leave_group(struct netconn *conn, const ip_addr_t *multiaddr,
                            const ip_addr_t *netif_addr, enum netconn_igmp join_or_leave);


      

Func netconn_join_leave_group_netif

err_t  netconn_join_leave_group_netif(struct netconn *conn, const ip_addr_t *multiaddr,
                            u8_t if_idx, enum netconn_igmp join_or_leave);


      

Func netconn_gethostbyname_addrtype

err_t  netconn_gethostbyname_addrtype(const char *name, ip_addr_t *addr, u8_t dns_addrtype);


      

Func netconn_gethostbyname

err_t  netconn_gethostbyname(const char *name, ip_addr_t *addr);


      

Func netconn_err

err_t  netconn_err(struct netconn *conn);


      

Func netconn_thread_init

err_t netconn_thread_init(void *ptask);


      

Func netconn_thread_cleanup

err_t netconn_thread_cleanup(void *ptask);

      

Vars

Variable ip_pcb

struct ip_pcb;
/* forward-declare some structs to avoid to include their headers */

Variable tcp_pcb

struct tcp_pcb;


      

Variable udp_pcb

struct udp_pcb;


      

Variable raw_pcb

struct raw_pcb;


      

Variable netconn

struct netconn;


      

Variable api_msg

struct api_msg;


      

Variable pending_err

err_t pending_err;
/** the last asynchronous unreported error this netconn had */

Variable op_completed

sys_sem_t op_completed;
/** sem that is used to synchronously execute functions in the core context */

Variable recvmbox

sys_mbox_t recvmbox;
/** mbox where received packets are stored until they are fetched
      by the netconn application thread (can grow quite big) */

Variable acceptmbox

sys_mbox_t acceptmbox;
/** mbox where new connections are stored until processed
      by the application thread */

Variable mbox_threads_waiting

int mbox_threads_waiting;
/** number of threads waiting on an mbox. This is required to unblock
      all threads when closing while threads are waiting. */

Variable socket

int socket;


      

Variable s32_t

s32_t send_timeout;
/** timeout to wait for sending data (which means enqueueing data for sending
      in internal buffers) in milliseconds */

Variable recv_timeout

u32_t recv_timeout;
/** timeout in milliseconds to wait for new data to be received
      (or connections to arrive for listening netconns) */

Variable recv_bufsize

int recv_bufsize;
/** maximum amount of bytes queued in recvmbox
      not used for TCP: adjust TCP_WND instead! */

Variable recv_avail

int recv_avail;
/** number of bytes currently in recvmbox to be received,
      tested against recv_bufsize to limit bytes on recvmbox
      for UDP and RAW, used for FIONREAD */

Variable linger

s16_t linger;
/** values <0 mean linger is disabled, values > 0 are seconds to linger */

Variable flags

u8_t flags;
/** flags holding more netconn-internal state, see NETCONN_FLAG_* defines */

Variable api_msg

struct api_msg *current_msg;
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
      this temporarily stores the message.
      Also used during connect and close. */

Variable callback

netconn_callback callback;
/** A callback function that is informed about events for this netconn */

Variable netconn

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

      

Consts

Types

Typedefs

Typedef netconn_callback

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