Exemplo n.º 1
0
/* Function which parses command options; returns true if it
   ate an option */
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_ah *ahinfo = (struct ipt_ah *)(*match)->data;

	switch (c) {
	case '1':
		if (*flags & AH_SPI)
			exit_error(PARAMETER_PROBLEM,
				   "Only one `--ahspi' allowed");
		check_inverse(optarg, &invert, &optind, 0);
		parse_ah_spis(argv[optind-1], ahinfo->spis);
		if (invert)
			ahinfo->invflags |= IPT_AH_INV_SPI;
		*flags |= AH_SPI;
		break;
	default:
		return 0;
	}

	return 1;
}
Exemplo n.º 2
0
static int ah_parse(int c, char **argv, int invert, unsigned int *flags,
                    const void *entry, struct xt_entry_match **match)
{
	struct ipt_ah *ahinfo = (struct ipt_ah *)(*match)->data;

	switch (c) {
	case '1':
		if (*flags & AH_SPI)
			xtables_error(PARAMETER_PROBLEM,
				   "Only one `--ahspi' allowed");
		xtables_check_inverse(optarg, &invert, &optind, 0, argv);
		parse_ah_spis(optarg, ahinfo->spis);
		if (invert)
			ahinfo->invflags |= IPT_AH_INV_SPI;
		*flags |= AH_SPI;
		break;
	}

	return 1;
}
Exemplo n.º 3
0
static int ah_parse(int c, char **argv, int invert, unsigned int *flags,
                    const void *entry, struct xt_entry_match **match)
{
    struct ip6t_ah *ahinfo = (struct ip6t_ah *)(*match)->data;

    switch (c) {
    case '1':
        if (*flags & IP6T_AH_SPI)
            xtables_error(PARAMETER_PROBLEM,
                          "Only one `--ahspi' allowed");
        xtables_check_inverse(optarg, &invert, &optind, 0, argv);
        parse_ah_spis(optarg, ahinfo->spis);
        if (invert)
            ahinfo->invflags |= IP6T_AH_INV_SPI;
        *flags |= IP6T_AH_SPI;
        break;
    case '2':
        if (*flags & IP6T_AH_LEN)
            xtables_error(PARAMETER_PROBLEM,
                          "Only one `--ahlen' allowed");
        xtables_check_inverse(optarg, &invert, &optind, 0, argv);
        ahinfo->hdrlen = parse_ah_spi(optarg, "length");
        if (invert)
            ahinfo->invflags |= IP6T_AH_INV_LEN;
        *flags |= IP6T_AH_LEN;
        break;
    case '3':
        if (*flags & IP6T_AH_RES)
            xtables_error(PARAMETER_PROBLEM,
                          "Only one `--ahres' allowed");
        ahinfo->hdrres = 1;
        *flags |= IP6T_AH_RES;
        break;
    default:
        return 0;
    }

    return 1;
}