Subversion Repositories SvarDOS

Rev

Rev 616 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
207 mateuszvis 1
/*!\file netinet/ip_mrout.h
2
 * IP multicast forwarding.
3
 */
4
 
5
/*
6
 * Copyright (c) 1989 Stephen Deering.
7
 * Copyright (c) 1992, 1993
8
 *      The Regents of the University of California.  All rights reserved.
9
 *
10
 * This code is derived from software contributed to Berkeley by
11
 * Stephen Deering of Stanford University.
12
 *
13
 * Redistribution and use in source and binary forms, with or without
14
 * modification, are permitted provided that the following conditions
15
 * are met:
16
 * 1. Redistributions of source code must retain the above copyright
17
 *    notice, this list of conditions and the following disclaimer.
18
 * 2. Redistributions in binary form must reproduce the above copyright
19
 *    notice, this list of conditions and the following disclaimer in the
20
 *    documentation and/or other materials provided with the distribution.
21
 * 3. All advertising materials mentioning features or use of this software
22
 *    must display the following acknowledgement:
23
 *      This product includes software developed by the University of
24
 *      California, Berkeley and its contributors.
25
 * 4. Neither the name of the University nor the names of its contributors
26
 *    may be used to endorse or promote products derived from this software
27
 *    without specific prior written permission.
28
 *
29
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39
 * SUCH DAMAGE.
40
 *
41
 *      @(#)ip_mroute.h 8.1 (Berkeley) 6/10/93
42
 * $Id: ip_mroute.h,v 1.10.4.1 1997/02/22 19:47:28 joerg Exp $
43
 */
44
 
45
#ifndef __NETINET_IP_MROUTE_H
46
#define __NETINET_IP_MROUTE_H
47
 
48
/*
49
 * Definitions for IP multicast forwarding.
50
 *
51
 * Written by David Waitzman, BBN Labs, August 1988.
52
 * Modified by Steve Deering, Stanford, February 1989.
53
 * Modified by Ajit Thyagarajan, PARC, August 1993.
54
 * Modified by Ajit Thyagarajan, PARC, August 1994.
55
 *
56
 * MROUTING Revision: 3.3.1.3
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 PIM assert processing */
71
 
72
 
73
#define GET_TIME(t)     microtime(&t)
74
 
75
/*
76
 * Types and macros for handling bitmaps with one bit per virtual interface.
77
 */
78
#define MAXVIFS 32
79
typedef u_long vifbitmap_t;
80
typedef u_short vifi_t;         /* type of a vif index */
81
#define ALL_VIFS (vifi_t)-1
82
 
83
#define VIFM_SET(n, m)          ((m) |= (1 << (n)))
84
#define VIFM_CLR(n, m)          ((m) &= ~(1 << (n)))
85
#define VIFM_ISSET(n, m)        ((m) & (1 << (n)))
86
#define VIFM_CLRALL(m)          ((m) = 0x00000000)
87
#define VIFM_COPY(mfrom, mto)   ((mto) = (mfrom))
88
#define VIFM_SAME(m1, m2)       ((m1) == (m2))
89
 
90
 
91
/*
92
 * Argument structure for MRT_ADD_VIF.
93
 * (MRT_DEL_VIF takes a single vifi_t argument.)
94
 */
95
struct vifctl {
96
        vifi_t  vifc_vifi;              /* the index of the vif to be added */
97
        u_char  vifc_flags;             /* VIFF_ flags defined below */
98
        u_char  vifc_threshold;         /* min ttl required to forward on vif */
99
        u_int   vifc_rate_limit;        /* max rate */
100
        struct  in_addr vifc_lcl_addr;  /* local interface address */
101
        struct  in_addr vifc_rmt_addr;  /* remote address (tunnels only) */
102
};
103
 
104
#define VIFF_TUNNEL     0x1             /* vif represents a tunnel end-point */
105
#define VIFF_SRCRT      0x2             /* tunnel uses IP source routing */
106
 
107
/*
108
 * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC
109
 * (mfcc_tos to be added at a future point)
110
 */
111
struct mfcctl {
112
    struct in_addr  mfcc_origin;                /* ip origin of mcasts       */
113
    struct in_addr  mfcc_mcastgrp;              /* multicast group associated*/
114
    vifi_t          mfcc_parent;                /* incoming vif              */
115
    u_char          mfcc_ttls[MAXVIFS];         /* forwarding ttls on vifs   */
116
};
117
 
118
/*
119
 * The kernel's multicast routing statistics.
120
 */
121
struct mrtstat {
122
    u_long      mrts_mfc_lookups;       /* # forw. cache hash table hits   */
123
    u_long      mrts_mfc_misses;        /* # forw. cache hash table misses */
124
    u_long      mrts_upcalls;           /* # calls to mrouted              */
125
    u_long      mrts_no_route;          /* no route for packet's origin    */
126
    u_long      mrts_bad_tunnel;        /* malformed tunnel options        */
127
    u_long      mrts_cant_tunnel;       /* no room for tunnel options      */
128
    u_long      mrts_wrong_if;          /* arrived on wrong interface      */
129
    u_long      mrts_upq_ovflw;         /* upcall Q overflow               */
130
    u_long      mrts_cache_cleanups;    /* # entries with no upcalls       */
131
    u_long      mrts_drop_sel;          /* pkts dropped selectively        */
132
    u_long      mrts_q_overflow;        /* pkts dropped - Q overflow       */
133
    u_long      mrts_pkt2large;         /* pkts dropped - size > BKT SIZE  */
134
    u_long      mrts_upq_sockfull;      /* upcalls dropped - socket full */
135
};
136
 
