LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How to send IP packets directly to IP layer? (https://www.linuxquestions.org/questions/linux-networking-3/how-to-send-ip-packets-directly-to-ip-layer-4175416561/)

palt 07-13-2012 12:28 PM

How to send IP packets directly to IP layer?
 
Hello!
At first I should say that I have no a lot of experience in Linux network programming under the kernel. But I want to implement one idea that is interesting for me. And this implementation should work under the kernel.
Shortly this idea consist in using netfilter framework to filter internal IP traffic. I want to redirect all input IP traffic from remote host (for example under Windows OS) to my machine. How it will work under Windows is not important now. One importance I will receive external IP traffic via serial line. Receiving IP packets is implemented under the kernel by special module. Now I want to send received IP packets directly to IP layer of my Linux machine to use netfilter framework to filter these packets. But I don't know exactly how to do this . Is it possible to use ip_rcv() function directly? Or may be I should emulate a network device? Also may be somebody have source examples for my situation...

Thanks!

Maz_ 07-13-2012 04:41 PM

I guess it would be way better to do that in userspace. If you really want to do that in kernel, you'd better go ask this in netdev mail list. If your idea is reasonable you'll propably get help - it if is not - well, you'll hear that too. Just do not forget the etiquette when mailing at netdev ;)

in userspace you could propably get packets for filtering using netlink sockets.

palt 07-14-2012 05:57 AM

Maz, thanks for your reply! I want to use the kernel level due to perfomance. High level of perfomance if very important for me.
As you recomend I have read a part of documentation to the netlink. To get filtered packets I should use NETLINK_FIREWALL protocol. But I didn't find what kind of netlink protocols I should use to send IP packets into the netfilter kernel chains to filter these packets. Can you promt to me what protocol I should use to send IP packets into the kernel?

SuperJediWombat! 07-18-2012 03:45 AM

That has already been implemented in the kernel using tun/tap devices.

palt 07-20-2012 03:59 PM

SuperJediWombat,
thanks! I've read short information about tun/tap devices. I think it seems to be very intersting for me. I'll continue to investigate these devices. Thanks!


All times are GMT -5. The time now is 11:47 PM.