コード例 #1
0
static void iprange_parse(struct xt_option_call *cb)
{
	struct ipt_iprange_info *info = cb->data;
	union nf_inet_addr range[2];

	xtables_option_parse(cb);
	switch (cb->entry->id) {
	case O_SRC_RANGE:
		info->flags |= IPRANGE_SRC;
		if (cb->invert)
			info->flags |= IPRANGE_SRC_INV;
		iprange_parse_range(cb->arg, range,
				    NFPROTO_IPV4, "--src-range");
		info->src.min_ip = range[0].ip;
		info->src.max_ip = range[1].ip;
		break;
	case O_DST_RANGE:
		info->flags |= IPRANGE_DST;
		if (cb->invert)
			info->flags |= IPRANGE_DST_INV;
		iprange_parse_range(cb->arg, range,
				    NFPROTO_IPV4, "--dst-range");
		info->dst.min_ip = range[0].ip;
		info->dst.max_ip = range[1].ip;
		break;
	}
}
コード例 #2
0
static int
iprange_mt6_parse(int c, char **argv, int invert, unsigned int *flags,
                  const void *entry, struct xt_entry_match **match)
{
	struct xt_iprange_mtinfo *info = (void *)(*match)->data;

	switch (c) {
	case '1': /* --src-range */
		iprange_parse_range(optarg, &info->src_min, NFPROTO_IPV6,
			"--src-range");
		info->flags |= IPRANGE_SRC;
		if (invert)
			info->flags |= IPRANGE_SRC_INV;
		*flags |= F_SRCIP;
		return true;

	case '2': /* --dst-range */
		iprange_parse_range(optarg, &info->dst_min, NFPROTO_IPV6,
			"--dst-range");
		info->flags |= IPRANGE_DST;
		if (invert)
			info->flags |= IPRANGE_DST_INV;
		*flags |= F_DSTIP;
		return true;
	}
	return false;
}
コード例 #3
0
static int iprange_parse(int c, char **argv, int invert, unsigned int *flags,
                         const void *entry, struct xt_entry_match **match)
{
	struct ipt_iprange_info *info = (struct ipt_iprange_info *)(*match)->data;
	union nf_inet_addr range[2];

	switch (c) {
	case '1':
		if (*flags & IPRANGE_SRC)
			xtables_error(PARAMETER_PROBLEM,
				   "iprange match: Only use --src-range ONCE!");
		*flags |= IPRANGE_SRC;

		info->flags |= IPRANGE_SRC;
		xtables_check_inverse(optarg, &invert, &optind, 0, argv);
		if (invert)
			info->flags |= IPRANGE_SRC_INV;
		iprange_parse_range(optarg, range, NFPROTO_IPV4, "--src-range");
		info->src.min_ip = range[0].ip;
		info->src.max_ip = range[1].ip;
		break;

	case '2':
		if (*flags & IPRANGE_DST)
			xtables_error(PARAMETER_PROBLEM,
				   "iprange match: Only use --dst-range ONCE!");
		*flags |= IPRANGE_DST;

		info->flags |= IPRANGE_DST;
		xtables_check_inverse(optarg, &invert, &optind, 0, argv);
		if (invert)
			info->flags |= IPRANGE_DST_INV;

		iprange_parse_range(optarg, range, NFPROTO_IPV4, "--dst-range");
		info->dst.min_ip = range[0].ip;
		info->dst.max_ip = range[1].ip;
		break;

	default:
		return 0;
	}
	return 1;
}
コード例 #4
0
static void iprange_mt_parse(struct xt_option_call *cb, uint8_t nfproto)
{
	struct xt_iprange_mtinfo *info = cb->data;

	xtables_option_parse(cb);
	switch (cb->entry->id) {
	case O_SRC_RANGE:
		iprange_parse_range(cb->arg, &info->src_min, nfproto,
			"--src-range");
		info->flags |= IPRANGE_SRC;
		if (cb->invert)
			info->flags |= IPRANGE_SRC_INV;
		break;
	case O_DST_RANGE:
		iprange_parse_range(cb->arg, &info->dst_min, nfproto,
			"--dst-range");
		info->flags |= IPRANGE_DST;
		if (cb->invert)
			info->flags |= IPRANGE_DST_INV;
		break;
	}
}