简体   繁体   中英

Replacement for sys/socket.h in linux kernel module?

There is a TPM 2.0 Simulator by IBM, that communicates over sockets. I have to connect to the locahost at a specific port and then send my commands over that connection.

I want to be able to use it as if I have a hardware TPM, though. So I thought I would write a kernel module, that provides a character device driver for this under /dev/tpm0 .

It is basically a proxy, that sends all the commands it receives to the Simulator and relays the answers.

I would need socket s for this task and already successfully connected to the Simulator with a user mode application I wrote.

When transferring this to the driver I wrote, though, the make file complains, that sys/socket.h can not be found.

Through research I already heard, that some libraries can only be used in user mode and I assume that sys/socket.h is one of them.

So what is the kernel replacement for it? I read a lot of articles explaining how to configure a server in a kernel module, but nothing on a client.

This should help:

A sample tcp server runs in kernel:

https://gist.github.com/llj098/752417

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM