tags:

views:

253

answers:

2

Could i inject packets to Linux TCP stack without modifying the ethernet driver? Could i do this with using a library or sth ?

Thank you,

+1  A: 

If by 'inject packets to Linux TCP stack' you mean send some data that the Linux kernel will treat as a frame coming from an Ethernet interface then you can use a 'tap' device. If an IP packet (layer 3) is good enough, then use a 'tun' device.

http://en.wikipedia.org/wiki/TUN/TAP

http://www.kernel.org/pub/linux/kernel/people/marcelo/linux-2.4/Documentation/networking/tuntap.txt

Jacek Konieczny
Yes i mean send packets from same computer that the packets are like coming from ethernet device.I am searching for a solution that i can embed to my C++ code. If i create a network tap, how could i send packets to the OS that my application runs on?
Cem Cahit
Just open /dev/net/tun, configure it and write your packets there... See the other link added to my answer (already linked in the Wikipedia article).
Jacek Konieczny
A: 

Otherwise, if you're just wondering about injecting hand-crafted packets into the network, read the man pages and look for online help with raw sockets. Some good places to start are man 7 raw, man packet, and there are some ok tutorials at security-freak.net, though the code there is not written particularly well for my tastes.

OlduvaiHand