some -Wall changes, from Jim Jegers, improved (in some cases) by me.

still needs a bit of work, but closer.
This commit is contained in:
cgd 1994-12-18 05:43:48 +00:00
parent 4c998ed311
commit e072e2ae63
10 changed files with 131 additions and 37 deletions

View File

@ -33,7 +33,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)af.c 8.1 (Berkeley) 6/5/93";*/
static char *rcsid = "$Id: af.c,v 1.5 1994/05/13 08:04:31 mycroft Exp $";
static char *rcsid = "$Id: af.c,v 1.6 1994/12/18 05:43:48 cgd Exp $";
#endif /* not lint */
#include "defs.h"
@ -41,10 +41,14 @@ static char *rcsid = "$Id: af.c,v 1.5 1994/05/13 08:04:31 mycroft Exp $";
/*
* Address family support routines
*/
int inet_hash(), inet_netmatch(), inet_output(),
inet_portmatch(), inet_portcheck(),
inet_checkhost(), inet_rtflags(), inet_sendroute(), inet_canon();
char *inet_format();
int inet_canon __P((struct sockaddr_in *));
int inet_checkhost __P((struct sockaddr_in *));
char *inet_format __P((struct sockaddr_in *));
int inet_hash __P((struct sockaddr_in *, struct afhash *));
int inet_netmatch __P((struct sockaddr_in *, struct sockaddr_in *));
int inet_portcheck __P((struct sockaddr_in *));
int inet_portmatch __P((struct sockaddr_in *));
int inet_output __P((int, int, struct sockaddr_in *, int));
#define NIL { 0 }
#define INET \
@ -68,13 +72,14 @@ struct sockaddr_in inet_default = {
#endif
AF_INET, INADDR_ANY };
int
inet_hash(sin, hp)
register struct sockaddr_in *sin;
struct afhash *hp;
{
register u_long n;
n = inet_netof(sin->sin_addr);
n = inet_netof_subnet(sin->sin_addr);
if (n)
while ((n & 0xff) == 0)
n >>= 8;
@ -83,16 +88,19 @@ inet_hash(sin, hp)
hp->afh_hosthash &= 0x7fffffff;
}
int
inet_netmatch(sin1, sin2)
struct sockaddr_in *sin1, *sin2;
{
return (inet_netof(sin1->sin_addr) == inet_netof(sin2->sin_addr));
return (inet_netof_subnet(sin1->sin_addr) ==
inet_netof_subnet(sin2->sin_addr));
}
/*
* Verify the message is from the right port.
*/
int
inet_portmatch(sin)
register struct sockaddr_in *sin;
{
@ -103,6 +111,7 @@ inet_portmatch(sin)
/*
* Verify the message is from a "trusted" port.
*/
int
inet_portcheck(sin)
struct sockaddr_in *sin;
{
@ -113,6 +122,7 @@ inet_portcheck(sin)
/*
* Internet output routine.
*/
int
inet_output(s, flags, sin, size)
int s, flags;
struct sockaddr_in *sin;
@ -135,6 +145,7 @@ inet_output(s, flags, sin, size)
* Return 1 if the address is believed
* for an Internet host -- THIS IS A KLUDGE.
*/
int
inet_checkhost(sin)
struct sockaddr_in *sin;
{
@ -154,6 +165,7 @@ inet_checkhost(sin)
return (1);
}
int
inet_canon(sin)
struct sockaddr_in *sin;
{

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)defs.h 8.1 (Berkeley) 6/5/93
* $Id: defs.h,v 1.7 1994/09/23 23:49:20 mycroft Exp $
* $Id: defs.h,v 1.8 1994/12/18 05:43:51 cgd Exp $
*/
/*
@ -47,9 +47,14 @@
#include <net/route.h>
#include <netinet/in.h>
#include <protocols/routed.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <netdb.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "trace.h"
#include "interface.h"
@ -92,13 +97,43 @@ char **argv0;
struct servent *sp;
struct in_addr inet_makeaddr();
int inet_addr();
int inet_maskof();
int sndmsg();
int supply();
int cleanup();
int rtioctl();
void addrouteforif __P((struct interface *));
void bumploglevel();
void dumppacket __P((FILE *, char *, struct sockaddr_in *, char *,
int, struct timeval *));
void gwkludge();
void hup();
void ifinit();
#ifdef notdef /* XXX FUNCTION UNUSED */
u_long inet_lnaof_subnet __P((struct in_addr));
#endif
int inet_maskof __P((u_long));
u_long inet_netof_subnet __P((struct in_addr));
int inet_rtflags __P((struct sockaddr_in *));
int inet_sendroute __P((struct rt_entry *, struct sockaddr_in *));
void rip_input __P((struct sockaddr *, struct rip *, int));
void rtadd __P((struct sockaddr *, struct sockaddr *, int, int));
void rtchange __P((struct rt_entry *, struct sockaddr *, short));
void rtdefault();
void rtdelete __P((struct rt_entry *));
void rtdeleteall __P((int));
void rtinit();
int rtioctl __P((int, struct rtuentry *));
void sigtrace __P((int));
int sndmsg __P((struct sockaddr *, int, struct interface *, int));
void timer();
void timevaladd __P((struct timeval *, struct timeval *));
void toall __P((int (*)(), int, struct interface *));
void traceoff();
void traceon __P((char *));
void trace __P((struct ifdebug *, struct sockaddr *, char *, int, int));
void traceaction __P((FILE *, char *, struct rt_entry *));
void traceinit __P((struct interface *));
void tracenewmetric __P((FILE *, struct rt_entry *, int));
#define ADD 1
#define DELETE 2
#define CHANGE 3

View File

@ -33,7 +33,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)inet.c 8.2 (Berkeley) 8/14/93";*/
static char *rcsid = "$Id: inet.c,v 1.6 1994/08/06 05:51:03 mycroft Exp $";
static char *rcsid = "$Id: inet.c,v 1.7 1994/12/18 05:43:52 cgd Exp $";
#endif /* not lint */
/*
@ -74,7 +74,8 @@ inet_makeaddr(net, host)
/*
* Return the network number from an internet address.
*/
inet_netof(in)
u_long
inet_netof_subnet(in)
struct in_addr in;
{
register u_long i = ntohl(in.s_addr);
@ -98,10 +99,13 @@ inet_netof(in)
return (net);
}
#ifdef notdef
/*
* Return the host portion of an internet address.
* XXX THIS FUNCTION UNUSED.
*/
inet_lnaof(in)
u_long
inet_lnaof_subnet(in)
struct in_addr in;
{
register u_long i = ntohl(in.s_addr);
@ -128,10 +132,12 @@ inet_lnaof(in)
return (host &~ ifp->int_subnetmask);
return (host);
}
#endif
/*
* Return the netmask pertaining to an internet address.
*/
int
inet_maskof(inaddr)
u_long inaddr;
{
@ -163,6 +169,7 @@ inet_maskof(inaddr)
* for an Internet host, RTF_SUBNET for a subnet,
* 0 for a network.
*/
int
inet_rtflags(sin)
struct sockaddr_in *sin;
{
@ -205,6 +212,7 @@ inet_rtflags(sin)
* Send it only if dst is on the same logical network if not "internal",
* otherwise only if the route is the "internal" route for the logical net.
*/
int
inet_sendroute(rt, dst)
struct rt_entry *rt;
struct sockaddr_in *dst;

View File

@ -33,7 +33,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)input.c 8.1 (Berkeley) 6/5/93";*/
static char *rcsid = "$Id: input.c,v 1.7 1994/09/23 23:49:24 mycroft Exp $";
static char *rcsid = "$Id: input.c,v 1.8 1994/12/18 05:43:54 cgd Exp $";
#endif /* not lint */
/*
@ -45,6 +45,7 @@ static char *rcsid = "$Id: input.c,v 1.7 1994/09/23 23:49:24 mycroft Exp $";
/*
* Process a newly received packet.
*/
void
rip_input(from, rip, size)
struct sockaddr *from;
register struct rip *rip;
@ -59,7 +60,7 @@ rip_input(from, rip, size)
static struct sockaddr badfrom, badfrom2;
ifp = 0;
TRACE_INPUT(ifp, from, (char *)rip, size);
TRACE_INPUT(ifp, (struct sockaddr_in *)from, (char *)rip, size);
if (from->sa_family >= af_max ||
(afp = &afswitch[from->sa_family])->af_hash == (int (*)())0) {
syslog(LOG_INFO,

View File

@ -39,7 +39,7 @@ static char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)main.c 8.1 (Berkeley) 6/5/93";*/
static char *rcsid = "$Id: main.c,v 1.5 1994/05/13 08:04:43 mycroft Exp $";
static char *rcsid = "$Id: main.c,v 1.6 1994/12/18 05:43:55 cgd Exp $";
#endif /* not lint */
/*
@ -60,21 +60,22 @@ int supplier = -1; /* process should supply updates */
int gateway = 0; /* 1 if we are a gateway to parts beyond */
int debug = 0;
int bufspace = 127*1024; /* max. input buffer size to request */
struct rip *msg = (struct rip *)packet;
void hup(), rtdeleteall(), sigtrace(), timer();
int getsocket __P((int, int, struct sockaddr_in *));
void timevalsub __P((struct timeval *, struct timeval *));
void process __P((int));
int
main(argc, argv)
int argc;
char *argv[];
{
int n, cc, nfd, omask, tflags = 0;
struct sockaddr from;
int n, nfd, omask, tflags = 0;
struct timeval *tvp, waittime;
struct itimerval itval;
register struct rip *query = msg;
fd_set ibits;
u_char retry;
argv0 = argv;
#if BSD >= 43
@ -170,7 +171,7 @@ main(argc, argv)
else
query->rip_nets[0].rip_dst.sa_family = AF_UNSPEC;
query->rip_nets[0].rip_metric = htonl((u_long)HOPCNT_INFINITY);
toall(sndmsg);
toall(sndmsg, 0, NULL);
signal(SIGALRM, timer);
signal(SIGHUP, hup);
signal(SIGTERM, hup);
@ -263,6 +264,7 @@ printf("s %d, ibits %x index %d, mod %d, sh %x, or %x &ibits %x\n",
}
}
void
timevaladd(t1, t2)
struct timeval *t1, *t2;
{
@ -274,6 +276,7 @@ timevaladd(t1, t2)
}
}
void
timevalsub(t1, t2)
struct timeval *t1, *t2;
{
@ -285,6 +288,7 @@ timevalsub(t1, t2)
}
}
void
process(fd)
int fd;
{
@ -309,6 +313,7 @@ process(fd)
}
}
int
getsocket(domain, type, sin)
int domain, type;
struct sockaddr_in *sin;

