These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!

Embed: (wiki syntax)

« Back to documentation index

uIP

Modules

 Clock interface
 

The clock interface is the interface between the timer library and the platform specific clock functionality.


 Protosockets library
 

The protosocket library provides an interface to the uIP stack that is similar to the traditional BSD socket interface.


 Timer library
 

The timer library provides functions for setting, resetting and restarting timers, and for checking if a timer has expired.


 The uIP TCP/IP stack
 

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


 Configuration options for uIP
 

uIP is configured using the per-project configuration file uipopt.h.


 Apps
 Pt

Files

file  uip.c
 

The uIP TCP/IP stack code.


Functions

void uip_add32 (u8_t *op32, u16_t op16)
 Carry out a 32-bit addition.
u16_t uip_chksum (u16_t *data, 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.
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.
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_acc32 [4]
 4-byte array used for the 32-bit sequence number calculations.
struct uip_stats uip_stat
 The uIP TCP/IP statistics.

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 1902 of file uip.c.

void uip_add32 ( u8_t op32,
u16_t  op16 
)

Carry out a 32-bit addition.

Because not all architectures for which uIP is intended has native 32-bit arithmetic, uIP uses an external C function for doing the required 32-bit additions in the TCP protocol processing. This function should add the two arguments and place the result in the global variable uip_acc32.

Note:
The 32-bit integer pointed to by the op32 parameter and the result in the uip_acc32 variable are in network byte order (big endian).
Parameters:
op32A pointer to a 4-byte array representing a 32-bit integer in network byte order (big endian).
op16A 16-bit integer in host byte order.

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 327 of file uip.c.

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

Connect to a remote host using TCP.

This function is used to start a new connection to the specified port on the specied host. It allocates a new connection identifier, sets the connection to the SYN_SENT state and sets the retransmission timer to 0. This will cause a TCP SYN segment to be sent out the next time this connection is periodically processed, which usually is done within 0.5 seconds after the call to uip_connect().

Note:
This function is avaliable only if support for active open has been configured by defining UIP_ACTIVE_OPEN to 1 in uipopt.h.
Since this function requires the port number to be in network byte order, a conversion using HTONS() or htons() is necessary.
 uip_ipaddr_t ipaddr;

 uip_ipaddr(&ipaddr, 192,168,1,2);
 uip_connect(&ipaddr, HTONS(80));
Parameters:
ripaddrThe IP address of the remote hot.
portA 16-bit port number in network byte order.
Returns:
A pointer to the uIP connection identifier for the new connection, or NULL if no connection could be allocated.

Definition at line 423 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 395 of file uip.c.

u16_t uip_ipchksum ( void   )

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

The 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 334 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 545 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 1908 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 380 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.

This function sets up a new UDP connection. The function will automatically allocate an unused local port for the new connection. However, another port can be chosen by using the uip_udp_bind() call, after the uip_udp_new() function has been called.

Example:

 uip_ipaddr_t addr;
 struct uip_udp_conn *c;

 uip_ipaddr(&addr, 192,168,2,1);
 c = uip_udp_new(&addr, HTONS(12345));
 if(c != NULL) {
   uip_udp_bind(c, HTONS(12344));
 }
Parameters:
ripaddrThe IP address of the remote host.
rportThe remote port number in network byte order.
Returns:
The uip_udp_conn structure for the new connection or NULL if no connection could be allocated.

Definition at line 489 of file uip.c.

u16_t uip_udpchksum ( void   )

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

The 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 387 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 534 of file uip.c.


Variable Documentation

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

Definition at line 208 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 249 of file uip.c.