PDA

View Full Version : protocol testing...



quantt
09-01-2009, 07:32 AM
hello, may be someone know, how I can send packets from collected(via tcpdump) those before in pcap-dump to my target ip? I need this for testing my program with specify protocol without real interaction.

vart
09-01-2009, 10:05 PM
hello, may be someone know, how I can send packets from collected(via tcpdump) those before in pcap-dump to my target ip? I need this for testing my program with specify protocol without real interaction.

Take WinPCAP SDK (sorry - take PCAP lib for linux), take sample code that reads packets from the dump file, write application using this sample, that will read packets and then send them to the preconfigured port...

As a starting point look for function pcap_open_offline

quantt
09-03-2009, 03:14 AM
thanks for your reply, but how I can change addres while reading from the dump?

I'm collecting the data to pcap_t and then injecting it and there I'm unsure with 2 and 3 arguments, where I can get it?

pcap_t *p;
// int pcap_inject(pcap_t *p, const void *buf, size_t size)
sentbytes=pcap_inject(p, (void*)&data , sizeof(data) ));

and more over, I can't change second argument, because it's a const.

actually, I can filtering the dump by this...
pcap_compile();
pcap_setfilter();