137
/*
138
 * Argument structure used by mrouted to get src-grp pkt counts
139
 */
140
struct sioc_sg_req {
141
    struct in_addr src;
142
    struct in_addr grp;
143
    u_long pktcnt;
144
    u_long bytecnt;
145
    u_long wrong_if;
146
};
147
 
148
/*
149
 * Argument structure used by mrouted to get vif pkt counts
150
 */
151
struct sioc_vif_req {
152
    vifi_t vifi;                /* vif number                           */
153
    u_long icount;              /* Input packet count on vif            */
154
    u_long ocount;              /* Output packet count on vif           */
155
    u_long ibytes;              /* Input byte count on vif              */
156
    u_long obytes;              /* Output byte count on vif             */
157
};
158
 
159
 
160
/*
161
 * The kernel's virtual-interface structure.
162
 */
163
struct vif {
164
    u_char              v_flags;        /* VIFF_ flags defined above         */
165
    u_char              v_threshold;    /* min ttl required to forward on vif*/
166
    u_int               v_rate_limit;   /* max rate                          */
167
    struct tbf         *v_tbf;          /* token bucket structure at intf.   */
168
    struct in_addr      v_lcl_addr;     /* local interface address           */
169
    struct in_addr      v_rmt_addr;     /* remote address (tunnels only)     */
170
    struct ifnet       *v_ifp;          /* pointer to interface              */
171
    u_long              v_pkt_in;       /* # pkts in on interface            */
172
    u_long              v_pkt_out;      /* # pkts out on interface           */
173
    u_long              v_bytes_in;     /* # bytes in on interface           */
174
    u_long              v_bytes_out;    /* # bytes out on interface          */
175
    struct route        v_route;        /* cached route if this is a tunnel  */
176
    u_int               v_rsvp_on;      /* RSVP listening on this vif */
177
    struct socket      *v_rsvpd;        /* RSVP daemon socket */
178
};
179
 
180
/*
181
 * The kernel's multicast forwarding cache entry structure 
182
 * (A field for the type of service (mfc_tos) is to be added 
183
 * at a future point)
184
 */
185
struct mfc {
186
    struct in_addr  mfc_origin;                 /* IP origin of mcasts   */
187
    struct in_addr  mfc_mcastgrp;               /* multicast group associated*/
188
    vifi_t          mfc_parent;                 /* incoming vif              */
189
    u_char          mfc_ttls[MAXVIFS];          /* forwarding ttls on vifs   */
190
    u_long          mfc_pkt_cnt;                /* pkt count for src-grp     */
191
    u_long          mfc_byte_cnt;               /* byte count for src-grp    */
192
    u_long          mfc_wrong_if;               /* wrong if for src-grp      */
193
    int             mfc_expire;                 /* time to clean entry up    */
194
    struct timeval  mfc_last_assert;            /* last time I sent an assert*/
195
};
196
 
197
/*
198
 * Struct used to communicate from kernel to multicast router
199
 * note the convenient similarity to an IP packet
200
 */
201
struct igmpmsg {
202
    u_long          unused1;
203
    u_long          unused2;
204
    u_char          im_msgtype;                 /* what type of message     */
205
#define IGMPMSG_NOCACHE         1
206
#define IGMPMSG_WRONGVIF        2
207
    u_char          im_mbz;                     /* must be zero             */
208
    u_char          im_vif;                     /* vif rec'd on             */
209
    u_char          unused3;
210
    struct in_addr  im_src, im_dst;
211
};
212
 
213
/*
214
 * Argument structure used for pkt info. while upcall is made
215
 */
216
struct rtdetq {
217
    struct mbuf         *m;             /* A copy of the packet             */
218
    struct ifnet        *ifp;           /* Interface pkt came in on         */
219
    vifi_t              xmt_vif;        /* Saved copy of imo_multicast_vif  */
220
#ifdef UPCALL_TIMING
221
    struct timeval      t;              /* Timestamp */
222
#endif
223
};
224
 
225
#define MFCTBLSIZ       256
226
#if (MFCTBLSIZ & (MFCTBLSIZ - 1)) == 0    /* from sys:route.h */
227
#define MFCHASHMOD(h)   ((h) & (MFCTBLSIZ - 1))
228
#else
229
#define MFCHASHMOD(h)   ((h) % MFCTBLSIZ)
230
#endif
231
 
232
#define MAX_UPQ 4               /* max. no of pkts in upcall Q */
233
 
234
/*
235
 * Token Bucket filter code 
236
 */
237
#define MAX_BKT_SIZE    10000             /* 10K bytes size             */
238
#define MAXQSIZE        10                /* max # of pkts in queue     */
239
 
240
/*
241
 * the token bucket filter at each vif
242
 */
243
struct tbf
244
{
245
    struct timeval tbf_last_pkt_t; /* arr. time of last pkt     */
246
    u_long tbf_n_tok;           /* no of tokens in bucket       */
247
    u_long tbf_q_len;           /* length of queue at this vif  */
248
    u_long tbf_max_q_len;       /* max. queue length            */
249
    struct mbuf *tbf_q;         /* Packet queue                 */
250
    struct mbuf *tbf_t;         /* tail-insertion pointer       */
251
};
252
 
253
#endif