printk mac address --hangs

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

 



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);
}
***********************************
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux