ID the MBED processor on the network if you have more than one. View MBED name on DHCP of your Router - Example \"MBED PE\" Change your ID in Core / host.h

Committer:
JeffM
Date:
Sat Nov 06 14:11:02 2010 +0000
Revision:
0:fd3b85615428
MBED ID 1A

Who changed what in which revision?

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