Hi,
On 14/04/14 03:39,
sushrut...@gmail.com wrote:
> - Is the vector that I am using need to be global in scope? (I tried
> making it global in scope - after that the behaviour I saw was exactly
> similar to what I wrote in the first post in this thread. I basically see
> the dataHandler being invoked multiple times for the HTTP GET response but
> post that there is a small text file being downloaded that I never get in
> any dataHandler invocation. endHandler also gets invoked.)
It's okay that the follower is global.
> - Should libtin's client own the responsibility of clearing out this
> vector (if it is global in scope)? Note that if I clear out the global
> vector after invoking the follow_stream function, I see no dataHandler or
> endHandler invocations.
After follow_streams processes a packet. you can erase it, since the
stream follower will keep any information it needs to reassemble the
PDU. So clearing the vector after processing it is fine.
> - Does follow_stream expect all possible packets of a particular session
> to be present when it is invoked - I believe that may not be the case? I
> ask because this is essentially what the unit test code in
> /tests/tcp_stream.cpp does, afaik.
No, you can give it one packet at a time and that will work as well.
The best you could do would be to generate a pcap file and attach it
here. That way, I could see if there's a problem in the packet
generation or the stream reassembly. The problem may be just packet
generation itself.
You can do that by modifying your code a little bit and use PacketWriter:
// global variable
PacketWriter writer("output.pcap", PacketWriter::ETH2);
callback_fn(....)
{
// same initialization of ip, tcp and rawpdu variables as you showed
EthernetII eth = EthernetII() / ip / tcp / rawpdu;
writer.write(eth);
}
A pcap file "output.pcap" will be generated in your current directory.
If you could upload it, that would be great.
Regards,
Matias