source: rtems-libbsd/dhcpcd/ipv6.h @ f949b43

55-freebsd-126-freebsd-12
Last change on this file since f949b43 was 338f300, checked in by Christian Mauderer <christian.mauderer@…>, on 04/25/18 at 14:28:00

buildset: Add minimal and everything config.

This adds two new buildset configurations: One that leaves out as much
features as possible and one that enables all features. For the default
configuration WiFi? support is now disabled.

To disable IPv6 for the minimal configuration, all -DINET6 are
eliminated in libbsd.py. They are now replaced by a #ifdef that checks
for RTEMS_BSD_MODULE_NETINET6 instead.

Close #3351.

  • Property mode set to 100644
File size: 5.5 KB
Line 
1/*
2 * dhcpcd - DHCP client daemon
3 * Copyright (c) 2006-2013 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 IPV6_H
29#define IPV6_H
30
31#include <sys/queue.h>
32
33#include <netinet/in.h>
34#ifdef __rtems__
35#include <rtems/bsd/local/opt_inet6.h>
36#endif /* __rtems__ */
37
38#define ALLROUTERS "ff02::2"
39#define HOPLIMIT 255
40
41#define ROUNDUP8(a) (1 + (((a) - 1) | 7))
42
43#ifndef ND6_INFINITE_LIFETIME
44#  define ND6_INFINITE_LIFETIME         ((uint32_t)~0)
45#endif
46
47/*
48 * BSD kernels don't inform userland of DAD results.
49 * Also, for RTM_NEWADDR messages the address flags could be
50 * undefined leading to false positive duplicate address errors.
51 * As such we listen for duplicate addresses on the wire and
52 * wait the maxium possible length of time as dictated by the DAD transmission
53 * counter and RFC timings.
54 * See the discussion here:
55 *    http://mail-index.netbsd.org/tech-net/2013/03/15/msg004019.html
56 */
57#ifndef __linux__
58/* We guard here to avoid breaking a compile on linux ppc-64 headers */
59#  include <sys/param.h>
60#endif
61#ifdef BSD
62#  define LISTEN_DAD
63#endif
64
65/* This was fixed in NetBSD */
66#ifdef __NetBSD_Prereq__
67#  if __NetBSD_Prereq__(6, 99, 20)
68#    undef LISTEN_DAD
69#  endif
70#endif
71
72struct ipv6_addr {
73        TAILQ_ENTRY(ipv6_addr) next;
74        struct interface *iface;
75        struct in6_addr prefix;
76        int prefix_len;
77        uint32_t prefix_vltime;
78        uint32_t prefix_pltime;
79        struct in6_addr addr;
80        short flags;
81        char saddr[INET6_ADDRSTRLEN];
82        uint8_t iaid[4];
83        struct interface *delegating_iface;
84
85        void (*dadcallback)(void *);
86        uint8_t *ns;
87        size_t nslen;
88        int nsprobes;
89};
90TAILQ_HEAD(ipv6_addrhead, ipv6_addr);
91
92#define IPV6_AF_ONLINK          0x0001
93#define IPV6_AF_NEW             0x0002
94#define IPV6_AF_STALE           0x0004
95#define IPV6_AF_ADDED           0x0008
96#define IPV6_AF_AUTOCONF        0x0010
97#define IPV6_AF_DUPLICATED      0x0020
98#define IPV6_AF_DADCOMPLETED    0x0040
99#define IPV6_AF_DELEGATED       0x0080
100
101struct rt6 {
102        TAILQ_ENTRY(rt6) next;
103        struct in6_addr dest;
104        struct in6_addr net;
105        struct in6_addr gate;
106        const struct interface *iface;
107        int metric;
108        unsigned int mtu;
109};
110TAILQ_HEAD(rt6head, rt6);
111
112struct ipv6_addr_l {
113        TAILQ_ENTRY(ipv6_addr_l) next;
114        struct in6_addr addr;
115};
116
117TAILQ_HEAD(ipv6_addr_l_head, ipv6_addr_l);
118
119struct ll_callback {
120        TAILQ_ENTRY(ll_callback) next;
121        void (*callback)(void *);
122        void *arg;
123};
124TAILQ_HEAD(ll_callback_head, ll_callback);
125
126struct ipv6_state {
127        struct ipv6_addr_l_head addrs;
128        struct ll_callback_head ll_callbacks;
129};
130
131#define IPV6_STATE(ifp)                                                        \
132        ((struct ipv6_state *)(ifp)->if_data[IF_DATA_IPV6])
133#define IPV6_CSTATE(ifp)                                                       \
134        ((const struct ipv6_state *)(ifp)->if_data[IF_DATA_IPV6])
135
136#ifdef INET6
137int ipv6_init(void);
138ssize_t ipv6_printaddr(char *, ssize_t, const uint8_t *, const char *);
139int ipv6_makeaddr(struct in6_addr *, const struct interface *,
140    const struct in6_addr *, int);
141int ipv6_makeprefix(struct in6_addr *, const struct in6_addr *, int);
142int ipv6_mask(struct in6_addr *, int);
143int ipv6_prefixlen(const struct in6_addr *);
144int ipv6_userprefix( const struct in6_addr *, short prefix_len,
145    uint64_t user_number, struct in6_addr *result, short result_len);
146int ipv6_addaddr(struct ipv6_addr *);
147void ipv6_freedrop_addrs(struct ipv6_addrhead *, int,
148    const struct interface *);
149void ipv6_handleifa(int, struct if_head *,
150    const char *, const struct in6_addr *, int);
151int ipv6_handleifa_addrs(int, struct ipv6_addrhead *,
152    const struct in6_addr *, int);
153const struct ipv6_addr_l *ipv6_linklocal(const struct interface *);
154const struct ipv6_addr_l *ipv6_findaddr(const struct interface *,
155    const struct in6_addr *);
156int ipv6_addlinklocalcallback(struct interface *, void (*)(void *), void *);
157void ipv6_free_ll_callbacks(struct interface *);
158void ipv6_free(struct interface *);
159int ipv6_removesubnet(const struct interface *, struct ipv6_addr *);
160void ipv6_buildroutes(void);
161
162int if_address6(const struct ipv6_addr *, int);
163#define add_address6(a) if_address6(a, 1)
164#define del_address6(a) if_address6(a, -1)
165int in6_addr_flags(const char *, const struct in6_addr *);
166
167int if_route6(const struct rt6 *rt, int);
168#define add_route6(rt) if_route6(rt, 1)
169#define change_route6(rt) if_route6(rt, 0)
170#define del_route6(rt) if_route6(rt, -1)
171#define del_src_route6(rt) if_route6(rt, -2);
172
173#else
174#define ipv6_init() -1
175#define ipv6_free_ll_callbacks(a)
176#define ipv6_free(a)
177#endif
178
179#endif
Note: See TracBrowser for help on using the repository browser.