LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-29-2006, 01:02 AM   #1
eternity_00
LQ Newbie
 
Registered: Apr 2006
Distribution: fedora 3.0
Posts: 4

Rep: Reputation: 0
communicating to user space


Hi,
Can anyone tell me what wud be the best way to communicate between kernel and user space?
More precisely, I m trying to capture a packet in kernel and want to forward it to user space program where I wud encapsulate it into another protocol and send away.
Any suggestions or help is highly appreciated. I read about Netlink thing, can someone tell me if its the best way and how should I go about doing it?
 
Old 04-30-2006, 01:36 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

This simplest way is:
1. Create your own kernel module (it sounds like you're doing this anyway).
2. Implement your own "open(), "close()", "read()" and "write()", etc methods.
3. "Mknod" a special device in "/dev".
4. "Insmod" your kernel driver and executeyour user-space program that uses it

The user-space program could be a background daemon (if you wish); the kernel module could support asynchronous I/O (if you wish).

Two other approaches would be:
/proc # actually, a bit more complicated
... or ...
netlink sockets # http://www.linuxjournal.com/article/7356

Strong suggestions:
1. Get a copy of "Linux Device Drivers, 3rd Ed", Corbett, Rubini, Hartmann
http://www.bookpool.com/sm/0596005903

2. Get a copy of "Linux Kernel Development, 2nd Ed", Robert Love
http://www.bookpool.com/sm/0672327201
<= The two books absolutely complement each other

'Hope that helps .. PSM

PS:
Even though your question is about "networking", you'd probably have better luck posting to the LQ "Non-*nix, Programming" forum instead...

Last edited by paulsm4; 04-30-2006 at 01:39 PM.
 
Old 05-01-2006, 06:48 AM   #3
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 34
You could have your program liston on some usused port (either directly or via inetd) and use iptables to forward the relevant packets to that port. I wouldn't have thought it would be necessary to write a kernel module.

Last edited by ioerror; 05-01-2006 at 06:49 AM.
 
  


Reply



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
notify user space application from the kernel space lordofring Linux - Software 2 06-22-2009 12:32 PM
Allot space to a new user ArulPrabhuT Programming 3 08-14-2004 08:52 AM
User Space - Kernel Space basu_arani Programming 3 05-25-2004 11:46 AM
limit user HD space pezplaya Linux - General 3 04-26-2004 05:36 PM
User space used grub Programming 6 06-11-2003 03:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:54 PM.

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