Hi again, get the process id associated to a packet
Hello again, im the insistent newbie :)
Im trying to get packet pid (process identifier) but netfilter and nfnetlink functions aren't very clear:
I saw a reference to packed pid in:
struct nlmsghdr
{
__u32 nlmsg_len; /* Length of message including header */
__u16 nlmsg_type; /* Message content */
__u16 nlmsg_flags; /* Additional flags */
__u32 nlmsg_seq; /* Sequence number */
__u32 nlmsg_pid; /* Sending process port ID */
};but isnt easy to get struct nlmsghdr from netfilter packet, i saw some could be but im not sure:
extern struct nlmsghdr *nfnl_get_msg_first(struct nfnl_handle *h,
const unsigned char *buf, size_t len);
I don't know what is buf and len, i saw library code with ddd but description is very short and i dont know how can i get buf and what is exactly. Please someone can help me to get packet's pid? I tried using netstat (-ntap | grep sourceport and destination ip) but is too slow.
Thanks for your time and sorry for my english.
Hi,
Quoted 7 lines · ilninno
Hello again, im the insistent newbie :)
Im trying to get packet pid (process identifier) but netfilter and nfnetlink functions aren't very clear:
I saw a reference to packed pid in:
Quoted 8 lines
struct nlmsghdr
{ __u32 nlmsg_len; /* Length of message including header */ __u16 nlmsg_type; /* Message content */ __u16 nlmsg_flags; /* Additional flags */ __u32 nlmsg_seq; /* Sequence number */ __u32 nlmsg_pid; /* Sending process port ID */ };
You won't find the process id information in the kernel to userspace message. The list of available fields is available in the (linux_)nfnetlink_queue.h file:
By the way, you will find some libnetfilter_queue documentation here:
http://www.nufw.org/doc/libnetfilter_queue/
PS: for your privately send question (please avoid this), you can't bind two programs to the same queue.
BR,
Signature · 3 lines
Eric Leblond <[email protected]> INL: http://www.inl.fr/ NuFW: http://www.nufw.org/
Quoted 3 lines · Eric Leblond
By the way, you will find some
libnetfilter_queuedocumentation here:
http://www.nufw.org/doc/libnetfilter_queue/
By the way, I notice that nfq_errno is not thread-safe.
Hi again!
then i will try using /proc/net/tcp to get the process associated, thanks
2009/1/5 Jan Engelhardt <[email protected]>:
Quoted 8 lines · Eric Leblond
Quoted 3 lines
By the way, you will find some
libnetfilter_queuedocumentation here:
http://www.nufw.org/doc/libnetfilter_queue/By the way, I notice that
nfq_errnois not thread-safe.