Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4729859
  • 博文数量: 930
  • 博客积分: 12070
  • 博客等级: 上将
  • 技术积分: 11448
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-15 16:57
文章分类

全部博文(930)

文章存档

2011年(60)

2010年(220)

2009年(371)

2008年(279)

分类: LINUX

2010-03-24 11:45:25

找网络通讯信息:

根据current,然后遍历 for_each_process遍历task
task_struct-->files_struct-->fd_array[fds],

 

由fd_array[fds]和sock_from_file得到struct socket结构体

 * @sk_type: socket type (%SOCK_STREAM, etc)
  * @sk_protocol: which protocol this socket belongs in this network

再inet_sk得到struct inet_sock *inet_sk(const struct sock *sk)
rcv_addr
最后得到是inet_sock结构体,里面就有sport、dport、daddr、rcv_addr等信息。


调用sock_from_file之前可以先判断下file是否是套接字,当然也可不判断,返回错误就不是套接字!!

参考内核源码应该可以很简单的就写出来了!!

等下谢谢

阅读(2047) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~