From a0cc21f8bb6752ffe0ee5f4f5b575dc50d6d46ae Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 22 Apr 2009 03:41:05 +0200 Subject: unix-fd: add message encoding/decoding for unix fds When appending unix fds to the message a new entry in the fd array will be allocated and the index to it will be written to the message payload. When parsing unix fds from the message the index will be read from the payload and then looked up in the fd array. When we read fds we put them in a queue first. Since each message knows how many fds are attached to it we will then pop enough fds from this queue each time we decode a message from the stream. This should make sending and receiving more portable since we don't make any strong requirements on the exact semantics of the SCM_RIGHTS implementation: as long as fds are recieved in order, none or lost and the arrive at the same time as at least one byte from the actual message dat we should be able to handle them correctly. --- dbus/dbus-message-internal.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'dbus/dbus-message-internal.h') diff --git a/dbus/dbus-message-internal.h b/dbus/dbus-message-internal.h index 2e995b47..032268f1 100644 --- a/dbus/dbus-message-internal.h +++ b/dbus/dbus-message-internal.h @@ -34,6 +34,9 @@ typedef struct DBusMessageLoader DBusMessageLoader; void _dbus_message_get_network_data (DBusMessage *message, const DBusString **header, const DBusString **body); +void _dbus_message_get_unix_fds (DBusMessage *messgage, + const int **fds, + unsigned *n_fds); void _dbus_message_lock (DBusMessage *message); void _dbus_message_unlock (DBusMessage *message); @@ -54,6 +57,14 @@ void _dbus_message_loader_get_buffer (DBusMessageLoader void _dbus_message_loader_return_buffer (DBusMessageLoader *loader, DBusString *buffer, int bytes_read); + +dbus_bool_t _dbus_message_loader_get_unix_fds (DBusMessageLoader *loader, + int **fds, + unsigned *max_n_fds); +void _dbus_message_loader_return_unix_fds (DBusMessageLoader *loader, + int *fds, + unsigned n_fds); + dbus_bool_t _dbus_message_loader_queue_messages (DBusMessageLoader *loader); DBusMessage* _dbus_message_loader_peek_message (DBusMessageLoader *loader); DBusMessage* _dbus_message_loader_pop_message (DBusMessageLoader *loader); @@ -67,6 +78,10 @@ void _dbus_message_loader_set_max_message_size (DBusMessageLoader long size); long _dbus_message_loader_get_max_message_size (DBusMessageLoader *loader); +void _dbus_message_loader_set_max_message_unix_fds(DBusMessageLoader *loader, + long n); +long _dbus_message_loader_get_max_message_unix_fds(DBusMessageLoader *loader); + DBUS_END_DECLS #endif /* DBUS_MESSAGE_INTERNAL_H */ -- cgit