All of lore.kernel.org
 help / color / mirror / Atom feed
* can't compile simple netfilter hook
@ 2002-10-26  9:03 Bogdan DUMITRIU
  0 siblings, 0 replies; only message in thread
From: Bogdan DUMITRIU @ 2002-10-26  9:03 UTC (permalink / raw)
  To: netfilter

[-- Attachment #1: Type: text/plain, Size: 4538 bytes --]

I have tried to compile the following netfilter hook (found in one of the documents listed in the documentation area at www.netfilter.org) and I just can't make it.

Here's how I tried to compile it:

gcc -c -I/lib/modules/`uname -r`/build/include ./netmod.c -Wall

Here's the error I got:

In file included from ./netfmod.c:4:
/lib/modules/2.4.18-4GB/build/include/linux/netfilter_ipv4.h:53: `INT_MIN' undeclared here (not in a function)
/lib/modules/2.4.18-4GB/build/include/linux/netfilter_ipv4.h:53: enumerator value for `NF_IP_PRI_FIRST' not integer constant
/lib/modules/2.4.18-4GB/build/include/linux/netfilter_ipv4.h:59: `INT_MAX' undeclared here (not in a function)
/lib/modules/2.4.18-4GB/build/include/linux/netfilter_ipv4.h:59: enumerator value for `NF_IP_PRI_LAST' not integer constant
./netfmod.c:12: warning: `struct net_device' declared inside parameter list
./netfmod.c:12: warning: its scope is only this definition or declaration, which is probably not what you want.
./netfmod.c:12: warning: `struct sk_buff' declared inside parameter list
./netfmod.c: In function `stupid_hook':
./netfmod.c:14: dereferencing pointer to incomplete type
./netfmod.c: At top level:
./netfmod.c:21: variable `stupid_ops' has initializer but incomplete type
./netfmod.c:21: extra brace group at end of initializer
./netfmod.c:21: (near initialization for `stupid_ops')
./netfmod.c:21: `NULL' undeclared here (not in a function)
./netfmod.c:21: `NULL' undeclared here (not in a function)
./netfmod.c:21: warning: excess elements in struct initializer
./netfmod.c:21: warning: (near initialization for `stupid_ops')
./netfmod.c:21: warning: excess elements in struct initializer
./netfmod.c:21: warning: (near initialization for `stupid_ops')
./netfmod.c:21: `PF_INET' undeclared here (not in a function)
./netfmod.c:21: warning: excess elements in struct initializer
./netfmod.c:21: warning: (near initialization for `stupid_ops')
./netfmod.c:21: warning: excess elements in struct initializer
./netfmod.c:21: warning: (near initialization for `stupid_ops')
./netfmod.c:21: warning: excess elements in struct initializer
./netfmod.c:21: warning: (near initialization for `stupid_ops')
./netfmod.c:23: parse error before `init'
./netfmod.c:24: warning: return-type defaults to `int'
./netfmod.c: In function `init':
./netfmod.c:25: warning: implicit declaration of function `nf_register_hook'
./netfmod.c: At top level:
./netfmod.c:28: parse error before `fini'
./netfmod.c:29: warning: return-type defaults to `int'
./netfmod.c: In function `fini':
./netfmod.c:30: warning: implicit declaration of function `nf_unregister_hook'
./netfmod.c:30: `linuxmag_ops' undeclared (first use in this function)
./netfmod.c:30: (Each undeclared identifier is reported only once
./netfmod.c:30: for each function it appears in.)
./netfmod.c:31: warning: control reaches end of non-void function
./netfmod.c: At top level:
./netfmod.c:33: warning: type defaults to `int' in declaration of `module_init'
./netfmod.c:33: warning: parameter names (without types) in function declaration
./netfmod.c:33: warning: data definition has no type or storage class
./netfmod.c:34: warning: type defaults to `int' in declaration of `module_exit'
./netfmod.c:34: warning: parameter names (without types) in function declaration
./netfmod.c:34: warning: data definition has no type or storage class 

Here is the code in netmod.c:

/* Rusty's Dumb netfilter hook example */
#include <linux/config.h>
#include <linux/module.h>
#include <linux/netfilter_ipv4.h>
#include <linux/ip.h>

/* The work comes in here from netfilter.c. */
static unsigned int
stupid_hook(unsigned int hook,
           struct sk_buff **pskb,
           const struct net_device *indev,
           const struct net_device *outdev,
           int (*okfn)(struct sk_buff *))
{
       if ((*pskb)->len == 200)
               return NF_DROP;

       return NF_ACCEPT;
}

static struct nf_hook_ops stupid_ops
= { { NULL, NULL }, stupid_hook, PF_INET, NF_IP_POST_ROUTING, 0 };

static int __init init(void)
{
        return nf_register_hook(&stupid_ops);
}

static void __exit fini(void)
{
        nf_unregister_hook(&linuxmag_ops);
}

module_init(init);
module_exit(fini);

I run a SuSE 8.0 Linux, kernel version 2.4.18, gcc version 2.95.3.

Please help with this as I need it for a school project and I can't get to actually doing what I have to do because I just can't make this work.

Thanks.
Bogdan.

[-- Attachment #2: Type: text/html, Size: 6452 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-26  9:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-26  9:03 can't compile simple netfilter hook Bogdan DUMITRIU

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.