Hi,
Thanks for your response, Actually I have two Linux machines which are in same LAN. I tried to send Ethernet packet from one Linux machine and tried to capture in another machine using BRIDGE NETFILTER kernel code. But I am not able to succeed, i couldn't see any packets received in my Kernel.
I used BRIDGE NETFilter Hook( PRE_ROUTING) in kernel to capture the packet, but i couldn't succeed.
Can you please give me idea,how to use to etables to capture ethernet Frames using kernel code. If you have any Kernel code related to etables, could you please share to me.
I have tried to understand the etables, but not able to implement the same in kernel.
=============
Example code:
=============
static unsigned int hook_entry_pre_routing(unsigned int hooknum,
struct sk_buff **skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
struct sk_buff *sb = *skb;
static int i=0;
unsigned char haddr[6];
const struct ethhdr *eth = eth_hdr(sb);
memcpy(haddr, eth->h_source, ETH_ALEN);
printk(KERN_INFO "NFNL PRE : The Mac address is %s\n", haddr);
return NF_ACCEPT;
}
static int __init muni_nf_init(void)
{
int ret = 0;
printk(KERN_INFO "NFNL Loading BRIDGING NF Module\n");
my_hook_pre_routing.hooknum = NF_BR_PRE_ROUTING;
my_hook_pre_routing.pf = PF_BRIDGE;
my_hook_pre_routing.hook = hook_entry_pre_routing;
my_hook_pre_routing.priority = NF_BR_PRI_BRNF;
if((ret = nf_register_hook(&my_hook_pre_routing)) < 0)
{
printk(KERN_INFO "NFNL Can't regiter the hook (ERR=%d)\n",ret);
nf_unregister_hook(&my_hook_pre_routing);
return ret;
}
static void __exit muni_nf_exit(void)
{
printk(KERN_INFO "NFNL UnLoading MUNI NF Module\n");
nf_unregister_hook(&my_hook_pre_routing);
}
module_init(muni_nf_init);
module_exit(muni_nf_exit);
/* Comment goes here */
MODULE_LICENSE("Proprietary");
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_VERSION("2.4.1.7");
Thanks
--sekhar
Last edited by Sekhar417; 07-29-2011 at 11:09 PM.
Reason: Added sample code...
|