Fwd: how to compile netfiletr hook programs??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
This is in response to a recent post on how to compile a netfilter
program. It should work for any of the 2.6+ kernels, for 2.4, you will
have to use ip_route_output_key instead of ip_route_output_flow.
Regards,


---------- Forwarded message ----------
From: Devesh Agrawal <devesh.agrawal@xxxxxxxxx>
Date: Thu, 24 Mar 2005 10:41:42 +0530
Subject: Re: how to compile netfiletr hook programs??
To: Raghu-kisore Neelisetti <neelira@xxxxxxxxxx>


On Mon, 21 Mar 2005 01:07:50 -0600, Raghu-kisore Neelisetti
<neelira@xxxxxxxxxx> wrote:
> Hi,
> i am newbie to linux. I had a tough compiling a simple netfilter hook
> program (would simply drop the packets). I would appreciate if you could
> provide me with step by step instructions to compile the netfilter
> programs. Iam using Fedora core 3 and kernel version is 2.6.9. I would
> be happy if you cold send make file necessary to compile the code.
> please let me know i f have to install any thing to be able to use
> netfilter.
Have you included these files:

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/netfilter_ipv4.h>
#include <linux/netdevice.h>
#include <linux/ip.h>
#include <linux/inet.h>
#include <net/checksum.h>
#include <net/ip.h>
#include <net/route.h>
#include <linux/gfp.h>
#include <linux/skbuff.h>
#include <linux/icmp.h>

Also you need to declare your handler funx like this :
nf_hookfn pre_route_handler;

And ofcourse this:
struct nf_hook_ops pre_route = {
        {NULL, NULL},
        pre_route_handler,
        THIS_MODULE,
        PF_INET,
        NF_IP_PRE_ROUTING,
        NF_IP_PRI_FIRST,
};
unsigned int pre_route_handler(unsigned int hooknum,
                struct sk_buff **skb,
                const struct net_device *in,
                const struct net_device *out,
                int (*okfn)(struct sk_buff *)){return NF_DROP;}

And then the standard procedure of make -C $(KERN_DIR) SUBDIRS=$PWD
modules, make sure that in your $(KERN_DIR), you have done make config
or something equivalent.
Hope this helps.

Regards,
Devesh Agrawal

>
> Thanks in advance.
> raghu.
>
>


-- 
Devesh Agrawal
==============
The program is absolutely right; 
therefore the computer must be wrong.
-----------------
How an engineer writes a program: 
Start by debugging an empty file...
----------------------
Systems programmers are the high priests of a low cult.  - R. S. Barton

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux