# uip/uip.h File Reference

## Detailed Description

Header file for the uIP TCP/IP stack.

Author:
  Adam Dunkels <adam@dunkels.com>

The uIP TCP/IP stack header file contains definitions for a number of C macros that are used by uIP programs as well as internal uIP structures, TCP/IP header structures and function declarations.

Definition in file uip.h.

`#include "uipopt.h"`

Go to the source code of this file.

## Data Structures

struct | uip_conn
| Representation of a uIP TCP connection. More...
struct | uip_udp_conn
| Representation of a uIP UDP connection. More...
struct | uip_stats
| The structure holding the TCP/IP statistics that are gathered if UIP_STATISTICS is set to 1. More...
struct | uip_tcpip_hdr
struct | uip_icmpip_hdr
struct | uip_udpip_hdr
struct | uip_eth_addr
| Representation of a 48-bit Ethernet address. More...

## Defines

#define | uip_sethostaddr(addr)
| Set the IP address of this host.
#define | uip_gethostaddr(addr)
| Get the IP address of this host.
#define | uip_setdraddr(addr)
| Set the default router's IP address.
#define | uip_setnetmask(addr)
| Set the netmask.
#define | uip_getdraddr(addr)
| Get the default router's IP address.
#define | uip_getnetmask(addr)
| Get the netmask.
#define | uip_input()
| Process an incoming packet.
#define | uip_periodic(conn)
| Periodic processing for a connection identified by its number.
#define | uip_conn_active(conn) (uip_conns[conn].tcpstateflags != UIP_CLOSED)
#define | uip_periodic_conn(conn)
| Perform periodic processing for a connection identified by a pointer to its structure.
#define | uip_poll_conn(conn)
| Reuqest that a particular connection should be polled.
#define | uip_udp_periodic(conn)
| Periodic processing for a UDP connection identified by its number.
#define | uip_udp_periodic_conn(conn)
| Periodic processing for a UDP connection identified by a pointer to its structure.
#define | uip_outstanding(conn) ((conn)->len)
#define | uip_datalen()
| The length of any incoming data that is currently avaliable (if avaliable) in the uip_appdata buffer.
#define | uip_urgdatalen()
| The length of any out-of-band data (urgent data) that has arrived on the connection.
#define | uip_close()
| Close the current connection.
#define | uip_abort()
| Abort the current connection.
#define | uip_stop()
| Tell the sending host to stop sending data.
#define | uip_stopped(conn)
| Find out if the current connection has been previously stopped with uip_stop().
#define | uip_restart()
| Restart the current connection, if is has previously been stopped with uip_stop().
#define | uip_udpconnection()
| Is the current connection a UDP connection?
#define | uip_newdata()
| Is new incoming data available?
#define | uip_acked()
| Has previously sent data been acknowledged?
#define | uip_connected()
| Has the connection just been connected?
#define | uip_closed()
| Has the connection been closed by the other end?
#define | uip_aborted()
| Has the connection been aborted by the other end?
#define | uip_timedout()
| Has the connection timed out?
#define | uip_rexmit()
| Do we need to retransmit previously data?
#define | uip_poll()
| Is the connection being polled by uIP?
#define | uip_initialmss()
| Get the initial maxium segment size (MSS) of the current connection.
#define | uip_mss()
| Get the current maxium segment size that can be sent on the current connection.
#define | uip_udp_remove(conn)
| Removed a UDP connection.
#define | uip_udp_bind(conn, port)
| Bind a UDP connection to a local port.
#define | uip_udp_send(len)
| Send a UDP datagram of length len on the current connection.
#define | uip_ipaddr(addr, addr0, addr1, addr2, addr3)
| Construct an IP address from four bytes.
#define | uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
| Construct an IPv6 address from eight 16-bit words.
#define | uip_ipaddr_copy(dest, src)
| Copy an IP address to another IP address.
#define | uip_ipaddr_cmp(addr1, addr2)
| Compare two IP addresses.
#define | uip_ipaddr_maskcmp(addr1, addr2, mask)
| Compare two IP addresses with netmasks.
#define | uip_ipaddr_mask(dest, src, mask)
| Mask out the network part of an IP address.
#define | uip_ipaddr1(addr)
| Pick the first octet of an IP address.
#define | uip_ipaddr2(addr)
| Pick the second octet of an IP address.
#define | uip_ipaddr3(addr)
| Pick the third octet of an IP address.
#define | uip_ipaddr4(addr)
| Pick the fourth octet of an IP address.
#define | HTONS(n)
| Convert 16-bit quantity from host byte order to network byte order.
#define | ntohs htons
#define | UIP_ACKDATA 1
#define | UIP_NEWDATA 2
#define | UIP_REXMIT 4
#define | UIP_POLL 8
#define | UIP_CLOSE 16
#define | UIP_ABORT 32
#define | UIP_CONNECTED 64
#define | UIP_TIMEDOUT 128
#define | UIP_DATA 1
#define | UIP_TIMER 2
#define | UIP_POLL_REQUEST 3
#define | UIP_UDP_SEND_CONN 4
#define | UIP_UDP_TIMER 5
#define | UIP_CLOSED 0
#define | UIP_SYN_RCVD 1
#define | UIP_SYN_SENT 2
#define | UIP_ESTABLISHED 3
#define | UIP_FIN_WAIT_1 4
#define | UIP_FIN_WAIT_2 5
#define | UIP_CLOSING 6
#define | UIP_TIME_WAIT 7
#define | UIP_LAST_ACK 8
#define | UIP_TS_MASK 15
#define | UIP_STOPPED 16
#define | UIP_APPDATA_SIZE
| The buffer size available for user data in the uip_buf buffer.
#define | UIP_PROTO_ICMP 1
#define | UIP_PROTO_TCP 6
#define | UIP_PROTO_UDP 17
#define | UIP_PROTO_ICMP6 58
#define | UIP_IPH_LEN 20
#define | UIP_UDPH_LEN 8
#define | UIP_TCPH_LEN 20
#define | UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN)
#define | UIP_IPTCPH_LEN (UIP_TCPH_LEN + UIP_IPH_LEN)
#define | UIP_TCPIP_HLEN UIP_IPTCPH_LEN

