This version Aug 16th -- source directory moved to /usr/src/etc/XNSrouted;
authorKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Sat, 17 Aug 1985 12:49:33 +0000 (04:49 -0800)
committerKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Sat, 17 Aug 1985 12:49:33 +0000 (04:49 -0800)
includes fix to response to request for specific net, and adds copyright notices

SCCS-vsn: sbin/XNSrouted/Makefile 5.3
SCCS-vsn: sbin/XNSrouted/af.c 5.3
SCCS-vsn: sbin/XNSrouted/defs.h 5.3
SCCS-vsn: sbin/XNSrouted/input.c 5.3
SCCS-vsn: sbin/XNSrouted/main.c 5.3
SCCS-vsn: sbin/XNSrouted/interface.h 5.3
SCCS-vsn: sbin/XNSrouted/output.c 5.3
SCCS-vsn: sbin/XNSrouted/startup.c 5.3
SCCS-vsn: sbin/XNSrouted/protocol.h 5.3
SCCS-vsn: sbin/XNSrouted/tables.c 5.3
SCCS-vsn: sbin/XNSrouted/timer.c 5.3
SCCS-vsn: sbin/XNSrouted/trace.c 5.3
SCCS-vsn: sbin/XNSrouted/trace.h 5.3

usr/src/sbin/XNSrouted/af.c
usr/src/sbin/XNSrouted/main.c
usr/src/sbin/XNSrouted/output.c
usr/src/sbin/XNSrouted/startup.c
usr/src/sbin/XNSrouted/tables.c
usr/src/sbin/XNSrouted/timer.c

index c4f7425..32e54b5 100644 (file)
@@ -1,6 +1,16 @@
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * This file include significant work done at Cornell University
+ * by Bill Nesheim.  That work included by permission.
+ */
+
 #ifndef lint
 #ifndef lint
-static char rcsid[] = "$Header$";
-#endif
+static char sccsid[] = "@(#)af.c       5.3 (Berkeley) %G%";
+#endif not lint
+
 
 #include "defs.h"
 
 
 #include "defs.h"
 
