Contiki-NG
Loading...
Searching...
No Matches
uIP application functions

Macros

#define uip_datalen()
 The length of any incoming data that is currently available (if available) 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 maximum segment size (MSS) of the current connection.
 
#define uip_mss()
 Get the current maximum segment size that can be sent on the current connection.
 
#define uip_udp_remove(conn)
 Remove 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.
 

Functions

void uip_listen (uint16_t port)
 Start listening to the specified port.
 
void uip_unlisten (uint16_t port)
 Stop listening to the specified port.
 
struct uip_connuip_connect (const uip_ipaddr_t *ripaddr, uint16_t port)
 Connect to a remote host using TCP.
 
void uip_send (const void *data, int len)
 Send data on the current connection.
 
struct uip_udp_connuip_udp_new (const uip_ipaddr_t *ripaddr, uint16_t rport)
 Set up a new UDP connection.
 

Detailed Description

Functions used by an application running on top of uIP.

Macro Definition Documentation

◆ uip_abort

#define uip_abort ( )

Abort the current connection.

This function will abort (reset) the current connection, and is usually used when an error has occurred that prevents using the uip_close() function.

Definition at line 624 of file uip.h.

◆ uip_aborted

#define uip_aborted ( )

Has the connection been aborted by the other end?

Non-zero if the current connection has been aborted (reset) by the remote host.

Definition at line 723 of file uip.h.

◆ uip_acked

#define uip_acked ( )

Has previously sent data been acknowledged?

Will reduce to non-zero if the previously sent data has been acknowledged by the remote host. This means that the application can send new data.

Definition at line 691 of file uip.h.

◆ uip_close

#define uip_close ( )

Close the current connection.

This function will close the current connection in a nice way.

Definition at line 613 of file uip.h.

◆ uip_closed

#define uip_closed ( )

Has the connection been closed by the other end?

Is non-zero if the connection has been closed by the remote host. The application may then do the necessary clean-ups.

Definition at line 713 of file uip.h.

◆ uip_connected

#define uip_connected ( )

Has the connection just been connected?

Reduces to non-zero if the current connection has been connected to a remote host. This will happen both if the connection has been actively opened (with uip_connect()) or passively opened (with uip_listen()).

Definition at line 703 of file uip.h.

◆ uip_datalen

#define uip_datalen ( )

The length of any incoming data that is currently available (if available) in the uip_appdata buffer.

The test function uip_data() must first be used to check if there is any data available at all.

Definition at line 593 of file uip.h.

Referenced by newdata().

◆ uip_mss

#define uip_mss ( )

Get the current maximum segment size that can be sent on the current connection.

The current maximum segment size that can be sent on the connection is computed from the receiver's window and the MSS of the connection (which also is available by calling uip_initialmss()).

Definition at line 780 of file uip.h.

◆ uip_newdata

#define uip_newdata ( )

Is new incoming data available?

Will reduce to non-zero if there is new data for the application present at the uip_appdata pointer. The size of the data is available through the uip_len variable.

Definition at line 680 of file uip.h.

◆ uip_poll

#define uip_poll ( )

Is the connection being polled by uIP?

Is non-zero if the reason the application is invoked is that the current connection has been idle for a while and should be polled.

The polling event can be used for sending data without having to wait for the remote host to send data.

Definition at line 759 of file uip.h.

◆ uip_restart

#define uip_restart ( )

Restart the current connection, if is has previously been stopped with uip_stop().

This function will open the receiver's window again so that we start receiving data for the current connection.

Definition at line 653 of file uip.h.

◆ uip_rexmit

#define uip_rexmit ( )

Do we need to retransmit previously data?

Reduces to non-zero if the previously sent data has been lost in the network, and the application should retransmit it. The application should send the exact same data as it did the last time, using the uip_send() function.

Definition at line 745 of file uip.h.

◆ uip_stop

#define uip_stop ( )

Tell the sending host to stop sending data.

This function will close our receiver's window so that we stop receiving data for the current connection.

Definition at line 634 of file uip.h.

◆ uip_timedout

#define uip_timedout ( )

Has the connection timed out?

Non-zero if the current connection has been aborted due to too many retransmissions.

