本文介绍了的Mac OS X:如何通过内核扩展而得到的TCP连接的连接TCPCB结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想提供一个用户空间的功能,通过实施内核扩展获得TCP连接的统计信息。从检查TCP源,我看到了tcpcp结构持有这样的统计数据。我怎样才能,给用户空间套接字句柄,获得通过内核扩展相关的连接TCPCB结构和统计数据返回到用户空间?

I want to provide a user space function that obtains TCP connection stats by implementing a kernel extension. From examining the TCP source, I see the tcpcp struct holds such stats. How can I, given a socket handle from user space, obtain the associated tcpcb struct via a kernel extension and return the stats to user space?

推荐答案

直接回答这个问题:我相信你不能从KEXT此信息获取,而无需使用一些私有头涉足该结构的内存布局。当苹果改变这些结构的布局,这将IF /打破。

Direct answer to the question: I believe you can't get at this information from a kext without using some private headers to get the memory layout of the structs involved. This will break if/when Apple changes the layout of those structs.

不过,它看起来像你真的不关心的kext方面,并很高兴能获得用户空间的信息,让你有调查 TCPCTL_PCBLIST sysctl的?这使您可转债为系统中的TCP连接,以及 xtcpcb64 结构不包含你后的字段。这种机制可能不适合你的目的是粒度不够细,但。

However, it looks like you don't really care about the kext aspect and are happy to get the information from userspace, so have you investigated the TCPCTL_PCBLIST sysctl? This gives you the CBs for the TCP connections in the system, and the xtcpcb64 struct does contain the fields you're after. This mechanism might not be granular enough for your purposes though.

这篇关于的Mac OS X:如何通过内核扩展而得到的TCP连接的连接TCPCB结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 02:08