mbed OS5

Fork of UIPEthernet by Zoltan Hudak

Embed: (wiki syntax)

« Back to documentation index

The UIP TCP/IP stack

The UIP TCP/IP stack

UIP is an implementation of the TCP/IP protocol stack intended for small 8-bit and 16-bit microcontrollers. More...

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_eth_addr
 Representation of a 48-bit Ethernet address. More...

Modules

 UIP configuration functions
 

The UIP configuration functions are used for setting run-time parameters in UIP such as IP addresses.


 UIP initialization functions
 

The UIP initialization functions are used for booting UIP.


 UIP device driver functions
 

These functions are used by a network device driver for interacting with UIP.


 UIP application functions
 

Functions used by an application running of top of UIP.


 UIP conversion functions
 

These functions can be used for converting between different data formats used by UIP.


 Variables used in UIP device drivers
 

UIP has a few global variables that are used in device drivers for UIP.


 UIP Address Resolution Protocol
 

The Address Resolution Protocol ARP is used for mapping between IP addresses and link level addresses such as the Ethernet MAC addresses.


 Architecture specific UIP functions
 

The functions in the architecture specific module implement the IP check sum and 32-bit additions.


Files

file  uip.c
 

The UIP TCP/IP stack code.


file  uip.h
 

Header file for the UIP TCP/IP stack.


Typedefs

typedef u16_t uip_ip4addr_t [2]
 Repressentation of an IP address.

Functions

void uip_setipid (u16_t id)
 UIP initialization function.
void uip_add32 (u8_t *op32, u16_t op16)
 Carry out a 32-bit addition.
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_icmp6chksum (void)
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.
void uip_init (void)
 UIP initialization function.
struct uip_connuip_connect (uip_ipaddr_t *ripaddr, u16_t rport)
 Connect to a remote host using TCP.
struct uip_udp_connuip_udp_new (uip_ipaddr_t *ripaddr, u16_t rport)
 Set up a new UDP connection.
void uip_unlisten (u16_t port)
 Stop listening to the specified port.
void uip_listen (u16_t port)
 Start listening to the specified port.
static u8_t uip_reass (void)
u16_t htons (u16_t val)
 Convert 16-bit quantity from host byte order to network byte order.
void uip_send (const void *data, int len)
 Send data on the current connection.

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.
struct uip_connuip_conn
 Pointer to the current TCP connection.
struct uip_udp_connuip_udp_conn
 The current UDP connection.
u8_t uip_acc32 [4]
 4-byte array used for the 32-bit sequence number calculations.
struct uip_stats uip_stat
 The UIP TCP/IP statistics.
void * uip_appdata
 Pointer to the application data in the packet buffer.
struct uip_connuip_conn
 Pointer to the current TCP connection.
struct uip_udp_connuip_udp_conn
 The current UDP connection.
struct uip_stats uip_stat
 The UIP TCP/IP statistics.

Detailed Description

UIP is an implementation of the TCP/IP protocol stack intended for small 8-bit and 16-bit microcontrollers.