@@ -81,13 +91,20 @@ xnnet_output(flags, sns, size)
 }
 
 /*
 }
 
 /*
- * Return 1 if the address is believed
- *  -- THIS IS A KLUDGE.
+ * Return 1 if we want this route.
+ * We use this to disallow route net G entries for one for multiple
+ * point to point links.
  */
 xnnet_checkhost(sns)
        struct sockaddr_ns *sns;
 {
  */
 xnnet_checkhost(sns)
        struct sockaddr_ns *sns;
 {
-       return (1);
+       register struct interface *ifp = if_ifwithnet(sns);
+       /*
+        * We want this route if there is no more than one 
+        * point to point interface with this network.
+        */
+       if (ifp == 0 || (ifp->int_flags & IFF_POINTOPOINT)==0) return (1);
+       return (ifp->int_sq.n == ifp->int_sq.p);
 }
 
 /*
 }
 
 /*
index 5dacdb4..1f51627 100644 (file)
@@ -1,6 +1,21 @@
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * Includes material written at Cornell University by Bill Nesheim
+ * with permission of the author.
+ */
+
 #ifndef lint
 #ifndef lint
-static char rcsid[] = "$Header$";
-#endif
+char copyright[] =
+"@(#) Copyright (c) 1983 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif not lint
+
+#ifndef lint
+static char sccsid[] = "@(#)main.c     5.3 (Berkeley) %G%";
+#endif not lint
 
 /*
  * XNS Routing Information Protocol Daemon
 
 /*
  * XNS Routing Information Protocol Daemon
@@ -31,11 +46,6 @@ main(argc, argv)
        u_char retry;
        
        argv0 = argv;
        u_char retry;
        
        argv0 = argv;
-       addr.sns_family = AF_NS;
-       addr.sns_port = htons(IDPPORT_RIF);
-       s = getsocket(SOCK_DGRAM, 0, &addr);
-       if (s < 0)
-               exit(1);
        argv++, argc--;
        while (argc > 0 && **argv == '-') {
                if (strcmp(*argv, "-s") == 0) {
        argv++, argc--;
        while (argc > 0 && **argv == '-') {
                if (strcmp(*argv, "-s") == 0) {
@@ -88,6 +98,11 @@ main(argc, argv)
                }
        }
 #endif
                }
        }
 #endif
+       addr.sns_family = AF_NS;
+       addr.sns_port = htons(IDPPORT_RIF);
+       s = getsocket(SOCK_DGRAM, 0, &addr);
+       if (s < 0)
+               exit(1);
        /*
         * Any extra argument is considered
         * a tracing log file.
        /*
         * Any extra argument is considered
         * a tracing log file.
@@ -143,22 +158,25 @@ process(fd)
                        perror("recvfrom");
                return;
        }
                        perror("recvfrom");
                return;
        }
-       /* We get the IDP header in front of the RIF packet*/
        if (tracepackets > 1) {
        if (tracepackets > 1) {
-           fprintf(ftrace,"rcv %d bytes on %s ",
-               cc, xns_ntoa(&idp->idp_dna));
+           fprintf(ftrace,"rcv %d bytes on %s ", cc, xns_ntoa(&idp->idp_dna));
            fprintf(ftrace," from %s\n", xns_ntoa(&idp->idp_sna));
        }
            fprintf(ftrace," from %s\n", xns_ntoa(&idp->idp_sna));
        }
-       
-       if (ns_netof(idp->idp_sna) != ns_netof(idp->idp_dna)) {
-               fprintf(ftrace, "XNSrouted: net of interface (%d) != net on ether (%d)!\n",
-                       ns_netof(idp->idp_dna), ns_netof(idp->idp_sna));
+       if (tracepackets > 0) {
+           if (ns_netof(idp->idp_sna) != ns_netof(idp->idp_dna)) {
+                   fprintf(ftrace,
+                           "XNSrouted: net of interface (%d) ",
+                           ns_netof(idp->idp_dna));
+                   fprintf(ftrace,
+                           "!= net on ether (%d)!\n", ns_netof(idp->idp_sna));
+           }
+           if (fromlen != sizeof (struct sockaddr_ns))
+                   fprintf(ftrace, "fromlen is %d instead of %d\n",
+                   fromlen, sizeof (struct sockaddr_ns));
        }
                        
        }
                        
+       /* We get the IDP header in front of the RIF packet*/
        cc -= sizeof (struct idp);
        cc -= sizeof (struct idp);
-       if (fromlen != sizeof (struct sockaddr_ns))
-               fprintf(ftrace, "fromlen is %d instead of %d\n",
-               fromlen, sizeof (struct sockaddr_ns));
 #define        mask(s) (1<<((s)-1))
        omask = sigblock(mask(SIGALRM));
        rip_input(&from, cc);
 #define        mask(s) (1<<((s)-1))
        omask = sigblock(mask(SIGALRM));
        rip_input(&from, cc);
index ebb67b0..d4b0e6f 100644 (file)
@@ -57,12 +57,14 @@ supply(dst, flags, ifp)
        struct interface *ifp;
 {
        register struct rt_entry *rt;
        struct interface *ifp;
 {
        register struct rt_entry *rt;
-       struct netinfo *n = msg->rip_nets;
        register struct rthash *rh;
        register struct rthash *rh;
+       register struct netinfo *nn;
+       register struct netinfo *n = msg->rip_nets;
        struct rthash *base = hosthash;
        struct rthash *base = hosthash;
-       int doinghost = 1, size;
        struct sockaddr_ns *sns =  (struct sockaddr_ns *) dst;
        int (*output)() = afswitch[dst->sa_family].af_output;
        struct sockaddr_ns *sns =  (struct sockaddr_ns *) dst;
        int (*output)() = afswitch[dst->sa_family].af_output;
+       int doinghost = 1, size, metric;
+       long net;
 
        msg->rip_cmd = ntohs(RIPCMD_RESPONSE);
 again:
 
        msg->rip_cmd = ntohs(RIPCMD_RESPONSE);
 again:
@@ -75,9 +77,24 @@ again:
                        n = msg->rip_nets;
                }
                sns = (struct sockaddr_ns *)&rt->rt_dst;
                        n = msg->rip_nets;
                }
                sns = (struct sockaddr_ns *)&rt->rt_dst;
-               xnnet(n->rip_dst[0]) = ns_netof(sns->sns_addr);
-               n->rip_metric = htons(min(rt->rt_metric + 1, HOPCNT_INFINITY));
+               metric = min(rt->rt_metric + 1, HOPCNT_INFINITY);
+               net = ns_netof(sns->sns_addr);
+               /*
+                * Make sure that we don't put out a two net entries
+                * for a pt to pt link (one for the G route, one for the if)
+                * This is a kludge, and won't work if there are lots of nets.
+                */
+               for (nn = msg->rip_nets; nn < n; nn++) {
+                       if(net == xnnet(nn->rip_dst[0])) {
+                               if(metric < ntohs(nn->rip_metric))
+                                       nn->rip_metric = htons(metric);
+                               goto next;
+                       }
+               }
+               xnnet(n->rip_dst[0]) = net;
+               n->rip_metric = htons(metric);
                n++;
                n++;
+       next:;
        }
        if (doinghost) {
                doinghost = 0;
        }
        if (doinghost) {
                doinghost = 0;
index ad0fc8c..2842a06 100644 (file)
@@ -1,6 +1,16 @@
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * Includes material written at Cornell University by Bill Nesheim,
+ * by permission of the author.
+ */
+
+
 #ifndef lint
 #ifndef lint
-static char rcsid[] = "$Header$";
-#endif
+static char sccsid[] = "@(#)startup.c  5.3 (Berkeley) %G%";
+#endif not lint
 
 /*
  * Routing Table Management Daemon
 
 /*
  * Routing Table Management Daemon
@@ -62,8 +72,8 @@ ifinit()
                        continue;
                }
                /* already known to us? */
                        continue;
                }
                /* already known to us? */
