Beispiel #1
0
static void
init_commands(void)
{
	attr_init();
	bmap_init();
	fadvise_init();
	file_init();
	freeze_init();
	fsync_init();
	getrusage_init();
	help_init();
	imap_init();
	inject_init();
	madvise_init();
	mincore_init();
	mmap_init();
	open_init();
	parent_init();
	pread_init();
	prealloc_init();
	fiemap_init();
	pwrite_init();
	quit_init();
	resblks_init();
	sendfile_init();
	shutdown_init();
	truncate_init();
}
Beispiel #2
0
static int
parse_option(char *option, flowop_t *flowop)
{
	char *key;	/* Key option */
	char *value;	/* Value for the key */
	char *tmp;
	char err[128];
	if (strcasecmp(option, "tcp_nodelay") == 0) {
		flowop->options.flag |= O_TCP_NODELAY;
		return (UPERF_SUCCESS);
	} else if (strcasecmp(option, "busy") == 0) {
		flowop->options.flag |= O_THINK_BUSY;
		return (UPERF_SUCCESS);
	} else if (strcasecmp(option, "idle") == 0) {
		flowop->options.flag |= O_THINK_IDLE;
		return (UPERF_SUCCESS);
	} else if (strcasecmp(option, "canfail") == 0) {
		flowop->options.flag |= O_CANFAIL;
		return (UPERF_SUCCESS);
	} else if (strcasecmp(option, "non_blocking") == 0) {
		flowop->options.flag |= O_NONBLOCKING;
		return (UPERF_SUCCESS);
	} else {
		key = strtok(option, "=");
		value = strtok(NULL, " ");

		if (value == NULL) {
			snprintf(err, sizeof (err),
				"option %s is not of type key=value\n",
				option);
			add_error(err);
			return (1);
		}

		if (value[0] == '$') {
			tmp = getenv(&value[1]);
			if (tmp == NULL) {
				snprintf(err, sizeof (err),
					"Env variable %s = %s not set\n",
					key, value);
				add_error(err);
				return (1);
			}
			value = tmp;
		}

		if (strcasecmp(key, "size") == 0) {
			flowop->options.size = parse_size(flowop, value);
			if (flowop->options.size == -1) {
				snprintf(err, sizeof (err),
				    "Could not parse %s\n", value);
				add_error(err);
				return (1);
			}
		} else if (strcasecmp(key, "rsize") == 0) {
			flowop->options.rsize = string2int(value);
		} else if (strcasecmp(key, "nfiles") == 0) {
			flowop->options.nfiles = string2int(value);
		} else if (strcasecmp(key, "dir") == 0) {
			strlcpy(flowop->options.dir, value, PATHMAX);
			if (sendfile_init(value) != 0) {
				snprintf(err, sizeof (err),
					"Error initializing dir: %s\n",
					value);
				add_error(err);
				return (1);
			}
		} else if (strcasecmp(key, "count") == 0) {
			flowop->options.count = atoi(value);
		} else if (strcasecmp(key, "port") == 0) {
			flowop->options.port = atoi(value);
		} else if (strcasecmp(key, "protocol") == 0) {
			flowop->options.protocol = protocol_type(value);
			if (protocol_type(value) == PROTOCOL_UNSUPPORTED) {
				snprintf(err, sizeof (err),
					"Protocol %s not supported\n",
					value);
				add_error(err);
				return (1);
			}
		} else if (strcasecmp(key, "conn") == 0) {
			if ((flowop->p_id = atoi(value)) <= 0) {
				snprintf(err, sizeof (err),
				    "connection id (conn=%s) should be > 0\n",
				    value);
				add_error(err);
				return (1);
			}
		} else if (strcasecmp(key, "remotehost") == 0) {
			strlcpy(flowop->options.remotehost, value, 256);
		} else if (strcasecmp(key, "localhost") == 0) {
			strlcpy(flowop->options.localhost, value, 256);
		} else if (strcasecmp(key, "wndsz") == 0) {
			flowop->options.wndsz = string2int(value);
		} else if (strcasecmp(key, "timeout") == 0) {
			flowop->options.poll_timeout = string2nsec(value);
			if (flowop->options.poll_timeout == 0) {
				snprintf(err, sizeof (err),
					"Cannot understand timeout:%s\n",
					value);
				add_error(err);
				return (1);
			}
		} else if (strcasecmp(key, "duration") == 0) {
			flowop->options.duration = string2nsec(value);
			if (flowop->options.duration == 0) {
				snprintf(err, sizeof (err),
					"Cannot understand duration:%s\n",
					value);
				add_error(err);
				return (1);
			}
		}
#ifdef HAVE_SSL
		else if (strcasecmp(key, "engine") == 0) {
			strlcpy(flowop->options.engine, value,
				sizeof (flowop->options.engine));
		} else if (strcasecmp(key, "cipher") == 0) {
			strcpy(flowop->options.cipher, value);
		} else if (strcasecmp(key, "method") == 0) {
			strcpy(flowop->options.method, value);
		}
#endif
		else {
			snprintf(err, sizeof (err),
				"parser - Option unrecognized %s=%s",
				key, value);
			add_error(err);
			return (1);
		}
	}
	return (0);
}