mbed Phone Platform

Dependencies:   ulaw mbed ConfigFile

Committer:
okini3939
Date:
Sun Dec 26 15:49:07 2010 +0000
Revision:
1:0f82c574096f

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okini3939 1:0f82c574096f 1 /*
okini3939 1:0f82c574096f 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
okini3939 1:0f82c574096f 3 * All rights reserved.
okini3939 1:0f82c574096f 4 *
okini3939 1:0f82c574096f 5 * Redistribution and use in source and binary forms, with or without modification,
okini3939 1:0f82c574096f 6 * are permitted provided that the following conditions are met:
okini3939 1:0f82c574096f 7 *
okini3939 1:0f82c574096f 8 * 1. Redistributions of source code must retain the above copyright notice,
okini3939 1:0f82c574096f 9 * this list of conditions and the following disclaimer.
okini3939 1:0f82c574096f 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
okini3939 1:0f82c574096f 11 * this list of conditions and the following disclaimer in the documentation
okini3939 1:0f82c574096f 12 * and/or other materials provided with the distribution.
okini3939 1:0f82c574096f 13 * 3. The name of the author may not be used to endorse or promote products
okini3939 1:0f82c574096f 14 * derived from this software without specific prior written permission.
okini3939 1:0f82c574096f 15 *
okini3939 1:0f82c574096f 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
okini3939 1:0f82c574096f 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
okini3939 1:0f82c574096f 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
okini3939 1:0f82c574096f 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
okini3939 1:0f82c574096f 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
okini3939 1:0f82c574096f 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
okini3939 1:0f82c574096f 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
okini3939 1:0f82c574096f 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
okini3939 1:0f82c574096f 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
okini3939 1:0f82c574096f 25 * OF SUCH DAMAGE.
okini3939 1:0f82c574096f 26 *
okini3939 1:0f82c574096f 27 * This file is part of the lwIP TCP/IP stack.
okini3939 1:0f82c574096f 28 *
okini3939 1:0f82c574096f 29 * Author: Adam Dunkels <adam@sics.se>
okini3939 1:0f82c574096f 30 *
okini3939 1:0f82c574096f 31 */
okini3939 1:0f82c574096f 32 #ifndef __LWIP_UDP_H__
okini3939 1:0f82c574096f 33 #define __LWIP_UDP_H__
okini3939 1:0f82c574096f 34
okini3939 1:0f82c574096f 35 #include "lwip/opt.h"
okini3939 1:0f82c574096f 36
okini3939 1:0f82c574096f 37 #if LWIP_UDP /* don't build if not configured for use in lwipopts.h */
okini3939 1:0f82c574096f 38
okini3939 1:0f82c574096f 39 #include "lwip/pbuf.h"
okini3939 1:0f82c574096f 40 #include "lwip/netif.h"
okini3939 1:0f82c574096f 41 #include "lwip/ip_addr.h"
okini3939 1:0f82c574096f 42 #include "lwip/ip.h"
okini3939 1:0f82c574096f 43
okini3939 1:0f82c574096f 44 #ifdef __cplusplus
okini3939 1:0f82c574096f 45 extern "C" {
okini3939 1:0f82c574096f 46 #endif
okini3939 1:0f82c574096f 47
okini3939 1:0f82c574096f 48 #define UDP_HLEN 8
okini3939 1:0f82c574096f 49
okini3939 1:0f82c574096f 50 /* Fields are (of course) in network byte order. */
okini3939 1:0f82c574096f 51 #ifdef PACK_STRUCT_USE_INCLUDES
okini3939 1:0f82c574096f 52 # include "arch/bpstruct.h"
okini3939 1:0f82c574096f 53 #endif
okini3939 1:0f82c574096f 54 PACK_STRUCT_BEGIN
okini3939 1:0f82c574096f 55 struct udp_hdr {
okini3939 1:0f82c574096f 56 PACK_STRUCT_FIELD(u16_t src);
okini3939 1:0f82c574096f 57 PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */
okini3939 1:0f82c574096f 58 PACK_STRUCT_FIELD(u16_t len);
okini3939 1:0f82c574096f 59 PACK_STRUCT_FIELD(u16_t chksum);
okini3939 1:0f82c574096f 60 } PACK_STRUCT_STRUCT;
okini3939 1:0f82c574096f 61 PACK_STRUCT_END
okini3939 1:0f82c574096f 62 #ifdef PACK_STRUCT_USE_INCLUDES
okini3939 1:0f82c574096f 63 # include "arch/epstruct.h"
okini3939 1:0f82c574096f 64 #endif
okini3939 1:0f82c574096f 65
okini3939 1:0f82c574096f 66 #define UDP_FLAGS_NOCHKSUM 0x01U
okini3939 1:0f82c574096f 67 #define UDP_FLAGS_UDPLITE 0x02U
okini3939 1:0f82c574096f 68 #define UDP_FLAGS_CONNECTED 0x04U
okini3939 1:0f82c574096f 69 #define UDP_FLAGS_MULTICAST_LOOP 0x08U
okini3939 1:0f82c574096f 70
okini3939 1:0f82c574096f 71 struct udp_pcb;
okini3939 1:0f82c574096f 72
okini3939 1:0f82c574096f 73 /** Function prototype for udp pcb receive callback functions
okini3939 1:0f82c574096f 74 * addr and port are in same byte order as in the pcb
okini3939 1:0f82c574096f 75 * The callback is responsible for freeing the pbuf
okini3939 1:0f82c574096f 76 * if it's not used any more.
okini3939 1:0f82c574096f 77 *
okini3939 1:0f82c574096f 78 * ATTENTION: Be aware that 'addr' points into the pbuf 'p' so freeing this pbuf
okini3939 1:0f82c574096f 79 * makes 'addr' invalid, too.
okini3939 1:0f82c574096f 80 *
okini3939 1:0f82c574096f 81 * @param arg user supplied argument (udp_pcb.recv_arg)
okini3939 1:0f82c574096f 82 * @param pcb the udp_pcb which received data
okini3939 1:0f82c574096f 83 * @param p the packet buffer that was received
okini3939 1:0f82c574096f 84 * @param addr the remote IP address from which the packet was received
okini3939 1:0f82c574096f 85 * @param port the remote port from which the packet was received
okini3939 1:0f82c574096f 86 */
okini3939 1:0f82c574096f 87 typedef void (*udp_recv_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
okini3939 1:0f82c574096f 88 ip_addr_t *addr, u16_t port);
okini3939 1:0f82c574096f 89
okini3939 1:0f82c574096f 90
okini3939 1:0f82c574096f 91 struct udp_pcb {
okini3939 1:0f82c574096f 92 /* Common members of all PCB types */
okini3939 1:0f82c574096f 93 IP_PCB;
okini3939 1:0f82c574096f 94
okini3939 1:0f82c574096f 95 /* Protocol specific PCB members */
okini3939 1:0f82c574096f 96
okini3939 1:0f82c574096f 97 struct udp_pcb *next;
okini3939 1:0f82c574096f 98
okini3939 1:0f82c574096f 99 u8_t flags;
okini3939 1:0f82c574096f 100 /** ports are in host byte order */
okini3939 1:0f82c574096f 101 u16_t local_port, remote_port;
okini3939 1:0f82c574096f 102
okini3939 1:0f82c574096f 103 #if LWIP_IGMP
okini3939 1:0f82c574096f 104 /** outgoing network interface for multicast packets */
okini3939 1:0f82c574096f 105 ip_addr_t multicast_ip;
okini3939 1:0f82c574096f 106 #endif /* LWIP_IGMP */
okini3939 1:0f82c574096f 107
okini3939 1:0f82c574096f 108 #if LWIP_UDPLITE
okini3939 1:0f82c574096f 109 /** used for UDP_LITE only */
okini3939 1:0f82c574096f 110 u16_t chksum_len_rx, chksum_len_tx;
okini3939 1:0f82c574096f 111 #endif /* LWIP_UDPLITE */
okini3939 1:0f82c574096f 112
okini3939 1:0f82c574096f 113 /** receive callback function */
okini3939 1:0f82c574096f 114 udp_recv_fn recv;
okini3939 1:0f82c574096f 115 /** user-supplied argument for the recv callback */
okini3939 1:0f82c574096f 116 void *recv_arg;
okini3939 1:0f82c574096f 117 };
okini3939 1:0f82c574096f 118 /* udp_pcbs export for exernal reference (e.g. SNMP agent) */
okini3939 1:0f82c574096f 119 extern struct udp_pcb *udp_pcbs;
okini3939 1:0f82c574096f 120
okini3939 1:0f82c574096f 121 /* The following functions is the application layer interface to the
okini3939 1:0f82c574096f 122 UDP code. */
okini3939 1:0f82c574096f 123 struct udp_pcb * udp_new (void);
okini3939 1:0f82c574096f 124 void udp_remove (struct udp_pcb *pcb);
okini3939 1:0f82c574096f 125 err_t udp_bind (struct udp_pcb *pcb, ip_addr_t *ipaddr,
okini3939 1:0f82c574096f 126 u16_t port);
okini3939 1:0f82c574096f 127 err_t udp_connect (struct udp_pcb *pcb, ip_addr_t *ipaddr,
okini3939 1:0f82c574096f 128 u16_t port);
okini3939 1:0f82c574096f 129 void udp_disconnect (struct udp_pcb *pcb);
okini3939 1:0f82c574096f 130 void udp_recv (struct udp_pcb *pcb, udp_recv_fn recv,
okini3939 1:0f82c574096f 131 void *recv_arg);
okini3939 1:0f82c574096f 132 err_t udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p,
okini3939 1:0f82c574096f 133 ip_addr_t *dst_ip, u16_t dst_port,
okini3939 1:0f82c574096f 134 struct netif *netif);
okini3939 1:0f82c574096f 135 err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p,
okini3939 1:0f82c574096f 136 ip_addr_t *dst_ip, u16_t dst_port);
okini3939 1:0f82c574096f 137 err_t udp_send (struct udp_pcb *pcb, struct pbuf *p);
okini3939 1:0f82c574096f 138
okini3939 1:0f82c574096f 139 #if LWIP_CHECKSUM_ON_COPY
okini3939 1:0f82c574096f 140 err_t udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p,
okini3939 1:0f82c574096f 141 ip_addr_t *dst_ip, u16_t dst_port,
okini3939 1:0f82c574096f 142 struct netif *netif, u8_t have_chksum,
okini3939 1:0f82c574096f 143 u16_t chksum);
okini3939 1:0f82c574096f 144 err_t udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p,
okini3939 1:0f82c574096f 145 ip_addr_t *dst_ip, u16_t dst_port,
okini3939 1:0f82c574096f 146 u8_t have_chksum, u16_t chksum);
okini3939 1:0f82c574096f 147 err_t udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p,
okini3939 1:0f82c574096f 148 u8_t have_chksum, u16_t chksum);
okini3939 1:0f82c574096f 149 #endif /* LWIP_CHECKSUM_ON_COPY */
okini3939 1:0f82c574096f 150
okini3939 1:0f82c574096f 151 #define udp_flags(pcb) ((pcb)->flags)
okini3939 1:0f82c574096f 152 #define udp_setflags(pcb, f) ((pcb)->flags = (f))
okini3939 1:0f82c574096f 153
okini3939 1:0f82c574096f 154 /* The following functions are the lower layer interface to UDP. */
okini3939 1:0f82c574096f 155 void udp_input (struct pbuf *p, struct netif *inp);
okini3939 1:0f82c574096f 156
okini3939 1:0f82c574096f 157 #define udp_init() /* Compatibility define, not init needed. */
okini3939 1:0f82c574096f 158
okini3939 1:0f82c574096f 159 #if UDP_DEBUG
okini3939 1:0f82c574096f 160 void udp_debug_print(struct udp_hdr *udphdr);
okini3939 1:0f82c574096f 161 #else
okini3939 1:0f82c574096f 162 #define udp_debug_print(udphdr)
okini3939 1:0f82c574096f 163 #endif
okini3939 1:0f82c574096f 164
okini3939 1:0f82c574096f 165 #ifdef __cplusplus
okini3939 1:0f82c574096f 166 }
okini3939 1:0f82c574096f 167 #endif
okini3939 1:0f82c574096f 168
okini3939 1:0f82c574096f 169 #endif /* LWIP_UDP */
okini3939 1:0f82c574096f 170
okini3939 1:0f82c574096f 171 #endif /* __LWIP_UDP_H__ */