Quintin
Quintin

Reputation: 109

(C) Virtual network adapter

Is there any way in linux to programatically create a virtual network adapter that can be listened to, so that whenever an attempt is made to send data through the adapter, a method is called?

I am trying to forward all packets to a single ip address, then include their original location in the packet.

something like this:

void sendPacket(char to[], char data[])

So like if I ping google.com through the virtual network adapter, the method will be called like this sendPacket("GooglesIp","Whatever data a ping sends")

Upvotes: 3

Views: 2758

Answers (1)

Mr. Shickadance
Mr. Shickadance

Reputation: 5473

I think what you are looking for is a TUN/TAP device in Linux, which allows a program to act as a network interface.

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

You could then write a program to listen to that TUN/TAP interface for incoming data, and process it accordingly. Basically you would route the pings to the new TUN/TAP interface, then have a program read the packets off the interface, and route them from there.

Upvotes: 10

Related Questions