Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have made a module which is transmitting but I don't know whether the packet which I am transmitting is a ping packet or not. Code is shown 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 can I 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 herei couldn't understand what to do from the link above

share|improve this question
    
Your question is a bit bewildering, I'm not sure I understand it. You've managed to write a kernel network device driver, but don't have (or don't know how to use) packet capture software (or hardware)? The second part of your question is probably off-topic here if you want to know how to write code for that. Sorry if I completely misunderstood you. –  Mat Feb 5 '12 at 15:36
    
I think the question is "how can the program verify the data being sent", but that seems a pretty pointless operation. –  Chris Down Feb 5 '12 at 17:27
    
@Mat currently I am able to send the packet but not sure whether it is ping packet or not and second part is how to capture packet(software).....I googled and had found somthing in www.cs.columbia.edu/~nahum/w6998/lectures/device-layer.ppt (please read reception - napi mode(i was not able to understand)) –  karan421 Feb 5 '12 at 18:09
    
I'm still not clear. Are you trying to programmatically figure out something, or just monitor network traffic to see the packet as it goes out? –  Michael Mrozek Feb 5 '12 at 22:49
    
@MichaelMrozek I just want to monitor network traffic as it is transmitted and received...... –  karan421 Feb 6 '12 at 4:33
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.