clean up, for off_t... ugliest 'cleaning' possible, i think...

This commit is contained in:
cgd 1994-03-28 10:29:31 +00:00
parent e26987fe07
commit 1e6c1e0ef2
8 changed files with 95 additions and 76 deletions

View File

@ -33,7 +33,7 @@
#ifndef lint #ifndef lint
/*static char sccsid[] = "from: @(#)if.c 5.15 (Berkeley) 3/1/91";*/ /*static char sccsid[] = "from: @(#)if.c 5.15 (Berkeley) 3/1/91";*/
static char rcsid[] = "$Id: if.c,v 1.5 1994/03/03 22:03:33 deraadt Exp $"; static char rcsid[] = "$Id: if.c,v 1.6 1994/03/28 10:29:31 cgd Exp $";
#endif /* not lint */ #endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
@ -54,6 +54,8 @@ static char rcsid[] = "$Id: if.c,v 1.5 1994/03/03 22:03:33 deraadt Exp $";
#include <netiso/iso_var.h> #include <netiso/iso_var.h>
#endif /* ISO */ #endif /* ISO */
#include <nlist.h>
#include <kvm.h>
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
@ -99,7 +101,7 @@ intpr(interval, ifnetaddr)
sidewaysintpr((unsigned)interval, ifnetaddr); sidewaysintpr((unsigned)interval, ifnetaddr);
return; return;
} }
kvm_read(ifnetaddr, (char *)&ifnetaddr, sizeof ifnetaddr); kvm_read((void *)(long)ifnetaddr, (char *)&ifnetaddr, sizeof ifnetaddr);
printf("%-5.5s %-5.5s %-11.11s %-15.15s %8.8s %5.5s %8.8s %5.5s", printf("%-5.5s %-5.5s %-11.11s %-15.15s %8.8s %5.5s %8.8s %5.5s",
"Name", "Mtu", "Network", "Address", "Ipkts", "Ierrs", "Name", "Mtu", "Network", "Address", "Ipkts", "Ierrs",
"Opkts", "Oerrs"); "Opkts", "Oerrs");
@ -120,10 +122,11 @@ intpr(interval, ifnetaddr)
struct in_addr inet_makeaddr(); struct in_addr inet_makeaddr();
if (ifaddraddr == 0) { if (ifaddraddr == 0) {
kvm_read(ifnetaddr, (char *)&ifnet, sizeof ifnet); kvm_read((void *)(long)ifnetaddr, (char *)&ifnet,
kvm_read((off_t)ifnet.if_name, name, 16); sizeof ifnet);
kvm_read(ifnet.if_name, name, 16);
name[15] = '\0'; name[15] = '\0';
ifnetaddr = (off_t) ifnet.if_next; ifnetaddr = (off_t)(long)ifnet.if_next;
if (interface != 0 && if (interface != 0 &&
(strcmp(name, interface) != 0 || unit != ifnet.if_unit)) (strcmp(name, interface) != 0 || unit != ifnet.if_unit))
continue; continue;
@ -132,16 +135,17 @@ intpr(interval, ifnetaddr)
if ((ifnet.if_flags&IFF_UP) == 0) if ((ifnet.if_flags&IFF_UP) == 0)
*cp++ = '*'; *cp++ = '*';
*cp = '\0'; *cp = '\0';
ifaddraddr = (off_t)ifnet.if_addrlist; ifaddraddr = (off_t)(long)ifnet.if_addrlist;
} }
printf("%-5.5s %-5d ", name, ifnet.if_mtu); printf("%-5.5s %-5d ", name, ifnet.if_mtu);
if (ifaddraddr == 0) { if (ifaddraddr == 0) {
printf("%-11.11s ", "none"); printf("%-11.11s ", "none");
printf("%-15.15s ", "none"); printf("%-15.15s ", "none");
} else { } else {
kvm_read(ifaddraddr, (char *)&ifaddr, sizeof ifaddr); kvm_read((void *)(long)ifaddraddr, (char *)&ifaddr,
sizeof ifaddr);
#define CP(x) ((char *)(x)) #define CP(x) ((char *)(x))
cp = (CP(ifaddr.ifa.ifa_addr) - CP(ifaddraddr)) + cp = (CP(ifaddr.ifa.ifa_addr) - CP((long)ifaddraddr)) +
CP(&ifaddr); sa = (struct sockaddr *)cp; CP(&ifaddr); sa = (struct sockaddr *)cp;
switch (sa->sa_family) { switch (sa->sa_family) {
case AF_UNSPEC: case AF_UNSPEC:
@ -222,7 +226,7 @@ intpr(interval, ifnetaddr)
putchar(' '); putchar(' ');
break; break;
} }
ifaddraddr = (off_t)ifaddr.ifa.ifa_next; ifaddraddr = (off_t)(long)ifaddr.ifa.ifa_next;
} }
printf("%8d %5d %8d %5d %5d", printf("%8d %5d %8d %5d %5d",
ifnet.if_ipackets, ifnet.if_ierrors, ifnet.if_ipackets, ifnet.if_ierrors,
@ -267,7 +271,7 @@ sidewaysintpr(interval, off)
int oldmask; int oldmask;
void catchalarm(); void catchalarm();
kvm_read(off, (char *)&firstifnet, sizeof (off_t)); kvm_read((void *)(long)off, (char *)&firstifnet, sizeof (off_t));
lastif = iftot; lastif = iftot;
sum = iftot + MAXIF - 1; sum = iftot + MAXIF - 1;
total = sum - 1; total = sum - 1;
@ -275,9 +279,9 @@ sidewaysintpr(interval, off)
for (off = firstifnet, ip = iftot; off;) { for (off = firstifnet, ip = iftot; off;) {
char *cp; char *cp;
kvm_read(off, (char *)&ifnet, sizeof ifnet); kvm_read((void *)(long)off, (char *)&ifnet, sizeof ifnet);
ip->ift_name[0] = '('; ip->ift_name[0] = '(';
kvm_read((off_t)ifnet.if_name, ip->ift_name + 1, 15); kvm_read(ifnet.if_name, ip->ift_name + 1, 15);
if (interface && strcmp(ip->ift_name + 1, interface) == 0 && if (interface && strcmp(ip->ift_name + 1, interface) == 0 &&
unit == ifnet.if_unit) unit == ifnet.if_unit)
interesting = ip; interesting = ip;
@ -287,7 +291,7 @@ sidewaysintpr(interval, off)
ip++; ip++;
if (ip >= iftot + MAXIF - 2) if (ip >= iftot + MAXIF - 2)
break; break;
off = (off_t) ifnet.if_next; off = (off_t)(long)ifnet.if_next;
} }
lastif = ip; lastif = ip;
@ -330,7 +334,7 @@ loop:
sum->ift_co = 0; sum->ift_co = 0;
sum->ift_dr = 0; sum->ift_dr = 0;
for (off = firstifnet, ip = iftot; off && ip < lastif; ip++) { for (off = firstifnet, ip = iftot; off && ip < lastif; ip++) {
kvm_read(off, (char *)&ifnet, sizeof ifnet); kvm_read((void *)(long)off, (char *)&ifnet, sizeof ifnet);
if (ip == interesting) { if (ip == interesting) {
printf("%8d %5d %8d %5d %5d", printf("%8d %5d %8d %5d %5d",
ifnet.if_ipackets - ip->ift_ip, ifnet.if_ipackets - ip->ift_ip,
@ -354,7 +358,7 @@ loop:
sum->ift_oe += ip->ift_oe; sum->ift_oe += ip->ift_oe;
sum->ift_co += ip->ift_co; sum->ift_co += ip->ift_co;
sum->ift_dr += ip->ift_dr; sum->ift_dr += ip->ift_dr;
off = (off_t) ifnet.if_next; off = (off_t)(long)ifnet.if_next;
} }
if (lastif - iftot > 0) { if (lastif - iftot > 0) {
printf(" %8d %5d %8d %5d %5d", printf(" %8d %5d %8d %5d %5d",

View File

@ -66,6 +66,8 @@ static char rcsid[] = "inet.c,v 1.4 1993/05/20 12:03:49 cgd Exp";
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <nlist.h>
#include <kvm.h>
struct inpcb inpcb; struct inpcb inpcb;
struct tcpcb tcpcb; struct tcpcb tcpcb;
@ -95,15 +97,15 @@ protopr(off, name)
if (off == 0) if (off == 0)
return; return;
istcp = strcmp(name, "tcp") == 0; istcp = strcmp(name, "tcp") == 0;
kvm_read(off, (char *)&cb, sizeof (struct inpcb)); kvm_read((void *)(long)off, (char *)&cb, sizeof (struct inpcb));
inpcb = cb; inpcb = cb;
prev = (struct inpcb *)off; prev = (struct inpcb *)(long)off;
if (inpcb.inp_next == (struct inpcb *)off) if (inpcb.inp_next == (struct inpcb *)(long)off)
return; return;
while (inpcb.inp_next != (struct inpcb *)off) { while (inpcb.inp_next != (struct inpcb *)(long)off) {
next = inpcb.inp_next; next = inpcb.inp_next;
kvm_read((off_t)next, (char *)&inpcb, sizeof (inpcb)); kvm_read(next, (char *)&inpcb, sizeof (inpcb));
if (inpcb.inp_prev != prev) { if (inpcb.inp_prev != prev) {
printf("???\n"); printf("???\n");
break; break;
@ -113,11 +115,10 @@ protopr(off, name)
prev = next; prev = next;
continue; continue;
} }
kvm_read((off_t)inpcb.inp_socket, kvm_read(inpcb.inp_socket, (char *)&sockb, sizeof (sockb));
(char *)&sockb, sizeof (sockb));
if (istcp) { if (istcp) {
kvm_read((off_t)inpcb.inp_ppcb, kvm_read(inpcb.inp_ppcb, (char *)&tcpcb,
(char *)&tcpcb, sizeof (tcpcb)); sizeof (tcpcb));
} }
if (first) { if (first) {
printf("Active Internet connections"); printf("Active Internet connections");
@ -165,7 +166,7 @@ tcp_stats(off, name)
if (off == 0) if (off == 0)
return; return;
printf ("%s:\n", name); printf ("%s:\n", name);
kvm_read(off, (char *)&tcpstat, sizeof (tcpstat)); kvm_read((void *)(long)off, (char *)&tcpstat, sizeof (tcpstat));
#define p(f, m) printf(m, tcpstat.f, plural(tcpstat.f)) #define p(f, m) printf(m, tcpstat.f, plural(tcpstat.f))
#define p2(f1, f2, m) printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2, plural(tcpstat.f2)) #define p2(f1, f2, m) printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2, plural(tcpstat.f2))
@ -230,7 +231,7 @@ udp_stats(off, name)
if (off == 0) if (off == 0)
return; return;
kvm_read(off, (char *)&udpstat, sizeof (udpstat)); kvm_read((void *)(long)off, (char *)&udpstat, sizeof (udpstat));
printf("%s:\n\t%u packet%s sent\n", name, printf("%s:\n\t%u packet%s sent\n", name,
udpstat.udps_opackets, plural(udpstat.udps_opackets)); udpstat.udps_opackets, plural(udpstat.udps_opackets));
printf("\t%u packet%s received\n", printf("\t%u packet%s received\n",
@ -262,7 +263,7 @@ ip_stats(off, name)
if (off == 0) if (off == 0)
return; return;
kvm_read(off, (char *)&ipstat, sizeof (ipstat)); kvm_read((void *)(long)off, (char *)&ipstat, sizeof (ipstat));
printf("%s:\n\t%u total packets received\n", name, printf("%s:\n\t%u total packets received\n", name,
ipstat.ips_total); ipstat.ips_total);
printf("\t%u bad header checksum%s\n", printf("\t%u bad header checksum%s\n",
@ -319,7 +320,7 @@ icmp_stats(off, name)
if (off == 0) if (off == 0)
return; return;
kvm_read(off, (char *)&icmpstat, sizeof (icmpstat)); kvm_read((void *)(long)off, (char *)&icmpstat, sizeof (icmpstat));
printf("%s:\n\t%u call%s to icmp_error\n", name, printf("%s:\n\t%u call%s to icmp_error\n", name,
icmpstat.icps_error, plural(icmpstat.icps_error)); icmpstat.icps_error, plural(icmpstat.icps_error));
printf("\t%u error%s not generated 'cuz old message was icmp\n", printf("\t%u error%s not generated 'cuz old message was icmp\n",
@ -373,7 +374,7 @@ igmp_stats(off, name)
if (off == 0) if (off == 0)
return; return;
kvm_read(off, (char *)&igmpstat, sizeof (igmpstat)); kvm_read((void *)(long)off, (char *)&igmpstat, sizeof (igmpstat));
printf("%s:\n", name ); printf("%s:\n", name );
printf("\t%u message%s received\n", printf("\t%u message%s received\n",
igmpstat.igps_rcv_total, plural(igmpstat.igps_rcv_total)); igmpstat.igps_rcv_total, plural(igmpstat.igps_rcv_total));

View File

@ -33,7 +33,7 @@
#ifndef lint #ifndef lint
/*static char sccsid[] = "from: @(#)iso.c 5.6 (Berkeley) 4/27/91";*/ /*static char sccsid[] = "from: @(#)iso.c 5.6 (Berkeley) 4/27/91";*/
static char rcsid[] = "$Id: iso.c,v 1.6 1994/03/26 04:08:45 glass Exp $"; static char rcsid[] = "$Id: iso.c,v 1.7 1994/03/28 10:29:43 cgd Exp $";
#endif /* not lint */ #endif /* not lint */
/******************************************************************************* /*******************************************************************************
@ -93,6 +93,8 @@ SOFTWARE.
#endif #endif
#include <netiso/cons_pcb.h> #include <netiso/cons_pcb.h>
#include <netdb.h> #include <netdb.h>
#include <nlist.h>
#include <kvm.h>
char *tp_sstring[] = { char *tp_sstring[] = {
"ST_ERROR(0x0)", "ST_ERROR(0x0)",
@ -145,7 +147,8 @@ esis_stats(off, name)
if (off == 0) if (off == 0)
return; return;
kvm_read(off, (char *)&esis_stat, sizeof (struct esis_stat)); kvm_read((void *)(long)off, (char *)&esis_stat,
sizeof (struct esis_stat));
printf("%s:\n", name); printf("%s:\n", name);
printf("\t%d esh sent, %d esh received\n", esis_stat.es_eshsent, printf("\t%d esh sent, %d esh received\n", esis_stat.es_eshsent,
esis_stat.es_eshrcvd); esis_stat.es_eshrcvd);
@ -173,7 +176,7 @@ clnp_stats(off, name)
if (off == 0) if (off == 0)
return; return;
kvm_read(off, (char *)&clnp_stat, sizeof (clnp_stat)); kvm_read((void *)(long)off, (char *)&clnp_stat, sizeof (clnp_stat));
printf("%s:\n\t%d total packets sent\n", name, clnp_stat.cns_sent); printf("%s:\n\t%d total packets sent\n", name, clnp_stat.cns_sent);
printf("\t%d total fragments sent\n", clnp_stat.cns_fragments); printf("\t%d total fragments sent\n", clnp_stat.cns_fragments);
@ -207,7 +210,7 @@ cltp_stats(off, name)
if (off == 0) if (off == 0)
return; return;
kvm_read(off, (char *)&cltpstat, sizeof (cltpstat)); kvm_read((void *)(long)off, (char *)&cltpstat, sizeof (cltpstat));
printf("%s:\n\t%u incomplete header%s\n", name, printf("%s:\n\t%u incomplete header%s\n", name,
cltpstat.cltps_hdrops, plural(cltpstat.cltps_hdrops)); cltpstat.cltps_hdrops, plural(cltpstat.cltps_hdrops));
printf("\t%u bad data length field%s\n", printf("\t%u bad data length field%s\n",
@ -224,7 +227,7 @@ struct sockaddr_iso siso;
char data[128]; char data[128];
} laddr, faddr; } laddr, faddr;
#define kget(o, p) \ #define kget(o, p) \
(kvm_read((off_t)(o), (char *)&p, sizeof (p))) (kvm_read((void *)(long)(o), (char *)&p, sizeof (p)))
extern int Aflag; extern int Aflag;
extern int aflag; extern int aflag;
extern int nflag; extern int nflag;
@ -253,10 +256,10 @@ iso_protopr(off, name)
} }
kget(off, cb); kget(off, cb);
isopcb = cb; isopcb = cb;
prev = (struct isopcb *)off; prev = (struct isopcb *)(long)off;
if (isopcb.isop_next == (struct isopcb *)off) if (isopcb.isop_next == (struct isopcb *)(long)off)
return; return;
while (isopcb.isop_next != (struct isopcb *)off) { while (isopcb.isop_next != (struct isopcb *)(long)off) {
next = isopcb.isop_next; next = isopcb.isop_next;
kget(next, isopcb); kget(next, isopcb);
if (isopcb.isop_prev != prev) { if (isopcb.isop_prev != prev) {
@ -293,7 +296,7 @@ iso_protopr(off, name)
} }
if (Aflag) if (Aflag)
printf("%8x ", printf("%8x ",
(istp ? (off_t)sockb.so_tpcb : (off_t)next)); (istp ? (long)sockb.so_tpcb : (long)next));
printf("%-5.5s %6d %6d ", name, sockb.so_rcv.sb_cc, printf("%-5.5s %6d %6d ", name, sockb.so_rcv.sb_cc,
sockb.so_snd.sb_cc); sockb.so_snd.sb_cc);
if (isopcb.isop_laddr == 0) if (isopcb.isop_laddr == 0)

View File

@ -33,10 +33,12 @@
#ifndef lint #ifndef lint
/*static char sccsid[] = "from: @(#)mbuf.c 5.10 (Berkeley) 1/30/91";*/ /*static char sccsid[] = "from: @(#)mbuf.c 5.10 (Berkeley) 1/30/91";*/
static char rcsid[] = "$Id: mbuf.c,v 1.2 1993/08/01 18:10:50 mycroft Exp $"; static char rcsid[] = "$Id: mbuf.c,v 1.3 1994/03/28 10:29:48 cgd Exp $";
#endif /* not lint */ #endif /* not lint */
#include <stdio.h> #include <stdio.h>
#include <nlist.h>
#include <kvm.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/mbuf.h> #include <sys/mbuf.h>
#define YES 1 #define YES 1
@ -86,7 +88,7 @@ mbpr(mbaddr)
printf("mbstat: symbol not in namelist\n"); printf("mbstat: symbol not in namelist\n");
return; return;
} }
if (kvm_read(mbaddr, (char *)&mbstat, sizeof (mbstat)) if (kvm_read((void *)(long)mbaddr, (char *)&mbstat, sizeof (mbstat))
!= sizeof (mbstat)) { != sizeof (mbstat)) {
printf("mbstat: bad read\n"); printf("mbstat: bad read\n");
return; return;

View File

@ -5,10 +5,12 @@
*/ */
#ifndef lint #ifndef lint
static char rcsid[] = "$Id: mroute.c,v 1.1 1994/01/11 19:42:55 brezak Exp $"; static char rcsid[] = "$Id: mroute.c,v 1.2 1994/03/28 10:29:52 cgd Exp $";
#endif /* not lint */ #endif /* not lint */
#include <stdio.h> #include <stdio.h>
#include <nlist.h>
#include <kvm.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/mbuf.h> #include <sys/mbuf.h>
#include <netinet/in.h> #include <netinet/in.h>
@ -59,7 +61,7 @@ mroutepr(mrpaddr, mrtaddr, vifaddr)
return; return;
} }
kvm_read(mrpaddr, (char *)&mrtproto, sizeof(mrtproto)); kvm_read((void *)(long)mrpaddr, (char *)&mrtproto, sizeof(mrtproto));
switch (mrtproto) { switch (mrtproto) {
case 0: case 0:
printf("no multicast routing compiled into this system\n"); printf("no multicast routing compiled into this system\n");
@ -85,7 +87,7 @@ mroutepr(mrpaddr, mrtaddr, vifaddr)
saved_nflag = nflag; saved_nflag = nflag;
nflag = 1; nflag = 1;
kvm_read(vifaddr, (char *)viftable, sizeof(viftable)); kvm_read((void *)(long)vifaddr, (char *)viftable, sizeof(viftable));
banner_printed = 0; banner_printed = 0;
for (vifi = 0, v = viftable; vifi < MAXVIFS; ++vifi, ++v) { for (vifi = 0, v = viftable; vifi < MAXVIFS; ++vifi, ++v) {
struct in_addr v_lcl_grps[1024]; struct in_addr v_lcl_grps[1024];
@ -119,7 +121,7 @@ mroutepr(mrpaddr, mrtaddr, vifaddr)
} }
if (!banner_printed) printf("\nVirtual Interface Table is empty\n"); if (!banner_printed) printf("\nVirtual Interface Table is empty\n");
kvm_read(mrtaddr, (char *)mrttable, sizeof(mrttable)); kvm_read((void *)(long)mrtaddr, (char *)mrttable, sizeof(mrttable));
banner_printed = 0; banner_printed = 0;
for (i = 0; i < MRTHASHSIZ; ++i) { for (i = 0; i < MRTHASHSIZ; ++i) {
for (mp = mrttable[i]; mp != NULL; for (mp = mrttable[i]; mp != NULL;
@ -176,7 +178,7 @@ mrt_stats(mrpaddr, mstaddr)
return; return;
} }
kvm_read(mrpaddr, (char *)&mrtproto, sizeof(mrtproto)); kvm_read((void *)(long)mrpaddr, (char *)&mrtproto, sizeof(mrtproto));
switch (mrtproto) { switch (mrtproto) {
case 0: case 0:
printf("no multicast routing compiled into this system\n"); printf("no multicast routing compiled into this system\n");
@ -195,7 +197,7 @@ mrt_stats(mrpaddr, mstaddr)
return; return;
} }
kvm_read(mstaddr, (char *)&mrtstat, sizeof(mrtstat)); kvm_read((void *)(long)mstaddr, (char *)&mrtstat, sizeof(mrtstat));
printf("multicast routing:\n"); printf("multicast routing:\n");
printf(" %10u multicast route lookup%s\n", printf(" %10u multicast route lookup%s\n",
mrtstat.mrts_mrt_lookups, plural(mrtstat.mrts_mrt_lookups)); mrtstat.mrts_mrt_lookups, plural(mrtstat.mrts_mrt_lookups));

View File

@ -33,7 +33,7 @@
#ifndef lint #ifndef lint
/*static char sccsid[] = "from: @(#)ns.c 5.13 (Berkeley) 3/1/91";*/ /*static char sccsid[] = "from: @(#)ns.c 5.13 (Berkeley) 3/1/91";*/
static char rcsid[] = "$Id: ns.c,v 1.4 1993/08/01 18:10:49 mycroft Exp $"; static char rcsid[] = "$Id: ns.c,v 1.5 1994/03/28 10:29:55 cgd Exp $";
#endif /* not lint */ #endif /* not lint */
#include <sys/param.h> #include <sys/param.h>
@ -60,6 +60,7 @@ static char rcsid[] = "$Id: ns.c,v 1.4 1993/08/01 18:10:49 mycroft Exp $";
#include <netns/spp_debug.h> #include <netns/spp_debug.h>
#include <nlist.h> #include <nlist.h>
#include <kvm.h>
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -93,16 +94,16 @@ nsprotopr(off, name)
if (off == 0) if (off == 0)
return; return;
isspp = strcmp(name, "spp") == 0; isspp = strcmp(name, "spp") == 0;
kvm_read(off, (char *)&cb, sizeof (struct nspcb)); kvm_read((void *)(long)off, (char *)&cb, sizeof (struct nspcb));
nspcb = cb; nspcb = cb;
prev = (struct nspcb *)off; prev = (struct nspcb *)(long)off;
if (nspcb.nsp_next == (struct nspcb *)off) if (nspcb.nsp_next == (struct nspcb *)(long)off)
return; return;
for (;nspcb.nsp_next != (struct nspcb *)off; prev = next) { for (;nspcb.nsp_next != (struct nspcb *)(long)off; prev = next) {
off_t ppcb; off_t ppcb;
next = nspcb.nsp_next; next = nspcb.nsp_next;
kvm_read((off_t)next, (char *)&nspcb, sizeof (nspcb)); kvm_read(next, (char *)&nspcb, sizeof (nspcb));
if (nspcb.nsp_prev != prev) { if (nspcb.nsp_prev != prev) {
printf("???\n"); printf("???\n");
break; break;
@ -110,12 +111,13 @@ nsprotopr(off, name)
if (!aflag && ns_nullhost(nspcb.nsp_faddr) ) { if (!aflag && ns_nullhost(nspcb.nsp_faddr) ) {
continue; continue;
} }
kvm_read((off_t)nspcb.nsp_socket, kvm_read(nspcb.nsp_socket,
(char *)&sockb, sizeof (sockb)); (char *)&sockb, sizeof (sockb));
ppcb = (off_t) nspcb.nsp_pcb; ppcb = (off_t)(long)nspcb.nsp_pcb;
if (ppcb) { if (ppcb) {
if (isspp) { if (isspp) {
kvm_read(ppcb, (char *)&sppcb, sizeof (sppcb)); kvm_read((void *)(long)ppcb, (char *)&sppcb,
sizeof (sppcb));
} else continue; } else continue;
} else } else
if (isspp) continue; if (isspp) continue;
@ -165,7 +167,7 @@ spp_stats(off, name)
if (off == 0) if (off == 0)
return; return;
kvm_read(off, (char *)&spp_istat, sizeof (spp_istat)); kvm_read((void *)(long)off, (char *)&spp_istat, sizeof (spp_istat));
printf("%s:\n", name); printf("%s:\n", name);
ANY(spp_istat.nonucn, "connection", " dropped due to no new sockets "); ANY(spp_istat.nonucn, "connection", " dropped due to no new sockets ");
ANY(spp_istat.gonawy, "connection", " terminated due to our end dying"); ANY(spp_istat.gonawy, "connection", " terminated due to our end dying");
@ -241,7 +243,7 @@ idp_stats(off, name)
if (off == 0) if (off == 0)
return; return;
kvm_read(off, (char *)&idpstat, sizeof (idpstat)); kvm_read((void *)(long)off, (char *)&idpstat, sizeof (idpstat));
printf("%s:\n", name); printf("%s:\n", name);
ANY(idpstat.idps_toosmall, "packet", " smaller than a header"); ANY(idpstat.idps_toosmall, "packet", " smaller than a header");
ANY(idpstat.idps_tooshort, "packet", " smaller than advertised"); ANY(idpstat.idps_tooshort, "packet", " smaller than advertised");
@ -279,7 +281,7 @@ nserr_stats(off, name)
if (off == 0) if (off == 0)
return; return;
kvm_read(off, (char *)&ns_errstat, sizeof (ns_errstat)); kvm_read((void *)(long)off, (char *)&ns_errstat, sizeof (ns_errstat));
printf("NS error statistics:\n"); printf("NS error statistics:\n");
ANY(ns_errstat.ns_es_error, "call", " to ns_error"); ANY(ns_errstat.ns_es_error, "call", " to ns_error");
ANY(ns_errstat.ns_es_oldshort, "error", ANY(ns_errstat.ns_es_oldshort, "error",

View File

@ -33,7 +33,7 @@
#ifndef lint #ifndef lint
/*static char sccsid[] = "from: @(#)route.c 5.20 (Berkeley) 11/29/90";*/ /*static char sccsid[] = "from: @(#)route.c 5.20 (Berkeley) 11/29/90";*/
static char rcsid[] = "$Id: route.c,v 1.7 1994/03/07 09:19:56 cgd Exp $"; static char rcsid[] = "$Id: route.c,v 1.8 1994/03/28 10:29:58 cgd Exp $";
#endif /* not lint */ #endif /* not lint */
#include <sys/param.h> #include <sys/param.h>
@ -60,6 +60,8 @@ static char rcsid[] = "$Id: route.c,v 1.7 1994/03/07 09:19:56 cgd Exp $";
#include <sys/kinfo.h> #include <sys/kinfo.h>
#include <stdio.h> #include <stdio.h>
#include <nlist.h>
#include <kvm.h>
#include <string.h> #include <string.h>
extern int nflag, aflag, Aflag, af; extern int nflag, aflag, Aflag, af;
@ -70,7 +72,7 @@ extern char *ns_print();
#endif #endif
extern char *malloc(); extern char *malloc();
#define kget(p, d) \ #define kget(p, d) \
(kvm_read((off_t)(p), (char *)&(d), sizeof (d))) (kvm_read((p), (char *)&(d), sizeof (d)))
/* /*
* Definitions for showing gateway flags. * Definitions for showing gateway flags.
@ -132,9 +134,10 @@ routepr(hostaddr, netaddr, hashsizeaddr, treeaddr)
printf("rthashsize: symbol not in namelist\n"); printf("rthashsize: symbol not in namelist\n");
return; return;
} }
kget(hashsizeaddr, hashsize); kget((void *)(long)hashsizeaddr, hashsize);
routehash = (struct mbuf **)malloc( hashsize*sizeof (struct mbuf *) ); routehash = (struct mbuf **)malloc( hashsize*sizeof (struct mbuf *) );
kvm_read(hostaddr, (char *)routehash, hashsize*sizeof (struct mbuf *)); kvm_read((void *)(long)hostaddr, (char *)routehash,
hashsize*sizeof (struct mbuf *));
again: again:
for (i = 0; i < hashsize; i++) { for (i = 0; i < hashsize; i++) {
if (routehash[i] == 0) if (routehash[i] == 0)
@ -149,7 +152,7 @@ again:
} }
} }
if (doinghost) { if (doinghost) {
kvm_read(netaddr, (char *)routehash, kvm_read((void *)(long)netaddr, (char *)routehash,
hashsize*sizeof (struct mbuf *)); hashsize*sizeof (struct mbuf *));
doinghost = 0; doinghost = 0;
goto again; goto again;
@ -225,7 +228,7 @@ off_t rtree;
if (Aflag == 0 && NewTree) if (Aflag == 0 && NewTree)
return(ntreestuff()); return(ntreestuff());
for (kget(rtree, rnh); rnh; rnh = head.rnh_next) { for (kget((void *)(long)rtree, rnh); rnh; rnh = head.rnh_next) {
kget(rnh, head); kget(rnh, head);
if (head.rnh_af == 0) { if (head.rnh_af == 0) {
if (Aflag || af == AF_UNSPEC) { if (Aflag || af == AF_UNSPEC) {
@ -248,7 +251,7 @@ register struct sockaddr *dst;
{ {
kget(dst, pt_u.u_sa); kget(dst, pt_u.u_sa);
if (pt_u.u_sa.sa_len > sizeof (pt_u.u_sa)) { if (pt_u.u_sa.sa_len > sizeof (pt_u.u_sa)) {
kvm_read((off_t)dst, pt_u.u_data, pt_u.u_sa.sa_len); kvm_read(dst, pt_u.u_data, pt_u.u_sa.sa_len);
} }
return (&pt_u.u_sa); return (&pt_u.u_sa);
} }
@ -563,7 +566,7 @@ p_interface_nl(rt)
return; return;
} }
kget(rt->rt_ifp, ifnet); kget(rt->rt_ifp, ifnet);
kvm_read((off_t)ifnet.if_name, name, 16); kvm_read(ifnet.if_name, name, 16);
printf(" %.15s%d%s", name, ifnet.if_unit, printf(" %.15s%d%s", name, ifnet.if_unit,
rt->rt_nodes[0].rn_dupedkey ? " =>\n" : "\n"); rt->rt_nodes[0].rn_dupedkey ? " =>\n" : "\n");
} }
@ -602,7 +605,7 @@ register struct ortentry *rt;
return; return;
} }
kget(rt->rt_ifp, ifnet); kget(rt->rt_ifp, ifnet);
kvm_read((off_t)ifnet.if_name, name, 16); kvm_read(ifnet.if_name, name, 16);
printf(" %.15s%d\n", name, ifnet.if_unit); printf(" %.15s%d\n", name, ifnet.if_unit);
} }
@ -718,7 +721,7 @@ rt_stats(off)
printf("rtstat: symbol not in namelist\n"); printf("rtstat: symbol not in namelist\n");
return; return;
} }
kvm_read(off, (char *)&rtstat, sizeof (rtstat)); kvm_read((void *)(long)off, (char *)&rtstat, sizeof (rtstat));
printf("routing:\n"); printf("routing:\n");
printf("\t%u bad routing redirect%s\n", printf("\t%u bad routing redirect%s\n",
rtstat.rts_badredirect, plural(rtstat.rts_badredirect)); rtstat.rts_badredirect, plural(rtstat.rts_badredirect));

View File

@ -33,7 +33,7 @@
#ifndef lint #ifndef lint
/*static char sccsid[] = "from: @(#)unix.c 5.11 (Berkeley) 7/1/91";*/ /*static char sccsid[] = "from: @(#)unix.c 5.11 (Berkeley) 7/1/91";*/
static char rcsid[] = "$Id: unix.c,v 1.7 1994/01/11 23:27:10 mycroft Exp $"; static char rcsid[] = "$Id: unix.c,v 1.8 1994/03/28 10:30:03 cgd Exp $";
#endif /* not lint */ #endif /* not lint */
/* /*
@ -53,6 +53,8 @@ struct uio;
#include <sys/time.h> #include <sys/time.h>
#include <sys/proc.h> #include <sys/proc.h>
#include <sys/file.h> #include <sys/file.h>
#include <nlist.h>
#include <kvm.h>
struct file *file, *fileNFILE; struct file *file, *fileNFILE;
int nfiles; int nfiles;
@ -72,12 +74,12 @@ unixpr(fileheadaddr, nfilesaddr, unixsw)
printf("filehead or nfiles not in namelist.\n"); printf("filehead or nfiles not in namelist.\n");
return; return;
} }
if (kvm_read(nfilesaddr, (char *)&nfiles, sizeof (nfiles)) != if (kvm_read((void *)(long)nfilesaddr, (char *)&nfiles,
sizeof (nfiles)) { sizeof (nfiles)) != sizeof (nfiles)) {
printf("nfiles: bad read.\n"); printf("nfiles: bad read.\n");
return; return;
} }
if (kvm_read(fileheadaddr, (char *)&filep, sizeof (filep)) if (kvm_read((void *)(long)fileheadaddr, (char *)&filep, sizeof (filep))
!= sizeof (filep)) { != sizeof (filep)) {
printf("File table address, bad read.\n"); printf("File table address, bad read.\n");
return; return;
@ -91,7 +93,7 @@ unixpr(fileheadaddr, nfilesaddr, unixsw)
filep != NULL && i-- > 0; filep != NULL && i-- > 0;
filep = lfp->f_filef, lfp++) filep = lfp->f_filef, lfp++)
{ {
if(kvm_read((off_t)filep, (char *)lfp, sizeof (struct file)) if(kvm_read(filep, (char *)lfp, sizeof (struct file))
!= sizeof(struct file)) { != sizeof(struct file)) {
printf("File table read error.\n"); printf("File table read error.\n");
return; return;
@ -101,7 +103,7 @@ unixpr(fileheadaddr, nfilesaddr, unixsw)
for (fp = file; fp < fileNFILE; fp++) { for (fp = file; fp < fileNFILE; fp++) {
if (fp->f_count == 0 || fp->f_type != DTYPE_SOCKET) if (fp->f_count == 0 || fp->f_type != DTYPE_SOCKET)
continue; continue;
if (kvm_read((off_t)fp->f_data, (char *)so, sizeof (*so)) if (kvm_read(fp->f_data, (char *)so, sizeof (*so))
!= sizeof (*so)) != sizeof (*so))
continue; continue;
/* kludge */ /* kludge */
@ -124,12 +126,12 @@ unixdomainpr(so, soaddr)
struct sockaddr_un *sa; struct sockaddr_un *sa;
static int first = 1; static int first = 1;
if (kvm_read((off_t)so->so_pcb, (char *)unp, sizeof (*unp)) if (kvm_read(so->so_pcb, (char *)unp, sizeof (*unp))
!= sizeof (*unp)) != sizeof (*unp))
return; return;
if (unp->unp_addr) { if (unp->unp_addr) {
m = &mbuf; m = &mbuf;
if (kvm_read((off_t)unp->unp_addr, (char *)m, sizeof (*m)) if (kvm_read(unp->unp_addr, (char *)m, sizeof (*m))
!= sizeof (*m)) != sizeof (*m))
m = (struct mbuf *)0; m = (struct mbuf *)0;
sa = (struct sockaddr_un *)(m->m_dat); sa = (struct sockaddr_un *)(m->m_dat);