{@

UIP provides the necessary protocols for Internet communication, with a very small code footprint and RAM requirements - the UIP code size is on the order of a few kilobytes and RAM usage is on the order of a few hundred bytes.


Typedef Documentation

typedef u16_t uip_ip4addr_t[2]

Repressentation of an IP address.

Definition at line 60 of file uip.h.


Function Documentation

u16_t htons ( u16_t  val )

Convert 16-bit quantity from host byte order to network byte order.

This function is primarily used for converting variables from host byte order to network byte order. For converting constants to network byte order, use the HTONS() macro instead.

Definition at line 2045 of file uip.c.

void uip_add32 ( u8_t *  op32,
u16_t  op16 
)

Carry out a 32-bit addition.

Note:
Parameters:
@retval

Definition at line 265 of file uip.c.

u16_t uip_chksum ( u16_t *  buf,
u16_t  len 
)

Calculate the Internet checksum over a buffer.

The Internet checksum is the one's complement of the one's complement sum of all 16-bit words in the buffer.

See RFC1071.

Parameters:
bufA pointer to the buffer over which the checksum is to be computed.
lenThe length of the buffer over which the checksum is to be computed.
Returns:
The Internet checksum of the buffer.

Definition at line 326 of file uip.c.

struct uip_conn* uip_connect ( uip_ipaddr_t *  ripaddr,
u16_t  rport 
) [read]

Connect to a remote host using TCP.

Note:
Parameters:
@retval

Definition at line 443 of file uip.c.

u16_t uip_icmp6chksum ( void   )
Note:
Parameters:
@retval

Definition at line 382 of file uip.c.

void uip_init ( void   )

UIP initialization function.

This function should be called at boot up to initilize the UIP TCP/IP stack.

Definition at line 408 of file uip.c.

u16_t uip_ipchksum ( void   )

Calculate the IP header checksum of the packet header in uip_buf.

Note:
Parameters:
@retvalThe IP header checksum is the Internet checksum of the 20 bytes of the IP header.
Returns:
The IP header checksum of the IP header in the uip_buf buffer.

Definition at line 339 of file uip.c.

void uip_listen ( u16_t  port )

Start listening to the specified port.

Note:
Since this function expects the port number in network byte order, a conversion using HTONS() or htons() is necessary.
 uip_listen(HTONS(80));
Parameters:
portA 16-bit port number in network byte order.

Definition at line 572 of file uip.c.

static u8_t uip_reass ( void   ) [static]
Note:
Parameters:
@retval

Definition at line 601 of file uip.c.

void uip_send ( const void *  data,
int  len 
)

Send data on the current connection.

This function is used to send out a single segment of TCP data. Only applications that have been invoked by UIP for event processing can send data.

The amount of data that actually is sent out after a call to this funcion is determined by the maximum amount of data TCP allows. UIP will automatically crop the data so that only the appropriate amount of data is sent. The function uip_mss() can be used to query UIP for the amount of data that actually will be sent.

Note:
This function does not guarantee that the sent data will arrive at the destination. If the data is lost in the network, the application will be invoked with the uip_rexmit() event being set. The application will then have to resend the data using this function.
Parameters:
dataA pointer to the data which is to be sent.
lenThe maximum amount of data bytes to be sent.

Definition at line 2050 of file uip.c.

void uip_setipid ( u16_t  id )

UIP initialization function.

Note:
Parameters:
@retval

Definition at line 188 of file uip.c.

u16_t uip_tcpchksum ( void   )

Calculate the TCP checksum of the packet in uip_buf and uip_appdata.

The TCP checksum is the Internet checksum of data contents of the TCP segment, and a pseudo-header as defined in RFC793.

Returns:
The TCP checksum of the TCP segment in uip_buf and pointed to by uip_appdata.

Definition at line 388 of file uip.c.

struct uip_udp_conn* uip_udp_new ( uip_ipaddr_t *  ripaddr,
u16_t  rport 
) [read]

Set up a new UDP connection.

Note:
Parameters:
@retval

Definition at line 516 of file uip.c.

u16_t uip_udpchksum ( void   )

Calculate the UDP checksum of the packet in uip_buf and uip_appdata.

Note:
Parameters:
@retvalThe UDP checksum is the Internet checksum of data contents of the UDP segment, and a pseudo-header as defined in RFC768.
Returns:
The UDP checksum of the UDP segment in uip_buf and pointed to by uip_appdata.

Definition at line 401 of file uip.c.

void uip_unlisten ( u16_t  port )

Stop listening to the specified port.

Note:
Since this function expects the port number in network byte order, a conversion using HTONS() or htons() is necessary.
 uip_unlisten(HTONS(80));
Parameters:
portA 16-bit port number in network byte order.

Definition at line 562 of file uip.c.


Variable Documentation

u8_t uip_acc32[4]

4-byte array used for the 32-bit sequence number calculations.

Definition at line 202 of file uip.c.

void* uip_appdata

Pointer to the application data in the packet buffer.

This pointer points to the application data when the application is called. If the application wishes to send data, the application may use this space to write the data into before calling uip_send().

Definition at line 142 of file uip.c.

void* uip_appdata

Pointer to the application data in the packet buffer.

This pointer points to the application data when the application is called. If the application wishes to send data, the application may use this space to write the data into before calling uip_send().

Definition at line 142 of file uip.c.

u8_t uip_buf[UIP_BUFSIZE+2]

The UIP packet buffer.

The uip_buf array is used to hold incoming and outgoing packets. The device driver should place incoming data into this buffer. When sending data, the device driver should read the link level headers and the TCP/IP headers from this buffer. The size of the link level headers is configured by the UIP_LLH_LEN define.

Note:
The application data need not be placed in this buffer, so the device driver must read it from the place pointed to by the uip_appdata pointer as illustrated by the following example:
 void
 devicedriver_send(void)
 {
    hwsend(&uip_buf[0], UIP_LLH_LEN);
    if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN) {
      hwsend(&uip_buf[UIP_LLH_LEN], uip_len - UIP_LLH_LEN);
    } else {
      hwsend(&uip_buf[UIP_LLH_LEN], UIP_TCPIP_HLEN);
      hwsend(uip_appdata, uip_len - UIP_TCPIP_HLEN - UIP_LLH_LEN);
    }
 }

Definition at line 138 of file uip.c.

struct uip_conn* uip_conn

Pointer to the current TCP connection.

The uip_conn pointer can be used to access the current TCP connection.

Definition at line 162 of file uip.c.

struct uip_conn* uip_conn

Pointer to the current TCP connection.

The uip_conn pointer can be used to access the current TCP connection.

Definition at line 162 of file uip.c.

u16_t uip_len

The length of the packet in the uip_buf buffer.

The global variable uip_len holds the length of the packet in the uip_buf buffer.

When the network device driver calls the UIP input function, uip_len should be set to the length of the packet in the uip_buf buffer.

When sending packets, the device driver should use the contents of the uip_len variable to determine the length of the outgoing packet.

Definition at line 154 of file uip.c.

The UIP TCP/IP statistics.

This is the variable in which the UIP TCP/IP statistics are gathered.

Definition at line 243 of file uip.c.

The UIP TCP/IP statistics.

This is the variable in which the UIP TCP/IP statistics are gathered.

Definition at line 243 of file uip.c.

The current UDP connection.

Definition at line 174 of file uip.c.

The current UDP connection.

Definition at line 174 of file uip.c.