Contiki 2.6
|
00001 /** 00002 * \addtogroup uip 00003 * @{ 00004 */ 00005 00006 00007 /** 00008 * \defgroup simple-udp 00009 * 00010 * The default Contiki UDP API is difficult to use. The simple-udp 00011 * module provides a significantly simpler API. 00012 * 00013 * @{ 00014 */ 00015 00016 /* 00017 * Copyright (c) 2011, Swedish Institute of Computer Science. 00018 * All rights reserved. 00019 * 00020 * Redistribution and use in source and binary forms, with or without 00021 * modification, are permitted provided that the following conditions 00022 * are met: 00023 * 1. Redistributions of source code must retain the above copyright 00024 * notice, this list of conditions and the following disclaimer. 00025 * 2. Redistributions in binary form must reproduce the above copyright 00026 * notice, this list of conditions and the following disclaimer in the 00027 * documentation and/or other materials provided with the distribution. 00028 * 3. Neither the name of the Institute nor the names of its contributors 00029 * may be used to endorse or promote products derived from this software 00030 * without specific prior written permission. 00031 * 00032 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 00033 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00034 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00035 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 00036 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00037 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00038 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00039 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00040 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00041 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00042 * SUCH DAMAGE. 00043 * 00044 * This file is part of the Contiki operating system. 00045 * 00046 * \file 00047 * Header file for the simple-udp module. 00048 * \author 00049 * Adam Dunkels <adam@sics.se> 00050 * 00051 */ 00052 00053 #ifndef SIMPLE_UDP_H 00054 #define SIMPLE_UDP_H 00055 00056 #include "net/uip.h" 00057 00058 struct simple_udp_connection; 00059 00060 typedef void (* simple_udp_callback)(struct simple_udp_connection *c, 00061 const uip_ipaddr_t *source_addr, 00062 uint16_t source_port, 00063 const uip_ipaddr_t *dest_addr, 00064 uint16_t dest_port, 00065 const uint8_t *data, uint16_t datalen); 00066 00067 struct simple_udp_connection { 00068 struct simple_udp_connection *next; 00069 uip_ipaddr_t remote_addr; 00070 uint16_t remote_port, local_port; 00071 simple_udp_callback receive_callback; 00072 struct uip_udp_conn *udp_conn; 00073 struct process *client_process; 00074 }; 00075 00076 int simple_udp_register(struct simple_udp_connection *c, 00077 uint16_t local_port, 00078 uip_ipaddr_t *remote_addr, 00079 uint16_t remote_port, 00080 simple_udp_callback receive_callback); 00081 00082 int simple_udp_send(struct simple_udp_connection *c, 00083 const void *data, uint16_t datalen); 00084 00085 int simple_udp_sendto(struct simple_udp_connection *c, 00086 const void *data, uint16_t datalen, 00087 const uip_ipaddr_t *to); 00088 00089 void simple_udp_init(void); 00090 00091 #endif /* SIMPLE_UDP_H */ 00092 00093 /** @} */ 00094 /** @} */