TCP/IP support in Contiki is implemented using the uIP TCP/IP stack.
For sending and receiving data, Contiki uses the functions provided by the uIP module, but Contiki adds a set of functions for connection management. The connection management functions make sure that the uIP TCP/IP connections are connected to the correct process.
Contiki also includes an optional protosocket library that provides an API similar to the BSD socket API.
Data Structures | |
struct | tcpip_uipstate |
Files | |
file | wireless/SmartConnect_6LoWPAN/core/net/ip/tcpip.h |
Header for the Contiki/uIP interface. | |
Macros | |
#define | UIP_APPCALL tcpip_uipcall |
The name of the application function that uIP should call in response to TCP/IP events. More... | |
#define | UIP_ICMP6_APPCALL tcpip_icmp6_call |
#define | UIP_UDP_APPCALL tcpip_uipcall |
Typedefs | |
typedef struct tcpip_uipstate | uip_icmp6_appstate_t |
Functions | |
PROCESS_NAME (tcpip_process) | |
void | tcpip_uipcall (void) |
Variables | |
CCIF process_event_t | tcpip_event |
The uIP event. More... | |
TCP functions | |
CCIF void | tcp_attach (struct uip_conn *conn, void *appstate) |
Attach a TCP connection to the current process. More... | |
CCIF void | tcp_listen (uint16_t port) |
Open a TCP port. More... | |
CCIF void | tcp_unlisten (uint16_t port) |
Close a listening TCP port. More... | |
CCIF struct uip_conn * | tcp_connect (uip_ipaddr_t *ripaddr, uint16_t port, void *appstate) |
Open a TCP connection to the specified IP address and port. More... | |
void | tcpip_poll_tcp (struct uip_conn *conn) |
Cause a specified TCP connection to be polled. More... | |
#define | tcp_markconn(conn, appstate) tcp_attach(conn, appstate) |
UDP functions | |
void | udp_attach (struct uip_udp_conn *conn, void *appstate) |
Attach the current process to a UDP connection. More... | |
CCIF struct uip_udp_conn * | udp_new (const uip_ipaddr_t *ripaddr, uint16_t port, void *appstate) |
Create a new UDP connection. More... | |
struct uip_udp_conn * | udp_broadcast_new (uint16_t port, void *appstate) |
Create a new UDP broadcast connection. More... | |
CCIF void | tcpip_poll_udp (struct uip_udp_conn *conn) |
Cause a specified UDP connection to be polled. More... | |
#define | udp_markconn(conn, appstate) udp_attach(conn, appstate) |
#define | udp_bind(conn, port) uip_udp_bind(conn, port) |
Bind a UDP connection to a local port. More... | |
TCP/IP packet processing | |
unsigned char | tcpip_do_forwarding |
Is forwarding generally enabled? More... | |
unsigned char | tcpip_is_forwarding |
CCIF void | tcpip_input (void) |
Deliver an incoming packet to the TCP/IP stack. More... | |
uint8_t | tcpip_output (const uip_lladdr_t *) |
Output packet to layer 2 The eventual parameter is the MAC address of the destination. More... | |
void | tcpip_set_outputfunc (uint8_t(*f)(const uip_lladdr_t *)) |
void | tcpip_ipv6_output (void) |
This function does address resolution and then calls tcpip_output. More... | |
#define | tcpip_set_forwarding(forwarding) tcpip_do_forwarding = (forwarding) |
#define tcp_markconn | ( | conn, | |
appstate | |||
) | tcp_attach(conn, appstate) |
Referenced by appcall(), httpd_appcall(), websocket_http_client_appcall(), and websocket_http_client_get().
#define tcpip_set_forwarding | ( | forwarding | ) | tcpip_do_forwarding = (forwarding) |
#define udp_bind | ( | conn, | |
port | |||
) | uip_udp_bind(conn, port) |
Bind a UDP connection to a local port.
This function binds a UDP connection to a specified local port.
When a connection is created with udp_new(), it gets a local port number assigned automatically. If the application needs to bind the connection to a specified local port, this function should be used.
conn | A pointer to the UDP connection that is to be bound. |
port | The port number in network byte order to which to bind the connection. |
Referenced by dhcpc_init(), ip64_dhcpc_init(), PROCESS_THREAD(), simple_udp_register(), and udp_socket_bind().
#define udp_markconn | ( | conn, | |
appstate | |||
) | udp_attach(conn, appstate) |
define UIP_APPCALL tcpip_uipcall |
The name of the application function that uIP should call in response to TCP/IP events.
Referenced by uip_process().
#define UIP_ICMP6_APPCALL tcpip_icmp6_call |
Referenced by uip_process().
#define UIP_UDP_APPCALL tcpip_uipcall |
Referenced by uip_process().
typedef struct tcpip_uipstate uip_icmp6_appstate_t |
PROCESS_NAME | ( | tcpip_process | ) |
CCIF void tcp_attach | ( | struct uip_conn * | conn, |
void * | appstate | ||
) |
Attach a TCP connection to the current process.
This function attaches the current process to a TCP connection. Each TCP connection must be attached to a process in order for the process to be able to receive and send data. Additionally, this function can add a pointer with connection state to the connection.
conn | A pointer to the TCP connection. |
appstate | An opaque pointer that will be passed to the process whenever an event occurs on the connection. |
Referenced by tcp_socket_unregister().
CCIF struct uip_conn* tcp_connect | ( | uip_ipaddr_t * | ripaddr, |
uint16_t | port, | ||
void * | appstate | ||
) |
Open a TCP connection to the specified IP address and port.
This function opens a TCP connection to the specified port at the host specified with an IP address. Additionally, an opaque pointer can be attached to the connection. This pointer will be sent together with uIP events to the process.
ripaddr | Pointer to the IP address of the remote host. |
port | Port number in network byte order. |
appstate | Pointer to application defined data. |
Referenced by tcp_socket_connect(), and websocket_http_client_get().
CCIF void tcp_listen | ( | uint16_t | port | ) |
Open a TCP port.
This function opens a TCP port for listening. When a TCP connection request occurs for the port, the process will be sent a tcpip_event with the new connection request.
port | The port number in network byte order. |
Referenced by httpd_init(), and tcp_socket_listen().
CCIF void tcp_unlisten | ( | uint16_t | port | ) |
Close a listening TCP port.
This function closes a listening TCP port.
port | The port number in network byte order. |
Referenced by tcp_socket_unlisten().
CCIF void tcpip_input | ( | void | ) |
Deliver an incoming packet to the TCP/IP stack.
This function is called by network device drivers to deliver an incoming packet to the TCP/IP stack. The incoming packet must be present in the uip_buf buffer, and the length of the packet must be in the global uip_len variable.
References NULL, PACKET_INPUT, process_post_synch(), uip_ext_len, and uip_len.
void tcpip_ipv6_output | ( | void | ) |
This function does address resolution and then calls tcpip_output.
References rpl_dag::instance, rpl_instance::instance_id, uip_ds6_nbr::ipaddr, nbr, NBR_DELAY, NBR_INCOMPLETE, NBR_STALE, uip_ds6_nbr::nscount, NULL, printf, PRINTF, uip_ds6_nbr::reachable, remove_ext_hdr(), uip_ds6_netif::retrans_timer, rpl_repair_root(), rpl_update_header_final(), uip_ds6_nbr::sendns, uip_ds6_nbr::state, uip_ds6_route::state, stimer_set(), tcpip_output(), uip_ip6addr_t::u8, uip_ds6_defrt_choose(), uip_ds6_if, uip_ds6_is_addr_onlink(), uip_ds6_is_my_addr, uip_ds6_nbr_add(), uip_ds6_nbr_get_ll(), uip_ds6_nbr_lookup(), uip_ds6_route_lookup(), uip_ds6_route_nexthop(), uip_ds6_route_rm(), uip_ext_len, UIP_IP_BUF, uip_is_addr_mcast, uip_is_addr_unspecified, uip_len, UIP_LINK_MTU, UIP_LOG, UIP_ND6_DELAY_FIRST_PROBE_TIME, uip_nd6_ns_output(), uip_packetqueue_alloc(), uip_packetqueue_buf(), uip_packetqueue_buflen(), uip_packetqueue_free(), and uip_packetqueue_set_buflen().
Referenced by eventhandler(), packet_input(), uip_icmp6_send(), uip_split_output(), and uip_udp_packet_send().
uint8_t tcpip_output | ( | const uip_lladdr_t * | ) |
Output packet to layer 2 The eventual parameter is the MAC address of the destination.
References NULL, outputfunc, ret, and UIP_LOG.
Referenced by eventhandler(), packet_input(), tcpip_ipv6_output(), uip_split_output(), and uip_udp_packet_send().
void tcpip_poll_tcp | ( | struct uip_conn * | conn | ) |
Cause a specified TCP connection to be polled.
This function causes uIP to poll the specified TCP connection. The function is used when the application has data that is to be sent immediately and do not wish to wait for the periodic uIP polling mechanism.
conn | A pointer to the TCP connection that should be polled. |
Referenced by websocket_http_client_send().
CCIF void tcpip_poll_udp | ( | struct uip_udp_conn * | conn | ) |
Cause a specified UDP connection to be polled.
This function causes uIP to poll the specified UDP connection. The function is used when the application has data that is to be sent immediately and do not wish to wait for the periodic uIP polling mechanism.
conn | A pointer to the UDP connection that should be polled. |
Referenced by PROCESS_THREAD(), and while().
void tcpip_set_outputfunc | ( | uint8_t(*)(const uip_lladdr_t *) | f | ) |
References outputfunc.
void tcpip_uipcall | ( | void | ) |
void udp_attach | ( | struct uip_udp_conn * | conn, |
void * | appstate | ||
) |
Attach the current process to a UDP connection.
This function attaches the current process to a UDP connection. Each UDP connection must have a process attached to it in order for the process to be able to receive and send data over the connection. Additionally, this function can add a pointer with connection state to the connection.
conn | A pointer to the UDP connection. |
appstate | An opaque pointer that will be passed to the process whenever an event occurs on the connection. |
struct uip_udp_conn* udp_broadcast_new | ( | uint16_t | port, |
void * | appstate | ||
) |
Create a new UDP broadcast connection.
This function creates a new (link-local) broadcast UDP connection to a specified port.
port | Port number in network byte order. |
appstate | Pointer to application defined data. |
Referenced by PROCESS_THREAD().
CCIF struct uip_udp_conn* udp_new | ( | const uip_ipaddr_t * | ripaddr, |
uint16_t | port, | ||
void * | appstate | ||
) |
Create a new UDP connection.
This function creates a new UDP connection with the specified remote endpoint.
ripaddr | Pointer to the IP address of the remote host. |
port | Port number in network byte order. |
appstate | Pointer to application defined data. |
Referenced by dhcpc_init(), ip64_dhcpc_init(), PROCESS_THREAD(), simple_udp_register(), and udp_socket_register().
unsigned char tcpip_do_forwarding |
Is forwarding generally enabled?
CCIF process_event_t tcpip_event |
The uIP event.
This event is posted to a process whenever a uIP event has occurred.
Referenced by dhcpc_appcall(), ip64_dhcpc_appcall(), PROCESS_THREAD(), tcpip_uipcall(), and while().
unsigned char tcpip_is_forwarding |