The Pedigree Project  0.1
autoip.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
26 /*
27  *
28  * Copyright (c) 2007 Dominik Spies <kontakt@dspies.de>
29  * All rights reserved.
30  *
31  * Redistribution and use in source and binary forms, with or without modification,
32  * are permitted provided that the following conditions are met:
33  *
34  * 1. Redistributions of source code must retain the above copyright notice,
35  * this list of conditions and the following disclaimer.
36  * 2. Redistributions in binary form must reproduce the above copyright notice,
37  * this list of conditions and the following disclaimer in the documentation
38  * and/or other materials provided with the distribution.
39  * 3. The name of the author may not be used to endorse or promote products
40  * derived from this software without specific prior written permission.
41  *
42  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
43  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
44  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
45  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
46  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
47  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
48  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
49  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
50  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
51  * OF SUCH DAMAGE.
52  *
53  * Author: Dominik Spies <kontakt@dspies.de>
54  *
55  * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
56  * with RFC 3927.
57  *
58  */
59 
60 #ifndef LWIP_HDR_AUTOIP_H
61 #define LWIP_HDR_AUTOIP_H
62 
63 #include "lwip/opt.h"
64 
65 #if LWIP_IPV4 && LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
66 
67 #include "lwip/netif.h"
68 /* #include "lwip/udp.h" */
69 #include "lwip/etharp.h"
70 
71 #ifdef __cplusplus
72 extern "C" {
73 #endif
74 
76 #define AUTOIP_TMR_INTERVAL 100
77 #define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL)
78 
80 struct autoip
81 {
83  ip4_addr_t llipaddr;
85  u8_t state;
87  u8_t sent_num;
89  u16_t ttw;
91  u8_t lastconflict;
93  u8_t tried_llipaddr;
94 };
95 
96 
97 void autoip_set_struct(struct netif *netif, struct autoip *autoip);
99 #define autoip_remove_struct(netif) do { (netif)->autoip = NULL; } while (0)
100 err_t autoip_start(struct netif *netif);
101 err_t autoip_stop(struct netif *netif);
102 void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr);
103 void autoip_tmr(void);
104 void autoip_network_changed(struct netif *netif);
105 u8_t autoip_supplied_address(const struct netif *netif);
106 
107 /* for lwIP internal use by ip4.c */
108 u8_t autoip_accept_packet(struct netif *netif, const ip4_addr_t *addr);
109 
110 #define netif_autoip_data(netif) ((struct autoip*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP))
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif /* LWIP_IPV4 && LWIP_AUTOIP */
117 
118 #endif /* LWIP_HDR_AUTOIP_H */
Definition: netif.h:244
s8_t err_t
Definition: err.h:76