## Typedefs

typedef u16_t | uip_ip4addr_t [2]
| Repressentation of an IP address.
typedef u16_t | uip_ip6addr_t [8]
typedef uip_ip4addr_t | uip_ipaddr_t

## Functions

void | uip_init (void)
| uIP initialization function.
void | uip_setipid (u16_t id)
| uIP initialization function.
void | uip_listen (u16_t port)
| Start listening to the specified port.
void | uip_unlisten (u16_t port)
| Stop listening to the specified port.
uip_conn * | uip_connect (uip_ipaddr_t *ripaddr, u16_t port)
| Connect to a remote host using TCP.
void | uip_send (const void *data, int len)
| Send data on the current connection.
uip_udp_conn * | uip_udp_new (uip_ipaddr_t *ripaddr, u16_t rport)
| Set up a new UDP connection.
u16_t | htons (u16_t val)
| Convert 16-bit quantity from host byte order to network byte order.
void | uip_process (u8_t flag)
u16_t | uip_chksum (u16_t *buf, u16_t len)
| Calculate the Internet checksum over a buffer.
u16_t | uip_ipchksum (void)
| Calculate the IP header checksum of the packet header in uip_buf.
u16_t | uip_tcpchksum (void)
| Calculate the TCP checksum of the packet in uip_buf and uip_appdata.
u16_t | uip_udpchksum (void)
| Calculate the UDP checksum of the packet in uip_buf and uip_appdata.

## Variables

u8_t | uip_buf [UIP_BUFSIZE+2]
| The uIP packet buffer.
void * | uip_appdata
| Pointer to the application data in the packet buffer.
u16_t | uip_len
| The length of the packet in the uip_buf buffer.
uip_conn * | uip_conn
| Pointer to the current TCP connection.
uip_conn | uip_conns [UIP_CONNS]
u8_t | uip_acc32 [4]
| 4-byte array used for the 32-bit sequence number calculations.
uip_udp_conn * | uip_udp_conn
| The current UDP connection.
uip_udp_conn | uip_udp_conns [UIP_UDP_CONNS]
uip_stats | uip_stat
| The uIP TCP/IP statistics.
u8_t | uip_flags
uip_ipaddr_t | uip_hostaddr
uip_ipaddr_t | uip_netmask
uip_ipaddr_t | uip_draddr