From 55d340a44b8d65c5065824e0fb77169e684c2888 Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Thu, 26 May 1983 00:51:27 -0800 Subject: [PATCH] protocol change; byte swap those fields which need it; also add a version stamp to allow future changes SCCS-vsn: sbin/routed/af.c 4.11 SCCS-vsn: sbin/routed/if.c 4.3 SCCS-vsn: sbin/routed/input.c 4.4 SCCS-vsn: sbin/routed/main.c 4.5 SCCS-vsn: sbin/routed/output.c 4.3 SCCS-vsn: include/protocols/routed.h 4.9 SCCS-vsn: sbin/routed/startup.c 4.4 SCCS-vsn: sbin/routed/tables.c 4.3 SCCS-vsn: sbin/routed/timer.c 4.3 SCCS-vsn: sbin/routed/trace.c 4.3 SCCS-vsn: sbin/routed/trace.h 4.3 --- usr/src/include/protocols/routed.h | 10 ++++++++-- usr/src/sbin/routed/af.c | 2 +- usr/src/sbin/routed/if.c | 2 +- usr/src/sbin/routed/input.c | 23 ++++++++++++++++++++++- usr/src/sbin/routed/main.c | 9 +++++++-- usr/src/sbin/routed/output.c | 9 +++++++-- usr/src/sbin/routed/startup.c | 2 +- usr/src/sbin/routed/tables.c | 2 +- usr/src/sbin/routed/timer.c | 11 +++++++++-- usr/src/sbin/routed/trace.c | 2 +- usr/src/sbin/routed/trace.h | 4 ++-- 11 files changed, 60 insertions(+), 16 deletions(-) diff --git a/usr/src/include/protocols/routed.h b/usr/src/include/protocols/routed.h index 668dd09683..6636bcf6b8 100644 --- a/usr/src/include/protocols/routed.h +++ b/usr/src/include/protocols/routed.h @@ -1,4 +1,4 @@ -/* routed.h 82/08/18 4.8 */ +/* routed.h 83/05/25 4.9 */ /* * Routing Information Protocol * @@ -6,6 +6,8 @@ * by changing 32-bit net numbers to sockaddr's and * padding stuff to 32-bit boundaries. */ +#define RIPVERSION 1 + struct netinfo { struct sockaddr rip_dst; /* destination net/host */ int rip_metric; /* cost of route */ @@ -13,7 +15,8 @@ struct netinfo { struct rip { u_char rip_cmd; /* request/response */ - u_char rip_res1[3]; /* pad to 32-bit boundary */ + u_char rip_vers; /* protocol version # */ + u_char rip_res1[2]; /* pad to 32-bit boundary */ union { struct netinfo ru_nets[1]; /* variable length... */ char ru_tracefile[1]; /* ditto ... */ @@ -22,6 +25,9 @@ struct rip { #define rip_tracefile ripun.ru_tracefile }; +/* + * Packet types. + */ #define RIPCMD_REQUEST 1 /* want info */ #define RIPCMD_RESPONSE 2 /* responding to request */ #define RIPCMD_TRACEON 3 /* turn tracing on */ diff --git a/usr/src/sbin/routed/af.c b/usr/src/sbin/routed/af.c index b973c88a16..b53ee3f376 100644 --- a/usr/src/sbin/routed/af.c +++ b/usr/src/sbin/routed/af.c @@ -1,5 +1,5 @@ #ifndef lint -static char sccsid[] = "@(#)af.c 4.10 %G%"; +static char sccsid[] = "@(#)af.c 4.11 (Berkeley) %G%"; #endif #include "defs.h" diff --git a/usr/src/sbin/routed/if.c b/usr/src/sbin/routed/if.c index 4ac75b2234..b8ca7b6e0e 100644 --- a/usr/src/sbin/routed/if.c +++ b/usr/src/sbin/routed/if.c @@ -1,5 +1,5 @@ #ifndef lint -static char sccsid[] = "@(#)if.c 4.2 %G%"; +static char sccsid[] = "@(#)if.c 4.3 (Berkeley) %G%"; #endif /* diff --git a/usr/src/sbin/routed/input.c b/usr/src/sbin/routed/input.c index 0d4034f978..1a672288f2 100644 --- a/usr/src/sbin/routed/input.c +++ b/usr/src/sbin/routed/input.c @@ -1,5 +1,5 @@ #ifndef lint -static char sccsid[] = "@(#)input.c 4.3 %G%"; +static char sccsid[] = "@(#)input.c 4.4 (Berkeley) %G%"; #endif /* @@ -36,6 +36,13 @@ rip_input(from, size) break; size -= sizeof (struct netinfo); +#ifdef notyet + if (msg->rip_vers > 0) { + n->rip_dst.sa_family = + ntohs(n->rip_dst.sa_family); + n->rip_metric = ntohl(n->rip_metric); + } +#endif /* * A single entry with sa_family == AF_UNSPEC and * metric ``infinity'' means ``all routes''. @@ -48,6 +55,13 @@ rip_input(from, size) rt = rtlookup(&n->rip_dst); n->rip_metric = rt == 0 ? HOPCNT_INFINITY : min(rt->rt_metric+1, HOPCNT_INFINITY); +#ifdef notyet + if (msg->rip_vers > 0) { + n->rip_dst.sa_family = + htons(n->rip_dst.sa_family); + n->rip_metric = htonl(n->rip_metric); + } +#endif n++, newsize += sizeof (struct netinfo); } if (newsize > 0) { @@ -89,6 +103,13 @@ rip_input(from, size) for (; size > 0; size -= sizeof (struct netinfo), n++) { if (size < sizeof (struct netinfo)) break; +#ifdef notyet + if (msg->rip_vers > 0) { + n->rip_dst.sa_family = + ntohs(n->rip_dst.sa_family); + n->rip_metric = ntohl(n->rip_metric); + } +#endif if (n->rip_metric >= HOPCNT_INFINITY) continue; rt = rtlookup(&n->rip_dst); diff --git a/usr/src/sbin/routed/main.c b/usr/src/sbin/routed/main.c index e725ef8a92..a3d8aa81e4 100644 --- a/usr/src/sbin/routed/main.c +++ b/usr/src/sbin/routed/main.c @@ -1,5 +1,5 @@ #ifndef lint -static char sccsid[] = "@(#)main.c 4.4 %G%"; +static char sccsid[] = "@(#)main.c 4.5 (Berkeley) %G%"; #endif /* @@ -76,7 +76,7 @@ main(argc, argv) for (t = 0; t < 20; t++) if (t != s) #ifdef COMPAT - if (t != snoroute) + if (t != snoroute) #endif (void) close(cc); (void) open("/", 0); @@ -108,8 +108,13 @@ main(argc, argv) if (supplier < 0) supplier = 0; msg->rip_cmd = RIPCMD_REQUEST; + msg->rip_vers = RIPVERSION; msg->rip_nets[0].rip_dst.sa_family = AF_UNSPEC; msg->rip_nets[0].rip_metric = HOPCNT_INFINITY; +#ifdef notyet + msg->rip_nets[0].rip_dst.sa_family = htons(AF_UNSPEC); + msg->rip_nets[0].rip_metric = htonl(HOPCNT_INFINITY); +#endif toall(sendmsg); sigset(SIGALRM, timer); timer(); diff --git a/usr/src/sbin/routed/output.c b/usr/src/sbin/routed/output.c index 7d88143d96..707497247c 100644 --- a/usr/src/sbin/routed/output.c +++ b/usr/src/sbin/routed/output.c @@ -1,5 +1,5 @@ #ifndef lint -static char sccsid[] = "@(#)output.c 4.2 %G%"; +static char sccsid[] = "@(#)output.c 4.3 (Berkeley) %G%"; #endif /* @@ -27,7 +27,7 @@ toall(f) dst = ifp->int_flags & IFF_BROADCAST ? &ifp->int_broadaddr : ifp->int_flags & IFF_POINTOPOINT ? &ifp->int_dstaddr : &ifp->int_addr; - flags = ifp->int_flags & IFF_INTERFACE ? SOF_DONTROUTE : 0; + flags = ifp->int_flags & IFF_INTERFACE ? MSG_DONTROUTE : 0; (*f)(dst, flags, ifp); } } @@ -64,6 +64,7 @@ supply(dst, flags, ifp) int (*output)() = afswitch[dst->sa_family].af_output; msg->rip_cmd = RIPCMD_RESPONSE; + msg->rip_vers = RIPVERSION; again: for (rh = base; rh < &base[ROUTEHASHSIZ]; rh++) for (rt = rh->rt_forw; rt != (struct rt_entry *)rh; rt = rt->rt_forw) { @@ -75,6 +76,10 @@ again: } n->rip_dst = rt->rt_dst; n->rip_metric = min(rt->rt_metric + 1, HOPCNT_INFINITY); +#ifdef notyet + n->rip_dst.sa_family = htons(n->rip_dst.sa_family); + n->rip_metric = htonl(n->rip_metric); +#endif n++; } if (doinghost) { diff --git a/usr/src/sbin/routed/startup.c b/usr/src/sbin/routed/startup.c index 67ffafed76..1747b66b49 100644 --- a/usr/src/sbin/routed/startup.c +++ b/usr/src/sbin/routed/startup.c @@ -1,5 +1,5 @@ #ifndef lint -static char sccsid[] = "@(#)startup.c 4.3 %G%"; +static char sccsid[] = "@(#)startup.c 4.4 (Berkeley) %G%"; #endif /* diff --git a/usr/src/sbin/routed/tables.c b/usr/src/sbin/routed/tables.c index 915f7a62d7..5796c42c7b 100644 --- a/usr/src/sbin/routed/tables.c +++ b/usr/src/sbin/routed/tables.c @@ -1,5 +1,5 @@ #ifndef lint -static char sccsid[] = "@(#)tables.c 4.2 %G%"; +static char sccsid[] = "@(#)tables.c 4.3 (Berkeley) %G%"; #endif /* diff --git a/usr/src/sbin/routed/timer.c b/usr/src/sbin/routed/timer.c index 954ca7cce8..f6da47baf0 100644 --- a/usr/src/sbin/routed/timer.c +++ b/usr/src/sbin/routed/timer.c @@ -1,5 +1,5 @@ #ifndef lint -static char sccsid[] = "@(#)timer.c 4.2 %G%"; +static char sccsid[] = "@(#)timer.c 4.3 (Berkeley) %G%"; #endif /* @@ -54,9 +54,16 @@ again: if (!supplier || timetobroadcast) continue; msg->rip_cmd = RIPCMD_RESPONSE; + msg->rip_vers = RIPVERSION; msg->rip_nets[0].rip_dst = rt->rt_dst; msg->rip_nets[0].rip_metric = - min(rt->rt_metric+1, HOPCNT_INFINITY); + min(rt->rt_metric+1, HOPCNT_INFINITY); +#ifdef notyet + msg->rip_nets[0].rip_dst.sa_family = + htons(msg->rip_nets[0].rip_dst.sa_family); + msg->rip_nets[0].rip_metric = + htonl(msg->rip_nets[0].rip_metric); +#endif toall(sendmsg); } } diff --git a/usr/src/sbin/routed/trace.c b/usr/src/sbin/routed/trace.c index 8c446b5028..f0c2d04016 100644 --- a/usr/src/sbin/routed/trace.c +++ b/usr/src/sbin/routed/trace.c @@ -1,5 +1,5 @@ #ifndef lint -static char sccsid[] = "@(#)trace.c 4.2 %G%"; +static char sccsid[] = "@(#)trace.c 4.3 (Berkeley) %G%"; #endif /* diff --git a/usr/src/sbin/routed/trace.h b/usr/src/sbin/routed/trace.h index 0ee3ebb8a4..48a15e0a93 100644 --- a/usr/src/sbin/routed/trace.h +++ b/usr/src/sbin/routed/trace.h @@ -1,4 +1,4 @@ -/* trace.h 4.2 83/01/31 */ +/* trace.h 4.3 83/05/25 */ /* * Routing table management daemon. @@ -43,7 +43,7 @@ FILE *ftrace; /* output trace file */ ifp = if_iflookup(src); \ if (ifp) \ trace(&ifp->int_input, src, packet, size, \ - ifp->int_metric); \ + ntohl(ifp->int_metric)); \ } \ if (tracepackets) \ dumppacket(stdout, "from", src, packet, size); \ -- 2.20.1