LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 03-21-2012, 12:12 AM   #1
karan2386
Member
 
Registered: Jan 2012
Posts: 34

Rep: Reputation: Disabled
contents of skb->transport_header


I am trying to send the ping pkt. by writting a kernel module. when i checked whats being sent through tcpdump i saw somthing but it was not an icmp header.so decided to check whats in the headers transport_header and network_header(member of skb).how could i use printk command to do it(or any other).please see the follwing code

icmp.type = ICMP_ECHO;
icmp.code = 0;
icmp.un.echo.sequence = i++;
icmp.un.echo.id = current->pid & 0xFFFF;

skb->transport_header =skb_push(skb,sizeof(icmp));
memset(skb->transport_header,0,sizeof(struct icmphdr));
memcpy(skb->transport_header,&icmp,sizeof(struct icmphdr));
 
Old 03-21-2012, 04:57 AM   #2
karan2386
Member
 
Registered: Jan 2012
Posts: 34

Original Poster
Rep: Reputation: Disabled
taking packet headers from kernel

I am making a kernel module in which I would be sending packets. I just want to know how to initialize or from where could I take packet headers to transmit my packet.
 
Old 03-21-2012, 11:39 AM   #3
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,535

Rep: Reputation: 148Reputation: 148
The most correct way would be to estabilish proper connection using TCP or UDP in your module and use the standard network stack to generate the packets based on the data you want to send. Do you have any special requirements on the headers (are you modyfiying network protocols?) or they can be typical?

Remember that the packet headers must go well with the data you send and will differ between two sends if (and not only) the data size is different. It includes the size and content (there are checksums to calculate).
 
Old 03-21-2012, 12:55 PM   #4
karan2386
Member
 
Registered: Jan 2012
Posts: 34

Original Poster
Rep: Reputation: Disabled
no i am not changing network protocols.........could you give me some example
 
Old 03-22-2012, 02:25 PM   #5
nini09
Member
 
Registered: Apr 2009
Posts: 979

Rep: Reputation: 67
If you want to fill in TCP/UDP and IP header yourself instead of TCP/IP stack, opening a raw socket is easy solution. Otherwise you can use skb to generate packet but it is more complicated.
 
Old 04-09-2012, 03:39 AM   #6
karan2386
Member
 
Registered: Jan 2012
Posts: 34

Original Poster
Rep: Reputation: Disabled
hmmm... how to open a raw socket ???
 
Old 04-09-2012, 02:08 PM   #7
nini09
Member
 
Registered: Apr 2009
Posts: 979

Rep: Reputation: 67
Following link give you a example.
http://www.tenouk.com/Module43a.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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Updated to kernel 3.0.4 but now source package can not find kernel headers. ReaperX7 Slackware 2 10-03-2011 06:48 PM
Trying to install ethernet adapter driver, not finding kernel-devel or kernel-headers oneFishtwoFish Red Hat 5 08-31-2010 06:24 PM
Zypper wants to dl the wrong kernel headers... YaST doesnt have current headers zorb Suse/Novell 2 11-28-2009 11:12 AM
Automatic removal of kernel headers package when kernel packages are removed bgoodr Debian 3 12-30-2008 08:14 PM
send packets with kernel routing and without kernel messing with headers bassdemon Programming 5 02-08-2005 06:29 PM


All times are GMT -5. The time now is 10:19 AM.

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 Google+: linuxquestions
Open Source Consulting | Domain Registration