LinuxQuestions.org
Review your favorite Linux distribution.
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 07-23-2014, 05:02 AM   #1
zerop
Member
 
Registered: Jul 2014
Posts: 65

Rep: Reputation: Disabled
Question how to compile kernel module program when include sys/socket.h in module program


how to compile kernel module program when include sys/socket.h in module program

or

if can not use above,
how to write network program send and recv in kernel module program

or

if can not use sys/socket.h
does it mean that have to use snull_tx and snull_rx?
if snull_tx is layer 2, does it mean that i call the source code template in oreilly linux device drive first edition,
then another side of computer can receive this in snull_rx in module?

wonder@wonder-VirtualBox:~/layer$ sudo make -C /usr/src/linux-headers-3.8.0-29-generic cli.c M=/home/wonder/layer modules
make: Entering directory `/usr/src/linux-headers-3.8.0-29-generic'
make: Nothing to be done for `/home/wonder/layer/cli.c'.
CC [M] /home/wonder/layer/cli.o
/home/wonder/layer/cli.c:2:0: warning: "MODULE" redefined [enabled by default]
<command-line>:0:0: note: this is the location of the previous definition
/home/wonder/layer/cli.c:5:24: fatal error: sys/socket.h: No such file or directory
compilation terminated.
make[1]: *** [/home/wonder/layer/cli.o] Error 1
make: *** [_module_/home/wonder/layer] Error 2
make: Leaving directory `/usr/src/linux-headers-3.8.0-29-generic'
 
Old 07-23-2014, 01:06 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,137

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
You can't use user space libraries in kernel code. snull is example code, not part of the kernel.
If you find yourself wanting to use user space functions, don't you think you should be writing your code in user space? Most programs that send and recv over the network are in user space. Only network drivers are in the kernel.
 
Old 07-23-2014, 06:51 PM   #3
zerop
Member
 
Registered: Jul 2014
Posts: 65

Original Poster
Rep: Reputation: Disabled
Because I can use tasklet and more faster in kernel space

I find existing template about network driver
But comment said that rx and tx function are called by kernel

Should we use the network driver 's rx and tx to recv and send?

How to use these function? For example, how to pass a device eth0 to it?
 
  


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 call a kernel inserted module from a userland program?? raga4223688 Linux - Kernel 6 08-03-2011 01:32 PM
Compile and load kernel module automatically after boot? (Intel NIC module) touser Linux - Newbie 3 08-29-2009 08:45 PM
How add assebly in linux kernel module program? aminoamide Linux - Kernel 3 02-24-2009 10:39 AM
How to load the kernel module program using FC6? anandhakumar Programming 1 10-05-2007 10:22 AM
Allocating memory for user program variable from kernel module appas Programming 2 08-12-2004 10:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 04:05 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