]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/netinet/igmp_var.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / netinet / igmp_var.h
1 /*-a
2  * Copyright (c) 1988 Stephen Deering.
3  * Copyright (c) 1992, 1993
4  *      The Regents of the University of California.  All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * Stephen Deering of Stanford University.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  *      from: @(#)igmp_var.h    8.1 (Berkeley) 7/19/93
34  * $FreeBSD$
35  */
36
37 #ifndef _NETINET_IGMP_VAR_H_
38 #define _NETINET_IGMP_VAR_H_
39
40 /*
41  * Internet Group Management Protocol (IGMP),
42  * implementation-specific definitions.
43  *
44  * Written by Steve Deering, Stanford, May 1988.
45  *
46  * MULTICAST Revision: 3.5.1.3
47  */
48
49 #ifndef BURN_BRIDGES
50 /*
51  * Pre-IGMPV3 igmpstat structure.
52  */
53 struct oigmpstat {
54         u_int igps_rcv_total;           /* total IGMP messages received */
55         u_int igps_rcv_tooshort;        /* received with too few bytes */
56         u_int igps_rcv_badsum;          /* received with bad checksum */
57         u_int igps_rcv_queries;         /* received membership queries */
58         u_int igps_rcv_badqueries;      /* received invalid queries */
59         u_int igps_rcv_reports;         /* received membership reports */
60         u_int igps_rcv_badreports;      /* received invalid reports */
61         u_int igps_rcv_ourreports;      /* received reports for our groups */
62         u_int igps_snd_reports;         /* sent membership reports */
63         u_int igps_rcv_toolong;         /* received with too many bytes */
64 };
65 #endif
66
67 /*
68  * IGMPv3 protocol statistics.
69  */
70 struct igmpstat {
71         /*
72          * Structure header (to insulate ABI changes).
73          */
74         uint32_t igps_version;          /* version of this structure */
75         uint32_t igps_len;              /* length of this structure */
76         /*
77          * Message statistics.
78          */
79         uint64_t igps_rcv_total;        /* total IGMP messages received */
80         uint64_t igps_rcv_tooshort;     /* received with too few bytes */
81         uint64_t igps_rcv_badttl;       /* received with ttl other than 1 */
82         uint64_t igps_rcv_badsum;       /* received with bad checksum */
83         /*
84          * Query statistics.
85          */
86         uint64_t igps_rcv_v1v2_queries; /* received IGMPv1/IGMPv2 queries */
87         uint64_t igps_rcv_v3_queries;   /* received IGMPv3 queries */
88         uint64_t igps_rcv_badqueries;   /* received invalid queries */
89         uint64_t igps_rcv_gen_queries;  /* received general queries */
90         uint64_t igps_rcv_group_queries;/* received group queries */
91         uint64_t igps_rcv_gsr_queries;  /* received group-source queries */
92         uint64_t igps_drop_gsr_queries; /* dropped group-source queries */
93         /*
94          * Report statistics.
95          */
96         uint64_t igps_rcv_reports;      /* received membership reports */
97         uint64_t igps_rcv_badreports;   /* received invalid reports */
98         uint64_t igps_rcv_ourreports;   /* received reports for our groups */
99         uint64_t igps_rcv_nora;         /* received w/o Router Alert option */
100         uint64_t igps_snd_reports;      /* sent membership reports */
101         /*
102          * Padding for future additions.
103          */
104         uint64_t __igps_pad[4];
105 };
106 #define IGPS_VERSION_3  3               /* as of FreeBSD 8.x */
107 #define IGPS_VERSION3_LEN               168
108
109 #ifdef _KERNEL
110 #define IGMPSTAT_ADD(name, val)         V_igmpstat.name += (val)
111 #define IGMPSTAT_INC(name)              IGMPSTAT_ADD(name, 1)
112 #endif
113
114 #ifdef CTASSERT
115 CTASSERT(sizeof(struct igmpstat) == 168);
116 #endif
117
118 #ifdef _KERNEL
119 #define IGMP_RANDOM_DELAY(X) (random() % (X) + 1)
120
121 #define IGMP_MAX_STATE_CHANGES          24 /* Max pending changes per group */
122
123 /*
124  * IGMP per-group states.
125  */
126 #define IGMP_NOT_MEMBER                 0 /* Can garbage collect in_multi */
127 #define IGMP_SILENT_MEMBER              1 /* Do not perform IGMP for group */
128 #define IGMP_REPORTING_MEMBER           2 /* IGMPv1/2/3 we are reporter */
129 #define IGMP_IDLE_MEMBER                3 /* IGMPv1/2 we reported last */
130 #define IGMP_LAZY_MEMBER                4 /* IGMPv1/2 other member reporting */
131 #define IGMP_SLEEPING_MEMBER            5 /* IGMPv1/2 start query response */
132 #define IGMP_AWAKENING_MEMBER           6 /* IGMPv1/2 group timer will start */
133 #define IGMP_G_QUERY_PENDING_MEMBER     7 /* IGMPv3 group query pending */
134 #define IGMP_SG_QUERY_PENDING_MEMBER    8 /* IGMPv3 source query pending */
135 #define IGMP_LEAVING_MEMBER             9 /* IGMPv3 dying gasp (pending last */
136                                           /* retransmission of INCLUDE {}) */
137
138 /*
139  * IGMP version tag.
140  */
141 #define IGMP_VERSION_NONE               0 /* Invalid */
142 #define IGMP_VERSION_1                  1
143 #define IGMP_VERSION_2                  2
144 #define IGMP_VERSION_3                  3 /* Default */
145
146 /*
147  * IGMPv3 protocol control variables.
148  */
149 #define IGMP_RV_INIT            2       /* Robustness Variable */
150 #define IGMP_RV_MIN             1
151 #define IGMP_RV_MAX             7
152
153 #define IGMP_QI_INIT            125     /* Query Interval (s) */
154 #define IGMP_QI_MIN             1
155 #define IGMP_QI_MAX             255
156
157 #define IGMP_QRI_INIT           10      /* Query Response Interval (s) */
158 #define IGMP_QRI_MIN            1
159 #define IGMP_QRI_MAX            255
160
161 #define IGMP_URI_INIT           3       /* Unsolicited Report Interval (s) */
162 #define IGMP_URI_MIN            0
163 #define IGMP_URI_MAX            10
164
165 #define IGMP_MAX_G_GS_PACKETS           8 /* # of packets to answer G/GS */
166 #define IGMP_MAX_STATE_CHANGE_PACKETS   8 /* # of packets per state change */
167 #define IGMP_MAX_RESPONSE_PACKETS       16 /* # of packets for general query */
168 #define IGMP_MAX_RESPONSE_BURST         4 /* # of responses to send at once */
169 #define IGMP_RESPONSE_BURST_INTERVAL    (PR_FASTHZ / 2) /* 500ms */
170
171 /*
172  * IGMP-specific mbuf flags.
173  */
174 #define M_IGMPV2        M_PROTO1        /* Packet is IGMPv2 */
175 #define M_IGMPV3_HDR    M_PROTO2        /* Packet has IGMPv3 headers */
176 #define M_GROUPREC      M_PROTO3        /* mbuf chain is a group record */
177 #define M_IGMP_LOOP     M_PROTO4        /* transmit on loif, not real ifp */
178
179 /*
180  * Default amount of leading space for IGMPv3 to allocate at the
181  * beginning of its mbuf packet chains, to avoid fragmentation and
182  * unnecessary allocation of leading mbufs.
183  */
184 #define RAOPT_LEN       4               /* Length of IP Router Alert option */
185 #define IGMP_LEADINGSPACE               \
186         (sizeof(struct ip) + RAOPT_LEN + sizeof(struct igmp_report))
187
188 /*
189  * Subsystem lock macros.
190  * The IGMP lock is only taken with IGMP. Currently it is system-wide.
191  * VIMAGE: The lock could be pushed to per-VIMAGE granularity in future.
192  */
193 #define IGMP_LOCK_INIT()        mtx_init(&igmp_mtx, "igmp_mtx", NULL, MTX_DEF)
194 #define IGMP_LOCK_DESTROY()     mtx_destroy(&igmp_mtx)
195 #define IGMP_LOCK()             mtx_lock(&igmp_mtx)
196 #define IGMP_LOCK_ASSERT()      mtx_assert(&igmp_mtx, MA_OWNED)
197 #define IGMP_UNLOCK()           mtx_unlock(&igmp_mtx)
198 #define IGMP_UNLOCK_ASSERT()    mtx_assert(&igmp_mtx, MA_NOTOWNED)
199
200 struct igmp_ifinfo;
201
202 int     igmp_change_state(struct in_multi *);
203 void    igmp_fasttimo(void);
204 struct igmp_ifinfo *
205         igmp_domifattach(struct ifnet *);
206 void    igmp_domifdetach(struct ifnet *);
207 void    igmp_ifdetach(struct ifnet *);
208 void    igmp_input(struct mbuf *, int);
209 void    igmp_slowtimo(void);
210
211 SYSCTL_DECL(_net_inet_igmp);
212
213 #endif /* _KERNEL */
214
215 /*
216  * Names for IGMP sysctl objects
217  */
218 #define IGMPCTL_STATS           1       /* statistics (read-only) */
219 #define IGMPCTL_MAXID           2
220
221 #define IGMPCTL_NAMES { \
222         { 0, 0 }, \
223         { "stats", CTLTYPE_STRUCT } \
224 }
225 #endif