Exemple #1
0
static int
ipdadm_drop(int argc, char *argv[])
{
	long val;
	int fd, rval;
	ipd_ioc_perturb_t ipip;

	if (argc != 1) {
		(void) fprintf(stderr, "%s: drop <percentage>\n",
		    g_pname);
		return (usage(stderr));
	}

	val = ipdadm_parse_long(argv[0], "drop", 0, 100);
	fd = ipdadm_open();
	ipip.ipip_zoneid = g_zid;
	ipip.ipip_arg = val;
	rval = ioctl(fd, IPDIOC_DROP, &ipip);
	(void) close(fd);
	if (rval == -1) {
		(void) fprintf(stderr, "%s: failed to change drop value: %s\n",
		    g_pname, strerror(errno));
		return (E_ERROR);
	}

	return (E_SUCCESS);
}
Exemple #2
0
static int
ipdadm_delay(int argc, char *argv[])
{
	long val;
	int fd, rval;
	ipd_ioc_perturb_t ipip;

	if (argc != 1) {
		(void) fprintf(stderr, "%s: delay <microseconds>\n",
		    g_pname);
		return (usage(stderr));
	}

	val = ipdadm_parse_long(argv[0], "delay", 0, IPD_MAX_DELAY);
	fd = ipdadm_open();
	ipip.ipip_zoneid = g_zid;
	ipip.ipip_arg = val;
	rval = ioctl(fd, IPDIOC_DELAY, &ipip);
	(void) close(fd);
	if (rval == -1) {
		(void) fprintf(stderr, "%s: failed to change delay value: %s\n",
		    g_pname, strerror(errno));
		return (E_ERROR);
	}

	return (E_SUCCESS);
}
Exemple #3
0
static int
ipdadm_corrupt(int argc, char *argv[])
{
	int rval, fd;
	long val;
	ipd_ioc_perturb_t ipip;

	if (argc != 1) {
		(void) fprintf(stderr, "%s: corrupt <percentage>\n",
		    g_pname);
		return (usage(stderr));
	}

	val = ipdadm_parse_long(argv[0], "corrupt", 0, 100);
	fd = ipdadm_open();
	ipip.ipip_zoneid = g_zid;
	ipip.ipip_arg = val;
	rval = ioctl(fd, IPDIOC_CORRUPT, &ipip);
	(void) close(fd);
	if (rval == -1) {
		(void) fprintf(stderr, "%s: failed to change corrupt "
		    "value: %s\n", g_pname, strerror(errno));
		return (E_ERROR);
	}

	return (E_SUCCESS);
}
Exemple #4
0
static int
ipdadm_drop(int argc, char *argv[])
{
	long val;
	int fd, rval;
	ipd_config_t ic;

	if (argc != 1) {
		(void) fprintf(stderr, "%s: drop <percentage>\n",
		    g_pname);
		return (usage(stderr));
	}

	val = ipdadm_parse_long(argv[0], "drop", 0, 100);
	bzero(&ic, sizeof (ic));
	ic.ic_mask = IPDM_DROP;
	ic.ic_drop = val;

	fd = ipd_open(NULL);
	rval = ipd_ctl(fd, g_zid, &ic);
	(void) ipd_close(fd);

	if (rval != 0) {
		(void) fprintf(stderr, "%s: failed to change drop value: %s\n",
		    g_pname, ipd_errmsg);
		return (E_ERROR);
	}

	return (E_SUCCESS);
}
Exemple #5
0
static int
ipdadm_delay(int argc, char *argv[])
{
	long val;
	int fd, rval;
	ipd_config_t ic;

	if (argc != 1) {
		(void) fprintf(stderr, "%s: delay <microseconds>\n",
		    g_pname);
		return (usage(stderr));
	}

	val = ipdadm_parse_long(argv[0], "delay", 0, MAXLONG);
	bzero(&ic, sizeof (ic));
	ic.ic_mask = IPDM_DELAY;
	ic.ic_delay = val;

	fd = ipd_open(NULL);
	rval = ipd_ctl(fd, g_zid, &ic);
	(void) ipd_close(fd);

	if (rval != 0) {
		(void) fprintf(stderr, "%s: failed to change delay value: %s\n",
		    g_pname, ipd_errmsg);
		return (E_ERROR);
	}

	return (E_SUCCESS);
}
Exemple #6
0
static int
ipdadm_corrupt(int argc, char *argv[])
{
	int rval, fd;
	long val;
	ipd_config_t ic;

	if (argc != 1) {
		(void) fprintf(stderr, "%s: corrupt <percentage>\n",
		    g_pname);
		return (usage(stderr));
	}

	val = ipdadm_parse_long(argv[0], "corrupt", 0, 100);
	bzero(&ic, sizeof (ic));
	ic.ic_mask = IPDM_CORRUPT;
	ic.ic_corrupt = val;

	fd = ipd_open(NULL);
	rval = ipd_ctl(fd, g_zid, &ic);
	(void) ipd_close(fd);

	if (rval != 0) {
		(void) fprintf(stderr, "%s: failed to change corrupt "
		    "value: %s\n", g_pname, ipd_errmsg);
		return (E_ERROR);
	}

	return (E_SUCCESS);
}