LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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
 
LinkBack Search this Thread
Old 02-05-2012, 08:17 AM   #1
karan2386
Member
 
Registered: Jan 2012
Posts: 34

Rep: Reputation: Disabled
network device module equivalent to ping


have make a module which is transmitting but i dont know whther the packet which i am transmitting is a ping packet or not ......code is shown as below.......

icmp.type = 8;
icmp.code = 0;
icmp.un.echo.sequence = i;
ip4.protocol = 1; //for icmp protocol
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);
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);

how to know that it is a ping packet which i am creating and transmitting ....further i want to receieve the ping packet in response to my ping packet which i have transmitted.......i would like to use napi but wont mind any other suggestions

please read a topic : reception napi mode http://http://www.cs.columbia.edu/~n...vice-layer.ppt i could nt understand what to do from the link above....

regards karan

Last edited by karan2386; 02-05-2012 at 12:29 PM.
 
Old 02-06-2012, 02:23 PM   #2
nini09
Member
 
Registered: Apr 2009
Posts: 505

Rep: Reputation: 41
The ping packet Linux generated use ICMP type echo as ping request and echo reply as ping response. If you follow the rule, your packet should be ping packet. Or if you can reveive ping resonse from peer, it should be ping request.
 
Old 02-07-2012, 11:46 AM   #3
karan2386
Member
 
Registered: Jan 2012
Posts: 34

Original Poster
Rep: Reputation: Disabled
ok... but do you have any idea how to recieve a packet using napi.....
 
Old 02-07-2012, 02:38 PM   #4
nini09
Member
 
Registered: Apr 2009
Posts: 505

Rep: Reputation: 41
You use generic network device API. The NAPI is in network device driver.
 
Old 02-09-2012, 04:47 AM   #5
karan2386
Member
 
Registered: Jan 2012
Posts: 34

Original Poster
Rep: Reputation: Disabled
Hi nini09

could you give me any links for generic network device api(where i could see the approach)....

regards
ka
 
Old 02-09-2012, 02:13 PM   #6
nini09
Member
 
Registered: Apr 2009
Posts: 505

Rep: Reputation: 41
Check network section of following link.
http://gnugeneration.com/mirrors/kernel-api/book1.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need help configuring kernel module for network device (forcedeth) r00tb33r Linux - Software 8 04-16-2007 08:08 PM
Which network device module do i use with the Asus P5WD2 motherboard? asilentmurmur Slackware 14 04-11-2006 05:18 AM
USB Network Device does not run well ... module error suspo Linux - Networking 0 03-23-2005 10:30 AM
Wireless woes - acx100 module loaded, card detected in harddrake no network device brownb2 Mandriva 1 01-02-2005 05:02 PM


All times are GMT -5. The time now is 12:40 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration