dbus_message_demarshal() and partial messages

Avery Pennarun apenwarr at gmail.com
Fri Aug 17 15:03:41 PDT 2007


On 17/08/07, Havoc Pennington <hp at redhat.com> wrote:
> On 8/17/07, Avery Pennarun <apenwarr at gmail.com> wrote:
> > Having now done it (I'm linking with libdbus statically so I can
> > access its internal functions for now), I can confirm that only the
> > one new function is needed, and its implementation is pretty much
> > trivial as discussed.
>
> Propose the exact API (was that in the previous message? I forget ;-)

uint32_t dbus_message_demarshal_bytes_needed(const char *buf, uint32_t len).

Given a buffer containing the first part of a message, returns the
length of the completed message.  When that number of bytes is
available, dbus_message_demarshal() should succeed (unless the message
is corrupt in some way).

len must be >= DBUS_MINIMUM_HEADER_SIZE.  If the buffer contains a
corrupt message header or is too small, returns 0.

> > There's also a question of how a serial number gets set: unless I'm
> > mistaken, dbus_marshal() doesn't set it.  You have to lock the message
> > first, but that's private too.  dbus_marshal() should do that,
> > perhaps?
>
> The next serial to use is a property of the outgoing queue, so in this
> case libdbus won't know what it is. dbus_message_set_serial() could be
> made public I suppose.

That would be fine.

Have fun,

Avery


More information about the dbus mailing list