45 #include "contiki-net.h"
51 PROCESS(simple_udp_process,
"Simple UDP process");
52 static uint8_t started = 0;
55 #define UIP_IP_BUF ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])
69 const void *data, uint16_t datalen)
71 if(c->udp_conn !=
NULL) {
72 uip_udp_packet_sendto(c->udp_conn, data, datalen,
73 &c->remote_addr,
UIP_HTONS(c->remote_port));
80 const void *data, uint16_t datalen,
81 const uip_ipaddr_t *to)
83 if(c->udp_conn !=
NULL) {
84 uip_udp_packet_sendto(c->udp_conn, data, datalen,
92 const void *data, uint16_t datalen,
93 const uip_ipaddr_t *to,
96 if(c->udp_conn !=
NULL) {
97 uip_udp_packet_sendto(c->udp_conn, data, datalen,
106 uip_ipaddr_t *remote_addr,
107 uint16_t remote_port,
113 c->local_port = local_port;
114 c->remote_port = remote_port;
115 if(remote_addr !=
NULL) {
118 c->receive_callback = receive_callback;
122 if(c->udp_conn !=
NULL) {
127 if(c->udp_conn ==
NULL) {
164 if(c->receive_callback !=
NULL) {
166 c->receive_callback(c,
int simple_udp_sendto_port(struct simple_udp_connection *c, const void *data, uint16_t datalen, const uip_ipaddr_t *to, uint16_t port)
Send a UDP packet to a specified IP address and UDP port.
#define PROCESS_BEGIN()
Define the beginning of a process.
CCIF struct uip_udp_conn * udp_new(const uip_ipaddr_t *ripaddr, uint16_t port, void *appstate)
Create a new UDP connection.
#define uip_newdata()
Is new incoming data available?
int simple_udp_send(struct simple_udp_connection *c, const void *data, uint16_t datalen)
Send a UDP packet.
int simple_udp_sendto(struct simple_udp_connection *c, const void *data, uint16_t datalen, const uip_ipaddr_t *to)
Send a UDP packet to a specified IP address.
#define NULL
The null pointer.
Header file for the simple-udp module.
void(* simple_udp_callback)(struct simple_udp_connection *c, const uip_ipaddr_t *source_addr, uint16_t source_port, const uip_ipaddr_t *dest_addr, uint16_t dest_port, const uint8_t *data, uint16_t datalen)
Simple UDP Callback function type.
#define UIP_BUFSIZE
The size of the uIP packet buffer.
#define UIP_HTONS(n)
Convert 16-bit quantity from host byte order to network byte order.
#define UIP_IP_BUF
Pointer to IP header.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_END()
Define the end of a process.
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
#define PROCESS_WAIT_EVENT()
Wait for an event to be posted to the process.
#define PROCESS(name, strname)
Declare a process.
#define uip_datalen()
The length of any incoming data that is currently available (if available) in the uip_appdata buffer...
process_event_t tcpip_event
The uIP event.
void process_start(struct process *p, process_data_t data)
Start a process.
#define udp_bind(conn, port)
Bind a UDP connection to a local port.
#define PROCESS_CONTEXT_BEGIN(p)
Switch context to another process.
int simple_udp_register(struct simple_udp_connection *c, uint16_t local_port, uip_ipaddr_t *remote_addr, uint16_t remote_port, simple_udp_callback receive_callback)
Register a UDP connection.
uip_appdata
Pointer to the application data in the packet buffer.
#define PROCESS_CONTEXT_END(p)
End a context switch.