想要查看一些结构体的定义,比如struct ip_mreq,可以查看头文件, 所有的系统预定义的结构体都在内核源代码的/include下有定义,ubuntu里面是/usr/include 。 比如要找上面提到的struct ip_mreq,可以这样:find /usr/include -name "*.h" | xargs grep "struct ip_mreq" -rn ,结果显示,这个结构体在/usr/include/netinet/in.h 的251行有定义。 其他的情况举一反三即可。 [root@localhost linux-2.6.32]# find /usr/include -name "*.h" | xargs grep "struct ip_mreq" -rn /usr/include/netinet/in.h:244:struct ip_mreq /usr/include/netinet/in.h:253:struct ip_mreq_source /usr/include/bits/in.h:88:/* Like `struct ip_mreq' but including interface specification by index. */ /usr/include/bits/in.h:89:struct ip_mreqn /usr/include/linux/in.h:112:struct ip_mreq /usr/include/linux/in.h:118:struct ip_mreqn /usr/include/linux/in.h:125:struct ip_mreq_source {