summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mrouted/prune.h
blob: fd1fd2344fc27ad6688ebe0e0b4cb24ddf502491 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 * The mrouted program is covered by the license in the accompanying file
 * named "LICENSE".  Use of the mrouted program represents acceptance of
 * the terms and conditions listed in that file.
 *
 * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
 * Leland Stanford Junior University.
 *
 *
 * $Id: prune.h,v 1.2 1994/09/08 02:51:24 wollman Exp $
 */

/*
 * Macro for copying the user-level cache table to the kernel
 * level table variable passed on by the setsock option
 */

#define COPY_TABLES(from, to) { \
	register u_int _i; \
	(to).mfcc_origin.s_addr     = (from)->kt_origin; \
	(to).mfcc_mcastgrp.s_addr   = (from)->kt_mcastgrp; \
	(to).mfcc_originmask.s_addr = (from)->kt_originmask; \
	(to).mfcc_parent            = (from)->kt_parent; \
	for (_i = 0; _i < numvifs; _i++) \
	    (to).mfcc_ttls[_i]	  = (from)->kt_ttls[_i]; \
};


/*
 * User level Kernel Cache Table structure
 *
 * A copy of the kernel table is kept at the user level. Modifications are
 * made to this table and then passed on to the kernel. A timeout value is
 * an extra field in the user level table.
 *
 */
struct ktable
{
    struct ktable  *kt_next;       	/* pointer to the next entry        */
    u_long	    kt_origin;		/* subnet origin of multicasts      */
    u_long	    kt_mcastgrp;    	/* multicast group associated       */
    u_long	    kt_originmask;	/* subnet mask for origin           */
    vifi_t	    kt_parent; 	    	/* incoming vif                     */
    u_long	    kt_gateway;		/* upstream router                  */
    vifbitmap_t	    kt_children;	/* outgoing children vifs           */
    vifbitmap_t	    kt_leaves;		/* subset of outgoing children vifs */
    vifbitmap_t     kt_scope;		/* scoped interfaces                */
    u_char	    kt_ttls[MAXVIFS];	/* ttl vector for forwarding        */
    vifbitmap_t	    kt_grpmems;		/* forw. vifs for src, grp          */
    int		    kt_timer;		/* for timing out entry in cache    */
    struct prunlst *kt_rlist;		/* router list nghboring this rter  */
    u_short	    kt_prun_count;	/* count of total no. of prunes     */
    int		    kt_prsent_timer;	/* prune lifetime timer             */
    u_int	    kt_grftsnt;		/* graft sent upstream              */
};

/*
 * structure to store incoming prunes
 */
struct prunlst
{
    struct prunlst *rl_next;
    u_long	    rl_router;
    u_long	    rl_router_subnet;
    vifi_t	    rl_vifi;
    int		    rl_timer;
};

struct tr_query {
    u_long  tr_src;		/* traceroute source */
    u_long  tr_dst;		/* traceroute destination */
    u_long  tr_raddr;		/* traceroute response address */
    struct {
	u_int   ttl : 8;	/* traceroute response ttl */
	u_int   qid : 24;	/* traceroute query id */
    } q;
} tr_query;

#define tr_rttl q.ttl
#define tr_qid  q.qid

struct tr_resp {
    u_long  tr_qarr;		/* query arrival time */
    u_long  tr_inaddr;		/* incoming interface address */
    u_long  tr_outaddr;		/* outgoing interface address */
    u_long  tr_rmtaddr;		/* parent address in source tree */
    u_long  tr_vifin;		/* input packet count on interface */
    u_long  tr_vifout;		/* output packet count on interface */
    u_long  tr_pktcnt;		/* total incoming packets for src-grp */
    u_char  tr_rproto;		/* routing protocol deployed on router */
    u_char  tr_fttl;		/* ttl required to forward on outvif */
    u_char  tr_smask;		/* subnet mask for src addr */
    u_char  tr_rflags;		/* forwarding error codes */
} tr_resp;

/* defs within mtrace */
#define QUERY	1
#define RESP	2
#define QLEN	sizeof(struct tr_query)
#define RLEN	sizeof(struct tr_resp)

/* fields for tr_rflags (forwarding error codes) */
#define TR_NO_ERR	0x0
#define TR_WRONG_IF	0x1
#define TR_PRUNED	0x2
#define TR_SCOPED	0x4
#define TR_NO_RTE	0x5

/* fields for tr_rproto (routing protocol) */
#define PROTO_DVMRP	0x1
#define PROTO_MOSPF	0x2
#define PROTO_PIM	0x3
#define PROTO_CBT	0x4

#define MASK_TO_VAL(x, i) { \
			(i) = 0; \
			while ((x) << (i)) \
				(i)++; \
			}

#define VAL_TO_MASK(x, i) { \
			x = ~((1 << (32 - (i))) - 1); \
			}
OpenPOWER on IntegriCloud