]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/netinet6/ip6_mroute.h
nvmecontrol(8): Fix a few mandoc related issues and add a SEE ALSO section
[FreeBSD/FreeBSD.git] / sys / netinet6 / ip6_mroute.h
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (C) 1998 WIDE Project.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
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.
15  * 3. Neither the name of the project nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  *      $KAME: ip6_mroute.h,v 1.19 2001/06/14 06:12:55 suz Exp $
32  * $FreeBSD$
33  */
34
35 /*      BSDI ip_mroute.h,v 2.5 1996/10/11 16:01:48 pjd Exp      */
36
37 /*
38  * Definitions for IP multicast forwarding.
39  *
40  * Written by David Waitzman, BBN Labs, August 1988.
41  * Modified by Steve Deering, Stanford, February 1989.
42  * Modified by Ajit Thyagarajan, PARC, August 1993.
43  * Modified by Ajit Thyagarajan, PARC, August 1994.
44  * Modified by Ahmed Helmy, USC, September 1996.
45  *
46  * MROUTING Revision: 1.2
47  */
48
49 #ifndef _NETINET6_IP6_MROUTE_H_
50 #define _NETINET6_IP6_MROUTE_H_
51
52 /*
53  * Multicast Routing set/getsockopt commands.
54  */
55 #ifdef _KERNEL
56 #define MRT6_OINIT              100     /* initialize forwarder (omrt6msg) */
57 #endif
58 #define MRT6_DONE               101     /* shut down forwarder */
59 #define MRT6_ADD_MIF            102     /* add multicast interface */
60 #define MRT6_DEL_MIF            103     /* delete multicast interface */
61 #define MRT6_ADD_MFC            104     /* insert forwarding cache entry */
62 #define MRT6_DEL_MFC            105     /* delete forwarding cache entry */
63 #define MRT6_PIM                107     /* enable pim code */
64 #define MRT6_INIT               108     /* initialize forwarder (mrt6msg) */
65
66 #if BSD >= 199103
67 #define GET_TIME(t)     microtime(&t)
68 #elif defined(sun)
69 #define GET_TIME(t)     uniqtime(&t)
70 #else
71 #define GET_TIME(t)     ((t) = time)
72 #endif
73
74 /*
75  * Types and macros for handling bitmaps with one bit per multicast interface.
76  */
77 typedef u_short mifi_t;         /* type of a mif index */
78 #define MAXMIFS         64
79
80 #ifndef IF_SETSIZE
81 #define IF_SETSIZE      256
82 #endif
83
84 typedef u_int32_t       if_mask;
85 #define NIFBITS (sizeof(if_mask) * NBBY)        /* bits per mask */
86
87 #ifndef howmany
88 #define howmany(x, y)   (((x) + ((y) - 1)) / (y))
89 #endif
90
91 typedef struct if_set {
92         if_mask ifs_bits[howmany(IF_SETSIZE, NIFBITS)];
93 } if_set;
94
95 #define IF_SET(n, p)    ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS)))
96 #define IF_CLR(n, p)    ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS)))
97 #define IF_ISSET(n, p)  ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS)))
98 #define IF_COPY(f, t)   bcopy(f, t, sizeof(*(f)))
99 #define IF_ZERO(p)      bzero(p, sizeof(*(p)))
100
101 /*
102  * Argument structure for MRT6_ADD_IF.
103  */
104 struct mif6ctl {
105         mifi_t      mif6c_mifi;         /* the index of the mif to be added  */
106         u_char      mif6c_flags;        /* MIFF_ flags defined below         */
107         u_short     mif6c_pifi;         /* the index of the physical IF */
108 };
109
110 #define MIFF_REGISTER   0x1     /* mif represents a register end-point */
111
112 /*
113  * Argument structure for MRT6_ADD_MFC and MRT6_DEL_MFC
114  */
115 struct mf6cctl {
116         struct sockaddr_in6 mf6cc_origin;       /* IPv6 origin of mcasts */
117         struct sockaddr_in6 mf6cc_mcastgrp; /* multicast group associated */
118         mifi_t          mf6cc_parent;   /* incoming ifindex */
119         struct if_set   mf6cc_ifset;    /* set of forwarding ifs */
120 };
121
122 /*
123  * The kernel's multicast routing statistics.
124  */
125 struct mrt6stat {
126         uint64_t mrt6s_mfc_lookups;     /* # forw. cache hash table hits   */
127         uint64_t mrt6s_mfc_misses;      /* # forw. cache hash table misses */
128         uint64_t mrt6s_upcalls;         /* # calls to multicast routing daemon */
129         uint64_t mrt6s_no_route;        /* no route for packet's origin    */
130         uint64_t mrt6s_bad_tunnel;      /* malformed tunnel options        */
131         uint64_t mrt6s_cant_tunnel;     /* no room for tunnel options      */
132         uint64_t mrt6s_wrong_if;        /* arrived on wrong interface      */
133         uint64_t mrt6s_upq_ovflw;       /* upcall Q overflow               */
134         uint64_t mrt6s_cache_cleanups;  /* # entries with no upcalls       */
135         uint64_t mrt6s_drop_sel;        /* pkts dropped selectively        */
136         uint64_t mrt6s_q_overflow;      /* pkts dropped - Q overflow       */
137         uint64_t mrt6s_pkt2large;       /* pkts dropped - size > BKT SIZE  */
138         uint64_t mrt6s_upq_sockfull;    /* upcalls dropped - socket full   */
139 };
140
141 #ifdef MRT6_OINIT
142 /*
143  * Struct used to communicate from kernel to multicast router
144  * note the convenient similarity to an IPv6 header.
145  * XXX old version, superseded by mrt6msg.
146  */
147 struct omrt6msg {
148         u_long      unused1;
149         u_char      im6_msgtype;                /* what type of message     */
150         u_char      im6_mbz;                    /* must be zero             */
151         u_char      im6_mif;                    /* mif rec'd on             */
152         u_char      unused2;
153         struct in6_addr  im6_src, im6_dst;
154 };
155 #endif
156
157 /*
158  * Structure used to communicate from kernel to multicast router.
159  * We'll overlay the structure onto an MLD header (not an IPv6 header
160  * like igmpmsg{} used for IPv4 implementation). This is because this
161  * structure will be passed via an IPv6 raw socket, on which an application
162  * will only receive the payload i.e. the data after the IPv6 header and all
163  * the extension headers. (see Section 3 of RFC3542)
164  */
165 struct mrt6msg {
166 #define MRT6MSG_NOCACHE         1
167 #define MRT6MSG_WRONGMIF        2
168 #define MRT6MSG_WHOLEPKT        3               /* used for user level encap*/
169         u_char      im6_mbz;                    /* must be zero             */
170         u_char      im6_msgtype;                /* what type of message     */
171         u_int16_t   im6_mif;                    /* mif rec'd on             */
172         u_int32_t   im6_pad;                    /* padding for 64bit arch   */
173         struct in6_addr  im6_src, im6_dst;
174 };
175
176 /*
177  * Argument structure used by multicast routing daemon to get src-grp
178  * packet counts
179  */
180 struct sioc_sg_req6 {
181         struct sockaddr_in6 src;
182         struct sockaddr_in6 grp;
183         u_quad_t pktcnt;
184         u_quad_t bytecnt;
185         u_quad_t wrong_if;
186 };
187
188 /*
189  * Argument structure used by mrouted to get mif pkt counts
190  */
191 struct sioc_mif_req6 {
192         mifi_t mifi;            /* mif number                           */
193         u_quad_t icount;        /* Input packet count on mif            */
194         u_quad_t ocount;        /* Output packet count on mif           */
195         u_quad_t ibytes;        /* Input byte count on mif              */
196         u_quad_t obytes;        /* Output byte count on mif             */
197 };
198
199 /*
200  * Structure to export 'struct mif6' to userland via sysctl.
201  */
202 struct mif6_sctl {
203         u_char          m6_flags;       /* MIFF_ flags defined above         */
204         u_int           m6_rate_limit;  /* max rate                          */
205         struct in6_addr m6_lcl_addr;    /* local interface address           */
206         uint32_t        m6_ifp;         /* interface index                   */
207         u_quad_t        m6_pkt_in;      /* # pkts in on interface            */
208         u_quad_t        m6_pkt_out;     /* # pkts out on interface           */
209         u_quad_t        m6_bytes_in;    /* # bytes in on interface           */
210         u_quad_t        m6_bytes_out;   /* # bytes out on interface          */
211 };
212
213 #if defined(_KERNEL) || defined(KERNEL)
214 /*
215  * The kernel's multicast-interface structure.
216  */
217 struct mif6 {
218         u_char          m6_flags;       /* MIFF_ flags defined above         */
219         u_int           m6_rate_limit;  /* max rate                          */
220         struct in6_addr m6_lcl_addr;    /* local interface address           */
221         struct ifnet    *m6_ifp;        /* pointer to interface              */
222         u_quad_t        m6_pkt_in;      /* # pkts in on interface            */
223         u_quad_t        m6_pkt_out;     /* # pkts out on interface           */
224         u_quad_t        m6_bytes_in;    /* # bytes in on interface           */
225         u_quad_t        m6_bytes_out;   /* # bytes out on interface          */
226 #ifdef notyet
227         u_int           m6_rsvp_on;     /* RSVP listening on this vif */
228         struct socket   *m6_rsvpd;      /* RSVP daemon socket */
229 #endif
230 };
231
232 /*
233  * The kernel's multicast forwarding cache entry structure
234  */
235 struct mf6c {
236         struct sockaddr_in6  mf6c_origin;       /* IPv6 origin of mcasts     */
237         struct sockaddr_in6  mf6c_mcastgrp;     /* multicast group associated*/
238         mifi_t           mf6c_parent;           /* incoming IF               */
239         struct if_set    mf6c_ifset;            /* set of outgoing IFs */
240
241         u_quad_t        mf6c_pkt_cnt;           /* pkt count for src-grp     */
242         u_quad_t        mf6c_byte_cnt;          /* byte count for src-grp    */
243         u_quad_t        mf6c_wrong_if;          /* wrong if for src-grp      */
244         int             mf6c_expire;            /* time to clean entry up    */
245         struct timeval  mf6c_last_assert;       /* last time I sent an assert*/
246         struct rtdetq  *mf6c_stall;             /* pkts waiting for route */
247         struct mf6c    *mf6c_next;              /* hash table linkage */
248 };
249
250 #define MF6C_INCOMPLETE_PARENT ((mifi_t)-1)
251
252 /*
253  * Argument structure used for pkt info. while upcall is made
254  */
255 #ifndef _NETINET_IP_MROUTE_H_
256 struct rtdetq {         /* XXX: rtdetq is also defined in ip_mroute.h */
257     struct mbuf         *m;             /* A copy of the packet             */
258     struct ifnet        *ifp;           /* Interface pkt came in on         */
259 #ifdef UPCALL_TIMING
260     struct timeval      t;              /* Timestamp */
261 #endif /* UPCALL_TIMING */
262     struct rtdetq       *next;
263 };
264 #endif /* _NETINET_IP_MROUTE_H_ */
265
266 #define MF6CTBLSIZ      256
267 #if (MF6CTBLSIZ & (MF6CTBLSIZ - 1)) == 0          /* from sys:route.h */
268 #define MF6CHASHMOD(h)  ((h) & (MF6CTBLSIZ - 1))
269 #else
270 #define MF6CHASHMOD(h)  ((h) % MF6CTBLSIZ)
271 #endif
272
273 #define MAX_UPQ6        4               /* max. no of pkts in upcall Q */
274
275 extern int      (*ip6_mrouter_set)(struct socket *so, struct sockopt *sopt);
276 extern int      (*ip6_mrouter_get)(struct socket *so, struct sockopt *sopt);
277 extern int      (*ip6_mrouter_done)(void);
278 extern int      (*mrt6_ioctl)(u_long, caddr_t);
279 #endif /* _KERNEL */
280
281 #endif /* !_NETINET6_IP6_MROUTE_H_ */