[457] | 1 | /**
|
---|
| 2 | * @file
|
---|
| 3 | * Ethernet output function - handles OUTGOING ethernet level traffic, implements
|
---|
| 4 | * ARP resolving.
|
---|
| 5 | * To be used in most low-level netif implementations
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | /*
|
---|
| 9 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
---|
| 10 | * Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv>
|
---|
| 11 | * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands.
|
---|
| 12 | * All rights reserved.
|
---|
| 13 | *
|
---|
| 14 | * Redistribution and use in source and binary forms, with or without modification,
|
---|
| 15 | * are permitted provided that the following conditions are met:
|
---|
| 16 | *
|
---|
| 17 | * 1. Redistributions of source code must retain the above copyright notice,
|
---|
| 18 | * this list of conditions and the following disclaimer.
|
---|
| 19 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
---|
| 20 | * this list of conditions and the following disclaimer in the documentation
|
---|
| 21 | * and/or other materials provided with the distribution.
|
---|
| 22 | * 3. The name of the author may not be used to endorse or promote products
|
---|
| 23 | * derived from this software without specific prior written permission.
|
---|
| 24 | *
|
---|
| 25 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
---|
| 26 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
---|
| 27 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
---|
| 28 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
| 29 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
---|
| 30 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
---|
| 31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
---|
| 32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
---|
| 33 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
---|
| 34 | * OF SUCH DAMAGE.
|
---|
| 35 | *
|
---|
| 36 | * This file is part of the lwIP TCP/IP stack.
|
---|
| 37 | *
|
---|
| 38 | * Author: Adam Dunkels <adam@sics.se>
|
---|
| 39 | *
|
---|
| 40 | */
|
---|
| 41 |
|
---|
| 42 | #ifndef LWIP_HDR_NETIF_ETHARP_H
|
---|
| 43 | #define LWIP_HDR_NETIF_ETHARP_H
|
---|
| 44 |
|
---|
| 45 | #include "lwip/opt.h"
|
---|
| 46 |
|
---|
| 47 | #if LWIP_ARP || LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */
|
---|
| 48 |
|
---|
| 49 | #include "lwip/pbuf.h"
|
---|
| 50 | #include "lwip/ip4_addr.h"
|
---|
| 51 | #include "lwip/netif.h"
|
---|
| 52 | #include "lwip/ip4.h"
|
---|
| 53 | #include "lwip/prot/ethernet.h"
|
---|
| 54 |
|
---|
| 55 | #if LWIP_IPV4 && LWIP_ARP /* don't build if not configured for use in lwipopts.h */
|
---|
| 56 |
|
---|
| 57 | #include "lwip/prot/etharp.h"
|
---|
| 58 |
|
---|
| 59 | #ifdef __cplusplus
|
---|
| 60 | extern "C" {
|
---|
| 61 | #endif
|
---|
| 62 |
|
---|
| 63 | /** 1 seconds period */
|
---|
| 64 | #define ARP_TMR_INTERVAL 1000
|
---|
| 65 |
|
---|
| 66 | #if ARP_QUEUEING
|
---|
| 67 | /** struct for queueing outgoing packets for unknown address
|
---|
| 68 | * defined here to be accessed by memp.h
|
---|
| 69 | */
|
---|
| 70 | struct etharp_q_entry {
|
---|
| 71 | struct etharp_q_entry *next;
|
---|
| 72 | struct pbuf *p;
|
---|
| 73 | };
|
---|
| 74 | #endif /* ARP_QUEUEING */
|
---|
| 75 |
|
---|
| 76 | #define etharp_init() /* Compatibility define, no init needed. */
|
---|
| 77 | void etharp_tmr(void);
|
---|
| 78 | ssize_t etharp_find_addr(struct netif *netif, const ip4_addr_t *ipaddr,
|
---|
| 79 | struct eth_addr **eth_ret, const ip4_addr_t **ip_ret);
|
---|
| 80 | int etharp_get_entry(size_t i, ip4_addr_t **ipaddr, struct netif **netif, struct eth_addr **eth_ret);
|
---|
| 81 | err_t etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr);
|
---|
| 82 | err_t etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q);
|
---|
| 83 | err_t etharp_request(struct netif *netif, const ip4_addr_t *ipaddr);
|
---|
| 84 | /** For Ethernet network interfaces, we might want to send "gratuitous ARP";
|
---|
| 85 | * this is an ARP packet sent by a node in order to spontaneously cause other
|
---|
| 86 | * nodes to update an entry in their ARP cache.
|
---|
| 87 | * From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */
|
---|
| 88 | #define etharp_gratuitous(netif) etharp_request((netif), netif_ip4_addr(netif))
|
---|
| 89 | void etharp_cleanup_netif(struct netif *netif);
|
---|
| 90 |
|
---|
| 91 | #if ETHARP_SUPPORT_STATIC_ENTRIES
|
---|
| 92 | err_t etharp_add_static_entry(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr);
|
---|
| 93 | err_t etharp_remove_static_entry(const ip4_addr_t *ipaddr);
|
---|
| 94 | #endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
|
---|
| 95 |
|
---|
| 96 | void etharp_input(struct pbuf *p, struct netif *netif);
|
---|
| 97 |
|
---|
| 98 | #ifdef __cplusplus
|
---|
| 99 | }
|
---|
| 100 | #endif
|
---|
| 101 |
|
---|
| 102 | #endif /* LWIP_IPV4 && LWIP_ARP */
|
---|
| 103 | #endif /* LWIP_ARP || LWIP_ETHERNET */
|
---|
| 104 |
|
---|
| 105 | #endif /* LWIP_HDR_NETIF_ETHARP_H */
|
---|