Program the control the fischertechnik robo interface or intelligent interface via tcp socket or via a java gui.

Dependencies:   mbed ConfigFile

Committer:
networker
Date:
Fri Dec 31 14:01:14 2010 +0000
Revision:
0:7f26f0680202
initial release: comprises ftlib (no usb), ft-over-ip socket server, and the http server (the html page and java jar I still have to publish somewhere)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
networker 0:7f26f0680202 1 /*
networker 0:7f26f0680202 2 * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
networker 0:7f26f0680202 3 * Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv>
networker 0:7f26f0680202 4 * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands.
networker 0:7f26f0680202 5 * All rights reserved.
networker 0:7f26f0680202 6 *
networker 0:7f26f0680202 7 * Redistribution and use in source and binary forms, with or without modification,
networker 0:7f26f0680202 8 * are permitted provided that the following conditions are met:
networker 0:7f26f0680202 9 *
networker 0:7f26f0680202 10 * 1. Redistributions of source code must retain the above copyright notice,
networker 0:7f26f0680202 11 * this list of conditions and the following disclaimer.
networker 0:7f26f0680202 12 * 2. Redistributions in binary form must reproduce the above copyright notice,
networker 0:7f26f0680202 13 * this list of conditions and the following disclaimer in the documentation
networker 0:7f26f0680202 14 * and/or other materials provided with the distribution.
networker 0:7f26f0680202 15 * 3. The name of the author may not be used to endorse or promote products
networker 0:7f26f0680202 16 * derived from this software without specific prior written permission.
networker 0:7f26f0680202 17 *
networker 0:7f26f0680202 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
networker 0:7f26f0680202 19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
networker 0:7f26f0680202 20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
networker 0:7f26f0680202 21 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
networker 0:7f26f0680202 22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
networker 0:7f26f0680202 23 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
networker 0:7f26f0680202 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
networker 0:7f26f0680202 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
networker 0:7f26f0680202 26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
networker 0:7f26f0680202 27 * OF SUCH DAMAGE.
networker 0:7f26f0680202 28 *
networker 0:7f26f0680202 29 * This file is part of the lwIP TCP/IP stack.
networker 0:7f26f0680202 30 *
networker 0:7f26f0680202 31 * Author: Adam Dunkels <adam@sics.se>
networker 0:7f26f0680202 32 *
networker 0:7f26f0680202 33 */
networker 0:7f26f0680202 34
networker 0:7f26f0680202 35 #ifndef __NETIF_ETHARP_H__
networker 0:7f26f0680202 36 #define __NETIF_ETHARP_H__
networker 0:7f26f0680202 37
networker 0:7f26f0680202 38 #include "lwip/opt.h"
networker 0:7f26f0680202 39
networker 0:7f26f0680202 40 #if LWIP_ARP || LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */
networker 0:7f26f0680202 41
networker 0:7f26f0680202 42 #include "lwip/pbuf.h"
networker 0:7f26f0680202 43 #include "lwip/ip_addr.h"
networker 0:7f26f0680202 44 #include "lwip/netif.h"
networker 0:7f26f0680202 45 #include "lwip/ip.h"
networker 0:7f26f0680202 46
networker 0:7f26f0680202 47 #ifdef __cplusplus
networker 0:7f26f0680202 48 extern "C" {
networker 0:7f26f0680202 49 #endif
networker 0:7f26f0680202 50
networker 0:7f26f0680202 51 #ifndef ETHARP_HWADDR_LEN
networker 0:7f26f0680202 52 #define ETHARP_HWADDR_LEN 6
networker 0:7f26f0680202 53 #endif
networker 0:7f26f0680202 54
networker 0:7f26f0680202 55 #ifdef PACK_STRUCT_USE_INCLUDES
networker 0:7f26f0680202 56 # include "arch/bpstruct.h"
networker 0:7f26f0680202 57 #endif
networker 0:7f26f0680202 58 PACK_STRUCT_BEGIN
networker 0:7f26f0680202 59 struct eth_addr {
networker 0:7f26f0680202 60 PACK_STRUCT_FIELD(u8_t addr[ETHARP_HWADDR_LEN]);
networker 0:7f26f0680202 61 } PACK_STRUCT_STRUCT;
networker 0:7f26f0680202 62 PACK_STRUCT_END
networker 0:7f26f0680202 63 #ifdef PACK_STRUCT_USE_INCLUDES
networker 0:7f26f0680202 64 # include "arch/epstruct.h"
networker 0:7f26f0680202 65 #endif
networker 0:7f26f0680202 66
networker 0:7f26f0680202 67 #ifdef PACK_STRUCT_USE_INCLUDES
networker 0:7f26f0680202 68 # include "arch/bpstruct.h"
networker 0:7f26f0680202 69 #endif
networker 0:7f26f0680202 70 PACK_STRUCT_BEGIN
networker 0:7f26f0680202 71 /* Ethernet header */
networker 0:7f26f0680202 72 struct eth_hdr {
networker 0:7f26f0680202 73 #if ETH_PAD_SIZE
networker 0:7f26f0680202 74 PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);
networker 0:7f26f0680202 75 #endif
networker 0:7f26f0680202 76 PACK_STRUCT_FIELD(struct eth_addr dest);
networker 0:7f26f0680202 77 PACK_STRUCT_FIELD(struct eth_addr src);
networker 0:7f26f0680202 78 PACK_STRUCT_FIELD(u16_t type);
networker 0:7f26f0680202 79 } PACK_STRUCT_STRUCT;
networker 0:7f26f0680202 80 PACK_STRUCT_END
networker 0:7f26f0680202 81 #ifdef PACK_STRUCT_USE_INCLUDES
networker 0:7f26f0680202 82 # include "arch/epstruct.h"
networker 0:7f26f0680202 83 #endif
networker 0:7f26f0680202 84
networker 0:7f26f0680202 85 #define SIZEOF_ETH_HDR (14 + ETH_PAD_SIZE)
networker 0:7f26f0680202 86
networker 0:7f26f0680202 87 #if ETHARP_SUPPORT_VLAN
networker 0:7f26f0680202 88
networker 0:7f26f0680202 89 #ifdef PACK_STRUCT_USE_INCLUDES
networker 0:7f26f0680202 90 # include "arch/bpstruct.h"
networker 0:7f26f0680202 91 #endif
networker 0:7f26f0680202 92 PACK_STRUCT_BEGIN
networker 0:7f26f0680202 93 /* VLAN header inserted between ethernet header and payload
networker 0:7f26f0680202 94 * if 'type' in ethernet header is ETHTYPE_VLAN.
networker 0:7f26f0680202 95 * See IEEE802.Q */
networker 0:7f26f0680202 96 struct eth_vlan_hdr {
networker 0:7f26f0680202 97 PACK_STRUCT_FIELD(u16_t tpid);
networker 0:7f26f0680202 98 PACK_STRUCT_FIELD(u16_t prio_vid);
networker 0:7f26f0680202 99 } PACK_STRUCT_STRUCT;
networker 0:7f26f0680202 100 PACK_STRUCT_END
networker 0:7f26f0680202 101 #ifdef PACK_STRUCT_USE_INCLUDES
networker 0:7f26f0680202 102 # include "arch/epstruct.h"
networker 0:7f26f0680202 103 #endif
networker 0:7f26f0680202 104
networker 0:7f26f0680202 105 #define SIZEOF_VLAN_HDR 4
networker 0:7f26f0680202 106 #define VLAN_ID(vlan_hdr) (htons((vlan_hdr)->prio_vid) & 0xFFF)
networker 0:7f26f0680202 107
networker 0:7f26f0680202 108 #endif /* ETHARP_SUPPORT_VLAN */
networker 0:7f26f0680202 109
networker 0:7f26f0680202 110 #ifdef PACK_STRUCT_USE_INCLUDES
networker 0:7f26f0680202 111 # include "arch/bpstruct.h"
networker 0:7f26f0680202 112 #endif
networker 0:7f26f0680202 113 PACK_STRUCT_BEGIN
networker 0:7f26f0680202 114 /* the ARP message, see RFC 826 ("Packet format") */
networker 0:7f26f0680202 115 struct etharp_hdr {
networker 0:7f26f0680202 116 PACK_STRUCT_FIELD(u16_t hwtype);
networker 0:7f26f0680202 117 PACK_STRUCT_FIELD(u16_t proto);
networker 0:7f26f0680202 118 PACK_STRUCT_FIELD(u8_t hwlen);
networker 0:7f26f0680202 119 PACK_STRUCT_FIELD(u8_t protolen);
networker 0:7f26f0680202 120 PACK_STRUCT_FIELD(u16_t opcode);
networker 0:7f26f0680202 121 PACK_STRUCT_FIELD(struct eth_addr shwaddr);
networker 0:7f26f0680202 122 PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);
networker 0:7f26f0680202 123 PACK_STRUCT_FIELD(struct eth_addr dhwaddr);
networker 0:7f26f0680202 124 PACK_STRUCT_FIELD(struct ip_addr2 dipaddr);
networker 0:7f26f0680202 125 } PACK_STRUCT_STRUCT;
networker 0:7f26f0680202 126 PACK_STRUCT_END
networker 0:7f26f0680202 127 #ifdef PACK_STRUCT_USE_INCLUDES
networker 0:7f26f0680202 128 # include "arch/epstruct.h"
networker 0:7f26f0680202 129 #endif
networker 0:7f26f0680202 130
networker 0:7f26f0680202 131 #define SIZEOF_ETHARP_HDR 28
networker 0:7f26f0680202 132 #define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR)
networker 0:7f26f0680202 133
networker 0:7f26f0680202 134 /* 5 seconds period */
networker 0:7f26f0680202 135 #define ARP_TMR_INTERVAL 5000
networker 0:7f26f0680202 136
networker 0:7f26f0680202 137 #define ETHTYPE_ARP 0x0806
networker 0:7f26f0680202 138 #define ETHTYPE_IP 0x0800
networker 0:7f26f0680202 139 #define ETHTYPE_VLAN 0x8100
networker 0:7f26f0680202 140 #define ETHTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */
networker 0:7f26f0680202 141 #define ETHTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */
networker 0:7f26f0680202 142
networker 0:7f26f0680202 143 /* MEMCPY-like macro to copy to/from struct eth_addr's that are local variables
networker 0:7f26f0680202 144 * or known to be 32-bit aligned within the protocol header. */
networker 0:7f26f0680202 145 #ifndef ETHADDR32_COPY
networker 0:7f26f0680202 146 #define ETHADDR32_COPY(src, dst) SMEMCPY(src, dst, ETHARP_HWADDR_LEN)
networker 0:7f26f0680202 147 #endif
networker 0:7f26f0680202 148
networker 0:7f26f0680202 149 /* MEMCPY-like macro to copy to/from struct eth_addr's that are no local
networker 0:7f26f0680202 150 * variables and known to be 16-bit aligned within the protocol header. */
networker 0:7f26f0680202 151 #ifndef ETHADDR16_COPY
networker 0:7f26f0680202 152 #define ETHADDR16_COPY(src, dst) SMEMCPY(src, dst, ETHARP_HWADDR_LEN)
networker 0:7f26f0680202 153 #endif
networker 0:7f26f0680202 154
networker 0:7f26f0680202 155 #if LWIP_ARP /* don't build if not configured for use in lwipopts.h */
networker 0:7f26f0680202 156
networker 0:7f26f0680202 157 /* ARP message types (opcodes) */
networker 0:7f26f0680202 158 #define ARP_REQUEST 1
networker 0:7f26f0680202 159 #define ARP_REPLY 2
networker 0:7f26f0680202 160
networker 0:7f26f0680202 161 /* Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type)
networker 0:7f26f0680202 162 * to a filter function that returns the correct netif when using multiple
networker 0:7f26f0680202 163 * netifs on one hardware interface where the netif's low-level receive
networker 0:7f26f0680202 164 * routine cannot decide for the correct netif (e.g. when mapping multiple
networker 0:7f26f0680202 165 * IP addresses to one hardware interface).
networker 0:7f26f0680202 166 */
networker 0:7f26f0680202 167 #ifndef LWIP_ARP_FILTER_NETIF
networker 0:7f26f0680202 168 #define LWIP_ARP_FILTER_NETIF 0
networker 0:7f26f0680202 169 #endif
networker 0:7f26f0680202 170
networker 0:7f26f0680202 171 #if ARP_QUEUEING
networker 0:7f26f0680202 172 /* struct for queueing outgoing packets for unknown address
networker 0:7f26f0680202 173 * defined here to be accessed by memp.h
networker 0:7f26f0680202 174 */
networker 0:7f26f0680202 175 struct etharp_q_entry {
networker 0:7f26f0680202 176 struct etharp_q_entry *next;
networker 0:7f26f0680202 177 struct pbuf *p;
networker 0:7f26f0680202 178 };
networker 0:7f26f0680202 179 #endif /* ARP_QUEUEING */
networker 0:7f26f0680202 180
networker 0:7f26f0680202 181 #define etharp_init() /* Compatibility define, not init needed. */
networker 0:7f26f0680202 182 void etharp_tmr(void);
networker 0:7f26f0680202 183 s8_t etharp_find_addr(struct netif *netif, ip_addr_t *ipaddr,
networker 0:7f26f0680202 184 struct eth_addr **eth_ret, ip_addr_t **ip_ret);
networker 0:7f26f0680202 185 err_t etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr);
networker 0:7f26f0680202 186 err_t etharp_query(struct netif *netif, ip_addr_t *ipaddr, struct pbuf *q);
networker 0:7f26f0680202 187 err_t etharp_request(struct netif *netif, ip_addr_t *ipaddr);
networker 0:7f26f0680202 188 /* For Ethernet network interfaces, we might want to send "gratuitous ARP";
networker 0:7f26f0680202 189 * this is an ARP packet sent by a node in order to spontaneously cause other
networker 0:7f26f0680202 190 * nodes to update an entry in their ARP cache.
networker 0:7f26f0680202 191 * From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */
networker 0:7f26f0680202 192 #define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr)
networker 0:7f26f0680202 193
networker 0:7f26f0680202 194 #if ETHARP_SUPPORT_STATIC_ENTRIES
networker 0:7f26f0680202 195 err_t etharp_add_static_entry(ip_addr_t *ipaddr, struct eth_addr *ethaddr);
networker 0:7f26f0680202 196 err_t etharp_remove_static_entry(ip_addr_t *ipaddr);
networker 0:7f26f0680202 197 #endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
networker 0:7f26f0680202 198
networker 0:7f26f0680202 199 #if LWIP_AUTOIP
networker 0:7f26f0680202 200 err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
networker 0:7f26f0680202 201 const struct eth_addr *ethdst_addr,
networker 0:7f26f0680202 202 const struct eth_addr *hwsrc_addr, const ip_addr_t *ipsrc_addr,
networker 0:7f26f0680202 203 const struct eth_addr *hwdst_addr, const ip_addr_t *ipdst_addr,
networker 0:7f26f0680202 204 const u16_t opcode);
networker 0:7f26f0680202 205 #endif /* LWIP_AUTOIP */
networker 0:7f26f0680202 206
networker 0:7f26f0680202 207 #endif /* LWIP_ARP */
networker 0:7f26f0680202 208
networker 0:7f26f0680202 209 err_t ethernet_input(struct pbuf *p, struct netif *netif);
networker 0:7f26f0680202 210
networker 0:7f26f0680202 211 #define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0)
networker 0:7f26f0680202 212
networker 0:7f26f0680202 213 extern const struct eth_addr ethbroadcast, ethzero;
networker 0:7f26f0680202 214
networker 0:7f26f0680202 215 #ifdef __cplusplus
networker 0:7f26f0680202 216 }
networker 0:7f26f0680202 217 #endif
networker 0:7f26f0680202 218
networker 0:7f26f0680202 219 #endif /* LWIP_ARP || LWIP_ETHERNET */
networker 0:7f26f0680202 220
networker 0:7f26f0680202 221 #endif /* __NETIF_ARP_H__ */