View File

@ -33,7 +33,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)output.c 8.1 (Berkeley) 6/5/93";*/
static char *rcsid = "$Id: output.c,v 1.6 1994/09/23 14:28:06 mycroft Exp $";
static char *rcsid = "$Id: output.c,v 1.7 1994/12/18 05:43:56 cgd Exp $";
#endif /* not lint */
/*
@ -47,6 +47,7 @@ static char *rcsid = "$Id: output.c,v 1.6 1994/09/23 14:28:06 mycroft Exp $";
* use of broadcasting use it, otherwise address
* the output to the known router.
*/
void
toall(f, rtstate, skipif)
int (*f)();
int rtstate;
@ -72,6 +73,7 @@ toall(f, rtstate, skipif)
* Output a preformed packet.
*/
/*ARGSUSED*/
int
sndmsg(dst, flags, ifp, rtstate)
struct sockaddr *dst;
int flags;
@ -88,6 +90,7 @@ sndmsg(dst, flags, ifp, rtstate)
* Supply dst with the contents of the routing tables.
* If this won't fit in one packet, chop it up into several.
*/
int
supply(dst, flags, ifp, rtstate)
struct sockaddr *dst;
int flags;

View File

@ -33,7 +33,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)startup.c 8.1 (Berkeley) 6/5/93";*/
static char *rcsid = "$Id: startup.c,v 1.8 1994/10/31 04:35:58 cgd Exp $";
static char *rcsid = "$Id: startup.c,v 1.9 1994/12/18 05:43:57 cgd Exp $";
#endif /* not lint */
/*
@ -56,6 +56,9 @@ int externalinterfaces = 0; /* # of remote and local interfaces */
int foundloopback; /* valid flag for loopaddr */
struct sockaddr loopaddr; /* our address on loopback */
void add_ptopt_localrt __P((struct interface *));
int getnetorhostname __P((char *, char *, struct sockaddr_in *));
int gethostnameornumber __P((char *, struct sockaddr_in *));
void
quit(s)
@ -105,6 +108,7 @@ rt_xaddrs(cp, cplim, rtinfo)
* ARPANET IMP), set the lookforinterfaces flag so we'll
* come back later and look again.
*/
void
ifinit()
{
struct interface ifs, *ifp;
@ -267,6 +271,7 @@ ifinit()
* otherwise a route to this (sub)network.
* INTERNET SPECIFIC.
*/
void
addrouteforif(ifp)
register struct interface *ifp;
{
@ -330,6 +335,7 @@ addrouteforif(ifp)
* If a route to this network is being sent to neighbors on other nets,
* mark this route as subnet so we don't have to propagate it too.
*/
void
add_ptopt_localrt(ifp)
register struct interface *ifp;
{
@ -373,6 +379,7 @@ add_ptopt_localrt(ifp)
*
* PASSIVE ENTRIES AREN'T NEEDED OR USED ON GATEWAYS RUNNING EGP.
*/
void
gwkludge()
{
struct sockaddr_in dst, gate;
@ -440,7 +447,7 @@ gwkludge()
memset(ifp, 0, sizeof (*ifp));
ifp->int_flags = IFF_REMOTE;
/* can't identify broadcast capability */
ifp->int_net = inet_netof(dst.sin_addr);
ifp->int_net = inet_netof_subnet(dst.sin_addr);
if (strcmp(type, "host") == 0) {
ifp->int_flags |= IFF_POINTOPOINT;
ifp->int_dstaddr = *((struct sockaddr *)&dst);
@ -454,6 +461,7 @@ gwkludge()
fclose(fp);
}
int
getnetorhostname(type, name, sin)
char *type, *name;
struct sockaddr_in *sin;
@ -499,6 +507,7 @@ getnetorhostname(type, name, sin)
return (0);
}
int
gethostnameornumber(name, sin)
char *name;
struct sockaddr_in *sin;

View File

@ -33,7 +33,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)tables.c 8.1 (Berkeley) 6/5/93";*/
static char *rcsid = "$Id: tables.c,v 1.9 1994/10/31 04:36:02 cgd Exp $";
static char *rcsid = "$Id: tables.c,v 1.10 1994/12/18 05:43:59 cgd Exp $";
#endif /* not lint */
/*
@ -41,8 +41,9 @@ static char *rcsid = "$Id: tables.c,v 1.9 1994/10/31 04:36:02 cgd Exp $";
*/
#include "defs.h"
#include <sys/ioctl.h>
#include <errno.h>
#include <sys/syslog.h>
#include <errno.h>
#include <search.h>
#include <stdlib.h>
#ifndef DEBUG
@ -145,6 +146,7 @@ again:
return (0);
}
void
rtadd(dst, gate, metric, state)
struct sockaddr *dst, *gate;
int metric, state;
@ -213,6 +215,7 @@ rtadd(dst, gate, metric, state)
}
}
void
rtchange(rt, gate, metric)
struct rt_entry *rt;
struct sockaddr *gate;
@ -285,6 +288,7 @@ rtchange(rt, gate, metric)
#endif
}
void
rtdelete(rt)
struct rt_entry *rt;
{
@ -305,6 +309,7 @@ rtdelete(rt)
free((char *)rt);
}
void
rtdeleteall(sig)
int sig;
{
@ -341,6 +346,7 @@ again:
* but this entry prevents us from listening to other people's defaults
* and installing them in the kernel here.
*/
void
rtdefault()
{
extern struct sockaddr inet_default;
@ -349,6 +355,7 @@ rtdefault()
RTS_CHANGED | RTS_PASSIVE | RTS_INTERNAL);
}
void
rtinit()
{
register struct rthash *rh;
@ -359,6 +366,7 @@ rtinit()
rh->rt_forw = rh->rt_back = (struct rt_entry *)rh;
}
int
rtioctl(action, ort)
int action;
struct rtuentry *ort;

