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