aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/mrouted/route.c
diff options
context:
space:
mode:
authorGarrett Wollman <wollman@FreeBSD.org>1995-06-28 17:58:49 +0000
committerGarrett Wollman <wollman@FreeBSD.org>1995-06-28 17:58:49 +0000
commite93ad7be435c657173467d2b5d96d976fd74aa8d (patch)
tree585fe426376ddd559974a1fec24c87c188352816 /usr.sbin/mrouted/route.c
parent5575abefeba383d796432fbac5c3faf1da9e67d8 (diff)
downloadsrc-e93ad7be435c657173467d2b5d96d976fd74aa8d.tar.gz
src-e93ad7be435c657173467d2b5d96d976fd74aa8d.zip
Upgrade to mrouted version 3.6. This includes a substantial clean-up
and ANSIfication of much of the source base. Thanks, Bill! Submitted by: patch from Bill Fenner <fenner@parc.xerox.com>
Notes
Notes: svn path=/head/; revision=9367
Diffstat (limited to 'usr.sbin/mrouted/route.c')
-rw-r--r--usr.sbin/mrouted/route.c64
1 files changed, 33 insertions, 31 deletions
diff --git a/usr.sbin/mrouted/route.c b/usr.sbin/mrouted/route.c
index 756623fa09cf..38b9002982f0 100644
--- a/usr.sbin/mrouted/route.c
+++ b/usr.sbin/mrouted/route.c
@@ -7,7 +7,7 @@
* Leland Stanford Junior University.
*
*
- * $Id: route.c,v 3.5 1995/05/09 01:00:39 fenner Exp $
+ * $Id: route.c,v 3.6 1995/06/25 19:20:19 fenner Exp $
*/
@@ -39,12 +39,25 @@ static struct rtentry *rt_end; /* pointer to last route entry */
unsigned int nroutes; /* current number of route entries */
/*
+ * Private functions.
+ */
+static int init_children_and_leaves __P((struct rtentry *r,
+ vifi_t parent));
+static int find_route __P((u_int32 origin, u_int32 mask));
+static void create_route __P((u_int32 origin, u_int32 mask));
+static void discard_route __P((struct rtentry *prev_r));
+static int compare_rts __P((const void *rt1, const void *rt2));
+static int report_chunk __P((struct rtentry *start_rt, vifi_t vifi,
+ u_int32 dst));
+
+/*
* Initialize the routing table and associated variables.
*/
void
init_routes()
{
routing_table = NULL;
+ rt_end = RT_ADDR;
nroutes = 0;
routes_changed = FALSE;
delay_change_reports = FALSE;
@@ -284,7 +297,7 @@ create_route(origin, mask)
if ((r = (struct rtentry *) malloc(sizeof(struct rtentry) +
(2 * numvifs * sizeof(u_int32)) +
- (numvifs * sizeof(u_long)))) == NULL) {
+ (numvifs * sizeof(u_int)))) == NULL) {
log(LOG_ERR, 0, "ran out of memory"); /* fatal */
}
r->rt_origin = origin;
@@ -296,7 +309,7 @@ create_route(origin, mask)
r->rt_flags = 0;
r->rt_dominants = (u_int32 *)(r + 1);
r->rt_subordinates = (u_int32 *)(r->rt_dominants + numvifs);
- r->rt_leaf_timers = (u_long *)(r->rt_subordinates + numvifs);
+ r->rt_leaf_timers = (u_int *)(r->rt_subordinates + numvifs);
r->rt_groups = NULL;
r->rt_next = rtp->rt_next;
@@ -345,7 +358,6 @@ update_route(origin, mask, metric, src, vifi)
vifi_t vifi;
{
register struct rtentry *r;
- struct rtentry *prev_r;
int adj_metric;
/*
@@ -366,10 +378,6 @@ update_route(origin, mask, metric, src, vifi)
* Look up the reported origin in the routing table.
*/
if (!find_route(origin, mask)) {
- register struct rtentry *rp;
- register struct gtable *gt;
- register struct stable *st, **stnp;
-
/*
* Not found.
* Don't create a new entry if the report says it's unreachable,
@@ -697,10 +705,7 @@ accept_probe(src, dst, p, datalen, level)
return;
}
- if (!update_neighbor(vifi, src, DVMRP_PROBE, p, datalen, level))
- return;
-
- report(ALL_ROUTES, vifi, src);
+ update_neighbor(vifi, src, DVMRP_PROBE, p, datalen, level);
}
struct newrt {
@@ -710,11 +715,13 @@ struct newrt {
int pad;
};
-int
-compare_rts(r1, r2)
- register struct newrt *r1;
- register struct newrt *r2;
+static int
+compare_rts(rt1, rt2)
+ const void *rt1;
+ const void *rt2;
{
+ register struct newrt *r1 = (struct newrt *)rt1;
+ register struct newrt *r2 = (struct newrt *)rt2;
register u_int32 m1 = ntohl(r1->mask);
register u_int32 m2 = ntohl(r2->mask);
register u_int32 o1, o2;
@@ -830,17 +837,15 @@ report(which_routes, vifi, dst)
register struct rtentry *r;
register char *p;
register int i;
- int datalen;
- int width;
- u_int32 mask;
+ int datalen = 0;
+ int width = 0;
+ u_int32 mask = 0;
u_int32 src;
u_int32 nflags;
src = uvifs[vifi].uv_lcl_addr;
p = send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN;
- datalen = 0;
- mask = 0;
#ifdef NOTYET
/* If I'm not a leaf, but the neighbor is a leaf, only advertise default */
@@ -880,7 +885,7 @@ report(which_routes, vifi, dst)
mask = 0;
}
- if(r->rt_originmask != mask) {
+ if (r->rt_originmask != mask || datalen == 0) {
mask = r->rt_originmask;
width = r->rt_originwidth;
if (datalen != 0) *(p-1) |= 0x80;
@@ -961,7 +966,7 @@ report_to_all_neighbors(which_routes)
* Send a route report message to destination 'dst', via virtual interface
* 'vifi'. 'which_routes' specifies ALL_ROUTES or CHANGED_ROUTES.
*/
-int
+static int
report_chunk(start_rt, vifi, dst)
register struct rtentry *start_rt;
vifi_t vifi;
@@ -971,16 +976,14 @@ report_chunk(start_rt, vifi, dst)
register char *p;
register int i;
register int nrt = 0;
- int datalen;
- int width;
- u_int32 mask;
+ int datalen = 0;
+ int width = 0;
+ u_int32 mask = 0;
u_int32 src;
u_int32 nflags;
src = uvifs[vifi].uv_lcl_addr;
p = send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN;
- datalen = 0;
- mask = 0;
nflags = (uvifs[vifi].uv_flags & VIFF_LEAF) ? 0 : LEAF_FLAGS;
@@ -1007,7 +1010,7 @@ report_chunk(start_rt, vifi, dst)
htonl(MROUTED_LEVEL | nflags), datalen);
return (nrt);
}
- if(r->rt_originmask != mask) {
+ if (r->rt_originmask != mask || datalen == 0) {
mask = r->rt_originmask;
width = r->rt_originwidth;
if (datalen != 0) *(p-1) |= 0x80;
@@ -1096,13 +1099,12 @@ dump_routes(fp)
{
register struct rtentry *r;
register int i;
- register time_t thyme = time(0);
fprintf(fp,
"Multicast Routing Table (%u %s)\n%s\n",
nroutes, (nroutes == 1) ? "entry" : "entries",
- " Origin-Subnet From-Gateway Metric Tmr In-Vif Out-Vifs");
+ " Origin-Subnet From-Gateway Metric Tmr In-Vif Out-Vifs");
for (r = routing_table; r != NULL; r = r->rt_next) {