View File

@ -33,7 +33,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)timer.c 8.1 (Berkeley) 6/5/93";*/
static char *rcsid = "$Id: timer.c,v 1.5 1994/05/13 08:04:56 mycroft Exp $";
static char *rcsid = "$Id: timer.c,v 1.6 1994/12/18 05:44:02 cgd Exp $";
#endif /* not lint */
/*
@ -56,7 +56,6 @@ timer()
register struct rt_entry *rt;
struct rthash *base = hosthash;
int doinghost = 1, timetobroadcast;
extern int externalinterfaces;
(void) gettimeofday(&now, (struct timezone *)NULL);
faketime += TIMER_RATE;
@ -103,6 +102,7 @@ again:
/*
* On hangup, let everyone know we're going away.
*/
void
hup()
{
register struct rthash *rh;

View File

@ -33,7 +33,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)trace.c 8.1 (Berkeley) 6/5/93";*/
static char *rcsid = "$Id: trace.c,v 1.6 1994/09/23 14:28:11 mycroft Exp $";
static char *rcsid = "$Id: trace.c,v 1.7 1994/12/18 05:44:04 cgd Exp $";
#endif /* not lint */
/*
@ -55,6 +55,11 @@ int traceactions = 0;
static struct timeval lastlog;
static char *savetracename;
static int iftraceinit __P((struct interface *, struct ifdebug *));
void dumpif __P((FILE *, struct interface *));
void dumptrace __P((FILE *, char *, struct ifdebug *));
void
traceinit(ifp)
register struct interface *ifp;
{
@ -67,7 +72,7 @@ traceinit(ifp)
fprintf(stderr, "traceinit: can't init %s\n", ifp->int_name);
}
static
static int
iftraceinit(ifp, ifd)
struct interface *ifp;
register struct ifdebug *ifd;
@ -88,6 +93,7 @@ iftraceinit(ifp, ifd)
return (1);
}
void
traceon(file)
char *file;
{
@ -108,6 +114,7 @@ traceon(file)
fprintf(ftrace, "Tracing enabled %s\n", ctime((time_t *)&now.tv_sec));
}
void
traceoff()
{
if (!traceactions)
@ -151,6 +158,7 @@ sigtrace(s)
* traceactions + tracehistory (packets and contents after change)
* traceactions + tracepackets + tracecontents
*/
void
bumploglevel()
{
@ -184,6 +192,7 @@ bumploglevel()
fflush(ftrace);
}
void
trace(ifd, who, p, len, m)
register struct ifdebug *ifd;
struct sockaddr *who;
@ -216,6 +225,7 @@ trace(ifd, who, p, len, m)
t->ift_metric = m;
}
void
traceaction(fd, action, rt)
FILE *fd;
char *action;
@ -243,7 +253,6 @@ traceaction(fd, action, rt)
register struct bits *p;
register int first;
char *cp;
struct interface *ifp;
if (fd == NULL)
return;
@ -287,6 +296,7 @@ traceaction(fd, action, rt)
traceoff();
}
void
tracenewmetric(fd, rt, newmetric)
FILE *fd;
struct rt_entry *rt;
@ -310,6 +320,7 @@ tracenewmetric(fd, rt, newmetric)
traceoff();
}
void
dumpif(fd, ifp)
FILE *fd;
register struct interface *ifp;
@ -325,6 +336,7 @@ dumpif(fd, ifp)
}
}
void
dumptrace(fd, dir, ifd)
FILE *fd;
char *dir;
@ -353,6 +365,7 @@ dumptrace(fd, dir, ifd)
}
}
void
dumppacket(fd, dir, who, cp, size, stamp)
FILE *fd;
struct sockaddr_in *who; /* should be sockaddr */
@ -371,9 +384,9 @@ dumppacket(fd, dir, who, cp, size, stamp)
ctime((time_t *)&stamp->tv_sec));
else {
fprintf(fd, "Bad cmd 0x%x %s %x.%d %.19s\n", msg->rip_cmd,
dir, inet_ntoa(who->sin_addr), ntohs(who->sin_port));
fprintf(fd, "size=%d cp=%x packet=%x\n", size, cp, packet,
dir, inet_ntoa(who->sin_addr), ntohs(who->sin_port),
ctime((time_t *)&stamp->tv_sec));
fprintf(fd, "size=%d cp=%x packet=%x\n", size, cp, packet);
fflush(fd);
return;
}