Dear All,
I am trying to create a module that will intercept all socket creation (locally) and will print (or log) the process id of the process that created the socket.
Any ideas how to do the linking between the socket system call and the process id of the process that created it ?
Thanks to all
sock_register()
Hi,
Use
sock_register()in yourmodule_initfunction to register a socket family (or I guess in your case multiple socket families).As a parameter you will need to pass in a pointer to a code>struct net_proto_family
. When you define thisstructyou will specify the.createhandler, which will be called everytime a user opens a socket of the socket family in question.As for how to get the pid, I am not exactly sure. I needed to do the same thing, but ended up having the process actually pass in its process id (inside sk_protinfo). If you find a way, please share :).
Cheers,
ib
Zdrasti :) Isn't getting the
Zdrasti :)
Isn't getting the current->pid in that case safe?
hi
hi,
its a good idea to do that, could you plz let me know more about teh thoughts and idea as i am new to it.
i appreciate your help and response in advance.