Deleted Added
full compact
mld6_var.h (174510) mld6_var.h (191672)
1/*-
1/*-
2 * Copyright (C) 1998 WIDE Project.
3 * All rights reserved.
2 * Copyright (c) 2009 Bruce Simpson.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the project nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
12 * 3. The name of the author may not be used to endorse or promote
13 * products derived from this software without specific prior written
14 * permission.
16 *
15 *
17 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
16 * 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
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
19 * 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
27 * SUCH DAMAGE.
28 *
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
26 * SUCH DAMAGE.
27 *
29 * $KAME: mld6_var.h,v 1.4 2000/03/25 07:23:54 sumikawa Exp $
30 * $FreeBSD: head/sys/netinet6/mld6_var.h 174510 2007-12-10 16:03:40Z obrien $
28 * $FreeBSD: head/sys/netinet6/mld6_var.h 191672 2009-04-29 19:19:13Z bms $
31 */
29 */
32
33#ifndef _NETINET6_MLD6_VAR_H_
34#define _NETINET6_MLD6_VAR_H_
35
30#ifndef _NETINET6_MLD6_VAR_H_
31#define _NETINET6_MLD6_VAR_H_
32
33/*
34 * Multicast Listener Discovery (MLD)
35 * implementation-specific definitions.
36 */
37
36#ifdef _KERNEL
37
38#ifdef _KERNEL
39
38#define MLD_RANDOM_DELAY(X) (arc4random() % (X) + 1)
40/*
41 * Per-link MLD state.
42 */
43struct mld_ifinfo {
44 LIST_ENTRY(mld_ifinfo) mli_link;
45 struct ifnet *mli_ifp; /* interface this instance belongs to */
46 uint32_t mli_version; /* MLDv1 Host Compatibility Mode */
47 uint32_t mli_v1_timer; /* MLDv1 Querier Present timer (s) */
48 uint32_t mli_v2_timer; /* MLDv2 General Query (interface) timer (s)*/
49 uint32_t mli_flags; /* MLD per-interface flags */
50 uint32_t mli_rv; /* MLDv2 Robustness Variable */
51 uint32_t mli_qi; /* MLDv2 Query Interval (s) */
52 uint32_t mli_qri; /* MLDv2 Query Response Interval (s) */
53 uint32_t mli_uri; /* MLDv2 Unsolicited Report Interval (s) */
54 SLIST_HEAD(,in6_multi) mli_relinmhead; /* released groups */
55 struct ifqueue mli_gq; /* queue of general query responses */
56};
57#define MLIF_SILENT 0x00000001 /* Do not use MLD on this ifp */
39
58
59#define MLD_RANDOM_DELAY(X) (arc4random() % (X) + 1)
60#define MLD_MAX_STATE_CHANGES 24 /* Max pending changes per group */
61
40/*
62/*
41 * States for MLD stop-listening processing
63 * MLD per-group states.
42 */
64 */
43#define MLD_OTHERLISTENER 0
44#define MLD_IREPORTEDLAST 1
45#define MLD_REPORTPENDING 2 /* implementation specific */
65#define MLD_NOT_MEMBER 0 /* Can garbage collect group */
66#define MLD_SILENT_MEMBER 1 /* Do not perform MLD for group */
67#define MLD_REPORTING_MEMBER 2 /* MLDv1 we are reporter */
68#define MLD_IDLE_MEMBER 3 /* MLDv1 we reported last */
69#define MLD_LAZY_MEMBER 4 /* MLDv1 other member reporting */
70#define MLD_SLEEPING_MEMBER 5 /* MLDv1 start query response */
71#define MLD_AWAKENING_MEMBER 6 /* MLDv1 group timer will start */
72#define MLD_G_QUERY_PENDING_MEMBER 7 /* MLDv2 group query pending */
73#define MLD_SG_QUERY_PENDING_MEMBER 8 /* MLDv2 source query pending */
74#define MLD_LEAVING_MEMBER 9 /* MLDv2 dying gasp (pending last */
75 /* retransmission of INCLUDE {}) */
46
76
47void mld6_init(void);
48void mld6_input(struct mbuf *, int);
49void mld6_start_listening(struct in6_multi *);
50void mld6_stop_listening(struct in6_multi *);
51void mld6_fasttimeo(void);
77/*
78 * MLD version tag.
79 */
80#define MLD_VERSION_NONE 0 /* Invalid */
81#define MLD_VERSION_1 1
82#define MLD_VERSION_2 2 /* Default */
83
84/*
85 * MLDv2 protocol control variables.
86 */
87#define MLD_RV_INIT 2 /* Robustness Variable */
88#define MLD_RV_MIN 1
89#define MLD_RV_MAX 7
90
91#define MLD_QI_INIT 125 /* Query Interval (s) */
92#define MLD_QI_MIN 1
93#define MLD_QI_MAX 255
94
95#define MLD_QRI_INIT 10 /* Query Response Interval (s) */
96#define MLD_QRI_MIN 1
97#define MLD_QRI_MAX 255
98
99#define MLD_URI_INIT 3 /* Unsolicited Report Interval (s) */
100#define MLD_URI_MIN 0
101#define MLD_URI_MAX 10
102
103#define MLD_MAX_GS_SOURCES 256 /* # of sources in rx GS query */
104#define MLD_MAX_G_GS_PACKETS 8 /* # of packets to answer G/GS */
105#define MLD_MAX_STATE_CHANGE_PACKETS 8 /* # of packets per state change */
106#define MLD_MAX_RESPONSE_PACKETS 16 /* # of packets for general query */
107#define MLD_MAX_RESPONSE_BURST 4 /* # of responses to send at once */
108#define MLD_RESPONSE_BURST_INTERVAL (PR_FASTHZ / 2) /* 500ms */
109
110/*
111 * MLD-specific mbuf flags.
112 */
113#define M_MLDV1 M_PROTO1 /* Packet is MLDv1 */
114#define M_GROUPREC M_PROTO3 /* mbuf chain is a group record */
115
116/*
117 * Leading space for MLDv2 reports inside MTU.
118 *
119 * NOTE: This differs from IGMPv3 significantly. KAME IPv6 requires
120 * that a fully formed mbuf chain *without* the Router Alert option
121 * is passed to ip6_output(), however we must account for it in the
122 * MTU if we need to split an MLDv2 report into several packets.
123 *
124 * We now put the MLDv2 report header in the initial mbuf containing
125 * the IPv6 header.
126 */
127#define MLD_MTUSPACE (sizeof(struct ip6_hdr) + sizeof(struct mld_raopt) + \
128 sizeof(struct icmp6_hdr))
129
130/*
131 * Subsystem lock macros.
132 * The MLD lock is only taken with MLD. Currently it is system-wide.
133 * VIMAGE: The lock could be pushed to per-VIMAGE granularity in future.
134 */
135#define MLD_LOCK_INIT() mtx_init(&mld_mtx, "mld_mtx", NULL, MTX_DEF)
136#define MLD_LOCK_DESTROY() mtx_destroy(&mld_mtx)
137#define MLD_LOCK() mtx_lock(&mld_mtx)
138#define MLD_LOCK_ASSERT() mtx_assert(&mld_mtx, MA_OWNED)
139#define MLD_UNLOCK() mtx_unlock(&mld_mtx)
140#define MLD_UNLOCK_ASSERT() mtx_assert(&mld_mtx, MA_NOTOWNED)
141
142/*
143 * Per-link MLD context.
144 */
145#define MLD_IFINFO(ifp) \
146 (((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->mld_ifinfo)
147
148int mld_change_state(struct in6_multi *, const int);
149struct mld_ifinfo *
150 mld_domifattach(struct ifnet *);
151void mld_domifdetach(struct ifnet *);
152void mld_fasttimo(void);
153void mld_ifdetach(struct ifnet *);
154int mld_input(struct mbuf *, int, int);
155void mld_slowtimo(void);
156
157#ifdef SYSCTL_DECL
158SYSCTL_DECL(_net_inet6_mld);
159#endif
160
52#endif /* _KERNEL */
53
54#endif /* _NETINET6_MLD6_VAR_H_ */
161#endif /* _KERNEL */
162
163#endif /* _NETINET6_MLD6_VAR_H_ */