LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 02-20-2012, 02:38 AM   #1
karan2386
Member
 
Registered: Jan 2012
Posts: 34

Rep: Reputation: Disabled
how to send a ping packet using dev_queue_xmit


i have written a driver which sends a ping packet but its not working (i checked using tcpdump -i wlan0 icmp) . basically i have used ioctl call from an user program to start the transmission(its working)but there some problem in module code ,following is my code for transmission:

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));
//skb->mac_header = ()
skb->mac_header = skb->dev->dev_addr;
if(dev_queue_xmit(skb)==NET_XMIT_SUCCESS)
printk(KERN_ALERT"success");

i am using dev_queue_xmit .

regards

karan
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] how to send a ping packet karan2386 Linux - Kernel 1 02-18-2012 03:36 AM
Ping - Packet FIltered pembo13 Linux - Networking 3 06-25-2010 11:24 AM
why doesn't dev_queue_xmit actually transmit the packet? drblmb Programming 1 09-17-2009 01:05 PM
why doesn't dev_queue_xmit actually transmit the packet? drblmb Linux - Networking 0 09-17-2009 09:33 AM
Packet filtered can't ping henrymaher Linux - Networking 2 01-04-2002 09:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration