1 /* $NetBSD: ipv6nd.h,v 1.13 2015/07/09 10:15:34 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
41 struct interface
*iface
;
43 char sfrom
[INET6_ADDRSTRLEN
];
46 struct timespec acquired
;
52 struct ipv6_addrhead addrs
;
55 uint8_t no_public_warned
;
58 TAILQ_HEAD(ra_head
, ra
);
66 #define RS_STATE(a) ((struct rs_state *)(ifp)->if_data[IF_DATA_IPV6ND])
67 #define RS_STATE_RUNNING(a) (ipv6nd_hasra((a)) && ipv6nd_dadcompleted((a)))
69 #define ND_CFIRST_OPTION(m) \
70 ((const struct nd_opt_hdr *) \
71 ((const uint8_t *)(m)->data + sizeof(struct nd_router_advert)))
72 #define ND_OPTION_LEN(o) ((size_t)((o)->nd_opt_len * 8) - \
73 sizeof(struct nd_opt_hdr))
74 #define ND_CNEXT_OPTION(o) \
75 ((const struct nd_opt_hdr *)((const uint8_t *)(o) + \
76 (size_t)((o)->nd_opt_len * 8)))
77 #define ND_COPTION_DATA(o) \
78 ((const uint8_t *)(o) + sizeof(struct nd_opt_hdr))
80 #define MAX_RTR_SOLICITATION_DELAY 1 /* seconds */
81 #define MAX_UNICAST_SOLICIT 3 /* 3 transmissions */
82 #define RTR_SOLICITATION_INTERVAL 4 /* seconds */
83 #define MAX_RTR_SOLICITATIONS 3 /* times */
85 /* On carrier up, expire known routers after RTR_CARRIER_EXPIRE seconds. */
86 #define RTR_CARRIER_EXPIRE \
87 (MAX_RTR_SOLICITATION_DELAY + \
88 (MAX_RTR_SOLICITATIONS + 1) * \
89 RTR_SOLICITATION_INTERVAL)
91 #define MAX_REACHABLE_TIME 3600000 /* milliseconds */
92 #define REACHABLE_TIME 30000 /* milliseconds */
93 #define RETRANS_TIMER 1000 /* milliseconds */
94 #define DELAY_FIRST_PROBE_TIME 5 /* seconds */
96 #define IPV6ND_REACHABLE (1 << 0)
97 #define IPV6ND_ROUTER (1 << 1)
100 void ipv6nd_printoptions(const struct dhcpcd_ctx
*,
101 const struct dhcp_opt
*, size_t);
102 void ipv6nd_startrs(struct interface
*);
103 ssize_t
ipv6nd_env(char **, const char *, const struct interface
*);
104 const struct ipv6_addr
*ipv6nd_iffindaddr(const struct interface
*ifp
,
105 const struct in6_addr
*addr
, short flags
);
106 struct ipv6_addr
*ipv6nd_findaddr(struct dhcpcd_ctx
*,
107 const struct in6_addr
*, short);
108 void ipv6nd_freedrop_ra(struct ra
*, int);
109 #define ipv6nd_free_ra(ra) ipv6nd_freedrop_ra((ra), 0)
110 #define ipv6nd_drop_ra(ra) ipv6nd_freedrop_ra((ra), 1)
111 ssize_t
ipv6nd_free(struct interface
*);
112 void ipv6nd_expirera(void *arg
);
113 int ipv6nd_hasra(const struct interface
*);
114 int ipv6nd_hasradhcp(const struct interface
*);
115 void ipv6nd_runignoredra(struct interface
*);
116 void ipv6nd_handleifa(struct dhcpcd_ctx
*, int,
117 const char *, const struct in6_addr
*, int);
118 int ipv6nd_dadcompleted(const struct interface
*);
119 void ipv6nd_expire(struct interface
*, uint32_t);
120 void ipv6nd_drop(struct interface
*);
121 void ipv6nd_neighbour(struct dhcpcd_ctx
*, struct in6_addr
*, int);
123 #define ipv6nd_startrs(a) {}
124 #define ipv6nd_free(a) {}
125 #define ipv6nd_hasra(a) (0)
126 #define ipv6nd_dadcompleted(a) (0)
127 #define ipv6nd_drop(a) {}
128 #define ipv6nd_expire(a, b) {}