netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* printk mac address --hangs
@ 2010-05-13 15:45 ratheesh k
  2010-05-13 16:19 ` Jan Engelhardt
  0 siblings, 1 reply; 8+ messages in thread
From: ratheesh k @ 2010-05-13 15:45 UTC (permalink / raw)
  To: Netfilter mailing list

Why this program cause kernel crash ? , If i comment out "memcpy " ,
it works fine


*******************************************************************************************
 #include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
# include <linux/skbuff.h>

# include <linux/ip.h>
# include <linux/tcp.h>
MODULE_LICENSE("Dual BSD/GPL");

#define NF_IP_LOCAL_OUT     3


/* This is the structure we shall use to register our function */

static struct nf_hook_ops nfho;

/* This is the hook function itself */
unsigned int hook_func(unsigned int hooknum,
                       struct sk_buff *skb,
                       const struct net_device *in,
                       const struct net_device *out,
                       int (*okfn)(struct sk_buff *))
{
    struct iphdr* ip_header;
    struct tcphdr* tcp_header;
    struct ethhdr * eth_header ;
    char src[ETH_ALEN+2];
    char dst[ETH_ALEN+2];
      src[ETH_ALEN+1]='\0';
      dst[ETH_ALEN+1]='\0' ;

     ip_header  = ip_hdr(skb);
    tcp_header = tcp_hdr(skb);
    eth_header = eth_hdr(skb);


      memcpy(src , eth_header->h_source , ETH_ALEN );
      memcpy(dst , eth_header->h_dest , ETH_ALEN );

    return NF_ACCEPT;           /* Drop ALL packets */
}

/* Initialisation routine */
int init_module()
{
    /* Fill in our hook structure */
    nfho.hook = hook_func;         /* Handler function */

    nfho.hooknum  = NF_IP_LOCAL_OUT; /* First hook for IPv4 */

    nfho.pf       = PF_INET;

    nfho.priority = NF_IP_PRI_FIRST;   /* Make our function first */

    nf_register_hook(&nfho);

    return 0;
}
	
/* Cleanup routine */
void cleanup_module()
{
    nf_unregister_hook(&nfho);
}
***********************************

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-05-14  3:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-13 15:45 printk mac address --hangs ratheesh k
2010-05-13 16:19 ` Jan Engelhardt
2010-05-13 17:07   ` ratheesh k
2010-05-13 17:16     ` Jan Engelhardt
2010-05-13 17:24       ` ratheesh k
2010-05-13 19:26         ` Jan Engelhardt
2010-05-14  2:37           ` ratheesh k
2010-05-14  3:41             ` ratheesh k

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).