Definition at line 733 of file uip.h.

◆ uip_udp_bind

#define uip_udp_bind ( conn,
port )

Bind a UDP connection to a local port.

Parameters
connA pointer to the uip_udp_conn structure for the connection.
portThe local port number, in network byte order.

Definition at line 830 of file uip.h.

◆ uip_udp_remove

#define uip_udp_remove ( conn)

Remove a UDP connection.

Parameters
connA pointer to the uip_udp_conn structure for the connection.

Definition at line 818 of file uip.h.

◆ uip_udp_send

#define uip_udp_send ( len)

Send a UDP datagram of length len on the current connection.

This function can only be called in response to a UDP event (poll or newdata). The data must be present in the uip_buf buffer, at the place pointed to by the uip_appdata pointer.

Parameters
lenThe length of the data in the uip_buf buffer.

Definition at line 843 of file uip.h.

◆ uip_udpconnection

#define uip_udpconnection ( )

Is the current connection a UDP connection?

This function checks whether the current connection is a UDP connection.

Definition at line 669 of file uip.h.

◆ uip_urgdatalen

#define uip_urgdatalen ( )

The length of any out-of-band data (urgent data) that has arrived on the connection.

Note
The configuration parameter UIP_URGDATA must be set for this function to be enabled.

Definition at line 604 of file uip.h.

Function Documentation

◆ uip_connect()

struct uip_conn * uip_connect ( const uip_ipaddr_t * ripaddr,
uint16_t port )

Connect to a remote host using TCP.

This function is used to start a new connection to the specified port on the specified 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 available 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 UIP_HTONS() or uip_htons() is necessary.
uip_ipaddr_t ipaddr;
uip_ipaddr(&ipaddr, 192,168,1,2);
struct uip_conn * uip_connect(const uip_ipaddr_t *ripaddr, uint16_t port)
Connect to a remote host using TCP.
#define UIP_HTONS(n)
Convert 16-bit quantity from host byte order to network byte order.
Definition uip.h:1157
#define uip_ipaddr(addr, addr0, addr1, addr2, addr3)
Construct an IP address from four bytes.
Definition uip.h:898
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
Definition uip-nd6.c:116
Parameters
ripaddrThe IP address of the remote host.
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.

◆ uip_listen()

void uip_listen ( uint16_t port)

Start listening to the specified port.

Note
Since this function expects the port number in network byte order, a conversion using UIP_HTONS() or uip_htons() is necessary.
void uip_listen(uint16_t port)
Start listening to the specified port.
Definition uip6.c:578
Parameters
portA 16-bit port number in network byte order.

Definition at line 578 of file uip6.c.

References UIP_LISTENPORTS.

Referenced by tcp_listen().

◆ uip_send()

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 function 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 2353 of file uip6.c.

References UIP_BUFSIZE.

◆ uip_udp_new()

struct uip_udp_conn * uip_udp_new ( const uip_ipaddr_t * ripaddr,
uint16_t rport )

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, UIP_HTONS(12345));
if(c != NULL) {
}
#define uip_udp_bind(conn, port)
Bind a UDP connection to a local port.
Definition uip.h:830
struct uip_udp_conn * uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport)
Set up a new UDP connection.
Definition uip6.c:520
Representation of a uIP UDP connection.
Definition uip.h:1309
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
Definition uip-nd6.c:107
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 520 of file uip6.c.

References uip_udp_conn::lport, uip_udp_conn::ripaddr, uip_udp_conn::rport, uip_ds6_if, UIP_HTONS, uip_htons(), uip_ipaddr_copy, and UIP_UDP_CONNS.

Referenced by udp_new().

◆ uip_unlisten()

void uip_unlisten ( uint16_t port)

Stop listening to the specified port.

Note
Since this function expects the port number in network byte order, a conversion using UIP_HTONS() or uip_htons() is necessary.
void uip_unlisten(uint16_t port)
Stop listening to the specified port.
Definition uip6.c:566
Parameters
portA 16-bit port number in network byte order.

Definition at line 566 of file uip6.c.

References UIP_LISTENPORTS.

Referenced by tcp_unlisten().