source: rtems/cpukit/libnetworking/netinet/ip_mroute.h @ c95ac2f3

4.104.114.84.95
Last change on this file since c95ac2f3 was c95ac2f3, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/27/07 at 10:17:09

2007-03-26 Ralf Corsépius <ralf.corsepius@…>

  • libnetworking/netinet/ip_mroute.h: Partial update from FreeBSD.
  • Property mode set to 100644
File size: 9.7 KB
Line 
1/*
2 * Copyright (c) 1989 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 *      @(#)ip_mroute.h 8.1 (Berkeley) 6/10/93
34 * $FreeBSD: src/sys/netinet/ip_mroute.h,v 1.31 2007/02/08 23:05:08 bms Exp $
35 */
36
37/*
38 * $Id$
39 */
40
41#ifndef _NETINET_IP_MROUTE_H_
42#define _NETINET_IP_MROUTE_H_
43
44/*
45 * Definitions for IP multicast forwarding.
46 *
47 * Written by David Waitzman, BBN Labs, August 1988.
48 * Modified by Steve Deering, Stanford, February 1989.
49 * Modified by Ajit Thyagarajan, PARC, August 1993.
50 * Modified by Ajit Thyagarajan, PARC, August 1994.
51 * Modified by Ahmed Helmy, SGI, June 1996.
52 * Modified by Pavlin Radoslavov, ICSI, October 2002.
53 *
54 * MROUTING Revision: 3.3.1.3
55 * and PIM-SMv2 and PIM-DM support, advanced API support,
56 * bandwidth metering and signaling.
57 */
58
59
60/*
61 * Multicast Routing set/getsockopt commands.
62 */
63#define MRT_INIT        100     /* initialize forwarder */
64#define MRT_DONE        101     /* shut down forwarder */
65#define MRT_ADD_VIF     102     /* create virtual interface */
66#define MRT_DEL_VIF     103     /* delete virtual interface */
67#define MRT_ADD_MFC     104     /* insert forwarding cache entry */
68#define MRT_DEL_MFC     105     /* delete forwarding cache entry */
69#define MRT_VERSION     106     /* get kernel version number */
70#define MRT_ASSERT      107     /* enable assert processing */
71#define MRT_PIM         MRT_ASSERT /* enable PIM processing */
72#define MRT_API_SUPPORT 109     /* supported MRT API */
73#define MRT_API_CONFIG  110     /* config MRT API */
74#define MRT_ADD_BW_UPCALL 111   /* create bandwidth monitor */
75#define MRT_DEL_BW_UPCALL 112   /* delete bandwidth monitor */
76
77
78#define GET_TIME(t)     microtime(&t)
79
80/*
81 * Types and macros for handling bitmaps with one bit per virtual interface.
82 */
83#define MAXVIFS 32
84typedef u_long vifbitmap_t;
85typedef u_short vifi_t;         /* type of a vif index */
86#define ALL_VIFS (vifi_t)-1
87
88#define VIFM_SET(n, m)          ((m) |= (1 << (n)))
89#define VIFM_CLR(n, m)          ((m) &= ~(1 << (n)))
90#define VIFM_ISSET(n, m)        ((m) & (1 << (n)))
91#define VIFM_CLRALL(m)          ((m) = 0x00000000)
92#define VIFM_COPY(mfrom, mto)   ((mto) = (mfrom))
93#define VIFM_SAME(m1, m2)       ((m1) == (m2))
94
95
96/*
97 * Argument structure for MRT_ADD_VIF.
98 * (MRT_DEL_VIF takes a single vifi_t argument.)
99 */
100struct vifctl {
101        vifi_t  vifc_vifi;              /* the index of the vif to be added */
102        u_char  vifc_flags;             /* VIFF_ flags defined below */
103        u_char  vifc_threshold;         /* min ttl required to forward on vif */
104        u_int   vifc_rate_limit;        /* max rate */
105        struct  in_addr vifc_lcl_addr;  /* local interface address */
106        struct  in_addr vifc_rmt_addr;  /* remote address (tunnels only) */
107};
108
109#define VIFF_TUNNEL     0x1             /* vif represents a tunnel end-point */
110#define VIFF_SRCRT      0x2             /* tunnel uses IP source routing */
111
112/*
113 * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC
114 * (mfcc_tos to be added at a future point)
115 */
116struct mfcctl {
117    struct in_addr  mfcc_origin;                /* ip origin of mcasts       */
118    struct in_addr  mfcc_mcastgrp;              /* multicast group associated*/
119    vifi_t          mfcc_parent;                /* incoming vif              */
120    u_char          mfcc_ttls[MAXVIFS];         /* forwarding ttls on vifs   */
121};
122
123/*
124 * The kernel's multicast routing statistics.
125 */
126struct mrtstat {
127    u_long      mrts_mfc_lookups;       /* # forw. cache hash table hits   */
128    u_long      mrts_mfc_misses;        /* # forw. cache hash table misses */
129    u_long      mrts_upcalls;           /* # calls to mrouted              */
130    u_long      mrts_no_route;          /* no route for packet's origin    */
131    u_long      mrts_bad_tunnel;        /* malformed tunnel options        */
132    u_long      mrts_cant_tunnel;       /* no room for tunnel options      */
133    u_long      mrts_wrong_if;          /* arrived on wrong interface      */
134    u_long      mrts_upq_ovflw;         /* upcall Q overflow               */
135    u_long      mrts_cache_cleanups;    /* # entries with no upcalls       */
136    u_long      mrts_drop_sel;          /* pkts dropped selectively        */
137    u_long      mrts_q_overflow;        /* pkts dropped - Q overflow       */
138    u_long      mrts_pkt2large;         /* pkts dropped - size > BKT SIZE  */
139    u_long      mrts_upq_sockfull;      /* upcalls dropped - socket full */
140};
141
142/*
143 * Argument structure used by mrouted to get src-grp pkt counts
144 */
145struct sioc_sg_req {
146    struct in_addr src;
147    struct in_addr grp;
148    u_long pktcnt;
149    u_long bytecnt;
150    u_long wrong_if;
151};
152
153/*
154 * Argument structure used by mrouted to get vif pkt counts
155 */
156struct sioc_vif_req {
157    vifi_t vifi;                /* vif number                           */
158    u_long icount;              /* Input packet count on vif            */
159    u_long ocount;              /* Output packet count on vif           */
160    u_long ibytes;              /* Input byte count on vif              */
161    u_long obytes;              /* Output byte count on vif             */
162};
163   
164
165/*
166 * The kernel's virtual-interface structure.
167 */
168struct vif {
169    u_char              v_flags;        /* VIFF_ flags defined above         */
170    u_char              v_threshold;    /* min ttl required to forward on vif*/
171    u_int               v_rate_limit;   /* max rate                          */
172    struct tbf         *v_tbf;          /* token bucket structure at intf.   */
173    struct in_addr      v_lcl_addr;     /* local interface address           */
174    struct in_addr      v_rmt_addr;     /* remote address (tunnels only)     */
175    struct ifnet       *v_ifp;          /* pointer to interface              */
176    u_long              v_pkt_in;       /* # pkts in on interface            */
177    u_long              v_pkt_out;      /* # pkts out on interface           */
178    u_long              v_bytes_in;     /* # bytes in on interface           */
179    u_long              v_bytes_out;    /* # bytes out on interface          */
180    struct route        v_route;        /* cached route if this is a tunnel */
181    u_int               v_rsvp_on;      /* RSVP listening on this vif */
182    struct socket      *v_rsvpd;        /* RSVP daemon socket */
183};
184
185/*
186 * The kernel's multicast forwarding cache entry structure
187 * (A field for the type of service (mfc_tos) is to be added
188 * at a future point)
189 */
190struct mfc {
191    struct in_addr  mfc_origin;                 /* IP origin of mcasts   */
192    struct in_addr  mfc_mcastgrp;               /* multicast group associated*/
193    vifi_t          mfc_parent;                 /* incoming vif              */
194    u_char          mfc_ttls[MAXVIFS];          /* forwarding ttls on vifs   */
195    u_long          mfc_pkt_cnt;                /* pkt count for src-grp     */
196    u_long          mfc_byte_cnt;               /* byte count for src-grp    */
197    u_long          mfc_wrong_if;               /* wrong if for src-grp      */
198    int             mfc_expire;                 /* time to clean entry up    */
199    struct timeval  mfc_last_assert;            /* last time I sent an assert*/
200};
201
202/*
203 * Struct used to communicate from kernel to multicast router
204 * note the convenient similarity to an IP packet
205 */
206struct igmpmsg {
207    u_long          unused1;
208    u_long          unused2;
209    u_char          im_msgtype;                 /* what type of message     */
210#define IGMPMSG_NOCACHE         1
211#define IGMPMSG_WRONGVIF        2
212    u_char          im_mbz;                     /* must be zero             */
213    u_char          im_vif;                     /* vif rec'd on             */
214    u_char          unused3;
215    struct in_addr  im_src, im_dst;
216};
217
218/*
219 * Argument structure used for pkt info. while upcall is made
220 */
221struct rtdetq {
222    struct mbuf         *m;             /* A copy of the packet             */
223    struct ifnet        *ifp;           /* Interface pkt came in on         */
224    vifi_t              xmt_vif;        /* Saved copy of imo_multicast_vif  */
225#ifdef UPCALL_TIMING
226    struct timeval      t;              /* Timestamp */
227#endif /* UPCALL_TIMING */
228};
229
230#define MFCTBLSIZ       256
231#if (MFCTBLSIZ & (MFCTBLSIZ - 1)) == 0    /* from sys:route.h */
232#define MFCHASHMOD(h)   ((h) & (MFCTBLSIZ - 1))
233#else
234#define MFCHASHMOD(h)   ((h) % MFCTBLSIZ)
235#endif
236
237#define MAX_UPQ 4               /* max. no of pkts in upcall Q */
238
239/*
240 * Token Bucket filter code
241 */
242#define MAX_BKT_SIZE    10000             /* 10K bytes size             */
243#define MAXQSIZE        10                /* max # of pkts in queue     */
244
245/*
246 * the token bucket filter at each vif
247 */
248struct tbf
249{
250    struct timeval tbf_last_pkt_t; /* arr. time of last pkt     */
251    u_long tbf_n_tok;           /* no of tokens in bucket       */
252    u_long tbf_q_len;           /* length of queue at this vif  */
253    u_long tbf_max_q_len;       /* max. queue length            */
254    struct mbuf *tbf_q;         /* Packet queue                 */
255    struct mbuf *tbf_t;         /* tail-insertion pointer       */
256};
257
258#ifdef _KERNEL
259
260extern int      (*ip_mrouter_set)(int, struct socket *, struct mbuf *);
261extern int      (*ip_mrouter_get)(int, struct socket *, struct mbuf **);
262extern int      (*ip_mrouter_done)(void);
263#ifdef MROUTING
264extern int      (*mrt_ioctl)(int, caddr_t);
265#else
266extern int      (*mrt_ioctl)(int, caddr_t, struct proc *);
267#endif
268
269#endif /* _KERNEL */
270
271#endif /* _NETINET_IP_MROUTE_H_ */
Note: See TracBrowser for help on using the repository browser.