title: how to send a ping packet
body: <p>i have made a module which aims to send the ping packet using ioctl command from user space(application). however i am not sure whether its sending a ping packet or not because when i try to recieve a packet thru hook function there is no reply to it. i am sending the ping packet to router(192.168.1.1).following is my code its compiling and running w/o errors:</p>
  
  <pre><code>int device_ioctl(struct net_device *dev,struct ifreq *ifr, int cmd)
  {
  
  int len;
  
  //printk("%s , %d",__func__,__LINE__);
  switch(cmd)
  {
  case SIOCDEVPRIVATE:
                       printk("here it is : %s: %d\n",__func__,__LINE__);
                       break;
  
  case WLAN_TRANSMIT :
                       icmp.type = ICMP_ECHO;
                       icmp.code = 0;
                       icmp.un.echo.sequence = i++;
                       icmp.un.echo.id = current-&gt;pid &amp; 0xFFFF;
                       printk(KERN_ALERT"ID::%X\n",icmp.un.echo.id);
                       ip4.protocol = 0x01;                               //for icmp protocol
                       ip4.tos = 0x00;
                       ip4.frag_off = 0;
                       ip4.daddr = in_aton(procfs_buffer);
                       ip4.saddr = in_aton(ifr-&gt;ifr_addr.sa_data);
                       len = sizeof(data);
                       skb = dev_alloc_skb(1500);
                       skb-&gt;dev = __dev_get_by_name(&amp;init_net,"wlan0");
                       skb_reserve(skb,NET_IP_ALIGN);  //header of 2 bytes; increments tail and data pointer
                       skb-&gt;data = skb_put(skb,sizeof(len)); // increments all pointer or adds data
                       memcpy(data,skb-&gt;data,len);
                      wdev = skb-&gt;dev;
                      skb-&gt;transport_header =skb_push(skb,sizeof(icmp));
                      memset(skb-&gt;transport_header,0,sizeof(struct icmphdr));
                      memcpy(skb-&gt;transport_header,&amp;icmp,sizeof(struct icmphdr));
  
                      skb-&gt;network_header=skb_push(skb,sizeof(ip4));
                      memset(skb-&gt;network_header,0,sizeof(struct iphdr));
                      memcpy(skb-&gt;network_header,&amp;ip4,sizeof(struct iphdr));
                     // printk("i::%d\n",i);
                    // skb-&gt;mac_header = skb_push(skb,6*sizeof(0xFF)); 
                  //  memset(skb-&gt;mac_header,0xFF,6*sizeof(0xFF));  
                     dev_queue_xmit(skb);
  
                    // kfree(skb);
    }
  
    return 0;
    }
  
    unsigned int hook_func(unsigned int hooknum, struct sk_buff *skb1, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *))
    {
       struct sk_buff *sock_buff;
       struct iphdr *ip1;
       struct icmphdr *icmp1;
       sock_buff = skb1;
      //printk("ihere we are::%s,%d\n",__func__,__LINE__);
      ip1 = (struct iphdr *)skb_network_header(sock_buff);
    //printk(KERN_ALERT"proto:%d,addr:%X::%X\n",ip1-&gt;protocol,ip1-&gt;saddr,ip1-&gt;daddr);
     if(ip1-&gt;protocol==1)
      {
        printk(KERN_ALERT"proto:%d,addr:%X::%X\n",ip1-&gt;protocol,ip1-&gt;saddr,ip1-&gt;daddr);
        icmp1 = (struct icmphdr *)skb_transport_header(sock_buff);
        printk(KERN_ALERT"reply type: %c,,seq : %04X\n",icmp1-&gt;type,icmp1-&gt;un.echo.id);
           }
     // kfree(sock_buff);
     return NF_ACCEPT;
  
       }
  </code></pre>
  
  <p>hook function is working fine but not sure how to send a ping packet(in doubt because not getting a reply packet).</p>
  
  <p>regards</p>
  
  <p>karan</p>