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