Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7515231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:44:23+00:00 2026-05-30T00:44:23+00:00

i have made a module which aims to send the ping packet using ioctl

  • 0

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:

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->pid & 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->ifr_addr.sa_data);
                     len = sizeof(data);
                     skb = dev_alloc_skb(1500);
                     skb->dev = __dev_get_by_name(&init_net,"wlan0");
                     skb_reserve(skb,NET_IP_ALIGN);  //header of 2 bytes; increments tail and data pointer
                     skb->data = skb_put(skb,sizeof(len)); // increments all pointer or adds data
                     memcpy(data,skb->data,len);
                    wdev = skb->dev;
                    skb->transport_header =skb_push(skb,sizeof(icmp));
                    memset(skb->transport_header,0,sizeof(struct icmphdr));
                    memcpy(skb->transport_header,&icmp,sizeof(struct icmphdr));

                    skb->network_header=skb_push(skb,sizeof(ip4));
                    memset(skb->network_header,0,sizeof(struct iphdr));
                    memcpy(skb->network_header,&ip4,sizeof(struct iphdr));
                   // printk("i::%d\n",i);
                  // skb->mac_header = skb_push(skb,6*sizeof(0xFF)); 
                //  memset(skb->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->protocol,ip1->saddr,ip1->daddr);
   if(ip1->protocol==1)
    {
      printk(KERN_ALERT"proto:%d,addr:%X::%X\n",ip1->protocol,ip1->saddr,ip1->daddr);
      icmp1 = (struct icmphdr *)skb_transport_header(sock_buff);
      printk(KERN_ALERT"reply type: %c,,seq : %04X\n",icmp1->type,icmp1->un.echo.id);
         }
   // kfree(sock_buff);
   return NF_ACCEPT;

     }

hook function is working fine but not sure how to send a ping packet(in doubt because not getting a reply packet).

regards

karan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:44:24+00:00Added an answer on May 30, 2026 at 12:44 am

    You can check if the ping is going out of your box using the following command, as root:

    # tcpdump -i eth0 icmp
    

    Replace eth0 with the real interface name of your machine, of course.
    This command will dump all the ICMP traffic in that interface, so you should be able to check what is happening.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a web app where I am using a module which redirects
I have a custom module I made for Magento. From the admin, there is
I have made a new windows service which works fine using barebone code (just
I have made a class which a form can inherit from and it handles
On my Drupal site, I have made a Users page using the Views module,
Have some Perl code which is using the DBI module - (the code is
I have a huge multi-module project , which is being built using maven. Most
I have a PHP web application where I've made a little module system, that
I have a very simple SQL query that I made which retrieves some user
I have made a module which is transmitting but I don't know whether the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.