static int
dccp_parse(int c, char **argv, int invert, unsigned int *flags,
           const void *entry, struct xt_entry_match **match)
{
	struct xt_dccp_info *einfo
		= (struct xt_dccp_info *)(*match)->data;

	switch (c) {
	case '1':
		if (*flags & XT_DCCP_SRC_PORTS)
			xtables_error(PARAMETER_PROBLEM,
			           "Only one `--source-port' allowed");
		einfo->flags |= XT_DCCP_SRC_PORTS;
		xtables_check_inverse(optarg, &invert, &optind, 0, argv);
		parse_dccp_ports(optarg, einfo->spts);
		if (invert)
			einfo->invflags |= XT_DCCP_SRC_PORTS;
		*flags |= XT_DCCP_SRC_PORTS;
		break;

	case '2':
		if (*flags & XT_DCCP_DEST_PORTS)
			xtables_error(PARAMETER_PROBLEM,
				   "Only one `--destination-port' allowed");
		einfo->flags |= XT_DCCP_DEST_PORTS;
		xtables_check_inverse(optarg, &invert, &optind, 0, argv);
		parse_dccp_ports(optarg, einfo->dpts);
		if (invert)
			einfo->invflags |= XT_DCCP_DEST_PORTS;
		*flags |= XT_DCCP_DEST_PORTS;
		break;

	case '3':
		if (*flags & XT_DCCP_TYPE)
			xtables_error(PARAMETER_PROBLEM,
				   "Only one `--dccp-types' allowed");
		einfo->flags |= XT_DCCP_TYPE;
		xtables_check_inverse(optarg, &invert, &optind, 0, argv);
		einfo->typemask = parse_dccp_types(optarg);
		if (invert)
			einfo->invflags |= XT_DCCP_TYPE;
		*flags |= XT_DCCP_TYPE;
		break;

	case '4':
		if (*flags & XT_DCCP_OPTION)
			xtables_error(PARAMETER_PROBLEM,
				   "Only one `--dccp-option' allowed");
		einfo->flags |= XT_DCCP_OPTION;
		xtables_check_inverse(optarg, &invert, &optind, 0, argv);
		einfo->option = parse_dccp_option(optarg);
		if (invert)
			einfo->invflags |= XT_DCCP_OPTION;
		*flags |= XT_DCCP_OPTION;
		break;
	default:
		return 0;
	}
	return 1;
}
Ejemplo n.º 2
0
static int
parse(int c, char **argv, int invert, unsigned int *flags,
      const struct ipt_entry *entry,
      unsigned int *nfcache,
      struct ipt_entry_match **match)
{
	struct ipt_dccp_info *einfo
		= (struct ipt_dccp_info *)(*match)->data;

	switch (c) {
	case '1':
		if (*flags & IPT_DCCP_SRC_PORTS)
			exit_error(PARAMETER_PROBLEM,
			           "Only one `--source-port' allowed");
		einfo->flags |= IPT_DCCP_SRC_PORTS;
		check_inverse(optarg, &invert, &optind, 0);
		parse_dccp_ports(argv[optind-1], einfo->spts);
		if (invert)
			einfo->invflags |= IPT_DCCP_SRC_PORTS;
		*flags |= IPT_DCCP_SRC_PORTS;
		break;

	case '2':
		if (*flags & IPT_DCCP_DEST_PORTS)
			exit_error(PARAMETER_PROBLEM,
				   "Only one `--destination-port' allowed");
		einfo->flags |= IPT_DCCP_DEST_PORTS;
		check_inverse(optarg, &invert, &optind, 0);
		parse_dccp_ports(argv[optind-1], einfo->dpts);
		if (invert)
			einfo->invflags |= IPT_DCCP_DEST_PORTS;
		*flags |= IPT_DCCP_DEST_PORTS;
		break;

	case '3':
		if (*flags & IPT_DCCP_TYPE)
			exit_error(PARAMETER_PROBLEM,
				   "Only one `--dccp-types' allowed");
		einfo->flags |= IPT_DCCP_TYPE;
		check_inverse(optarg, &invert, &optind, 0);
		einfo->typemask = parse_dccp_types(argv[optind-1]);
		if (invert)
			einfo->invflags |= IPT_DCCP_TYPE;
		*flags |= IPT_DCCP_TYPE;
		break;

	case '4':
		if (*flags & IPT_DCCP_OPTION)
			exit_error(PARAMETER_PROBLEM,
				   "Only one `--dccp-option' allowed");
		einfo->flags |= IPT_DCCP_OPTION;
		check_inverse(optarg, &invert, &optind, 0);
		einfo->option = parse_dccp_option(argv[optind-1]);
		if (invert)
			einfo->invflags |= IPT_DCCP_OPTION;
		*flags |= IPT_DCCP_OPTION;
		break;
	default:
		return 0;
	}
	return 1;
}