if (mib[3] == TCPCTL_BADDYNAMIC || mib[3] == UDPCTL_BADDYNAMIC) {
if ((mib[2] == IPPROTO_TCP && mib[3] == TCPCTL_BADDYNAMIC) || (mib[2] == IPPROTO_UDP && mib[3] == UDPCTL_BADDYNAMIC)) {
parse(string, flags)	char *string;	int flags;{	int indx, type, state;	int special = 0;	void *newval = 0;	int intval, newsize = 0;	quad_t quadval;	size_t size, len;	struct list *lp;	int mib[CTL_MAXNAME];	char *cp, *bufp, buf[BUFSIZ];	bufp = buf;	snprintf(buf, BUFSIZ, "%s", string);	if ((cp = strchr(string, '=')) != NULL) {		if (!wflag) {			fprintf(stderr, "Must specify -w to set variables\n");			exit(2);		}		*strchr(buf, '=') = '\0';		*cp++ = '\0';		while (isspace(*cp))			cp++;		newval = cp;		newsize = strlen(cp);	}	if ((indx = findname(string, "top", &bufp, &toplist)) == -1)		return;	mib[0] = indx;	if (indx == CTL_DEBUG)		debuginit();	lp = &secondlevel[indx];	if (lp->list == 0) {		fprintf(stderr, "%s: class is not implemented\n",		    topname[indx].ctl_name);		return;	}	if (bufp == NULL) {		listall(topname[indx].ctl_name, lp);		return;	}	if ((indx = findname(string, "second", &bufp, lp)) == -1)		return;	mib[1] = indx;	type = lp->list[indx].ctl_type;	len = 2;	switch (mib[0]) {	case CTL_KERN:		switch (mib[1]) {		case KERN_PROF:			mib[2] = GPROF_STATE;			size = sizeof state;			if (sysctl(mib, 3, &state, &size, NULL, 0) < 0) {				if (flags == 0)					return;				if (!nflag)					fprintf(stdout, "%s: ", string);				fprintf(stdout,				    "kernel is not compiled for profiling\n");				return;			}			if (!nflag)				fprintf(stdout, "%s = %s\n", string,				    state == GMON_PROF_OFF ? "off" : "running");			return;		case KERN_VNODE:		case KERN_FILE:			if (flags == 0)				return;			fprintf(stderr,			    "Use pstat to view %s information\n", string);			return;		case KERN_PROC:			if (flags == 0)				return;			fprintf(stderr,			    "Use ps to view %s information\n", string);			return;		case KERN_NTPTIME:			if (flags == 0)				return;			fprintf(stderr,			    "Use xntpd to view %s information\n", string);			return;		case KERN_CLOCKRATE:			special |= CLOCK;			break;		case KERN_BOOTTIME:			special |= BOOTTIME;			break;		case KERN_RND:			special |= RNDSTATS;			break;		}		break;	case CTL_HW:		break;	case CTL_VM:		if (mib[1] == VM_LOADAVG) {			double loads[3];			getloadavg(loads, 3);			if (!nflag)				fprintf(stdout, "%s = ", string);			fprintf(stdout, "%.2f %.2f %.2f\n", 			    loads[0], loads[1], loads[2]);			return;		} else if (mib[1] == VM_PSSTRINGS) {			struct _ps_strings _ps;			len = sizeof(_ps);			sysctl(mib, 2, &_ps, &len, NULL, 0);			if (!nflag)				fprintf(stdout, "%s = ", string);			fprintf(stdout, "%ld\n", _ps.val);			return;		}		if (flags == 0)			return;		fprintf(stderr,		    "Use vmstat or systat to view %s information\n", string);		return;	case CTL_NET:		if (mib[1] == PF_INET) {			len = sysctl_inet(string, &bufp, mib, flags, &type);			if (len < 0)				return;			if (mib[3] == TCPCTL_BADDYNAMIC ||			    mib[3] == UDPCTL_BADDYNAMIC) {				u_int32_t newbaddynamic[DP_MAPSIZE];				in_port_t port;				special |= BADDYNAMIC;				if (newval != NULL) {					(void)memset((void *)&newbaddynamic, 0,					    sizeof(newbaddynamic));					while (newval &&					    (cp = strsep((char **)&newval,					    ", \t")) && *cp) {						port = atoi(cp);						if (port < IPPORT_RESERVED/2 ||						    port >= IPPORT_RESERVED)							errx(1, "invalid port, "							    "range is %d to %d",							    IPPORT_RESERVED/2,							    IPPORT_RESERVED-1);						DP_SET(newbaddynamic, port);					}					newval = (void *)newbaddynamic;					newsize = sizeof(newbaddynamic);				}			}			break;		}		if (mib[1] == PF_IPX) {			len = sysctl_ipx(string, &bufp, mib, flags, &type);			if (len >= 0)				break;			return;		}		if (mib[1] == PF_ENCAP) {			len = sysctl_ipsec(string, &bufp, mib, flags, &type);			if (len >= 0)				break;			return;		}		if (flags == 0)			return;		fprintf(stderr, "Use netstat to view %s information\n", string);		return;	case CTL_DEBUG:		mib[2] = CTL_DEBUG_VALUE;		len = 3;		break;	case CTL_MACHDEP:#ifdef CPU_CONSDEV		if (mib[1] == CPU_CONSDEV)			special |= CONSDEV;#endif		break;	case CTL_FS:		len = sysctl_fs(string, &bufp, mib, flags, &type);		if (len >= 0)			break;		return;	case CTL_USER:	case CTL_DDB:		break;	default:		fprintf(stderr, "Illegal top level value: %d\n", mib[0]);		return;		}	if (bufp) {		fprintf(stderr, "name %s in %s is unknown\n", bufp, string);		return;	}	if (newsize > 0) {		switch (type) {		case CTLTYPE_INT:			intval = atoi(newval);			newval = &intval;			newsize = sizeof intval;			break;		case CTLTYPE_QUAD:			sscanf(newval, "%qd", &quadval);			newval = &quadval;			newsize = sizeof quadval;			break;		}	}	size = BUFSIZ;	if (sysctl(mib, len, buf, &size, newsize ? newval : 0, newsize) == -1) {		if (flags == 0)			return;		switch (errno) {		case EOPNOTSUPP:			fprintf(stderr, "%s: value is not available\n", string);			return;		case ENOTDIR:			fprintf(stderr, "%s: specification is incomplete\n",			    string);			return;		case ENOMEM:			fprintf(stderr, "%s: type is unknown to this program\n",			    string);			return;		default:			perror(string);			return;		}	}	if (special & CLOCK) {		struct clockinfo *clkp = (struct clockinfo *)buf;		if (!nflag)			fprintf(stdout, "%s = ", string);		fprintf(stdout,		    "tick = %d, tickadj = %d, hz = %d, profhz = %d, stathz = %d\n",		    clkp->tick, clkp->tickadj, clkp->hz, clkp->profhz, clkp->stathz);		return;	}	if (special & BOOTTIME) {		struct timeval *btp = (struct timeval *)buf;		time_t boottime;		if (!nflag) {			boottime = btp->tv_sec;			fprintf(stdout, "%s = %s\n", string, ctime(&boottime));		} else			fprintf(stdout, "%ld\n", btp->tv_sec);		return;	}	if (special & CONSDEV) {		dev_t dev = *(dev_t *)buf;		if (!nflag)			fprintf(stdout, "%s = %s\n", string,			    devname(dev, S_IFCHR));		else			fprintf(stdout, "0x%x\n", dev);		return;	}	if (special & RNDSTATS) {		struct rndstats *rndstats = (struct rndstats *)buf;		if (!nflag)			fprintf(stdout, "%s = ", string);		fprintf(stdout,		    "%u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u\n",		    rndstats->rnd_total, rndstats->rnd_used,		    rndstats->arc4_reads, rndstats->rnd_timer,		    rndstats->rnd_mouse, rndstats->rnd_tty,		    rndstats->rnd_disk, rndstats->rnd_net,		    rndstats->rnd_reads, rndstats->rnd_waits,		    rndstats->rnd_enqs, rndstats->rnd_deqs,		    rndstats->rnd_drops, rndstats->rnd_drople,		    rndstats->rnd_asleep, rndstats->rnd_queued);		return;	}	if (special & BADDYNAMIC) {		in_port_t port;		u_int32_t *baddynamic = (u_int32_t *)buf;		if (!nflag)			printf("%s%s", string, newsize ? ":" : " =");		for (port = IPPORT_RESERVED/2; port < IPPORT_RESERVED; port++)			if (DP_ISSET(baddynamic, port))				printf(" %hd", port);		if (newsize != 0) {			if (!nflag)				fputs(" ->", stdout);			baddynamic = (u_int32_t *)newval;			for (port = IPPORT_RESERVED/2; port < IPPORT_RESERVED;			    port++)				if (DP_ISSET(baddynamic, port))					printf(" %hd", port);		}		putchar('\n');		return;	}	switch (type) {	case CTLTYPE_INT:		if (newsize == 0) {			if (!nflag)				fprintf(stdout, "%s = ", string);			fprintf(stdout, "%d\n", *(int *)buf);		} else {			if (!nflag)				fprintf(stdout, "%s: %d -> ", string,				    *(int *)buf);			fprintf(stdout, "%d\n", *(int *)newval);		}		return;	case CTLTYPE_STRING:		if (newsize == 0) {			if (!nflag)				fprintf(stdout, "%s = ", string);			fprintf(stdout, "%s\n", buf);		} else {			if (!nflag)				fprintf(stdout, "%s: %s -> ", string, buf);			fprintf(stdout, "%s\n", (char *)newval);		}		return;	case CTLTYPE_QUAD:		if (newsize == 0) {			if (!nflag)				fprintf(stdout, "%s = ", string);			fprintf(stdout, "%qd\n", *(quad_t *)buf);		} else {			if (!nflag)				fprintf(stdout, "%s: %qd -> ", string,				    *(quad_t *)buf);			fprintf(stdout, "%qd\n", *(quad_t *)newval);		}		return;	case CTLTYPE_STRUCT:		fprintf(stderr, "%s: unknown structure returned\n",		    string);		return;	default:	case CTLTYPE_NODE:		fprintf(stderr, "%s: unknown type returned\n",		    string);		return;	}}