-2

What do I need to do import a Linux kernel module into python so that I can use its features in an application I want to build.

My target is to use the Better Approach To Mobile Ad-Hoc Networking (B.A.T.M.A.N) kernel module that has been included in the Linux Kernel since 2.6 for routing purposes for a mesh network that would consist of Raspberry Pis. I will be using Twisted for all the network programming.

4

2 回答 2

2

您不想加载内核模块。内核模块有许多非常奇怪的属性(例如,一些指令被编译为无操作,然后根据处理器在加载时替换。)

相反,将代码重新编译到可以从 Python 调用的用户空间库中会简单得多。

更简单的是,你可以抓住 BATMAN 算法的“用户空间”分支,称为 batmand 并使用它。http://www.open-mesh.org/projects/open-mesh/wiki/BranchesExplained

于 2013-04-28T03:16:55.973 回答
0

触发将该模块加载到内核中。将其加载到用户空间进程中可能是徒劳的。从理论上讲,您可以使用内核模块的源代码在 C 中构建 Python 模块,但这仍然不能为您提供例如硬件访问权限,并且您还必须模拟/复制大部分内核基础设施。听起来是个坏主意。

于 2013-04-27T17:36:53.310 回答