deft_code
deft_code

Reputation: 59269

Can I use protobufs to in the kernel?

I need to define a communication protocol with a Linux device driver. Protobufs look very nice, and there is an active C port.

Is it possible to use protobufs in a Linux device driver?
Obviously the vanilla c code will not work as it makes malloc calls, etc. Is there protobufs implementation that targets the kernel?

If there is a drop in solution, how much effort is it to port a C library for use in the kernel?

Bonus question: Are the answers significantly different when writing with windows drivers?

Upvotes: 7

Views: 1809

Answers (1)

caf
caf

Reputation: 239041

In theory, you could do this - but there really isn't any point in doing so. Protocol Buffers was created to ease the task of transferring data between different machines and languages that use different representations for binary data - but the interface between a kernel driver and userspace is on the same machine (and typically the same language - a C language library is usually used on the userspace side, even when writing application code in another language).

This means that the different representation issue doesn't arise - you can simply define structs in header files and pass those across the kernel/userspace boundary.

Upvotes: 7

Related Questions