LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-18-2004, 05:01 AM   #1
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Rep: Reputation: 30
Question adding a new protocol


i want to implement packet structure as (Ethernet header + MY Header + IP Header + TCP Header + Payload) that meance whenever packet comes on NIC and given for processing it should be handled by First My new routine and then by IP layer processing routine in ip_input.c file.
Also at transmitting end packet at IP layer with (IP Header + TCP Header + Payload) structure is processed at ip_output.c then given to my routine for adding a new header on that packet and then to Ethernet layer.
I search for this on google but unable to get any satisfactory answer.
I am using kernel 2.4.24 on redhat 9.
 
Old 08-18-2004, 12:08 PM   #2
shishir
Member
 
Registered: Jul 2003
Location: bangalore . india
Distribution: openSUSE 10.3
Posts: 251

Rep: Reputation: 33
learn how to use the skbuff structure and its associated apis, like skb_put, skb_push etc,
you can go to phrack.org and see how to hijack a packet and do whatever you want to do..it isnt very complicated..you can read linux device drivers - network drivers chapter to see how things get done...
read the linuxjournal.com and look for the skbuff tutorial to see how the skbuff handling is done...
 
Old 08-19-2004, 01:32 AM   #3
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Original Poster
Rep: Reputation: 30
Hello shishir,
I did some modification to kernel source in net/ipv4/ip_output.c file and implemented my own 8 byte header but it is having problem that it can support only UDP ,ICMP packets but not TCP packets. the only problem is that the statement in /net/core/dev.c file
skb->h.raw = skb->nh.raw = skb->data;
which makes me to remove it and then it works otherwies if i implement it as skb->mh.raw = skb->h.raw = skb->nh.raw = skb->data;
i got oops message.
Also tell me does that problem be solved by addine new handler and replacing it by IP packet handler i.e. ip_rcv.
 
Old 08-19-2004, 05:57 AM   #4
shishir
Member
 
Registered: Jul 2003
Location: bangalore . india
Distribution: openSUSE 10.3
Posts: 251

Rep: Reputation: 33
have you added the requisite part mh in the skbuff structure ...can you show the code...cos i dont know if this could really be the reason for the oops..
yeah, you can put your function in place of ip_rcv(), but you would have to have all the functionality before the ip_rcv performs its core actions, i.e., even though your function would be the one that gets called from netif_rx_action(), you'd have to give the packet to ip_rcv after you are done with your own header, mh's handling

you'd have to use dev_add_pack() to add your packet handling function...

Last edited by shishir; 08-19-2004 at 06:16 AM.
 
Old 08-20-2004, 02:04 AM   #5
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Original Poster
Rep: Reputation: 30
yes i did those changes in skbuff structure like
union
{
struct myownhdr *own;
unsigned char *raw;
}mh;
where struct myownhdr is
struct myownhdr
{
unsigned char *mytext;
unsigned long int seq;
};

this is the only implementation in include direcotry. one IMP thing is that i have not included yet my own packet handler in this code in ip_output.c and using ip_rcv to receive my new packet structure. At my home i will be receiving UDP and ICMP packets but not TCP when i run any socket program on loopback i will gwt oops kernel interrupt handler message only after i removed
skb->h.raw = skb->nh.raw = skb->data; from dev.c
if i make it like
skb->mh.raw = skb->h.raw = skb->nh.raw = skb->data;
i will not even able to boot kernel and get oops.
 
Old 08-20-2004, 10:11 AM   #6
shishir
Member
 
Registered: Jul 2003
Location: bangalore . india
Distribution: openSUSE 10.3
Posts: 251

Rep: Reputation: 33
ill look into it..i havent had much time to do something ...ill look at it and see if i am able to do anything..
 
Old 08-21-2004, 12:03 AM   #7
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Original Poster
Rep: Reputation: 30
Please if you get some time for me will you please reply me regarding where exactly modifications are nedded to add new protocol layer as whatever i am sending is not reaching to receiver with that statement in dev.c
 
Old 08-25-2004, 04:03 AM   #8
shishir
Member
 
Registered: Jul 2003
Location: bangalore . india
Distribution: openSUSE 10.3
Posts: 251

Rep: Reputation: 33
hi,
i am sorry for the delay...
i tried doing the modification..
i think i should have asked you beforehand itself,
but did you recompile your modules also? cos they would need to be re-built to be able to handle the new , modified sk_buff,
try it...and you should get rid of your problem.

hope this helps, it works for me...
 
Old 08-26-2004, 01:10 AM   #9
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Original Poster
Rep: Reputation: 30
hi,
i did all kernel compilations including modules also but problem resides that transmiting packet is not taken by receiving end in netif_receive_skb by that statement.
Have you also modified the skbuff and compile as i did and does it works?
 
Old 08-26-2004, 02:24 AM   #10
shishir
Member
 
Registered: Jul 2003
Location: bangalore . india
Distribution: openSUSE 10.3
Posts: 251

Rep: Reputation: 33
yeah...when i did the modification without modifying the modules...i got a panic in skb_put, and the backtrace showed me the nic card interrupt handler to be the function that led to it...
do you have the panic dump as to which function caused it ?
it makes a lot of sense 'cos we have changed the struicture, but the network driver still uses the smaller skbuff structure, without our changes...
i have made exactly the changes you made...
in fact even as i write i have the modified kernel running without any problems...

the changes that you list here are the only changes that i have made...i havent tried to do any more handling with the packet , as in removing the myhdr from the packet. if yo uhave made such changes also , then i guess you'd have to do some skb handling...to get the thing to work..
 
  


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
What is Protocol 50 jspsandhu Linux - Networking 6 08-11-2007 11:17 AM
Adding ets-game:// as protocol in Galeon Daem0hn Linux - Software 0 10-19-2003 12:02 AM
Unsupported protocol 'Compression Control Protocol' (0x80fd) received RKris Linux - Software 0 08-21-2002 08:24 AM
protocol Eddie9 Linux - General 1 06-06-2002 01:55 AM
Which protocol is better SkYzOpReNiCk Linux - Security 1 11-06-2001 12:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:46 AM.

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