diff options
Diffstat (limited to 'usr.sbin/mrouted/prune.c')
-rw-r--r-- | usr.sbin/mrouted/prune.c | 199 |
1 files changed, 0 insertions, 199 deletions
diff --git a/usr.sbin/mrouted/prune.c b/usr.sbin/mrouted/prune.c index 2adbf3d37f3..30112cf3d0d 100644 --- a/usr.sbin/mrouted/prune.c +++ b/usr.sbin/mrouted/prune.c @@ -372,205 +372,6 @@ update_kernel(struct gtable *g) Functions that are used externally ****************************************************************************/ -#ifdef SNMP -#include <sys/types.h> -#include "snmp.h" - -/* - * Find a specific group entry in the group table - */ -struct gtable * -find_grp(u_long grp) -{ - struct gtable *gt; - - for (gt = kernel_table; gt; gt = gt->gt_gnext) { - if (ntohl(grp) < ntohl(gt->gt_mcastgrp)) - break; - if (gt->gt_mcastgrp == grp) - return gt; - } - return NULL; -} - -/* - * Given a group entry and source, find the corresponding source table - * entry - */ -struct stable * -find_grp_src(struct gtable *gt, u_long src) -{ - struct stable *st; - u_long grp = gt->gt_mcastgrp; - struct gtable *gtcurr; - - for (gtcurr = gt; gtcurr->gt_mcastgrp == grp; gtcurr = gtcurr->gt_gnext) { - for (st = gtcurr->gt_srctbl; st; st = st->st_next) - if (st->st_origin == src) - return st; - } - return NULL; -} - -/* - * Find next entry > specification - * gtpp: ordered by group - * stpp: ordered by source - */ -int -next_grp_src_mask(struct gtable *gtpp, struct gtable *stpp, u_long grp, - u_long src, u_long mask) -{ - struct gtable *gt, *gbest = NULL; - struct stable *st, *sbest = NULL; - - /* Find first group entry >= grp spec */ - (*gtpp) = kernel_table; - while ((*gtpp) && ntohl((*gtpp)->gt_mcastgrp) < ntohl(grp)) - (*gtpp)=(*gtpp)->gt_gnext; - if (!(*gtpp)) - return 0; /* no more groups */ - - for (gt = kernel_table; gt; gt=gt->gt_gnext) { - /* Since grps are ordered, we can stop when group changes from gbest */ - if (gbest && gbest->gt_mcastgrp != gt->gt_mcastgrp) - break; - for (st = gt->gt_srctbl; st; st=st->st_next) { - - /* Among those entries > spec, find "lowest" one */ - if (((ntohl(gt->gt_mcastgrp)> ntohl(grp)) - || (ntohl(gt->gt_mcastgrp)==ntohl(grp) - && ntohl(st->st_origin)> ntohl(src)) - || (ntohl(gt->gt_mcastgrp)==ntohl(grp) - && ntohl(st->st_origin)==src && 0xFFFFFFFF>ntohl(mask))) - && (!gbest - || (ntohl(gt->gt_mcastgrp)< ntohl(gbest->gt_mcastgrp)) - || (ntohl(gt->gt_mcastgrp)==ntohl(gbest->gt_mcastgrp) - && ntohl(st->st_origin)< ntohl(sbest->st_origin)))) { - gbest = gt; - sbest = st; - } - } - } - (*gtpp) = gbest; - (*stpp) = sbest; - return (*gtpp)!=0; -} - -/* - * Ensure that sg contains current information for the given group,source. - * This is fetched from the kernel as a unit so that counts for the entry - * are consistent, i.e. packet and byte counts for the same entry are - * read at the same time. - */ -void -refresh_sg(struct sioc_sg_req *sg, struct gtable *gt, struct gtable *st) -{ - static int lastq = -1; - - if (quantum != lastq || sg->src.s_addr!=st->st_origin - || sg->grp.s_addr!=gt->gt_mcastgrp) { - lastq = quantum; - sg->src.s_addr = st->st_origin; - sg->grp.s_addr = gt->gt_mcastgrp; - ioctl(udp_socket, SIOCGETSGCNT, (char *)sg); - } -} - -/* - * Return pointer to a specific route entry. This must be a separate - * function from find_route() which modifies rtp. - */ -struct rtentry * -snmp_find_route(u_long src, u_long mask) -{ - register struct rtentry *rt; - - for (rt = routing_table; rt; rt = rt->rt_next) { - if (src == rt->rt_origin && mask == rt->rt_originmask) - return rt; - } - return NULL; -} - -/* - * Find next route entry > specification - */ -int -next_route(struct rtentry **rtpp, u_long src, u_long mask) -{ - struct rtentry *rt, *rbest = NULL; - - /* Among all entries > spec, find "lowest" one in order */ - for (rt = routing_table; rt; rt=rt->rt_next) { - if ((ntohl(rt->rt_origin) > ntohl(src) - || (ntohl(rt->rt_origin) == ntohl(src) - && ntohl(rt->rt_originmask) > ntohl(mask))) - && (!rbest || (ntohl(rt->rt_origin) < ntohl(rbest->rt_origin)) - || (ntohl(rt->rt_origin) == ntohl(rbest->rt_origin) - && ntohl(rt->rt_originmask) < ntohl(rbest->rt_originmask)))) - rbest = rt; - } - (*rtpp) = rbest; - return (*rtpp)!=0; -} - -/* - * Given a routing table entry, and a vifi, find the next vifi/entry - * vifi: vif at which to start looking - */ -int -next_route_child(struct rtentry **rtpp, u_long src, u_long mask, vifi_t vifi) -{ - struct rtentry *rt; - - /* Get (S,M) entry */ - if (!((*rtpp) = snmp_find_route(src,mask))) - if (!next_route(rtpp, src, mask)) - return 0; - - /* Continue until we get one with a valid next vif */ - do { - for (; (*rtpp)->rt_children && *vifi<numvifs; (*vifi)++) - if (VIFM_ISSET(*vifi, (*rtpp)->rt_children)) - return 1; - *vifi = 0; - } while( next_route(rtpp, (*rtpp)->rt_origin, (*rtpp)->rt_originmask) ); - - return 0; -} - -/* - * Given a routing table entry, and a vifi, find the next entry - * equal to or greater than those - * vifi: vif at which to start looking - */ -int -next_child(struct gtable *gtpp, struct gtable *stpp, u_long grp, - u_long src, u_long mask, vifi_t *vifi) -{ - struct stable *st; - - /* Get (G,S,M) entry */ - if (mask!=0xFFFFFFFF - || !((*gtpp) = find_grp(grp)) - || !((*stpp) = find_grp_src((*gtpp),src))) - if (!next_grp_src_mask(gtpp, stpp, grp, src, mask)) - return 0; - - /* Continue until we get one with a valid next vif */ - do { - for (; (*gtpp)->gt_route->rt_children && *vifi<numvifs; (*vifi)++) - if (VIFM_ISSET(*vifi, (*gtpp)->gt_route->rt_children)) - return 1; - *vifi = 0; - } while (next_grp_src_mask(gtpp, stpp, (*gtpp)->gt_mcastgrp, - (*stpp)->st_origin, 0xFFFFFFFF) ); - - return 0; -} -#endif /* SNMP */ - /* * Initialize the kernel table structure */ |