本文整理汇总了C++中xtables_check_inverse函数的典型用法代码示例。如果您正苦于以下问题:C++ xtables_check_inverse函数的具体用法?C++ xtables_check_inverse怎么用?C++ xtables_check_inverse使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xtables_check_inverse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dccp_parse
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;
}
示例2: limit_parse
static int
limit_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct xt_rateinfo *r = (struct xt_rateinfo *)(*match)->data;
unsigned int num;
switch(c) {
case '%':
if (xtables_check_inverse(optarg, &invert, &optind, 0, argv)) break;
if (!parse_rate(optarg, &r->avg))
xtables_error(PARAMETER_PROBLEM,
"bad rate `%s'", optarg);
break;
case '$':
if (xtables_check_inverse(optarg, &invert, &optind, 0, argv)) break;
if (!xtables_strtoui(optarg, NULL, &num, 0, 10000))
xtables_error(PARAMETER_PROBLEM,
"bad --limit-burst `%s'", optarg);
r->burst = num;
break;
default:
return 0;
}
if (invert)
xtables_error(PARAMETER_PROBLEM,
"limit does not support invert");
return 1;
}
示例3: dscp_parse
static int
dscp_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct xt_dscp_info *dinfo
= (struct xt_dscp_info *)(*match)->data;
switch (c) {
case 'F':
if (*flags)
xtables_error(PARAMETER_PROBLEM,
"DSCP match: Only use --dscp ONCE!");
xtables_check_inverse(optarg, &invert, &optind, 0, argv);
parse_dscp(optarg, dinfo);
if (invert)
dinfo->invert = 1;
*flags = 1;
break;
case 'G':
if (*flags)
xtables_error(PARAMETER_PROBLEM,
"DSCP match: Only use --dscp-class ONCE!");
xtables_check_inverse(optarg, &invert, &optind, 0, argv);
parse_class(optarg, dinfo);
if (invert)
dinfo->invert = 1;
*flags = 1;
break;
}
return 1;
}
示例4: addrtype_parse_v0
static int
addrtype_parse_v0(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct ipt_addrtype_info *info =
(struct ipt_addrtype_info *) (*match)->data;
switch (c) {
case '1':
if (*flags&IPT_ADDRTYPE_OPT_SRCTYPE)
xtables_error(PARAMETER_PROBLEM,
"addrtype: can't specify src-type twice");
xtables_check_inverse(optarg, &invert, &optind, 0);
parse_types(argv[optind-1], &info->source);
if (invert)
info->invert_source = 1;
*flags |= IPT_ADDRTYPE_OPT_SRCTYPE;
break;
case '2':
if (*flags&IPT_ADDRTYPE_OPT_DSTTYPE)
xtables_error(PARAMETER_PROBLEM,
"addrtype: can't specify dst-type twice");
xtables_check_inverse(optarg, &invert, &optind, 0);
parse_types(argv[optind-1], &info->dest);
if (invert)
info->invert_dest = 1;
*flags |= IPT_ADDRTYPE_OPT_DSTTYPE;
break;
default:
return 0;
}
return 1;
}
示例5: udp_parse
static int
udp_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct xt_udp *udpinfo = (struct xt_udp *)(*match)->data;
switch (c) {
case '1':
if (*flags & UDP_SRC_PORTS)
xtables_error(PARAMETER_PROBLEM,
"Only one `--source-port' allowed");
xtables_check_inverse(optarg, &invert, &optind, 0, argv);
parse_udp_ports(optarg, udpinfo->spts);
if (invert)
udpinfo->invflags |= XT_UDP_INV_SRCPT;
*flags |= UDP_SRC_PORTS;
break;
case '2':
if (*flags & UDP_DST_PORTS)
xtables_error(PARAMETER_PROBLEM,
"Only one `--destination-port' allowed");
xtables_check_inverse(optarg, &invert, &optind, 0, argv);
parse_udp_ports(optarg, udpinfo->dpts);
if (invert)
udpinfo->invflags |= XT_UDP_INV_DSTPT;
*flags |= UDP_DST_PORTS;
break;
default:
return 0;
}
return 1;
}
示例6: hbh_parse
static int hbh_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct ip6t_opts *optinfo = (struct ip6t_opts *)(*match)->data;
switch (c) {
case '1':
if (*flags & IP6T_OPTS_LEN)
xtables_error(PARAMETER_PROBLEM,
"Only one `--hbh-len' allowed");
xtables_check_inverse(optarg, &invert, &optind, 0, argv);
optinfo->hdrlen = parse_opts_num(optarg, "length");
if (invert)
optinfo->invflags |= IP6T_OPTS_INV_LEN;
optinfo->flags |= IP6T_OPTS_LEN;
*flags |= IP6T_OPTS_LEN;
break;
case '2':
if (*flags & IP6T_OPTS_OPTS)
xtables_error(PARAMETER_PROBLEM,
"Only one `--hbh-opts' allowed");
xtables_check_inverse(optarg, &invert, &optind, 0, argv);
if (invert)
xtables_error(PARAMETER_PROBLEM,
" '!' not allowed with `--hbh-opts'");
optinfo->optsnr = parse_options(optarg, optinfo->opts);
optinfo->flags |= IP6T_OPTS_OPTS;
*flags |= IP6T_OPTS_OPTS;
break;
}
return 1;
}
示例7: ecn_parse
static int ecn_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
unsigned int result;
struct ipt_ecn_info *einfo
= (struct ipt_ecn_info *)(*match)->data;
switch (c) {
case 'F':
if (*flags & IPT_ECN_OP_MATCH_CWR)
xtables_error(PARAMETER_PROBLEM,
"ECN match: can only use parameter ONCE!");
xtables_check_inverse(optarg, &invert, &optind, 0);
einfo->operation |= IPT_ECN_OP_MATCH_CWR;
if (invert)
einfo->invert |= IPT_ECN_OP_MATCH_CWR;
*flags |= IPT_ECN_OP_MATCH_CWR;
break;
case 'G':
if (*flags & IPT_ECN_OP_MATCH_ECE)
xtables_error(PARAMETER_PROBLEM,
"ECN match: can only use parameter ONCE!");
xtables_check_inverse(optarg, &invert, &optind, 0);
einfo->operation |= IPT_ECN_OP_MATCH_ECE;
if (invert)
einfo->invert |= IPT_ECN_OP_MATCH_ECE;
*flags |= IPT_ECN_OP_MATCH_ECE;
break;
case 'H':
if (*flags & IPT_ECN_OP_MATCH_IP)
xtables_error(PARAMETER_PROBLEM,
"ECN match: can only use parameter ONCE!");
xtables_check_inverse(optarg, &invert, &optind, 0);
if (invert)
einfo->invert |= IPT_ECN_OP_MATCH_IP;
*flags |= IPT_ECN_OP_MATCH_IP;
einfo->operation |= IPT_ECN_OP_MATCH_IP;
if (!xtables_strtoui(optarg, NULL, &result, 0, 3))
xtables_error(PARAMETER_PROBLEM,
"ECN match: Value out of range");
einfo->ip_ect = result;
break;
default:
return 0;
}
return 1;
}
示例8: __multiport_parse
/* Function which parses command options; returns true if it
ate an option */
static int
__multiport_parse(int c, char **argv, int invert, unsigned int *flags,
struct xt_entry_match **match, u_int16_t pnum,
u_int8_t invflags)
{
const char *proto;
struct xt_multiport *multiinfo
= (struct xt_multiport *)(*match)->data;
switch (c) {
case '1':
xtables_check_inverse(optarg, &invert, &optind, 0, argv);
proto = check_proto(pnum, invflags);
multiinfo->count = parse_multi_ports(optarg,
multiinfo->ports, proto);
multiinfo->flags = XT_MULTIPORT_SOURCE;
break;
case '2':
xtables_check_inverse(optarg, &invert, &optind, 0, argv);
proto = check_proto(pnum, invflags);
multiinfo->count = parse_multi_ports(optarg,
multiinfo->ports, proto);
multiinfo->flags = XT_MULTIPORT_DESTINATION;
break;
case '3':
xtables_check_inverse(optarg, &invert, &optind, 0, argv);
proto = check_proto(pnum, invflags);
multiinfo->count = parse_multi_ports(optarg,
multiinfo->ports, proto);
multiinfo->flags = XT_MULTIPORT_EITHER;
break;
default:
return 0;
}
if (invert)
xtables_error(PARAMETER_PROBLEM,
"multiport does not support invert");
if (*flags)
xtables_error(PARAMETER_PROBLEM,
"multiport can only have one option");
*flags = 1;
return 1;
}
示例9: addrtype_parse_v1
static int
addrtype_parse_v1(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct ipt_addrtype_info_v1 *info =
(struct ipt_addrtype_info_v1 *) (*match)->data;
switch (c) {
case '1':
if (*flags & IPT_ADDRTYPE_OPT_SRCTYPE)
xtables_error(PARAMETER_PROBLEM,
"addrtype: can't specify src-type twice");
xtables_check_inverse(optarg, &invert, &optind, 0);
parse_types(argv[optind-1], &info->source);
if (invert)
info->flags |= IPT_ADDRTYPE_INVERT_SOURCE;
*flags |= IPT_ADDRTYPE_OPT_SRCTYPE;
break;
case '2':
if (*flags & IPT_ADDRTYPE_OPT_DSTTYPE)
xtables_error(PARAMETER_PROBLEM,
"addrtype: can't specify dst-type twice");
xtables_check_inverse(optarg, &invert, &optind, 0);
parse_types(argv[optind-1], &info->dest);
if (invert)
info->flags |= IPT_ADDRTYPE_INVERT_DEST;
*flags |= IPT_ADDRTYPE_OPT_DSTTYPE;
break;
case '3':
if (*flags & IPT_ADDRTYPE_OPT_LIMIT_IFACE_IN)
xtables_error(PARAMETER_PROBLEM,
"addrtype: can't specify limit-iface-in twice");
info->flags |= IPT_ADDRTYPE_LIMIT_IFACE_IN;
*flags |= IPT_ADDRTYPE_OPT_LIMIT_IFACE_IN;
break;
case '4':
if (*flags & IPT_ADDRTYPE_OPT_LIMIT_IFACE_OUT)
xtables_error(PARAMETER_PROBLEM,
"addrtype: can't specify limit-iface-out twice");
info->flags |= IPT_ADDRTYPE_LIMIT_IFACE_OUT;
*flags |= IPT_ADDRTYPE_OPT_LIMIT_IFACE_OUT;
break;
default:
return 0;
}
return 1;
}
示例10: mark_parse
static int
mark_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct xt_mark_info *markinfo = (struct xt_mark_info *)(*match)->data;
switch (c) {
char *end;
case '1':
xtables_check_inverse(optarg, &invert, &optind, 0);
markinfo->mark = strtoul(optarg, &end, 0);
if (*end == '/') {
markinfo->mask = strtoul(end+1, &end, 0);
} else
markinfo->mask = 0xffffffff;
if (*end != '\0' || end == optarg)
xtables_error(PARAMETER_PROBLEM, "Bad MARK value \"%s\"", optarg);
if (invert)
markinfo->invert = 1;
*flags = 1;
break;
default:
return 0;
}
return 1;
}
示例11: parse_target
static void
parse_target(char **argv, int invert, unsigned int *flags,
struct ipt_set_info *info, const char *what)
{
if (info->flags[0])
xtables_error(PARAMETER_PROBLEM,
"--%s can be specified only once", what);
if (xtables_check_inverse(optarg, &invert, NULL, 0))
xtables_error(PARAMETER_PROBLEM,
"Unexpected `!' after --%s", what);
if (!argv[optind]
|| argv[optind][0] == '-' || argv[optind][0] == '!')
xtables_error(PARAMETER_PROBLEM,
"--%s requires two args.", what);
if (strlen(argv[optind-1]) > IP_SET_MAXNAMELEN - 1)
xtables_error(PARAMETER_PROBLEM,
"setname `%s' too long, max %d characters.",
argv[optind-1], IP_SET_MAXNAMELEN - 1);
get_set_byname(argv[optind - 1], info);
parse_bindings(argv[optind], info);
optind++;
*flags = 1;
}
示例12: REJECT_parse
static int REJECT_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_target **target)
{
struct ipt_reject_info *reject = (struct ipt_reject_info *)(*target)->data;
static const unsigned int limit = ARRAY_SIZE(reject_table);
unsigned int i;
switch(c) {
case '1':
if (xtables_check_inverse(optarg, &invert, NULL, 0, argv))
xtables_error(PARAMETER_PROBLEM,
"Unexpected `!' after --reject-with");
for (i = 0; i < limit; i++) {
if ((strncasecmp(reject_table[i].name, optarg, strlen(optarg)) == 0)
|| (strncasecmp(reject_table[i].alias, optarg, strlen(optarg)) == 0)) {
reject->with = reject_table[i].with;
return 1;
}
}
/* This due to be dropped late in 2.4 pre-release cycle --RR */
if (strncasecmp("echo-reply", optarg, strlen(optarg)) == 0
|| strncasecmp("echoreply", optarg, strlen(optarg)) == 0)
fprintf(stderr, "--reject-with echo-reply no longer"
" supported\n");
xtables_error(PARAMETER_PROBLEM, "unknown reject type \"%s\"", optarg);
default:
/* Fall through */
break;
}
return 0;
}
示例13: parse
/* 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 void *entry,
struct xt_entry_match ** match)//lint !e830
{
if(NULL == (*match))
{
xtables_error(OTHER_PROBLEM,"*match is NULL");
}
URL_STRING_ST *dnsinfo = (URL_STRING_ST *)((*match)->data); //lint !e826
switch (c)
{
case '1':
if (*flags)
{
xtables_error(PARAMETER_PROBLEM,"Only one `--str' allowed");
}
xtables_check_inverse(optarg, &invert, &optind, 0, argv);
parse_dns_str(argv[optind-1], (char*)(&dnsinfo->acURL), URL_STRING_LEN);
if (invert)
{
dnsinfo->u16Inv = 1;
}
*flags = 1;
break;
default:
return 0;
}
return 1;
}//lint !e818
示例14: ttl_parse
static int ttl_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct ipt_ttl_info *info = (struct ipt_ttl_info *) (*match)->data;
unsigned int value;
xtables_check_inverse(optarg, &invert, &optind, 0);
switch (c) {
case '2':
if (!xtables_strtoui(optarg, NULL, &value, 0, UINT8_MAX))
xtables_error(PARAMETER_PROBLEM,
"ttl: Expected value between 0 and 255");
if (invert)
info->mode = IPT_TTL_NE;
else
info->mode = IPT_TTL_EQ;
/* is 0 allowed? */
info->ttl = value;
break;
case '3':
if (!xtables_strtoui(optarg, NULL, &value, 0, UINT8_MAX))
xtables_error(PARAMETER_PROBLEM,
"ttl: Expected value between 0 and 255");
if (invert)
xtables_error(PARAMETER_PROBLEM,
"ttl: unexpected `!'");
info->mode = IPT_TTL_LT;
info->ttl = value;
break;
case '4':
if (!xtables_strtoui(optarg, NULL, &value, 0, UINT8_MAX))
xtables_error(PARAMETER_PROBLEM,
"ttl: Expected value between 0 and 255");
if (invert)
xtables_error(PARAMETER_PROBLEM,
"ttl: unexpected `!'");
info->mode = IPT_TTL_GT;
info->ttl = value;
break;
default:
return 0;
}
if (*flags)
xtables_error(PARAMETER_PROBLEM,
"Can't specify TTL option twice");
*flags = 1;
return 1;
}
示例15: TTL_parse
static int TTL_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_target **target)
{
struct ipt_TTL_info *info = (struct ipt_TTL_info *) (*target)->data;
unsigned int value;
if (*flags & IPT_TTL_USED) {
xtables_error(PARAMETER_PROBLEM,
"Can't specify TTL option twice");
}
if (!optarg)
xtables_error(PARAMETER_PROBLEM,
"TTL: You must specify a value");
if (xtables_check_inverse(optarg, &invert, NULL, 0, argv))
xtables_error(PARAMETER_PROBLEM,
"TTL: unexpected `!'");
if (!xtables_strtoui(optarg, NULL, &value, 0, UINT8_MAX))
xtables_error(PARAMETER_PROBLEM,
"TTL: Expected value between 0 and 255");
switch (c) {
case '1':
info->mode = IPT_TTL_SET;
break;
case '2':
if (value == 0) {
xtables_error(PARAMETER_PROBLEM,
"TTL: decreasing by 0?");
}
info->mode = IPT_TTL_DEC;
break;
case '3':
if (value == 0) {
xtables_error(PARAMETER_PROBLEM,
"TTL: increasing by 0?");
}
info->mode = IPT_TTL_INC;
break;
default:
return 0;
}
info->ttl = value;
*flags |= IPT_TTL_USED;
return 1;
}