From: Vlad <limonad@gmx.net>
To: netfilter-devel@vger.kernel.org
Subject: No chain/target/match by that name
Date: Tue, 17 Mar 2009 11:19:28 +0100 [thread overview]
Message-ID: <49BF7930.5000808@gmx.net> (raw)
Hallo , I'm trying to write a new module for iptables. I started with a
dummy module. I can successfully compile it. But if I trying to use it,
I get an error message:
$ iptables -A INPUT -s 128.0.0.1 -m secan --drop -j DROP
drop frame
iptables: No chain/target/match by that name
Can someone tell me what is a problem? Here is my code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <iptables.h>
#include <linux/netfilter_ipv4/ip_tables.h>
#include "libipt_secan.h"
static void secan_help(void)
{
printf(
"secan options:\n"
" --drop Drop Frame\n"
" --accept Accept Frame\n");
}
static int secan_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct ipt_secan_info *info = (struct ipt_secan_info *) (*match)->data;
switch (c) {
case '1':
if (*flags & SECAN_DROP)
exit_error(PARAMETER_PROBLEM, "Only use --drop once!");
*flags |= SECAN_DROP;
info->flags |= SECAN_DROP;
printf("drop frame\n");
break;
case '2':
if (*flags & SECAN_ACCEPT)
exit_error(PARAMETER_PROBLEM, "Only use --accept once!");
*flags |= SECAN_ACCEPT;
info->flags |= SECAN_ACCEPT;
printf("accept frame\n");
break;
default:
return 0;
}
return 1;
}
static void secan_check(unsigned int flags)
{
if (!flags)
exit_error(PARAMETER_PROBLEM,
"SECAN: You must specify one of "
"`--drop', `--accept'");
}
static void secan_print(const void *ip, const struct xt_entry_match *match,
int numeric)
{
printf("SECAN match ");
}
static void secan_save(const void *ip, const struct xt_entry_match *match)
{
const struct ipt_secan_info *info = (struct ipt_secan_info *)
match->data;
if (info->flags & SECAN_DROP)
{
printf("--drop ");
}
if (info->flags & SECAN_ACCEPT)
{
printf("--accept ");
}
printf("save");
}
static const struct option secan_opts[] = {
{ "drop", 0, NULL, '1' },
{ "accept", 0, NULL, '2'},
{ .name = NULL }
};
static struct xtables_match secan_reg = {
.name = "secan",
.version = XTABLES_VERSION,
.family = PF_INET,
.size = XT_ALIGN(sizeof(struct ipt_secan_info)),
.userspacesize = XT_ALIGN(sizeof(struct ipt_secan_info)),
.help = secan_help,
.parse = secan_parse,
.final_check = secan_check,
.print = secan_print,
.save = secan_save,
.extra_opts = secan_opts,
};
void _init(void)
{
xtables_register_match(&secan_reg);
}
As I sad this is only a dummy module now and it doesn't do much.
Sincerely,
Vlad
next reply other threads:[~2009-03-17 10:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-17 10:19 Vlad [this message]
2009-03-17 10:20 ` No chain/target/match by that name Jan Engelhardt
[not found] ` <49BF7B71.2080801@gmx.net>
[not found] ` <alpine.LSU.2.00.0903171131220.18190@fbirervta.pbzchgretzou.qr>
[not found] ` <49BF7D72.7010401@gmx.net>
2009-03-17 10:44 ` Jan Engelhardt
-- strict thread matches above, loose matches on Subject: below --
2004-09-05 14:31 Steve Turnbull
2004-09-05 14:54 ` Jason Opperisano
2004-09-05 15:52 ` Steve Turnbull
2004-09-05 15:55 ` Steve Turnbull
2004-09-05 16:41 ` Jose Maria Lopez
2004-09-05 17:51 ` Alistair Tonner
2004-09-05 18:32 ` Steve Turnbull
2004-09-06 23:38 ` Steve Turnbull
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49BF7930.5000808@gmx.net \
--to=limonad@gmx.net \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.