I'm trying to write a network device driver that creates a device file (for example, /dev/output), and when it's acessed (by system call read), returns a list of process and it's TCP connections at the moment it is called.

My question is, which are the kernel data structures I have to access to obtain the following data: PID, local ip address, local port, destination ip address and destination port? I read somewhere that the sock struct has almost all data I need, but I read the file in the kernel I downloaded, and I didn't found something like that. I'm using Ubuntu with kernel 2.6.35. Could someone help me, please? Thanks!