Prusa MINI Firmware overview
autoip.h
Go to the documentation of this file.
1 /**
2  * @file
3  *
4  * AutoIP Automatic LinkLocal IP Configuration
5  */
6 
7 /*
8  *
9  * Copyright (c) 2007 Dominik Spies <kontakt@dspies.de>
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without modification,
13  * are permitted provided that the following conditions are met:
14  *
15  * 1. Redistributions of source code must retain the above copyright notice,
16  * this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright notice,
18  * this list of conditions and the following disclaimer in the documentation
19  * and/or other materials provided with the distribution.
20  * 3. The name of the author may not be used to endorse or promote products
21  * derived from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
26  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
28  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
31  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32  * OF SUCH DAMAGE.
33  *
34  * Author: Dominik Spies <kontakt@dspies.de>
35  *
36  * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
37  * with RFC 3927.
38  *
39  */
40 
41 #ifndef LWIP_HDR_AUTOIP_H
42 #define LWIP_HDR_AUTOIP_H
43 
44 #include "lwip/opt.h"
45 
46 #if LWIP_IPV4 && LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
47 
48 #include "lwip/netif.h"
49 /* #include "lwip/udp.h" */
50 #include "lwip/etharp.h"
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 /** AutoIP Timing */
57 #define AUTOIP_TMR_INTERVAL 100
58 #define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL)
59 
60 /** AutoIP state information per netif */
61 struct autoip
62 {
63  /** the currently selected, probed, announced or used LL IP-Address */
64  ip4_addr_t llipaddr;
65  /** current AutoIP state machine state */
66  u8_t state;
67  /** sent number of probes or announces, dependent on state */
68  u8_t sent_num;
69  /** ticks to wait, tick is AUTOIP_TMR_INTERVAL long */
70  u16_t ttw;
71  /** ticks until a conflict can be solved by defending */
72  u8_t lastconflict;
73  /** total number of probed/used Link Local IP-Addresses */
74  u8_t tried_llipaddr;
75 };
76 
77 
78 void autoip_set_struct(struct netif *netif, struct autoip *autoip);
79 /** Remove a struct autoip previously set to the netif using autoip_set_struct() */
80 #define autoip_remove_struct(netif) do { (netif)->autoip = NULL; } while (0)
81 err_t autoip_start(struct netif *netif);
82 err_t autoip_stop(struct netif *netif);
83 void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr);
84 void autoip_tmr(void);
85 void autoip_network_changed(struct netif *netif);
86 u8_t autoip_supplied_address(const struct netif *netif);
87 
88 /* for lwIP internal use by ip4.c */
89 u8_t autoip_accept_packet(struct netif *netif, const ip4_addr_t *addr);
90 
91 #define netif_autoip_data(netif) ((struct autoip*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP))
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif /* LWIP_IPV4 && LWIP_AUTOIP */
98 
99 #endif /* LWIP_HDR_AUTOIP_H */
opt.h
u16_t
uint16_t u16_t
Definition: arch.h:121
etharp_hdr
Definition: etharp.h:57
state
static volatile fsensor_t state
Definition: filament_sensor.c:23
netif.h
u8_t
uint8_t u8_t
Definition: arch.h:119
netif
Definition: netif.h:225
err_t
s8_t err_t
Definition: err.h:57
etharp.h