[Date Prev][Date Next] [Chronological] [Thread] [Top]

HELP liblber API



		Hello

	HELP! I'm stuck.
	Is there a doc about the API for liblber? I have a TCP socket
sock. I want to read BER-encoded data from it. How can I do it? The man
page says:

       Normally, the only routines that  need  be  called  by  an
       application are ber_get_next() to get the next BER element
       and ber_scanf() to do the actual decoding.  In some cases,
       ber_peek_tag() may also need to be called in normal usage.
       The other routines are  provided  for  those  applications
       that need more control than ber_scanf() provides.  In gen-
       eral,  these  routines  return  the  tag  of  the  element
       decoded, or -1 if an error occurred.

       The  ber_get_next()  routine  is used to read the next BER
       element from the given Sockbuf, sb.  A Sockbuf consists of
       the  descriptor  (usually  socket,  but  a file descriptor
       works just as well) from which to read, and  a  BerElement
       structure  used  to maintain a buffer.  On the first call,
       the sb_ber struct should be zeroed.   It  strips  off  and
       returns  the  leading tag byte, strips off and returns the
       length of the entire element in len, and sets up  ber  for
       subsequent  calls  to ber_scanf() et al to decode the ele-
       ment.
 
	Okay, so that are the steps I need to make? I'm trying:

ber_int_t       msgid;
ber_tag_t       tag, berlen;
BerElement      ber;
Sockbuf         sockbuf;


psockbuf = ber_sockbuf_alloc_fd(sock);
memset(&ber, '\0', sizeof(BerElement));

tag = ber_get_next(psockbuf, &berlen, &ber);

	And I get a segfault and an assertion:

listen: io.c:492: ber_get_next: Assertion `(( ber
)->ber_opts.lbo_valid==0x2)' failed.

	What am I missing?
	The man page seems broken anyway, there is no BerElement in a
Sockbuf.

TIA,
Misa