int main(int argc, char *argv[]) { struct protox *tp = NULL; /* for printing cblocks & stats */ int ch; af = AF_UNSPEC; #ifdef LISP while ((ch = getopt(argc, argv, "AaBbdf:ghI:iLlM:mN:np:rSstuWw:zX")) != -1) #else while ((ch = getopt(argc, argv, "AaBbdf:ghI:iLlM:mN:np:rSstuWw:z")) != -1) #endif /* LISP */ switch(ch) { case 'A': Aflag = 1; break; case 'a': aflag = 1; break; case 'B': Bflag = 1; break; case 'b': bflag = 1; break; case 'd': dflag = 1; break; case 'f': if (strcmp(optarg, "ipx") == 0) af = AF_IPX; else if (strcmp(optarg, "inet") == 0) af = AF_INET; #ifdef INET6 else if (strcmp(optarg, "inet6") == 0) af = AF_INET6; #endif #ifdef IPSEC else if (strcmp(optarg, "pfkey") == 0) af = PF_KEY; #endif else if (strcmp(optarg, "unix") == 0) af = AF_UNIX; else if (strcmp(optarg, "atalk") == 0) af = AF_APPLETALK; #ifdef NETGRAPH else if (strcmp(optarg, "ng") == 0 || strcmp(optarg, "netgraph") == 0) af = AF_NETGRAPH; #endif else if (strcmp(optarg, "link") == 0) af = AF_LINK; else { errx(1, "%s: unknown address family", optarg); } break; case 'g': gflag = 1; break; case 'h': hflag = 1; break; case 'I': { char *cp; iflag = 1; for (cp = interface = optarg; isalpha(*cp); cp++) continue; unit = atoi(cp); break; } case 'i': iflag = 1; break; case 'L': Lflag = 1; break; case 'M': memf = optarg; break; case 'm': mflag = 1; break; case 'N': nlistf = optarg; break; case 'n': numeric_addr = numeric_port = 1; break; case 'p': if ((tp = name2protox(optarg)) == NULL) { errx(1, "%s: unknown or uninstrumented protocol", optarg); } pflag = 1; break; case 'r': rflag = 1; break; #ifdef LISP case 'X': Xflag = 1; break; #endif /* LISP */ case 's': ++sflag; break; case 'S': numeric_addr = 1; break; case 't': tflag = 1; break; case 'u': af = AF_UNIX; break; case 'W': case 'l': Wflag = 1; break; case 'w': interval = atoi(optarg); iflag = 1; break; case 'z': zflag = 1; break; case '?': default: usage(); } argv += optind; argc -= optind; #define BACKWARD_COMPATIBILITY #ifdef BACKWARD_COMPATIBILITY if (*argv) { if (isdigit(**argv)) { interval = atoi(*argv); if (interval <= 0) usage(); ++argv; iflag = 1; } if (*argv) { nlistf = *argv; if (*++argv) memf = *argv; } } #endif /* * Discard setgid privileges if not the running kernel so that bad * guys can't print interesting stuff from kernel memory. */ live = (nlistf == NULL && memf == NULL); if (!live) setgid(getgid()); if (Bflag) { if (!live) usage(); bpf_stats(interface); exit(0); } if (mflag) { if (!live) { if (kread(0, NULL, 0) == 0) mbpr(kvmd, nl[N_MBSTAT].n_value); } else mbpr(NULL, 0); exit(0); } #if 0 /* * Keep file descriptors open to avoid overhead * of open/close on each call to get* routines. */ sethostent(1); setnetent(1); #else /* * This does not make sense any more with DNS being default over * the files. Doing a setXXXXent(1) causes a tcp connection to be * used for the queries, which is slower. */ #endif kread(0, NULL, 0); if (iflag && !sflag) { intpr(interval, nl[N_IFNET].n_value, NULL); exit(0); } if (rflag) { if (sflag) rt_stats(nl[N_RTSTAT].n_value, nl[N_RTTRASH].n_value); else routepr(nl[N_RTREE].n_value); exit(0); } #ifdef LISP if (Xflag) { if (sflag) { map_stats(); exit(0); } else { kread(0, 0, 0); mappr(nl[N_MAPTREE].n_value); exit(0); }; }; #endif /* LISP */ if (gflag) { if (sflag) { if (af == AF_INET || af == AF_UNSPEC) mrt_stats(nl[N_MRTSTAT].n_value); #ifdef INET6 if (af == AF_INET6 || af == AF_UNSPEC) mrt6_stats(nl[N_MRT6STAT].n_value); #endif } else { if (af == AF_INET || af == AF_UNSPEC) mroutepr(nl[N_MFCTABLE].n_value, nl[N_VIFTABLE].n_value); #ifdef INET6 if (af == AF_INET6 || af == AF_UNSPEC) mroute6pr(nl[N_MF6CTABLE].n_value, nl[N_MIF6TABLE].n_value); #endif } ifmalist_dump(); exit(0); } if (tp) { printproto(tp, tp->pr_name); exit(0); } if (af == AF_INET || af == AF_UNSPEC) for (tp = protox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #ifdef INET6 if (af == AF_INET6 || af == AF_UNSPEC) for (tp = ip6protox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #endif /*INET6*/ #ifdef IPSEC if (af == PF_KEY || af == AF_UNSPEC) for (tp = pfkeyprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #endif /*IPSEC*/ #ifdef IPX if (af == AF_IPX || af == AF_UNSPEC) { for (tp = ipxprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); } #endif /* IPX */ if (af == AF_APPLETALK || af == AF_UNSPEC) for (tp = atalkprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #ifdef NETGRAPH if (af == AF_NETGRAPH || af == AF_UNSPEC) for (tp = netgraphprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #endif /* NETGRAPH */ if ((af == AF_UNIX || af == AF_UNSPEC) && !sflag) unixpr(nl[N_UNP_COUNT].n_value, nl[N_UNP_GENCNT].n_value, nl[N_UNP_DHEAD].n_value, nl[N_UNP_SHEAD].n_value); exit(0); }
int main(int argc, char *argv[]) { netsnmp_session session; struct protoent *p; char *cp; af = AF_UNSPEC; cp = strrchr( argv[0], '/' ); if (cp) progname = cp+1; else progname = argv[0]; switch (snmp_parse_args( argc, argv, &session, "C:iRs", optProc)) { case NETSNMP_PARSE_ARGS_ERROR: exit(1); case NETSNMP_PARSE_ARGS_SUCCESS_EXIT: exit(0); case NETSNMP_PARSE_ARGS_ERROR_USAGE: usage(); exit(1); default: break; } /* * Check argc vs optind ?? */ argv += optind; argc -= optind; /* * Open an SNMP session. */ SOCK_STARTUP; ss = snmp_open(&session); if (ss == NULL) { /* * diagnose snmp_open errors with the input netsnmp_session pointer */ snmp_sess_perror("snmpnetstat", &session); SOCK_CLEANUP; exit(1); } /* * Omitted: * Privilege handling * "Backward Compatibility" * Kernel namelis handling */ if (mflag) { /* mbpr(nl[N_MBSTAT].n_value, nl[N_MBPOOL].n_value, nl[N_MCLPOOL].n_value); */ exit(0); } if (pflag) { printproto(tp, tp->pr_name); exit(0); } /* * Keep file descriptors open to avoid overhead * of open/close on each call to get* routines. */ sethostent(1); setnetent(1); if (iflag) { intpr(interval); exit(0); } if (rflag) { /* if (sflag) rt_stats(); else */ if (Lflag || routexpr(af) == 0) { if (route4pr(af) == 0 && af == AF_INET) routepr(); route6pr(af); } exit(0); } /* if (gflag) { if (sflag) { if (af == AF_INET || af == AF_UNSPEC) mrt_stats(nl[N_MRTPROTO].n_value, nl[N_MRTSTAT].n_value); #ifdef NETSNMP_ENABLE_IPV6 if (af == AF_INET6 || af == AF_UNSPEC) mrt6_stats(nl[N_MRT6PROTO].n_value, nl[N_MRT6STAT].n_value); #endif } else { if (af == AF_INET || af == AF_UNSPEC) mroutepr(nl[N_MRTPROTO].n_value, nl[N_MFCHASHTBL].n_value, nl[N_MFCHASH].n_value, nl[N_VIFTABLE].n_value); #ifdef NETSNMP_ENABLE_IPV6 if (af == AF_INET6 || af == AF_UNSPEC) mroute6pr(nl[N_MRT6PROTO].n_value, nl[N_MF6CTABLE].n_value, nl[N_MIF6TABLE].n_value); #endif } exit(0); } */ setservent(1); if (af == AF_UNSPEC && Lflag) { setprotoent(1); /* ugh, this is O(MN) ... why do we do this? */ while ((p = getprotoent())) { for (tp = protox; tp->pr_name; tp++) if (strcmp(tp->pr_name, p->p_name) == 0) if (tp->pr_name && tp->pr_wanted) printproto(tp, p->p_name); } endprotoent(); } if (af == AF_UNSPEC && !Lflag) for (tp = ipxprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); if (af == AF_INET) for (tp = protox; tp->pr_name; tp++) printproto(tp, tp->pr_name); if (af == AF_INET6) for (tp = ip6protox; tp->pr_name; tp++) printproto(tp, tp->pr_name); /* if (af == AF_IPX || af == AF_UNSPEC) for (tp = ipxprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); if (af == AF_NS || af == AF_UNSPEC) for (tp = nsprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); if ((af == AF_UNIX || af == AF_UNSPEC) && !sflag) unixpr(nl[N_UNIXSW].n_value); if (af == AF_APPLETALK || af == AF_UNSPEC) for (tp = atalkprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); */ exit(0); }
int main(int argc, char **argv) { struct protox *tp = NULL; /* for printing cblocks & stats */ int ch; int n; af = AF_UNSPEC; while ((ch = getopt(argc, argv, "Aabc:df:gI:iLlM:mN:nPp:rSsBtuWw:z")) != -1) switch(ch) { case 'A': Aflag = 1; break; case 'a': aflag = 1; break; case 'b': bflag = 1; break; case 'c': kread(0, 0, 0); kread(nl[N_NCPUS].n_value, (char *)&n, sizeof(n)); cpuflag = strtol(optarg, NULL, 0); if (cpuflag < 0 || cpuflag >= n) errx(1, "cpu %d does not exist", cpuflag); break; case 'd': dflag = 1; break; case 'f': if (strcmp(optarg, "ipx") == 0) af = AF_IPX; else if (strcmp(optarg, "inet") == 0) af = AF_INET; #ifdef INET6 else if (strcmp(optarg, "inet6") == 0) af = AF_INET6; #endif /*INET6*/ #ifdef INET6 else if (strcmp(optarg, "pfkey") == 0) af = PF_KEY; #endif /*INET6*/ else if (strcmp(optarg, "unix") == 0) af = AF_UNIX; else if (strcmp(optarg, "ng") == 0 || strcmp(optarg, "netgraph") == 0) af = AF_NETGRAPH; #ifdef ISO else if (strcmp(optarg, "iso") == 0) af = AF_ISO; #endif else if (strcmp(optarg, "link") == 0) af = AF_LINK; else if (strcmp(optarg, "mpls") == 0) af = AF_MPLS; else { errx(1, "%s: unknown address family", optarg); } break; case 'g': gflag = 1; break; case 'I': { char *cp; iflag = 1; for (cp = interface = optarg; isalpha(*cp); cp++) continue; unit = atoi(cp); break; } case 'i': iflag = 1; break; case 'L': Lflag = 1; break; case 'M': memf = optarg; break; case 'm': mflag = 1; break; case 'N': nlistf = optarg; break; case 'n': numeric_addr = numeric_port = 1; break; case 'P': Pflag = 1; break; case 'p': if ((tp = name2protox(optarg)) == NULL) { errx(1, "%s: unknown or uninstrumented protocol", optarg); } pflag = 1; break; case 'r': rflag = 1; break; case 's': ++sflag; break; case 'S': numeric_addr = 1; break; case 'B': Bflag = 1; break; case 't': tflag = 1; break; case 'u': af = AF_UNIX; break; case 'W': case 'l': Wflag = 1; break; case 'w': interval = atoi(optarg); iflag = 1; break; case 'z': zflag = 1; break; case '?': default: usage(); } argv += optind; argc -= optind; #define BACKWARD_COMPATIBILITY #ifdef BACKWARD_COMPATIBILITY if (*argv) { if (isdigit(**argv)) { interval = atoi(*argv); if (interval <= 0) usage(); ++argv; iflag = 1; } if (*argv) { nlistf = *argv; if (*++argv) memf = *argv; } } #endif /* * Discard setgid privileges if not the running kernel so that bad * guys can't print interesting stuff from kernel memory. */ if (nlistf != NULL || memf != NULL) setgid(getgid()); if (mflag) { if (memf != NULL) { if (kread(0, 0, 0) == 0) mbpr(nl[N_MBSTAT].n_value, nl[N_MBTYPES].n_value, nl[N_NMBCLUSTERS].n_value, nl[N_NMBJCLUSTERS].n_value, nl[N_NMBUFS].n_value, nl[N_NCPUS].n_value); } else { mbpr(0, 0, 0, 0, 0, 0); } exit(0); } #if 0 /* * Keep file descriptors open to avoid overhead * of open/close on each call to get* routines. */ sethostent(1); setnetent(1); #else /* * This does not make sense any more with DNS being default over * the files. Doing a setXXXXent(1) causes a tcp connection to be * used for the queries, which is slower. */ #endif if (iflag && !sflag) { kread(0, 0, 0); intpr(interval, nl[N_IFNET].n_value, NULL, nl[N_NCPUS].n_value); exit(0); } if (rflag) { kread(0, 0, 0); if (sflag) rt_stats(); else routepr(nl[N_RTREE].n_value); exit(0); } if (gflag) { kread(0, 0, 0); if (sflag) { if (af == AF_INET || af == AF_UNSPEC) mrt_stats(nl[N_MRTSTAT].n_value); #ifdef INET6 if (af == AF_INET6 || af == AF_UNSPEC) mrt6_stats(nl[N_MRT6STAT].n_value); #endif } else { if (af == AF_INET || af == AF_UNSPEC) mroutepr(nl[N_MFCTABLE].n_value, nl[N_VIFTABLE].n_value); #ifdef INET6 if (af == AF_INET6 || af == AF_UNSPEC) mroute6pr(nl[N_MF6CTABLE].n_value, nl[N_MIF6TABLE].n_value); #endif } exit(0); } kread(0, 0, 0); if (tp) { printproto(tp, tp->pr_name, nl[N_NCPUS].n_value); exit(0); } if (af == AF_INET || af == AF_UNSPEC) for (tp = protox; tp->pr_name; tp++) printproto(tp, tp->pr_name, nl[N_NCPUS].n_value); #ifdef INET6 if (af == AF_INET6 || af == AF_UNSPEC) for (tp = ip6protox; tp->pr_name; tp++) printproto(tp, tp->pr_name, nl[N_NCPUS].n_value); #endif /*INET6*/ #ifdef IPSEC if (af == PF_KEY || af == AF_UNSPEC) for (tp = pfkeyprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name, nl[N_NCPUS].n_value); #endif /*IPSEC*/ if (af == AF_IPX || af == AF_UNSPEC) { kread(0, 0, 0); for (tp = ipxprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name, nl[N_NCPUS].n_value); } if (af == AF_NETGRAPH || af == AF_UNSPEC) for (tp = netgraphprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name, nl[N_NCPUS].n_value); #ifdef ISO if (af == AF_ISO || af == AF_UNSPEC) for (tp = isoprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name, nl[N_NCPUS].n_value); #endif if ((af == AF_UNIX || af == AF_UNSPEC) && !Lflag && !sflag) unixpr(); exit(0); }
int main(int argc, char *argv[]) { struct protox *tp = NULL; /* for printing cblocks & stats */ int ch; int fib = -1; char *endptr; af = AF_UNSPEC; while ((ch = getopt(argc, argv, "46AaBbdF:f:ghI:iLlM:mN:np:Qq:RrSTsuWw:xz")) != -1) switch(ch) { case '4': #ifdef INET af = AF_INET; #else errx(1, "IPv4 support is not compiled in"); #endif break; case '6': #ifdef INET6 af = AF_INET6; #else errx(1, "IPv6 support is not compiled in"); #endif break; case 'A': Aflag = 1; break; case 'a': aflag = 1; break; case 'B': Bflag = 1; break; case 'b': bflag = 1; break; case 'd': dflag = 1; break; case 'F': fib = strtol(optarg, &endptr, 0); if (*endptr != '\0' || (fib == 0 && (errno == EINVAL || errno == ERANGE))) errx(1, "%s: invalid fib", optarg); break; case 'f': if (strcmp(optarg, "inet") == 0) af = AF_INET; #ifdef INET6 else if (strcmp(optarg, "inet6") == 0) af = AF_INET6; #endif #ifdef IPSEC else if (strcmp(optarg, "pfkey") == 0) af = PF_KEY; #endif else if (strcmp(optarg, "unix") == 0) af = AF_UNIX; #ifdef NETGRAPH else if (strcmp(optarg, "ng") == 0 || strcmp(optarg, "netgraph") == 0) af = AF_NETGRAPH; #endif else if (strcmp(optarg, "link") == 0) af = AF_LINK; else { errx(1, "%s: unknown address family", optarg); } break; case 'g': gflag = 1; break; case 'h': hflag = 1; break; case 'I': { char *cp; iflag = 1; for (cp = interface = optarg; isalpha(*cp); cp++) continue; unit = atoi(cp); break; } case 'i': iflag = 1; break; case 'L': Lflag = 1; break; case 'M': memf = optarg; break; case 'm': mflag = 1; break; case 'N': nlistf = optarg; break; case 'n': numeric_addr = numeric_port = 1; break; case 'p': if ((tp = name2protox(optarg)) == NULL) { errx(1, "%s: unknown or uninstrumented protocol", optarg); } pflag = 1; break; case 'Q': Qflag = 1; break; case 'q': noutputs = atoi(optarg); if (noutputs != 0) noutputs++; break; case 'r': rflag = 1; break; case 'R': Rflag = 1; break; case 's': ++sflag; break; case 'S': numeric_addr = 1; break; case 'u': af = AF_UNIX; break; case 'W': case 'l': Wflag = 1; break; case 'w': interval = atoi(optarg); iflag = 1; break; case 'T': Tflag = 1; break; case 'x': xflag = 1; break; case 'z': zflag = 1; break; case '?': default: usage(); } argv += optind; argc -= optind; #define BACKWARD_COMPATIBILITY #ifdef BACKWARD_COMPATIBILITY if (*argv) { if (isdigit(**argv)) { interval = atoi(*argv); if (interval <= 0) usage(); ++argv; iflag = 1; } if (*argv) { nlistf = *argv; if (*++argv) memf = *argv; } } #endif /* * Discard setgid privileges if not the running kernel so that bad * guys can't print interesting stuff from kernel memory. */ live = (nlistf == NULL && memf == NULL); if (!live) setgid(getgid()); if (xflag && Tflag) errx(1, "-x and -T are incompatible, pick one."); if (Bflag) { if (!live) usage(); bpf_stats(interface); exit(0); } if (mflag) { if (!live) { if (kread(0, NULL, 0) == 0) mbpr(kvmd, nl[N_SFSTAT].n_value); } else mbpr(NULL, 0); exit(0); } if (Qflag) { if (!live) { if (kread(0, NULL, 0) == 0) netisr_stats(kvmd); } else netisr_stats(NULL); exit(0); } #if 0 /* * Keep file descriptors open to avoid overhead * of open/close on each call to get* routines. */ sethostent(1); setnetent(1); #else /* * This does not make sense any more with DNS being default over * the files. Doing a setXXXXent(1) causes a tcp connection to be * used for the queries, which is slower. */ #endif if (iflag && !sflag) { intpr(interval, NULL, af); exit(0); } if (rflag) { if (sflag) { rt_stats(); flowtable_stats(); } else routepr(fib, af); exit(0); } if (gflag) { if (sflag) { if (af == AF_INET || af == AF_UNSPEC) mrt_stats(); #ifdef INET6 if (af == AF_INET6 || af == AF_UNSPEC) mrt6_stats(); #endif } else { if (af == AF_INET || af == AF_UNSPEC) mroutepr(); #ifdef INET6 if (af == AF_INET6 || af == AF_UNSPEC) mroute6pr(); #endif } exit(0); } /* Load all necessary kvm symbols */ kresolve_list(nl); if (tp) { printproto(tp, tp->pr_name); exit(0); } if (af == AF_INET || af == AF_UNSPEC) for (tp = protox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #ifdef INET6 if (af == AF_INET6 || af == AF_UNSPEC) for (tp = ip6protox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #endif /*INET6*/ #ifdef IPSEC if (af == PF_KEY || af == AF_UNSPEC) for (tp = pfkeyprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #endif /*IPSEC*/ #ifdef NETGRAPH if (af == AF_NETGRAPH || af == AF_UNSPEC) for (tp = netgraphprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #endif /* NETGRAPH */ if ((af == AF_UNIX || af == AF_UNSPEC) && !sflag) unixpr(nl[N_UNP_COUNT].n_value, nl[N_UNP_GENCNT].n_value, nl[N_UNP_DHEAD].n_value, nl[N_UNP_SHEAD].n_value, nl[N_UNP_SPHEAD].n_value); exit(0); }
void main(int argc, char *argv[]) { Etherpkt e; Ippkt *ip; long n; int fd, cfd; int ts, len, t; long start; int delta; uchar target[6]; char buf[256]; ulong samples; samples = -1; ARGBEGIN{ case 'd': debug++; break; case 's': samples = atoi(ARGF()); break; }ARGEND; if(argc < 2){ fprint(2, "usage: %s device ip-addr [minutes-per-sample]\n", argv0); exits("usage"); } if(argc > 2) delta = atoi(argv[2])*60*1000; else delta = 5*60*1000; parseether(target, argv[1]); fmtinstall('E', eipfmt); fmtinstall('I', eipfmt); snprint(buf, sizeof(buf), "%s!-2", argv[0]); fd = dial(buf, 0, 0, &cfd); if(fd < 0) error("opening ether data"); if(write(cfd, "promiscuous", sizeof("promiscuous")-1) <= 0) error("connecting"); start = 0; fd = -1; for(;;){ if(fd < 0){ fd = dial(buf, 0, 0, &cfd); if(fd < 0) error("opening ether data"); if(write(cfd, "promiscuous", sizeof("promiscuous")-1) <= 0) error("connecting"); close(cfd); } n = read(fd, &e, sizeof(e)); if(n <= 0) break; ts = NetL(&e.d[60]); n = NetS(&e.d[58]) - ETHERHDRSIZE; if(n < 0) continue; if(start == 0) start = ts; t = NetS(e.type); if(t == 0x0800 || (t&0xFF00) == 0x1000){ ip = (Ippkt*)e.data; len = NetS(ip->length); if(len > n) len = n; if(debug) fprint(2, "%I -> %I %d\n", ip->src, ip->dst, len); if(memcmp(e.s, target, 6) == 0){ protopin[0]++; protoin[0] += len; if(ip->proto){ protopin[ip->proto]++; protoin[ip->proto] += len; } } if(memcmp(e.d, target, 6) == 0){ protopout[0]++; protoout[0] += len; if(ip->proto){ protopout[ip->proto]++; protoout[ip->proto] += len; } } } if(ts - start >= delta){ print("%8.8ld %ld", time(0), ts - start); printproto(0); printproto(IP_MBONEPROTO); printproto(IP_UDPPROTO); printproto(IP_TCPPROTO); print("\n"); start = 0; memset(protoin, 0, sizeof(protoin)); memset(protoout, 0, sizeof(protoout)); memset(protopin, 0, sizeof(protopin)); memset(protopout, 0, sizeof(protopout)); close(fd); fd = -1; if(--samples == 0) break; } } exits(0); }