Small Testprogram to have WebAccess via Webserver to a 433Mhz tranmitter to control remotly some devices from remote, with TFTP, NTP and RMF. This could be a base to develop applications.

Dependencies:   ChaNFSSD TFTPServer RMFWeb

Dependents:   RMFWeb

Committer:
ED7418
Date:
Mon Jun 16 07:40:08 2014 +0000
Revision:
1:809b59c7a800
Parent:
0:51f1ef89ec7b
mbed-lib and other libs are a based on a project, published in a Elektor-book "ARM-microkontroller Part II".

Who changed what in which revision?

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