Hi,
I have modified my patch according to your comments.
On Feb 6, 2009, at 7:53 PM, Anthony Liguori wrote:
Tristan Gingold wrote:
Hi,
this patch add a new network pseudo nic that dump traffic to a
tcpdump
compatible file. I have found this feature useful to debug
network protocols
with the user stack.
...
For better results, you should use this option before the @samp{-
net user}
+one as the user stack may send replies before the initial packet
was propagated
I'd rather you fix this properly.
I have fixed this by making slirp client somewhat special: it is
always the last client. I think this is
the simplest and most efficient method. The other ones are (that
come to my mind) are:
* slirp send packets after a small delay - somewhat complex and will
decrease performances.
* qemu_send_packet puts packet into a buffer in case of recursion -
not very good for performances.
+static VLANClientState *tcpdump_vc;
+static FILE *tcpdump_file;
+static int tcpdump_caplen;
Instead of it being globals, you should have a proper state. That
way you can use this functionality with multiple VLANs.
Done.
+ fwrite(&hdr, sizeof(hdr), 1, tcpdump_file);
+ fwrite(buf, caplen, 1, tcpdump_file);
You should have some error checking here.
In case of write error, the dump is now stopped and a message is
logged.
Are tcpdump files always native endian?
Yes, the reader will swap.
Thanks,
Tristan.
Signed-off-by: Tristan Gingold <address@hidden>
<dump.patch>