diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-03-23 04:18:42 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-03-23 04:18:42 +0000 |
commit | d445ea6639a25195558fb57542dd3fde0ff042cb (patch) | |
tree | bafc162f6cb2804c956a161b0265bd421c585623 /usr.sbin | |
parent | db9c2d97fd16c0d0acb4740de835ae7cb6d0c4aa (diff) |
cleanup for -Wall; fix routed+rarpd interaction pointed out by
Pierre.Beyssac@hsc.fr; and fix a buglet of greek origin.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/rarpd/arptab.c | 23 | ||||
-rw-r--r-- | usr.sbin/rarpd/rarpd.c | 35 |
2 files changed, 32 insertions, 26 deletions
diff --git a/usr.sbin/rarpd/arptab.c b/usr.sbin/rarpd/arptab.c index 596e4eb3002..dd69c15bd57 100644 --- a/usr.sbin/rarpd/arptab.c +++ b/usr.sbin/rarpd/arptab.c @@ -68,6 +68,8 @@ static char sccsid[] = "@(#)arp.c 8.2 (Berkeley) 1/2/94"; #include <errno.h> #include <nlist.h> #include <stdio.h> +#include <unistd.h> +#include <stdlib.h> #include <paths.h> #include <syslog.h> @@ -94,24 +96,30 @@ struct { char m_space[512]; } m_rtmsg; +int arptab_set __P((u_char *, u_int32_t)); +int rtmsg __P((int)); + /* * Set an individual arp entry */ +int arptab_set(eaddr, host) u_char *eaddr; - u_long host; + u_int32_t host; { register struct sockaddr_inarp *sin = &sin_m; register struct sockaddr_dl *sdl; register struct rt_msghdr *rtm = &(m_rtmsg.m_rtm); struct timeval time; + int rt; getsocket(); pid = getpid(); + sdl_m = blank_sdl; sin_m = blank_sin; sin->sin_addr.s_addr = host; - bcopy((char *)eaddr, (u_char *)LLADDR(&sdl_m), 6); + memcpy((u_char *)LLADDR(&sdl_m), (char *)eaddr, 6); sdl_m.sdl_alen = 6; doing_proxy = flags = export_only = expire_time = 0; gettimeofday(&time, 0); @@ -163,12 +171,15 @@ overwrite: } sdl_m.sdl_type = sdl->sdl_type; sdl_m.sdl_index = sdl->sdl_index; + rt = rtmsg(RTM_ADD); close(s); s = -1; - return (rtmsg(RTM_ADD)); + return (rt); } +int rtmsg(cmd) + int cmd; { static int seq; int rlen; @@ -179,7 +190,7 @@ rtmsg(cmd) errno = 0; if (cmd == RTM_DELETE) goto doit; - bzero((char *)&m_rtmsg, sizeof(m_rtmsg)); + memset((char *)&m_rtmsg, 0, sizeof(m_rtmsg)); rtm->rtm_flags = flags; rtm->rtm_version = RTM_VERSION; @@ -207,7 +218,9 @@ rtmsg(cmd) } #define NEXTADDR(w, s) \ if (rtm->rtm_addrs & (w)) { \ - bcopy((char *)&s, cp, sizeof(s)); cp += sizeof(s);} + memcpy(cp, (char *)&s, sizeof(s)); \ + cp += sizeof(s); \ + } NEXTADDR(RTA_DST, sin_m); NEXTADDR(RTA_GATEWAY, sdl_m); diff --git a/usr.sbin/rarpd/rarpd.c b/usr.sbin/rarpd/rarpd.c index 423f97b0b66..7d0c71762c7 100644 --- a/usr.sbin/rarpd/rarpd.c +++ b/usr.sbin/rarpd/rarpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rarpd.c,v 1.16 1997/12/17 08:55:22 deraadt Exp $ */ +/* $OpenBSD: rarpd.c,v 1.17 1998/03/23 04:18:41 deraadt Exp $ */ /* $NetBSD: rarpd.c,v 1.12 1996/03/21 18:28:23 jtc Exp $ */ /* @@ -28,7 +28,7 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char rcsid[] = "$OpenBSD: rarpd.c,v 1.16 1997/12/17 08:55:22 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: rarpd.c,v 1.17 1998/03/23 04:18:41 deraadt Exp $"; #endif @@ -108,20 +108,13 @@ main(argc, argv) char **argv; { int op, pid, devnull, f; - char *ifname, *hostname, *name; - + char *ifname, *hostname; + extern char *__progname; extern char *optarg; extern int optind, opterr; - if ((name = strrchr(argv[0], '/'))) - ++name; - else - name = argv[0]; - if (*name == '-') - ++name; - /* All error reporting is done through syslogs. */ - openlog(name, LOG_PID | LOG_CONS, LOG_DAEMON); + openlog(__progname, LOG_PID | LOG_CONS, LOG_DAEMON); opterr = 0; while ((op = getopt(argc, argv, "adf")) != -1) { @@ -399,11 +392,11 @@ rarp_check(p, len) err(NONFATAL, "request fails sanity check"); return 0; } - if (bcmp((char *) &ep->ether_shost, (char *) &ap->arp_sha, 6) != 0) { + if (memcmp((char *) &ep->ether_shost, (char *) &ap->arp_sha, 6) != 0) { err(NONFATAL, "ether/arp sender address mismatch"); return 0; } - if (bcmp((char *) &ap->arp_sha, (char *) &ap->arp_tha, 6) != 0) { + if (memcmp((char *) &ap->arp_sha, (char *) &ap->arp_tha, 6) != 0) { err(NONFATAL, "ether/arp target address mismatch"); return 0; } @@ -655,7 +648,7 @@ lookup_eaddr(ifname, eaddr) sdl->sdl_alen != 6) continue; if (!strncmp(ifr->ifr_name, ifname, sizeof(ifr->ifr_name))) { - bcopy((caddr_t)LLADDR(sdl), (caddr_t)eaddr, 6); + memcpy((caddr_t)eaddr, (caddr_t)LLADDR(sdl), 6); if (dflag) fprintf(stderr, "%s: %x:%x:%x:%x:%x:%x\n", ifr->ifr_name, eaddr[0], eaddr[1], @@ -734,7 +727,7 @@ update_arptab(ep, ipaddr) because AF_UNSPEC is zero and the kernel assumes that a zero sa_family means that the real sa_family value is in sa_len. */ request.arp_ha.sa_len = 16; /* XXX */ - bcopy((char *) ep, (char *) request.arp_ha.sa_data, 6); + memcpy((char *) request.arp_ha.sa_data, (char *) ep, 6); s = socket(AF_INET, SOCK_DGRAM, 0); if (ioctl(s, SIOCSARP, (caddr_t) & request) < 0) { @@ -797,13 +790,13 @@ rarp_reply(ii, ep, ipaddr) ap->ea_hdr.ar_pro = htons(ETHERTYPE_IP); ap->arp_op = htons(ARPOP_REVREPLY); - bcopy((char *) &ap->arp_sha, (char *) &ep->ether_dhost, 6); - bcopy((char *) ii->ii_eaddr, (char *) &ep->ether_shost, 6); - bcopy((char *) ii->ii_eaddr, (char *) &ap->arp_sha, 6); + memcpy((char *) &ep->ether_dhost, (char *) &ap->arp_sha, 6); + memcpy((char *) &ep->ether_shost, (char *) ii->ii_eaddr, 6); + memcpy((char *) &ap->arp_sha, (char *) ii->ii_eaddr, 6); - bcopy((char *) &ipaddr, (char *) ap->arp_tpa, 4); + memcpy((char *) ap->arp_tpa, (char *) &ipaddr, 4); /* Target hardware is unchanged. */ - bcopy((char *) &ii->ii_ipaddr, (char *) ap->arp_spa, 4); + memcpy((char *) ap->arp_spa, (char *) &ii->ii_ipaddr, 4); len = sizeof(*ep) + sizeof(*ap); n = write(ii->ii_fd, (char *) ep, len); |