LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   how to compile kernel module program when include sys/socket.h in module program (https://www.linuxquestions.org/questions/linux-kernel-70/how-to-compile-kernel-module-program-when-include-sys-socket-h-in-module-program-4175512006/)

zerop 07-23-2014 05:02 AM

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'

smallpond 07-23-2014 01:06 PM

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.

zerop 07-23-2014 06:51 PM

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?


All times are GMT -5. The time now is 05:47 PM.