tcpdump mailing list archives

Re: Questions about pcap_read() function


From: "Varuna De Silva" <varunax () gmail com>
Date: Mon, 1 Oct 2007 14:43:44 +0530

Hello

On 9/30/07, Guy Harris <guy () alum mit edu> wrote:

Varuna De Silva wrote:

And when we use this FT_Read(), we wait and read in 3968 bytes at a time

So, presumably, if the device has more than 3968 bytes available, only the
first 3968 bytes are read?


Yes

What if it has fewer than 3968 bytes available?  Does the read return only
what's available?


It waits checking until it receives 3968 bytes and then read it in

If no bytes are available, does FT_Read() just block waiting for data to
be available?


Yes this case is similar to "fewer than 3968 bytes"

So the device un-does the bit stuffing, but, in order to preserve frame
boundaries, the data it hands to the host is byte-stuffed?


Exactly

So what you'd do in the xxx_read() routine would be to call FT_Read(), and
then scan through the buffer, do the filtering, and, for each SS7 frame
you extract through the buffer, call the callback routine.


Yes, Exactly, that is what I hoped to do

Now Do we need to extract all the frames, when we read in one chunk of
3968
bytes? as I understand in septel_read(....,int cnt,....) function, it
processes only a number of packets specified by cnt.

Yes.  If the cnt argument is non-zero, you should call the callback
routine no more than cnt times; any frames that are still in your buffer
should be left there, and processed by any subsequent xxx_read() call
*before* reading another bufferful of frames from the device..


Thats right,

 If cnt is zero, keep processing frames and calling the callback routine
until you
run out of frames in the buffer.


Since I  hope to  do a FT_Read() in every call to xxx_read() I have to read
all the frames
in that buffer (3968 bytes), but I guess, I do not have control over cnt
variable. It
belongs to a higher layer sw ! is it? If so how will that piece of Higher
layer SW, know
to call my xxx_read() with a cnt value of zero or non-zero?

Will this reading a chunk of bytes together with reading one frame at a time
for
each frame in the chunk, work ? Or is it good for me to have a particular
library which
does all this filtering part and reading of chunks, (in the form of a dll
for the moment) and access it?

But I like to do it in the xxx_read() it self, because then the
implementation of our
device by another, would be quite easy I guess.

I guess that works, but it's not really necessary - adding it to the
pcap_md structure will work, too, and means you don't have to modify any
of the packet.dll code (and also means that if there's a driver for your
device for some form of UN*X, you might be able to use the same code).


Alright Ill work it out.

Thanks for your reply

Varuna Xavier
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


Current thread: