32 #include "contiki-net.h" 33 #include "udp-socket.h" 37 PROCESS(udp_socket_process,
"UDP socket process");
45 static uint8_t inited = 0;
53 udp_socket_register(
struct udp_socket *c,
55 udp_socket_input_callback_t input_callback)
63 c->input_callback = input_callback;
67 c->udp_conn =
udp_new(NULL, 0, c);
70 if(c->udp_conn == NULL) {
77 udp_socket_close(
struct udp_socket *c)
82 if(c->udp_conn != NULL) {
90 udp_socket_bind(
struct udp_socket *c,
93 if(c == NULL || c->udp_conn == NULL) {
102 udp_socket_connect(
struct udp_socket *c,
103 uip_ipaddr_t *remote_addr,
104 uint16_t remote_port)
106 if(c == NULL || c->udp_conn == NULL) {
110 if(remote_addr != NULL) {
113 c->udp_conn->rport =
UIP_HTONS(remote_port);
118 udp_socket_send(
struct udp_socket *c,
119 const void *data, uint16_t datalen)
121 if(c == NULL || c->udp_conn == NULL) {
125 uip_udp_packet_send(c->udp_conn, data, datalen);
130 udp_socket_sendto(
struct udp_socket *c,
131 const void *data, uint16_t datalen,
132 const uip_ipaddr_t *to,
135 if(c == NULL || c->udp_conn == NULL) {
139 if(c->udp_conn != NULL) {
140 uip_udp_packet_sendto(c->udp_conn, data, datalen,
149 struct udp_socket *c;
161 c = (
struct udp_socket *)data;
178 if(c->input_callback != NULL) {
180 c->input_callback(c, c->ptr,
#define UIP_IP_BUF
Direct access to IPv6 header.
#define PROCESS(name, strname)
Declare a process.
#define PROCESS_CONTEXT_END(p)
End a context switch.
#define PROCESS_WAIT_EVENT()
Wait for an event to be posted to the process.
#define PROCESS_BEGIN()
Define the beginning of a process.
#define PROCESS_END()
Define the end of a process.
process_event_t tcpip_event
The uIP event.
#define UIP_BUFSIZE
The size of the uIP packet buffer.
#define PROCESS_CURRENT()
Get a pointer to the currently running process.
#define uip_newdata()
Is new incoming data available?
struct uip_udp_conn * udp_new(const uip_ipaddr_t *ripaddr, uint16_t port, void *appstate)
Create a new UDP connection.
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
#define UIP_HTONS(n)
Convert 16-bit quantity from host byte order to network byte order.
#define PROCESS_CONTEXT_BEGIN(p)
Switch context to another process.
#define uip_udp_remove(conn)
Remove a UDP connection.
PROCESS_THREAD(cc2538_rf_process, ev, data)
Implementation of the cc2538 RF driver process.
#define udp_bind(conn, port)
Bind a UDP connection to a local port.
void * uip_appdata
Pointer to the application data in the packet buffer.
#define uip_datalen()
The length of any incoming data that is currently available (if available) in the uip_appdata buffer...
void process_start(struct process *p, process_data_t data)
Start a process.