1 /* SPDX-License-Identifier: BSD-2-Clause */
3 * dhcpcd - DHCP client daemon
4 * Copyright (c) 2006-2019 Roy Marples <roy@marples.name>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 /* ARP timings from RFC5227 */
37 #define ANNOUNCE_WAIT 2
38 #define ANNOUNCE_NUM 2
39 #define ANNOUNCE_INTERVAL 2
40 #define MAX_CONFLICTS 10
41 #define RATE_LIMIT_INTERVAL 60
42 #define DEFEND_INTERVAL 10
47 #ifdef IN_IFF_DUPLICATED
48 /* NetBSD gained RFC 5227 support in the kernel.
49 * This means dhcpcd doesn't need ARP except for ARPing support. */
50 #if defined(__NetBSD_Version__) && __NetBSD_Version__ >= 799003900
51 #define KERNEL_RFC5227
57 unsigned char sha
[HWADDR_LEN
];
59 unsigned char tha
[HWADDR_LEN
];
64 TAILQ_ENTRY(arp_state
) next
;
65 struct interface
*iface
;
67 void (*found_cb
)(struct arp_state
*, const struct arp_msg
*);
68 void (*not_found_cb
)(struct arp_state
*);
69 void (*announced_cb
)(struct arp_state
*);
70 void (*defend_failed_cb
)(struct arp_state
*);
71 void (*free_cb
)(struct arp_state
*);
76 struct timespec defend
;
78 TAILQ_HEAD(arp_statehead
, arp_state
);
82 unsigned int bpf_flags
;
83 struct arp_statehead arp_states
;
86 #define ARP_STATE(ifp) \
87 ((struct iarp_state *)(ifp)->if_data[IF_DATA_ARP])
88 #define ARP_CSTATE(ifp) \
89 ((const struct iarp_state *)(ifp)->if_data[IF_DATA_ARP])
92 struct arp_state
*arp_new(struct interface
*, const struct in_addr
*);
93 void arp_probe(struct arp_state
*);
94 void arp_announce(struct arp_state
*);
95 void arp_announceaddr(struct dhcpcd_ctx
*, const struct in_addr
*);
96 void arp_ifannounceaddr(struct interface
*, const struct in_addr
*);
97 void arp_cancel(struct arp_state
*);
98 void arp_free(struct arp_state
*);
99 void arp_freeaddr(struct interface
*, const struct in_addr
*);
100 void arp_drop(struct interface
*);