Hi Sushrut,
first of all, please keep in mind that the TCP stream reassembly feature
does not handle overlapping fragments, so you'll probably have problems
with it. However, I'm working on improving it right now, so luckily in a
couple of hours I'll be pushing the changes.
Regarding libtins thread-safety, almost everything in the library
provides the same thread-safety guarantees that the C++ standard does:
that means you can have multiple readers accessing an object at the same
time, but one or more readers and one or more writers at the same time
will cause troubles. This means you can sniff a packet and have multiple
objects reading its properties and that will be perfectly fine. This
also means that you can't access a Sniffer object in a multi-thread
manner, since the libpcap handle is not thread safe either. If you're
only sniffing(and not sending packets) you shouldn't encounter any problems.
I don't think I can share who is using it in production, but I can
assure you that there are some people who are. If you're worried about
the library's stability, you shouldn't be. I'm currently using it a lot
and have *never* seen a crash/bug/memory leak ever since the library got
mature enough(around version 1.0).
If you have any other questions, please ask.
Regards,
Matias
On 02/04/14 03:23,
sushrut...@gmail.com wrote:
> Thanks Matias. I'll try this out. I have a couple of queries in addition:
> - Is libtins multithread safe? Can I share libtins object instances
> amongst threads? Is there a guideline somewhere (I saw this<
http://libtins.github.io/tutorial/sending/#thread-safety>,
> but is there something else that I should be aware of?).
> - Can you share who all are using libtins currently in production?
>
> Rgds,
> Sushrut.
>
> On Tuesday, April 1, 2014 6:43:52 PM UTC+5:30, Matias Fontanini wrote:
>> Hi,
>>
>> this can indeed be done using libtins. If you have a look at the
>> *TCPStreamFollower* class, you'll see that one of the overloads<
https://github.com/mfontanini/libtins/blob/master/include/tcp_stream.h#L248>of the
>> *follow_streams* member function takes 2 iterators as parameters. What
>> you'd need to do is create an iterator class that wraps the other library.
>> The interface of those iterators should roughly look like this:
>>
>> class SomeLibraryIterator : public
>> std::iterator<std::forward_iterator_tag, PDU> {
>> public:
>> PDU& operator*();
>> PDU* operator->();
>> // ....
>> private:
>> std::unique_ptr<PDU> the_packet_sniffed_from_some_library;
>> something some_library_handler;
>> };
>>
>> You can have a look at the SnifferIterator class<
https://github.com/mfontanini/libtins/blob/master/include/sniffer.h#L325> which
>> does exactly the same over a *Tins::Sniffer*. The iterator should extract