pcap_compile 的输出的可移植性如何?

发布于 2024-08-14 04:27:44 字数 311 浏览 2 评论 0原文

pcap_compile() 将字符串编译为 bpf_program 结构形式的过滤器程序。理论上,我可以保存程序的编译形式,并将其提供给不同网络接口甚至不同机器上的pcap_setfilter()

那行得通吗? bpf_program 形式是否可以跨不同接口移植?不同的流程?不同的架构?或者每次我想使用表达式时编译它是最安全的吗?

基于 pcap_open_dead() 的存在,我认为它在某种程度上是可移植的,但文档中似乎没有明确说明什么是安全的,什么是不安全的。

pcap_compile() compiles a string into a filter program in the form of a bpf_program struct. In theory I could save the compiled form of the program and supply it to pcap_setfilter() on a different network interface or even on a different machine.

Will that work? Is the bpf_program form portable across different interfaces? Different processes? Different architectures? Or is it safest to compile the expression each time I want to use it?

Based on the existence of pcap_open_dead() I assume it is somewhat portable, but what's safe and what's not doesn't seem to be spelled out anywhere in the documentation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

莳間冲淡了誓言ζ 2024-08-21 04:27:44

不,它通常不便于携带。

您可以在同一台机器上使用它们。

在类似的机器上有点安全。
不同的架构?可能不会。也许如果他们有相似的类型。
不同的操作系统?不,但我不推荐其中任何一个。

如果您确实想确定,只需在使用表达式时对其进行编译即可。如果你很少做这件事,那么花费的时间确实微不足道。如果您快速切换表达方式,您可能需要保留一些表达方式。

No, it isn't portable in general.

You can use them on the same machine.

On similar machines somewhat safely.
Different architectures? Probably not. Maybe if they have similar types.
Different Operating Systems? No. I don't recommend any of these though.

If you really want to be sure, just compile the expression when you use it. It really takes an inconsequential amount of time if you're doing it rarely enough. If you're switching expressions rapidly, you might want to keep a few around.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文