Prusa MINI Firmware overview
etharp.h
Go to the documentation of this file.
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 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 #if LWIP_IPV4 && LWIP_ARP /* don't build if not configured for use in lwipopts.h */
60 
61 #include "lwip/prot/etharp.h"
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 s8_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 u8_t etharp_get_entry(u8_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 #endif /* LWIP_IPV4 && LWIP_ARP */
97 
98 void etharp_input(struct pbuf *p, struct netif *netif);
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif /* LWIP_ARP || LWIP_ETHERNET */
105 
106 #endif /* LWIP_HDR_NETIF_ETHARP_H */
opt.h
ipaddr
ip4_addr_t ipaddr
Definition: lwip.c:73
pbuf.h
i
uint8_t i
Definition: screen_test_graph.c:72
netif.h
u8_t
uint8_t u8_t
Definition: arch.h:119
netif
Definition: netif.h:225
s8_t
int8_t s8_t
Definition: arch.h:120
err_t
s8_t err_t
Definition: err.h:57
eth_addr
Definition: ethernet.h:58
ip4_addr.h
ethernet.h
ip4.h
pbuf
Definition: pbuf.h:142
etharp.h