本文整理汇总了C++中xtables_error函数的典型用法代码示例。如果您正苦于以下问题:C++ xtables_error函数的具体用法?C++ xtables_error怎么用?C++ xtables_error使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xtables_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: connlabel_open
/* cannot do this via _init, else static builds might spew error message
* for every iptables invocation.
*/
static int connlabel_open(void)
{
const char *fname;
if (map)
return 0;
map = nfct_labelmap_new(NULL);
if (map != NULL)
return 0;
fname = nfct_labels_get_path();
if (errno) {
fprintf(stderr, "Warning: cannot open %s: %s\n",
fname, strerror(errno));
} else {
xtables_error(RESOURCE_PROBLEM,
"cannot parse %s: no labels found", fname);
}
return 1;
}
示例2: ct_parse_events
static uint32_t ct_parse_events(const struct event_tbl *tbl, unsigned int size,
const char *events)
{
char str[strlen(events) + 1], *e = str, *t;
unsigned int mask = 0, i;
strcpy(str, events);
while ((t = strsep(&e, ","))) {
for (i = 0; i < size; i++) {
if (strcmp(t, tbl[i].name))
continue;
mask |= 1 << tbl[i].event;
break;
}
if (i == size)
xtables_error(PARAMETER_PROBLEM, "Unknown event type \"%s\"", t);
}
return mask;
}
示例3: icmp_parse
static int icmp_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct ipt_icmp *icmpinfo = (struct ipt_icmp *)(*match)->data;
switch (c) {
case '1':
if (*flags == 1)
xtables_error(PARAMETER_PROBLEM,
"icmp match: only use --icmp-type once!");
xtables_check_inverse(optarg, &invert, &optind, 0, argv);
parse_icmp(optarg, &icmpinfo->type,
icmpinfo->code);
if (invert)
icmpinfo->invflags |= IPT_ICMP_INV;
*flags = 1;
break;
}
return 1;
}
示例4: MYSNAT_parse
static void MYSNAT_parse(struct xt_option_call *cb)
{
const struct ipt_entry *entry = cb->xt_entry;
struct ipt_natinfo *info = (void *)(*cb->target);
int portok;
if (entry->ip.proto == IPPROTO_TCP
|| entry->ip.proto == IPPROTO_UDP
|| entry->ip.proto == IPPROTO_SCTP
|| entry->ip.proto == IPPROTO_DCCP
|| entry->ip.proto == IPPROTO_ICMP)
portok = 1;
else
portok = 0;
xtables_option_parse(cb);
switch (cb->entry->id) {
case O_TO_SRC:
if (cb->xflags & F_X_TO_SRC) {
if (!kernel_version)
get_kernel_version();
if (kernel_version > LINUX_VERSION(2, 6, 10))
xtables_error(PARAMETER_PROBLEM,
"MYSNAT: Multiple --to-source not supported");
}
*cb->target = parse_to(cb->arg, portok, info);
/* WTF do we need this for?? */
if (cb->xflags & F_RANDOM)
info->mr.range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM;
cb->xflags |= F_X_TO_SRC;
break;
case O_RANDOM:
if (cb->xflags & F_TO_SRC)
info->mr.range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM;
break;
case O_PERSISTENT:
info->mr.range[0].flags |= IP_NAT_RANGE_PERSISTENT;
break;
}
}
示例5: ct_parse_zone_id
static void ct_parse_zone_id(const char *opt, unsigned int opt_id,
uint16_t *zone_id, uint16_t *flags)
{
if (opt_id == O_ZONE_ORIG)
*flags |= XT_CT_ZONE_DIR_ORIG;
if (opt_id == O_ZONE_REPLY)
*flags |= XT_CT_ZONE_DIR_REPL;
*zone_id = 0;
if (strcasecmp(opt, "mark") == 0) {
*flags |= XT_CT_ZONE_MARK;
} else {
uintmax_t val;
if (!xtables_strtoul(opt, NULL, &val, 0, UINT16_MAX))
xtables_error(PARAMETER_PROBLEM,
"Cannot parse %s as a zone ID\n", opt);
*zone_id = (uint16_t)val;
}
}
示例6: conntrack1_mt_parse
static void conntrack1_mt_parse(struct xt_option_call *cb)
{
struct xt_conntrack_mtinfo1 *info = cb->data;
struct xt_conntrack_mtinfo3 up;
memset(&up, 0, sizeof(up));
cinfo_transform(&up, info);
up.origsrc_port_high = up.origsrc_port;
up.origdst_port_high = up.origdst_port;
up.replsrc_port_high = up.replsrc_port;
up.repldst_port_high = up.repldst_port;
cb->data = &up;
conntrack_mt_parse(cb, 3);
if (up.origsrc_port != up.origsrc_port_high ||
up.origdst_port != up.origdst_port_high ||
up.replsrc_port != up.replsrc_port_high ||
up.repldst_port != up.repldst_port_high)
xtables_error(PARAMETER_PROBLEM,
"conntrack rev 1 does not support port ranges");
cinfo_transform(info, &up);
cb->data = info;
}
示例7: brmark_print
static void brmark_print(const void *ip, const struct xt_entry_target *target,
int numeric)
{
struct ebt_mark_t_info *info = (struct ebt_mark_t_info *)target->data;
int tmp;
tmp = info->target & ~EBT_VERDICT_BITS;
if (tmp == MARK_SET_VALUE)
printf("--mark-set");
else if (tmp == MARK_OR_VALUE)
printf("--mark-or");
else if (tmp == MARK_XOR_VALUE)
printf("--mark-xor");
else if (tmp == MARK_AND_VALUE)
printf("--mark-and");
else
xtables_error(PARAMETER_PROBLEM, "Unknown mark action");
printf(" 0x%lx", info->mark);
tmp = info->target | ~EBT_VERDICT_BITS;
printf(" --mark-target %s", ebt_target_name(tmp));
}
示例8: parse_udp_ports
static void
parse_udp_ports(const char *portstring, u_int16_t *ports)
{
char *buffer;
char *cp;
buffer = strdup(portstring);
if ((cp = strchr(buffer, ':')) == NULL)
ports[0] = ports[1] = xtables_parse_port(buffer, "udp");
else {
*cp = '\0';
cp++;
ports[0] = buffer[0] ? xtables_parse_port(buffer, "udp") : 0;
ports[1] = cp[0] ? xtables_parse_port(cp, "udp") : 0xFFFF;
if (ports[0] > ports[1])
xtables_error(PARAMETER_PROBLEM,
"invalid portrange (min > max)");
}
free(buffer);
}
示例9: for_each_table
/* Debugging prototype. */
static int for_each_table(int (*func)(const char *tablename))
{
int ret = 1;
FILE *procfile = NULL;
char tablename[XT_TABLE_MAXNAMELEN+1];
procfile = fopen("/proc/net/ip6_tables_names", "re");
if (!procfile)
return ret;
while (fgets(tablename, sizeof(tablename), procfile)) {
if (tablename[strlen(tablename) - 1] != '\n')
xtables_error(OTHER_PROBLEM,
"Badly formed tablename `%s'\n",
tablename);
tablename[strlen(tablename) - 1] = '\0';
ret &= func(tablename);
}
fclose(procfile);
return ret;
}
示例10: comment_parse
static int
comment_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct xt_comment_info *commentinfo = (struct xt_comment_info *)(*match)->data;
switch (c) {
case '1':
xtables_check_inverse(argv[optind-1], &invert, &optind, 0);
if (invert) {
xtables_error(PARAMETER_PROBLEM,
"Sorry, you can't have an inverted comment");
}
parse_comment(argv[optind-1], commentinfo);
*flags = 1;
break;
default:
return 0;
}
return 1;
}
示例11: ah_parse
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;
default:
return 0;
}
return 1;
}
示例12: REJECT_parse
static void REJECT_parse(struct xt_option_call *cb)
{
struct ipt_reject_info *reject = cb->data;
unsigned int i;
xtables_option_parse(cb);
for (i = 0; i < ARRAY_SIZE(reject_table); ++i)
if (strncasecmp(reject_table[i].name,
cb->arg, strlen(cb->arg)) == 0 ||
strncasecmp(reject_table[i].alias,
cb->arg, strlen(cb->arg)) == 0) {
reject->with = reject_table[i].with;
return;
}
/* This due to be dropped late in 2.4 pre-release cycle --RR */
if (strncasecmp("echo-reply", cb->arg, strlen(cb->arg)) == 0 ||
strncasecmp("echoreply", cb->arg, strlen(cb->arg)) == 0)
fprintf(stderr, "--reject-with echo-reply no longer"
" supported\n");
xtables_error(PARAMETER_PROBLEM,
"unknown reject type \"%s\"", cb->arg);
}
示例13: ULOG_parse
static void ULOG_parse(struct xt_option_call *cb)
{
struct ipt_ulog_info *loginfo = cb->data;
xtables_option_parse(cb);
switch (cb->entry->id) {
case O_ULOG_NLGROUP:
loginfo->nl_group = 1 << (cb->val.u8 - 1);
break;
case O_ULOG_PREFIX:
if (strchr(cb->arg, '\n') != NULL)
xtables_error(PARAMETER_PROBLEM,
"Newlines not allowed in --ulog-prefix");
break;
case O_ULOG_CPRANGE:
loginfo->copy_range = cb->val.u64;
break;
case O_ULOG_QTHR:
loginfo->qthreshold = cb->val.u64;
break;
}
}
示例14: daddr_tg_parse
/* Function which parses command options; returns true if it
ate an option */
static int
daddr_tg_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_target **target,
parse_daddr_fn da_fn)
{
struct xt_daddr_tginfo *daddrinfo
= (struct xt_daddr_tginfo *)(*target)->data;
switch (c) {
case '1':
if (*flags)
xtables_error(PARAMETER_PROBLEM,
"DADDR target: Cant specify --set-daddr twice");
(da_fn)(optarg, daddrinfo);
*flags = 1;
break;
default:
return 0;
}
return 1;
}
示例15: dns_parse
static int
dns_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct xt_dns_info *dnsinfo = (struct xt_dns_info *)(*match)->data;
switch (c) {
case '1':
xtables_check_inverse(optarg, &invert, &optind, 0, argv);
if (str2qn(optarg, dnsinfo->fqdn, sizeof(dnsinfo->fqdn)))
xtables_error(PARAMETER_PROBLEM, "--dns-fqdn invalid "
"fqdn");
if (invert)
dnsinfo->invert = 1;
*flags = 1;
break;
default:
return 0;
}
return 1;
}