-               if (if_ifwithaddr(&ifs.int_addr))
-                       continue;
+               /*if (if_ifwithaddr(&ifs.int_addr))
+                       continue;*/
                /* argh, this'll have to change sometime */
                if (ifs.int_addr.sa_family != AF_NS)
                        continue;
                /* argh, this'll have to change sometime */
                if (ifs.int_addr.sa_family != AF_NS)
                        continue;
@@ -130,9 +140,26 @@ addrouteforif(ifp)
        int state, metric;
        struct rt_entry *rt;
 
        int state, metric;
        struct rt_entry *rt;
 
-       if (ifp->int_flags & IFF_POINTOPOINT)
+       if (ifp->int_flags & IFF_POINTOPOINT) {
+               int (*match)();
+               register struct interface *ifp2 = ifnet;
+               register struct interface *ifprev = ifnet;
+               
                dst = &ifp->int_dstaddr;
                dst = &ifp->int_dstaddr;
-       else {
+
+               /* Search for interfaces with the same net */
+               ifp->int_sq.n = ifp->int_sq.p = &(ifp->int_sq);
+               match = afswitch[dst->sa_family].af_netmatch;
+               if (match)
+               for (ifp2 = ifnet; ifp2; ifp2 =ifp2->int_next) {
+                       if (ifp->int_flags & IFF_POINTOPOINT == 0)
+                               continue;
+                       if ((*match)(&ifp2->int_dstaddr,&ifp->int_dstaddr)) {
+                               insque(&ifp2->int_sq,&ifp->int_sq);
+                               break;
+                       }
+               }
+       } else {
                dst = &ifp->int_broadaddr;
        }
        rt = rtlookup(dst);
                dst = &ifp->int_broadaddr;
        }
        rt = rtlookup(dst);
@@ -141,4 +168,3 @@ addrouteforif(ifp)
        rtadd(dst, &ifp->int_addr, ifp->int_metric,
                ifp->int_flags & (IFF_INTERFACE|IFF_PASSIVE|IFF_REMOTE));
 }
        rtadd(dst, &ifp->int_addr, ifp->int_metric,
                ifp->int_flags & (IFF_INTERFACE|IFF_PASSIVE|IFF_REMOTE));
 }
-
index 4433629..339b4d4 100644 (file)
@@ -1,6 +1,14 @@
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ */
+
+
 #ifndef lint
 #ifndef lint
-static char rcsid[] = "$Header$";
-#endif
+static char sccsid[] = "@(#)tables.c   5.3 (Berkeley) %G%";
+#endif not lint
 
 /*
  * Routing Table Management Daemon
 
 /*
  * Routing Table Management Daemon
@@ -76,10 +84,11 @@ again:
                if (doinghost) {
                        if (equal(&rt->rt_dst, dst))
                                return (rt);
                if (doinghost) {
                        if (equal(&rt->rt_dst, dst))
                                return (rt);
+               } else {
+                       if (rt->rt_dst.sa_family == af &&
+                           (*match)(&rt->rt_dst, dst))
+                               return (rt);
                }
                }
-               if (rt->rt_dst.sa_family == af &&
-                   (*match)(&rt->rt_dst, dst))
-                       return (rt);
        }
        if (doinghost) {
                doinghost = 0;
        }
        if (doinghost) {
                doinghost = 0;
index 3b1b71b..22aed5a 100644 (file)
@@ -1,6 +1,16 @@
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * Includes material written at Cornell University by Bill Nesheim,
+ * by permission of the author.
+ */
+
+
 #ifndef lint
 #ifndef lint
-static char rcsid[] = "$Header$";
-#endif
+static char sccsid[] = "@(#)timer.c    5.3 (Berkeley) %G%";
+#endif not lint
 
 /*
  * Routing Table Management Daemon
 
 /*
  * Routing Table Management Daemon