Meaning of the pointer field in the SANE network protocol
(too old to reply)
Daniel Kamil Kozar
2017-12-18 00:25:19 UTC
Hello, everyone.
I'm trying to understand the SANE network protocol. I sent a
SANE_NET_GET_DEVICES request to a SANE daemon running on a machine in
my network, and got the following response back :

200\x00\x00\x00\x00\x10""flatbed scanner\x00\x00\x00\x00\x01"

According to the documentation, this means that the request has been
completed with SANE_STATUS_GOOD. The response should thus contain a
"pointer to a NULL-terminated array of SANE_Device pointers". However,
the first SANE_Word after the status is 2, which is assumed to be the
length of the SANE_Device array. The next SANE_Word is a 0, whose
purpose is unknown to me. Four consecutive SANE_String values follow,
in line with the definition of a SANE_Device, but the whole packet
ends with a SANE_Word with value 1.
I had a look at existing implementations of the SANE network protocol
and there are generally two approaches that I've seen :
* The first one is to completely ignore the value before each of the
elements of the array, and the value following the whole array. This
is what's done by jFreeSane
* The second one is to expect the value before each of the elements
of the array to be zero, treating it is a "this record is valid" flag
(i.e. zero indicates validity). The value that comes after the whole
array is still ignored. This is what's done by WinSANE/WiaSANE
and SANEWinDS (https://sourceforge.net/p/sanewinds/code/ci/master/tree/SANEWinDS/classSANE.vb#l558).

These implementations apply the same behaviour to other arrays as
well, most notably the ones returned by

I would really like to get some clarification on what's the correct
behaviour of the client with regard to the array/pointer data returned
from the SANE server. I have to admit that the meaning of a "pointer"
in a network context is rather cryptic to me : the only scenario in
which something could be called a pointer inside a network packet is
to instruct the client to skip over a certain area in said packet -
but in that case, what's the point of sending the data anyway?

Thanks in advance,
sane-devel mailing list: sane-***@lists.alioth.debian.org
Unsubscribe: Send mail with subject "unsubscribe your_password"
to sane-devel-***@lists.alioth.debian.org