I can’t say what exactly may be wrong with your code, proofreading someones code is beyond support obligations, however here is the simple sample code which is confirmed to work:
Your sample code is working infact, I did the same test before I try to send UDP packet it works fine but when I try to send UDP/TCP its not going out.
I suspect I am doing something wrong in following line of code.
iph.ip_len = htons (sizeof(iphdr) + sizeof(udphdr) + datalen);
Is it the correct way of calculating the IP Length?
Is there any chance of other sniffers can sniff the packet and WinPkFilter can’t sniff?
If so, I would like to know in what instance it may happen?