xref: /openbsd/usr.sbin/mrouted/prune.h (revision 63fec25f)
1 /*	$NetBSD: prune.h,v 1.3 1995/12/10 10:07:11 mycroft Exp $	*/
2 
3 /*
4  * The mrouted program is covered by the license in the accompanying file
5  * named "LICENSE".  Use of the mrouted program represents acceptance of
6  * the terms and conditions listed in that file.
7  *
8  * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
9  * Leland Stanford Junior University.
10  */
11 
12 /*
13  * Group table
14  *
15  * Each group entry is a member of two doubly-linked lists:
16  *
17  * a) A list hanging off of the routing table entry for this source (rt_groups)
18  *	sorted by group address under the routing entry (gt_next, gt_prev)
19  * b) An independent list pointed to by kernel_table, which is a list of
20  *	active source,group's (gt_gnext, gt_gprev).
21  *
22  */
23 struct gtable {
24     struct gtable  *gt_next;		/* pointer to the next entry	    */
25     struct gtable  *gt_prev;		/* back pointer for linked list	    */
26     struct gtable  *gt_gnext;		/* fwd pointer for group list	    */
27     struct gtable  *gt_gprev;		/* rev pointer for group list	    */
28     u_int32_t	    gt_mcastgrp;	/* multicast group associated       */
29     vifbitmap_t     gt_scope;		/* scoped interfaces                */
30     u_char	    gt_ttls[MAXVIFS];	/* ttl vector for forwarding        */
31     vifbitmap_t	    gt_grpmems;		/* forw. vifs for src, grp          */
32     int		    gt_prsent_timer;	/* prune timer for this group	    */
33     int		    gt_timer;		/* timer for this group entry	    */
34     time_t	    gt_ctime;		/* time of entry creation         */
35     u_char	    gt_grftsnt;		/* graft sent/retransmit timer	    */
36     struct stable  *gt_srctbl;		/* source table			    */
37     struct ptable  *gt_pruntbl;		/* prune table			    */
38     struct rtentry *gt_route;		/* parent route			    */
39 #ifdef RSRR
40     struct rsrr_cache *gt_rsrr_cache;	/* RSRR cache                       */
41 #endif /* RSRR */
42 };
43 
44 /*
45  * Source table
46  *
47  * When source-based prunes exist, there will be a struct ptable here as well.
48  */
49 struct stable
50 {
51     struct stable  *st_next;		/* pointer to the next entry        */
52     u_int32_t	    st_origin;		/* host origin of multicasts        */
53     u_long	    st_pktcnt;		/* packet count for src-grp entry   */
54 };
55 
56 /*
57  * structure to store incoming prunes.  Can hang off of either group or source.
58  */
59 struct ptable
60 {
61     struct ptable  *pt_next;		/* pointer to the next entry	    */
62     u_int32_t	    pt_router;		/* router that sent this prune	    */
63     vifi_t	    pt_vifi;		/* vif prune received on	    */
64     int		    pt_timer;		/* timer for prune		    */
65 };
66 
67 /*
68  * The packet format for a traceroute request.
69  */
70 struct tr_query {
71     u_int32_t  tr_src;		/* traceroute source */
72     u_int32_t  tr_dst;		/* traceroute destination */
73     u_int32_t  tr_raddr;		/* traceroute response address */
74 #if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
75     struct {
76 	u_int	qid : 24;	/* traceroute query id */
77 	u_int	ttl : 8;	/* traceroute response ttl */
78     } q;
79 #else
80     struct {
81 	u_int   ttl : 8;	/* traceroute response ttl */
82 	u_int   qid : 24;	/* traceroute query id */
83     } q;
84 #endif /* BYTE_ORDER */
85 };
86 
87 #define tr_rttl q.ttl
88 #define tr_qid  q.qid
89 
90 /*
91  * Traceroute response format.  A traceroute response has a tr_query at the
92  * beginning, followed by one tr_resp for each hop taken.
93  */
94 struct tr_resp {
95     u_int32_t tr_qarr;		/* query arrival time */
96     u_int32_t tr_inaddr;		/* incoming interface address */
97     u_int32_t tr_outaddr;		/* outgoing interface address */
98     u_int32_t tr_rmtaddr;		/* parent address in source tree */
99     u_int32_t tr_vifin;		/* input packet count on interface */
100     u_int32_t tr_vifout;		/* output packet count on interface */
101     u_int32_t tr_pktcnt;		/* total incoming packets for src-grp */
102     u_char  tr_rproto;		/* routing protocol deployed on router */
103     u_char  tr_fttl;		/* ttl required to forward on outvif */
104     u_char  tr_smask;		/* subnet mask for src addr */
105     u_char  tr_rflags;		/* forwarding error codes */
106 };
107 
108 /* defs within mtrace */
109 #define QUERY	1
110 #define RESP	2
111 #define QLEN	sizeof(struct tr_query)
112 #define RLEN	sizeof(struct tr_resp)
113 
114 /* fields for tr_rflags (forwarding error codes) */
115 #define TR_NO_ERR	0
116 #define TR_WRONG_IF	1
117 #define TR_PRUNED	2
118 #define TR_OPRUNED	3
119 #define TR_SCOPED	4
120 #define TR_NO_RTE	5
121 #define TR_NO_FWD	7
122 #define TR_NO_SPACE	0x81
123 #define TR_OLD_ROUTER	0x82
124 
125 /* fields for tr_rproto (routing protocol) */
126 #define PROTO_DVMRP	1
127 #define PROTO_MOSPF	2
128 #define PROTO_PIM	3
129 #define PROTO_CBT	4
130 
131 #define MASK_TO_VAL(x, i) { \
132 			u_int32_t _x = ntohl(x); \
133 			(i) = 1; \
134 			while ((_x) <<= 1) \
135 				(i)++; \
136 			};
137 
138 #define VAL_TO_MASK(x, i) { \
139 			x = htonl(~((1 << (32 - (i))) - 1)); \
140 			};
141 
142 #define NBR_VERS(n)	(((n)->al_pv << 8) + (n)->al_mv)
143