if (mib[1] == PF_ENCAP) {
if (mib[1] == PF_KEY_V2) {
parse(string, flags)	char *string;	int flags;{	int indx, type, state, intval;	size_t size, len,  newsize = 0;	int special = 0;	void *newval = 0;	quad_t quadval;	struct list *lp;	struct vfsconf vfc;	int mib[CTL_MAXNAME];	char *cp, *bufp, buf[BUFSIZ];	(void)strncpy(buf, string, sizeof(buf) - 1);	buf[sizeof(buf) - 1] = '\0';	bufp = buf;	if ((cp = strchr(string, '=')) != NULL) {		if (!wflag)			errx(2, "must specify -w to set variables");		*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_VFS)		vfsinit();	if (indx == CTL_DEBUG)		debuginit();	lp = &secondlevel[indx];	if (lp->list == 0) {		warnx("%s: class is not implemented", 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) == -1) {				if (flags == 0)					return;				if (!nflag)					(void)printf("%s: ", string);				(void)puts("kernel is not compiled for profiling");				return;			}			if (!nflag)				(void)printf("%s = %s\n", string,				    state == GMON_PROF_OFF ? "off" : "running");			return;		case KERN_VNODE:		case KERN_FILE:			if (flags == 0)				return;			warnx("use pstat to view %s information", string);			return;		case KERN_PROC:			if (flags == 0)				return;			warnx("use ps to view %s information", string);			return;		case KERN_NTPTIME:			if (flags == 0)				return;			warnx("use xntpdc to view %s information", 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)				(void)printf("%s = ", string);			(void)printf("%.2f %.2f %.2f\n", loads[0],			    loads[1], loads[2]);			return;		} else if (mib[1] == VM_PSSTRINGS) {			struct _ps_strings _ps;			len = sizeof(_ps);			if (sysctl(mib, 2, &_ps, &len, NULL, 0) == -1) {				if (flags == 0)					return;				if (!nflag)					(void)printf("%s: ", string);				(void)puts("can't find ps strings");				return;			}			if (!nflag)				(void)printf("%s = ", string);			(void)printf("%p\n", _ps.val);			return;		}		if (flags == 0)			return;		warnx("use vmstat or systat to view %s information", string);		return;	case CTL_NET:		if (mib[1] == PF_INET) {			len = sysctl_inet(string, &bufp, mib, flags, &type);			if (len < 0)				return;			if ((mib[2] == IPPROTO_TCP &&			     mib[3] == TCPCTL_BADDYNAMIC) ||			    (mib[2] == IPPROTO_UDP &&			     mib[3] == UDPCTL_BADDYNAMIC)) {				special |= BADDYNAMIC;				if (newval != NULL)					parse_baddynamic(mib, len, string,					    &newval, &newsize, flags, nflag);			}			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;		warnx("use netstat to view %s information", 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 |= CHRDEV;#endif#ifdef CPU_BLK2CHR		if (mib[1] == CPU_BLK2CHR) {			if (bufp == NULL)				return;			mib[2] = makedev(atoi(bufp),0);			bufp = NULL;			len = 3;			special |= CHRDEV;			break;		}#endif#ifdef CPU_CHR2BLK		if (mib[1] == CPU_CHR2BLK) {			if (bufp == NULL)				return;			mib[2] = makedev(atoi(bufp),0);			bufp = NULL;			len = 3;			special |= BLKDEV;			break;		}#endif#ifdef CPU_BIOS		if (mib[1] == CPU_BIOS) {			len = sysctl_bios(string, &bufp, mib, flags, &type);			if (len < 0)				return;			if (mib[2] == BIOS_DEV)				special |= BIOSDEV;			if (mib[2] == BIOS_DISKINFO)				special |= BIOSGEO;			break;		}#endif		break;	case CTL_FS:		len = sysctl_fs(string, &bufp, mib, flags, &type);		if (len >= 0)			break;		return;	case CTL_VFS:		mib[3] = mib[1];		mib[1] = VFS_GENERIC;		mib[2] = VFS_CONF;		len = 4;		size = sizeof vfc;		if (sysctl(mib, 4, &vfc, &size, (void *)0, (size_t)0) < 0) {			if (errno != EOPNOTSUPP)				perror("vfs print");			return;		}		if (flags == 0 && vfc.vfc_refcount == 0)			return;		if (!nflag)			fprintf(stdout, "%s has %d mounted instance%s\n",			    string, vfc.vfc_refcount,			    vfc.vfc_refcount != 1 ? "s" : "");		else			fprintf(stdout, "%d\n", vfc.vfc_refcount);		return;	case CTL_USER:	case CTL_DDB:		break;	default:		warnx("illegal top level value: %d", mib[0]);		return;		}	if (bufp) {		warnx("name %s in %s is unknown", bufp, string);		return;	}	if (newsize > 0) {		switch (type) {		case CTLTYPE_INT:			intval = atoi(newval);			newval = &intval;			newsize = sizeof(intval);			break;		case CTLTYPE_QUAD:			(void)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:			warnx("%s: value is not available", string);			return;		case ENOTDIR:			warnx("%s: specification is incomplete", string);			return;		case ENOMEM:			warnx("%s: type is unknown to this program", string);			return;		case ENXIO:			if (special & BIOSGEO)				return;		default:			warn(string);			return;		}	}	if (special & CLOCK) {		struct clockinfo *clkp = (struct clockinfo *)buf;		if (!nflag)			(void)printf("%s = ", string);		(void)printf(		    "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;			(void)printf("%s = %s", string, ctime(&boottime));		} else			(void)printf("%ld\n", btp->tv_sec);		return;	}	if (special & BLKDEV) {		dev_t dev = *(dev_t *)buf;		if (!nflag)			(void)printf("%s = %s\n", string,			    devname(dev, S_IFBLK));		else			(void)printf("0x%x\n", dev);		return;	}	if (special & CHRDEV) {		dev_t dev = *(dev_t *)buf;		if (!nflag)			(void)printf("%s = %s\n", string,			    devname(dev, S_IFCHR));		else			(void)printf("0x%x\n", dev);		return;	}#ifdef CPU_BIOS	if (special & BIOSGEO) {		bios_diskinfo_t *pdi = (bios_diskinfo_t *)buf;		if (!nflag)			(void)printf("%s = ", string);		(void)printf("bootdev = 0x%x, "			     "cylinders = %u, heads = %u, sectors = %u\n",			     pdi->bsd_dev, pdi->bios_cylinders, pdi->bios_heads,			     pdi->bios_sectors);		return;	}	if (special & BIOSDEV) {		int dev = *(int*)buf;		if (!nflag)			(void)printf("%s = ", string);		(void) printf("0x%02x\n", dev);		return;	}#endif	if (special & RNDSTATS) {		struct rndstats *rndstats = (struct rndstats *)buf;		if (!nflag)			(void)printf("%s = ", string);		(void)printf(		    "%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, lastport;		u_int32_t *baddynamic = (u_int32_t *)buf;		if (!nflag)			(void)printf("%s%s", string, newsize ? ": " : " = ");		lastport = 0;		for (port = IPPORT_RESERVED/2; port < IPPORT_RESERVED; port++)			if (DP_ISSET(baddynamic, port)) {				(void)printf("%s%hd", lastport ? "," : "",				    port);				lastport = port;			}		if (newsize != 0) {			if (!nflag)				fputs(" -> ", stdout);			baddynamic = (u_int32_t *)newval;			lastport = 0;			for (port = IPPORT_RESERVED/2; port < IPPORT_RESERVED;			    port++)				if (DP_ISSET(baddynamic, port)) {					(void)printf("%s%hd",					    lastport ? "," : "", port);					lastport = port;				}		}		(void)putchar('\n');		return;	}	switch (type) {	case CTLTYPE_INT:		if (newsize == 0) {			if (!nflag)				(void)printf("%s = ", string);			(void)printf("%d\n", *(int *)buf);		} else {			if (!nflag)				(void)printf("%s: %d -> ", string,				    *(int *)buf);			(void)printf("%d\n", *(int *)newval);		}		return;	case CTLTYPE_STRING:		if (newsize == 0) {			if (!nflag)				(void)printf("%s = ", string);			(void)puts(buf);		} else {			if (!nflag)				(void)printf("%s: %s -> ", string, buf);			(void)puts((char *)newval);		}		return;	case CTLTYPE_QUAD:		if (newsize == 0) {			if (!nflag)				(void)printf("%s = ", string);			(void)printf("%qd\n", *(quad_t *)buf);		} else {			if (!nflag)				(void)printf("%s: %qd -> ", string,				    *(quad_t *)buf);			(void)printf("%qd\n", *(quad_t *)newval);		}		return;	case CTLTYPE_STRUCT:		warnx("%s: unknown structure returned", string);		return;	default:	case CTLTYPE_NODE:		warnx("%s: unknown type returned", string);		return;	}}