Contiki-NG
uIP device driver functions

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

Data Structures

union  uip_buf_t
 The uIP packet buffer. More...
 

Macros

#define uip_input()
 Process an incoming packet. More...
 
#define uip_periodic(conn)
 Periodic processing for a connection identified by its number. More...
 
#define uip_conn_active(conn)   (uip_conns[conn].tcpstateflags != UIP_CLOSED)
 Macro to determine whether a specific uIP connection is active. More...
 
#define uip_periodic_conn(conn)
 Perform periodic processing for a connection identified by a pointer to its structure. More...
 
#define uip_poll_conn(conn)
 Request that a particular connection should be polled. More...
 
#define uip_udp_periodic(conn)
 Periodic processing for a UDP connection identified by its number. More...
 
#define uip_udp_periodic_conn(conn)
 Periodic processing for a UDP connection identified by a pointer to its structure. More...
 
#define uip_buf   (uip_aligned_buf.u8)
 Macro to access uip_aligned_buf as an array of bytes.
 

Functions

void uip_reass_over (void)
 Abandon the reassembly of the current packet. More...
 

Variables

uip_buf_t uip_aligned_buf
 Packet buffer for incoming and outgoing packets.
 

Detailed Description

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

Macro Definition Documentation

◆ uip_conn_active

#define uip_conn_active (   conn)    (uip_conns[conn].tcpstateflags != UIP_CLOSED)

Macro to determine whether a specific uIP connection is active.

Parameters
connThe connection's number
Return values
0Connection closed

Definition at line 358 of file uip.h.

◆ uip_input

#define uip_input ( )

Process an incoming packet.

This function should be called when the device driver has received a packet from the network. The packet from the device driver must be present in the uip_buf buffer, and the length of the packet should be placed in the uip_len variable.

When the function returns, there may be an outbound packet placed in the uip_buf packet buffer. If so, the uip_len variable is set to the length of the packet. If no packet is to be sent out, the uip_len variable is set to 0.

The usual way of calling the function is presented by the source code below.

uip_len = devicedriver_poll();
if(uip_len > 0) {
if(uip_len > 0) {
devicedriver_send();
}
}
#define uip_input()
Process an incoming packet.
Definition: uip.h:303
uint16_t uip_len
The length of the packet in the uip_buf buffer.
Definition: uip6.c:159
Note
If you are writing a uIP device driver that needs ARP (Address Resolution Protocol), e.g., when running uIP over Ethernet, you will need to call the uIP ARP code before calling this function:
#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
uip_len = ethernet_devicedrver_poll();
if(uip_len > 0) {
if(BUF->type == UIP_HTONS(UIP_ETHTYPE_IP)) {
uip_arp_ipin();
if(uip_len > 0) {
uip_arp_out();
ethernet_devicedriver_send();
}
} else if(BUF->type == UIP_HTONS(UIP_ETHTYPE_ARP)) {
uip_arp_arpin();
if(uip_len > 0) {
ethernet_devicedriver_send();
}
}
#define UIP_HTONS(n)
Convert 16-bit quantity from host byte order to network byte order.
Definition: uip.h:1157

Definition at line 303 of file uip.h.

◆ uip_periodic

#define uip_periodic (   conn)

Periodic processing for a connection identified by its number.

This function does the necessary periodic processing (timers, polling) for a uIP TCP connection, and should be called when the periodic uIP timer goes off. It should be called for every connection, regardless of whether they are open of closed.

When the function returns, it may have an outbound packet waiting for service in the uIP packet buffer, and if so the uip_len variable is set to a value larger than zero. The device driver should be called to send out the packet.

The usual way of calling the function is through a for() loop like this:

for(i = 0; i < UIP_TCP_CONNS; ++i) {
if(uip_len > 0) {
devicedriver_send();
}
}
#define uip_periodic(conn)
Periodic processing for a connection identified by its number.
Definition: uip.h:349
#define UIP_TCP_CONNS
The maximum number of simultaneously open TCP connections.
Definition: uipopt.h:285
Note
If you are writing a uIP device driver that needs ARP (Address Resolution Protocol), e.g., when running uIP over Ethernet, you will need to call the uip_arp_out() function before calling the device driver:
for(i = 0; i < UIP_TCP_CONNS; ++i) {
if(uip_len > 0) {
uip_arp_out();
ethernet_devicedriver_send();
}
}
Parameters
connThe number of the connection which is to be periodically polled.

Definition at line 349 of file uip.h.

◆ uip_periodic_conn

#define uip_periodic_conn (   conn)

Perform periodic processing for a connection identified by a pointer to its structure.

Same as uip_periodic() but takes a pointer to the actual uip_conn struct instead of an integer as its argument. This function can be used to force periodic processing of a specific connection.

Parameters
connA pointer to the uip_conn struct for the connection to be processed.

Definition at line 373 of file uip.h.

◆ uip_poll_conn

#define uip_poll_conn (   conn)

Request that a particular connection should be polled.

Similar to uip_periodic_conn() but does not perform any timer processing. The application is polled for new data.

Parameters
connA pointer to the uip_conn struct for the connection to be processed.

Definition at line 387 of file uip.h.

◆ uip_udp_periodic

#define uip_udp_periodic (   conn)

Periodic processing for a UDP connection identified by its number.

This function is essentially the same as uip_periodic(), but for UDP connections. It is called in a similar fashion as the uip_periodic() function:

for(i = 0; i < UIP_UDP_CONNS; i++) {
if(uip_len > 0) {
devicedriver_send();
}
}
#define uip_udp_periodic(conn)
Periodic processing for a UDP connection identified by its number.
Definition: uip.h:424
#define UIP_UDP_CONNS
The maximum amount of concurrent UDP connections.
Definition: uipopt.h:231
Note
As for the uip_periodic() function, special care has to be taken when using uIP together with ARP and Ethernet:
for(i = 0; i < UIP_UDP_CONNS; i++) {
if(uip_len > 0) {
uip_arp_out();
ethernet_devicedriver_send();
}
}
Parameters
connThe number of the UDP connection to be processed.

Definition at line 424 of file uip.h.

◆ uip_udp_periodic_conn

#define uip_udp_periodic_conn (   conn)

Periodic processing for a UDP connection identified by a pointer to its structure.

Same as uip_udp_periodic() but takes a pointer to the actual uip_conn struct instead of an integer as its argument. This function can be used to force periodic processing of a specific connection.

Parameters
connA pointer to the uip_udp_conn struct for the connection to be processed.

Definition at line 441 of file uip.h.

Function Documentation

◆ uip_reass_over()

void uip_reass_over ( void  )

Abandon the reassembly of the current packet.

Note
We don't have a complete packet to put in the error message. We could include the first fragment but since its not mandated by any RFC, we decided not to include it as it reduces the size of the packet.

Definition at line 775 of file uip6.c.