LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 05-12-2005, 09:56 AM   #1
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Rep: Reputation: 30
How to add kernel module to kernel source?


hello,
I have written a C code that i want to execute at each NF_IP_POST_ROUTING Netfilter hook?
How to add that C file to kernel source code? I dont want to load it from user space as code require to start its working with first outgoing packet send by computer.
regards,
cranium.
 
Old 05-12-2005, 10:06 AM   #2
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
Just look at the way other modules are hooked in and follow that.
 
Old 05-12-2005, 11:02 AM   #3
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Original Poster
Rep: Reputation: 30
Other modules are located in /lib/modules/2.4.20-8/kernel/ and they are loaded automatically by kernel. what changes i have to do to add kernel module to /usr/src/linux/net/ipv4/netfilter directory?
 
Old 05-12-2005, 01:45 PM   #4
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
You'll need to change up the Makefiles, kernel build tree, and many other sections. Config scripts too. Why add it to the kernel tree?
 
Old 05-12-2005, 09:04 PM   #5
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Original Poster
Rep: Reputation: 30
Quote:
Why add it to the kernel tree?
As already said module has code that is to be used by kernel network stack. once packets starts transmitting from linux machine they will have to go throgh my code.
 
Old 05-12-2005, 09:44 PM   #6
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
If you are writing kernel-level code, you should have sufficient experience with the kernel to be able to simply add a file. If not, read the kernel documentation. If something seems unclear in the docs, I'd be happy to help clear it up.
 
Old 05-12-2005, 10:14 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,201

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
Quote:
Originally posted by Matir
If you are writing kernel-level code, you should have sufficient experience with the kernel to be able to simply add a file. If not, read the kernel documentation.
That ought to keep a body off the streets for a night or two ...
Quote:
If something seems unclear in the docs, I'd be happy to help clear it up.
Now, there's an offer too good to refuse.
I'll keep you in mind, Matir ...
 
Old 05-12-2005, 10:34 PM   #8
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
Quote:
Originally posted by syg00
That ought to keep a body off the streets for a night or two ...
Now, there's an offer too good to refuse.
I'll keep you in mind, Matir ...
LOL, keep in mind I said 'help'. I'm not Linus, or Andrew, or anything like that.

But really, adding another file to the kernel source is, I believe, well documented... somewhere.
 
  


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
How to add a kernel module source? rollo Linux - General 6 10-19-2005 03:21 PM
how to add new loadable module to kernel? Mistreated Linux - Software 7 02-02-2005 10:22 AM
Building kernel module from multiple source file in 2.6 kernel yogeshwar_s Programming 1 12-20-2004 09:31 AM
how to add my module to linux kernel eshwar_ind Linux - Newbie 3 02-10-2004 08:01 AM
how can i add the kernel source kudos Slackware 9 04-16-2003 11:42 PM


All times are GMT -5. The time now is 11:56 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 Google+: linuxquestions
Open Source Consulting | Domain Registration