1 /* 2 * dhcpcd - DHCP client daemon 3 * Copyright (c) 2006-2018 Roy Marples <roy@marples.name> 4 * All rights reserved 5 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28 #ifndef IPV4LL_H 29 #define IPV4LL_H 30 31 #define LINKLOCAL_ADDR 0xa9fe0000 32 #define LINKLOCAL_MASK IN_CLASSB_NET 33 #define LINKLOCAL_BCAST (LINKLOCAL_ADDR | ~LINKLOCAL_MASK) 34 35 #ifndef IN_LINKLOCAL 36 # define IN_LINKLOCAL(addr) ((addr & IN_CLASSB_NET) == LINKLOCAL_ADDR) 37 #endif 38 39 #ifdef IPV4LL 40 #include "arp.h" 41 42 struct ipv4ll_state { 43 struct ipv4_addr *addr; 44 struct arp_state *arp; 45 unsigned int conflicts; 46 struct timespec defend; 47 char randomstate[128]; 48 uint8_t down; 49 }; 50 51 #define IPV4LL_STATE(ifp) \ 52 ((struct ipv4ll_state *)(ifp)->if_data[IF_DATA_IPV4LL]) 53 #define IPV4LL_CSTATE(ifp) \ 54 ((const struct ipv4ll_state *)(ifp)->if_data[IF_DATA_IPV4LL]) 55 #define IPV4LL_STATE_RUNNING(ifp) \ 56 (IPV4LL_CSTATE((ifp)) && !IPV4LL_CSTATE((ifp))->down && \ 57 (IPV4LL_CSTATE((ifp))->addr != NULL)) 58 59 int ipv4ll_subnetroute(struct rt_head *, struct interface *); 60 int ipv4ll_defaultroute(struct rt_head *,struct interface *); 61 ssize_t ipv4ll_env(char **, const char *, const struct interface *); 62 void ipv4ll_start(void *); 63 void ipv4ll_claimed(void *); 64 void ipv4ll_handle_failure(void *); 65 #ifdef HAVE_ROUTE_METRIC 66 int ipv4ll_recvrt(int, const struct rt *); 67 #endif 68 69 #define ipv4ll_free(ifp) ipv4ll_freedrop((ifp), 0); 70 #define ipv4ll_drop(ifp) ipv4ll_freedrop((ifp), 1); 71 void ipv4ll_freedrop(struct interface *, int); 72 #else 73 #define IPV4LL_STATE_RUNNING(ifp) (0) 74 #define ipv4ll_subnetroute(route, ifp) (0) 75 #define ipv4ll_defaultroute(route, ifp) (0) 76 #define ipv4ll_handlert(a, b, c) (0) 77 #define ipv4ll_free(a) {} 78 #endif 79 80 #endif 81