I am trying to write an application that will read data mirrored from another tcp/ip connection.
Device A connects to machine B via tcp/ip and sends it data. The sent data is duplicated and sent to machine C from device A, but with the same destination address as it did before (pointing to B not C). machine C needs to read the data and do stuff with it.
My question is how do I create a socket that will do this? I know I will need to have it in promiscuous mode. Does it need to be a RAW socket? What is the best way to get the data?
machine C will basically be a network sniffer I guess, but on a network only consisting of those 3 devices.
You want to use libpcap to grab raw packets. Run man 3 pcap
to get a list of all the relevant functions.