1 /* $NetBSD: ipv4ll.h,v 1.10 2015/08/21 10:39:00 roy Exp $ */
4 * dhcpcd - DHCP client daemon
5 * Copyright (c) 2006-2015 Roy Marples <roy@marples.name>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 extern const struct in_addr inaddr_llmask
;
36 extern const struct in_addr inaddr_llbcast
;
38 #define LINKLOCAL_ADDR 0xa9fe0000
39 #define LINKLOCAL_MASK IN_CLASSB_NET
40 #define LINKLOCAL_BRDC (LINKLOCAL_ADDR | ~LINKLOCAL_MASK)
43 # define IN_LINKLOCAL(addr) ((addr & IN_CLASSB_NET) == LINKLOCAL_ADDR)
48 struct arp_state
*arp
;
49 unsigned int conflicts
;
50 struct timespec defend
;
51 char randomstate
[128];
55 #define IPV4LL_STATE(ifp) \
56 ((struct ipv4ll_state *)(ifp)->if_data[IF_DATA_IPV4LL])
57 #define IPV4LL_CSTATE(ifp) \
58 ((const struct ipv4ll_state *)(ifp)->if_data[IF_DATA_IPV4LL])
59 #define IPV4LL_STATE_RUNNING(ifp) \
60 (IPV4LL_CSTATE((ifp)) && !IPV4LL_CSTATE((ifp))->down && \
61 IN_LINKLOCAL(ntohl(IPV4LL_CSTATE((ifp))->addr.s_addr)))
63 struct rt
* ipv4ll_subnet_route(const struct interface
*);
64 struct rt
* ipv4ll_default_route(const struct interface
*);
65 ssize_t
ipv4ll_env(char **, const char *, const struct interface
*);
66 void ipv4ll_start(void *);
67 void ipv4ll_claimed(void *);
68 void ipv4ll_handle_failure(void *);
70 #define ipv4ll_free(ifp) ipv4ll_freedrop((ifp), 0);
71 #define ipv4ll_drop(ifp) ipv4ll_freedrop((ifp), 1);
72 void ipv4ll_freedrop(struct interface
*, int);