30#include "dbus-internals.h" 
   31#include "dbus-connection-internal.h" 
   32#include "dbus-nonce.h" 
   33#include "dbus-transport-socket.h" 
   34#include "dbus-transport-protected.h" 
   35#include "dbus-watch.h" 
   36#include "dbus-credentials.h" 
   81  _dbus_verbose (
"start\n");
 
  103  _dbus_verbose (
"end\n");
 
  111  _dbus_verbose (
"\n");
 
  113  free_watches (transport);
 
  151          DBusAuthState auth_state;
 
  159          if (auth_state == DBUS_AUTH_STATE_HAVE_BYTES_TO_SEND ||
 
  160              auth_state == DBUS_AUTH_STATE_WAITING_FOR_MEMORY)
 
  167  _dbus_verbose (
"check_write_watch(): needed = %d on connection %p watch %p fd = %" DBUS_SOCKET_FORMAT 
" outgoing messages exist %d\n",
 
  169                 _dbus_socket_printable (socket_transport->
fd),
 
  183  dbus_bool_t need_read_watch;
 
  185  _dbus_verbose (
"fd = %" DBUS_SOCKET_FORMAT 
"\n",
 
  186                 _dbus_socket_printable (socket_transport->
fd));
 
  206        need_read_watch = 
TRUE;
 
  213          DBusAuthState auth_state;
 
  223          if (auth_state == DBUS_AUTH_STATE_WAITING_FOR_INPUT ||
 
  224              auth_state == DBUS_AUTH_STATE_WAITING_FOR_MEMORY ||
 
  225              auth_state == DBUS_AUTH_STATE_AUTHENTICATED)
 
  226            need_read_watch = 
TRUE;
 
  228            need_read_watch = 
FALSE;
 
  232  _dbus_verbose (
"  setting read watch enabled = %d\n", need_read_watch);
 
  264  saved_errno = _dbus_save_socket_errno ();
 
  270      _dbus_verbose (
" read %d bytes in auth phase\n", bytes_read);
 
  274  else if (bytes_read < 0)
 
  286          _dbus_verbose (
"Error reading from remote app: %s\n",
 
  287                         _dbus_strerror (saved_errno));
 
  288          do_io_error (transport);
 
  297      _dbus_verbose (
"Disconnected from remote app\n");
 
  298      do_io_error (transport);
 
  320  saved_errno = _dbus_save_socket_errno ();
 
  322  if (bytes_written > 0)
 
  327  else if (bytes_written < 0)
 
  335          _dbus_verbose (
"Error writing to remote app: %s\n",
 
  336                         _dbus_strerror (saved_errno));
 
  337          do_io_error (transport);
 
  347                      dbus_bool_t    do_reading,
 
  348                      dbus_bool_t    do_writing)
 
  353  _dbus_verbose (
"exchange_credentials: do_reading = %d, do_writing = %d\n",
 
  354                  do_reading, do_writing);
 
  365          _dbus_verbose (
"Failed to write credentials: %s\n", error.
message);
 
  367          do_io_error (transport);
 
  388          _dbus_verbose (
"Failed to read credentials %s\n", error.
message);
 
  390          do_io_error (transport);
 
  407                   dbus_bool_t    do_reading,
 
  408                   dbus_bool_t    do_writing,
 
  409                   dbus_bool_t   *auth_completed)
 
  412  dbus_bool_t orig_auth_state;
 
  425        *auth_completed = 
FALSE;
 
  434      if (!exchange_credentials (transport, do_reading, do_writing))
 
  444          _dbus_verbose (
"send_credentials_pending = %d receive_credentials_pending = %d\n",
 
  450#define TRANSPORT_SIDE(t) ((t)->is_server ? "server" : "client") 
  453        case DBUS_AUTH_STATE_WAITING_FOR_INPUT:
 
  454          _dbus_verbose (
" %s auth state: waiting for input\n",
 
  455                         TRANSPORT_SIDE (transport));
 
  456          if (!do_reading || !read_data_into_auth (transport, &oom))
 
  460        case DBUS_AUTH_STATE_WAITING_FOR_MEMORY:
 
  461          _dbus_verbose (
" %s auth state: waiting for memory\n",
 
  462                         TRANSPORT_SIDE (transport));
 
  467        case DBUS_AUTH_STATE_HAVE_BYTES_TO_SEND:
 
  468          _dbus_verbose (
" %s auth state: bytes to send\n",
 
  469                         TRANSPORT_SIDE (transport));
 
  470          if (!do_writing || !write_data_from_auth (transport))
 
  474        case DBUS_AUTH_STATE_NEED_DISCONNECT:
 
  475          _dbus_verbose (
" %s auth state: need to disconnect\n",
 
  476                         TRANSPORT_SIDE (transport));
 
  477          do_io_error (transport);
 
  480        case DBUS_AUTH_STATE_AUTHENTICATED:
 
  481          _dbus_verbose (
" %s auth state: authenticated\n",
 
  482                         TRANSPORT_SIDE (transport));
 
  485        case DBUS_AUTH_STATE_INVALID:
 
  496  check_read_watch (transport);
 
  497  check_write_watch (transport);
 
  517      _dbus_verbose (
"Not authenticated, not writing anything\n");
 
  523      _dbus_verbose (
"Not connected, not writing anything\n");
 
  528  _dbus_verbose (
"do_writing(), have_messages = %d, fd = %" DBUS_SOCKET_FORMAT 
"\n",
 
  530                 _dbus_socket_printable (socket_transport->
fd));
 
  543      int header_len, body_len;
 
  544      int total_bytes_to_write;
 
  549          _dbus_verbose (
"%d bytes exceeds %d bytes written per iteration, returning\n",
 
  559      _dbus_verbose (
"writing message %p\n", message);
 
  571          _dbus_assert(!DBUS_TRANSPORT_CAN_SEND_UNIX_FD(transport));
 
  594          _dbus_verbose (
"encoded message is %d bytes\n",
 
  595                         total_bytes_to_write);
 
  603          saved_errno = _dbus_save_socket_errno ();
 
  607          total_bytes_to_write = header_len + body_len;
 
  610          _dbus_verbose (
"message is %d bytes\n",
 
  611                         total_bytes_to_write);
 
  614#ifdef HAVE_UNIX_FD_PASSING 
  624                _dbus_write_socket_with_unix_fds_two (socket_transport->
fd,
 
  632              saved_errno = _dbus_save_socket_errno ();
 
  634              if (bytes_written > 0 && n > 0)
 
  635                _dbus_verbose(
"Wrote %i unix fds\n", n);
 
  660              saved_errno = _dbus_save_socket_errno ();
 
  664      if (bytes_written < 0)
 
  693              _dbus_verbose (
" discard message of %d bytes due to ETOOMANYREFS\n",
 
  694                             total_bytes_to_write);
 
  708              _dbus_verbose (
"Error writing to remote app: %s\n",
 
  709                             _dbus_strerror (saved_errno));
 
  710              do_io_error (transport);
 
  716          _dbus_verbose (
" wrote %d bytes of %d\n", bytes_written,
 
  717                         total_bytes_to_write);
 
  719          total += bytes_written;
 
  723                        total_bytes_to_write);
 
  755  _dbus_verbose (
"fd = %" DBUS_SOCKET_FORMAT 
"\n",
 
  756                 _dbus_socket_printable (socket_transport->
fd));
 
  769  check_read_watch (transport);
 
  773      _dbus_verbose (
"%d bytes exceeds %d bytes read per iteration, returning\n",
 
  790      _dbus_assert(!DBUS_TRANSPORT_CAN_SEND_UNIX_FD(transport));
 
  799      saved_errno = _dbus_save_socket_errno ();
 
  815              _dbus_verbose (
"Out of memory decoding incoming data\n");
 
  833      dbus_bool_t may_read_unix_fds = 
TRUE;
 
  843#ifdef HAVE_UNIX_FD_PASSING 
  844      if (DBUS_TRANSPORT_CAN_SEND_UNIX_FD(transport) && may_read_unix_fds)
 
  849          if (!_dbus_message_loader_get_unix_fds(transport->
loader, &fds, &n_fds))
 
  851              _dbus_verbose (
"Out of memory reading file descriptors\n");
 
  861          saved_errno = _dbus_save_socket_errno ();
 
  863          if (bytes_read >= 0 && n_fds > 0)
 
  864            _dbus_verbose(
"Read %i unix fds\n", n_fds);
 
  866          _dbus_message_loader_return_unix_fds(transport->
loader, fds, bytes_read < 0 ? 0 : n_fds);
 
  872                                          buffer, max_to_read);
 
  873          saved_errno = _dbus_save_socket_errno ();
 
  886          _dbus_verbose (
"Out of memory in read()/do_reading()\n");
 
  894          _dbus_verbose (
"Error reading from remote app: %s\n",
 
  895                         _dbus_strerror (saved_errno));
 
  896          do_io_error (transport);
 
  900  else if (bytes_read == 0)
 
  902      _dbus_verbose (
"Disconnected from remote app\n");
 
  903      do_io_error (transport);
 
  908      _dbus_verbose (
" read %d bytes\n", bytes_read);
 
  915          _dbus_verbose (
" out of memory when queueing messages we just read in the transport\n");
 
  946      _dbus_watch_get_enabled (transport->
read_watch))
 
  967  if (!(flags & 
DBUS_WATCH_READABLE) && unix_error_with_read_to_come (transport, watch, flags))
 
  969      _dbus_verbose (
"Hang up or error on watch\n");
 
  977      dbus_bool_t auth_finished;
 
  979      _dbus_verbose (
"handling read watch %p flags = %x\n",
 
  982      if (!do_authentication (transport, 
TRUE, 
FALSE, &auth_finished))
 
  993          if (!do_reading (transport))
 
  995              _dbus_verbose (
"no memory to read\n");
 
 1001          _dbus_verbose (
"Not reading anything since we just completed the authentication\n");
 
 1004  else if (watch == socket_transport->
write_watch &&
 
 1008      _dbus_verbose (
"handling write watch, have_outgoing_messages = %d\n",
 
 1014      if (!do_writing (transport))
 
 1016          _dbus_verbose (
"no memory to write\n");
 
 1021      check_write_watch (transport);
 
 1023#ifdef DBUS_ENABLE_VERBOSE_MODE 
 1027        _dbus_verbose (
"asked to handle read watch with non-read condition 0x%x\n",
 
 1030        _dbus_verbose (
"asked to handle write watch with non-write condition 0x%x\n",
 
 1033        _dbus_verbose (
"asked to handle watch %p on fd %" DBUS_SOCKET_FORMAT 
" that we don't recognize\n",
 
 1034                       watch, _dbus_socket_printable (_dbus_watch_get_socket (watch)));
 
 1046  _dbus_verbose (
"\n");
 
 1048  free_watches (transport);
 
 1078  check_read_watch (transport);
 
 1079  check_write_watch (transport);
 
 1094                   int            timeout_milliseconds)
 
 1101  _dbus_verbose (
" iteration flags = %s%s timeout = %d read_watch = %p write_watch = %p fd = %" DBUS_SOCKET_FORMAT 
"\n",
 
 1102                 flags & DBUS_ITERATION_DO_READING ? 
"read" : 
"",
 
 1103                 flags & DBUS_ITERATION_DO_WRITING ? 
"write" : 
"",
 
 1104                 timeout_milliseconds,
 
 1105                 socket_transport->read_watch,
 
 1106                 socket_transport->write_watch,
 
 1107                 _dbus_socket_printable (socket_transport->fd));
 
 1115  poll_fd.
fd = _dbus_socket_get_pollable (socket_transport->
fd);
 
 1130      if ((flags & DBUS_ITERATION_DO_WRITING) &&
 
 1131          !(flags & (DBUS_ITERATION_DO_READING | DBUS_ITERATION_BLOCK)) &&
 
 1135          do_writing (transport);
 
 1144      if (flags & DBUS_ITERATION_DO_READING)
 
 1148      if (flags & DBUS_ITERATION_DO_WRITING)
 
 1153      DBusAuthState auth_state;
 
 1158          auth_state == DBUS_AUTH_STATE_WAITING_FOR_INPUT)
 
 1162          auth_state == DBUS_AUTH_STATE_HAVE_BYTES_TO_SEND)
 
 1170      if (flags & DBUS_ITERATION_BLOCK)
 
 1171        poll_timeout = timeout_milliseconds;
 
 1180      if (flags & DBUS_ITERATION_BLOCK)
 
 1182          _dbus_verbose (
"unlock pre poll\n");
 
 1187      poll_res = 
_dbus_poll (&poll_fd, 1, poll_timeout);
 
 1188      saved_errno = _dbus_save_socket_errno ();
 
 1193      if (flags & DBUS_ITERATION_BLOCK)
 
 1195          _dbus_verbose (
"lock post poll\n");
 
 1208            do_io_error (transport);
 
 1213              dbus_bool_t authentication_completed;
 
 1215              _dbus_verbose (
"in iteration, need_read=%d need_write=%d\n",
 
 1216                             need_read, need_write);
 
 1217              do_authentication (transport, need_read, need_write,
 
 1218                                 &authentication_completed);
 
 1221              if (authentication_completed)
 
 1224              if (need_read && (flags & DBUS_ITERATION_DO_READING))
 
 1225                do_reading (transport);
 
 1226              if (need_write && (flags & DBUS_ITERATION_DO_WRITING))
 
 1227                do_writing (transport);
 
 1232          _dbus_verbose (
"Error from _dbus_poll(): %s\n",
 
 1233                         _dbus_strerror (saved_errno));
 
 1249  check_write_watch (transport);
 
 1251  _dbus_verbose (
" ... leaving do_iteration()\n");
 
 1258  check_read_watch (transport);
 
 1268  *fd_p = socket_transport->
fd;
 
 1275  socket_handle_watch,
 
 1277  socket_connection_set,
 
 1278  socket_do_iteration,
 
 1279  socket_live_messages_changed,
 
 1280  socket_get_socket_fd
 
 1300  DBusString invalid = _DBUS_STRING_INIT_INVALID;
 
 1303  if (socket_transport == 
NULL)
 
 1332                                  server_guid, address))
 
 1335#ifdef HAVE_UNIX_FD_PASSING 
 1339  socket_transport->
fd = fd;
 
 
 1382                                    const char     *noncefile,
 
 1389  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
 
 1411  if (family != 
NULL &&
 
 1416  if (noncefile != 
NULL &&
 
 1421  fd = _dbus_connect_tcp_socket_with_nonce (host, port, family, noncefile, error);
 
 1422  if (!_dbus_socket_is_valid (fd))
 
 1424      _DBUS_ASSERT_ERROR_IS_SET (error);
 
 1429  _dbus_verbose (
"Successfully connected to tcp socket %s:%s\n",
 
 1434  if (transport == 
NULL)
 
 
 1456DBusTransportOpenResult
 
 1463  dbus_bool_t isNonceTcp;
 
 1468  isTcp = strcmp (method, 
"tcp") == 0;
 
 1469  isNonceTcp = strcmp (method, 
"nonce-tcp") == 0;
 
 1471  if (isTcp || isNonceTcp)
 
 1478      if ((isNonceTcp == 
TRUE) != (noncefile != 
NULL)) {
 
 1480          return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
 
 1486          return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
 
 1490      if (*transport_p == 
NULL)
 
 1492          _DBUS_ASSERT_ERROR_IS_SET (error);
 
 1493          return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
 
 1497          _DBUS_ASSERT_ERROR_IS_CLEAR (error);
 
 1498          return DBUS_TRANSPORT_OPEN_OK;
 
 1503      _DBUS_ASSERT_ERROR_IS_CLEAR (error);
 
 1504      return DBUS_TRANSPORT_OPEN_NOT_HANDLED;
 
 
 1519                                       dbus_bool_t     abstract,
 
 1527  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
 
 1548  if (!_dbus_socket_is_valid (fd))
 
 1550      _DBUS_ASSERT_ERROR_IS_SET (error);
 
 1554  _dbus_verbose (
"Successfully connected to unix socket %s\n",
 
 1558  if (transport == 
NULL)
 
 
 1583DBusTransportOpenResult
 
 1593  if (strcmp (method, 
"unix") == 0)
 
 1602                                 "cannot use the \"tmpdir\" option for an address to connect to, only in an address to listen on");
 
 1603          return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
 
 1606      if (path == 
NULL && abstract == 
NULL)
 
 1611          return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
 
 1614      if (path != 
NULL && abstract != 
NULL)
 
 1617                                 "can't specify both \"path\" and \"abstract\" options in an address");
 
 1618          return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
 
 1627      if (*transport_p == 
NULL)
 
 1629          _DBUS_ASSERT_ERROR_IS_SET (error);
 
 1630          return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
 
 1634          _DBUS_ASSERT_ERROR_IS_CLEAR (error);
 
 1635          return DBUS_TRANSPORT_OPEN_OK;
 
 1640      _DBUS_ASSERT_ERROR_IS_CLEAR (error);
 
 1641      return DBUS_TRANSPORT_OPEN_NOT_HANDLED;
 
 
dbus_bool_t _dbus_address_append_escaped(DBusString *escaped, const DBusString *unescaped)
Appends an escaped version of one string to another string, using the D-Bus address escaping mechanis...
void _dbus_set_bad_address(DBusError *error, const char *address_problem_type, const char *address_problem_field, const char *address_problem_other)
Sets DBUS_ERROR_BAD_ADDRESS.
const char * dbus_address_entry_get_method(DBusAddressEntry *entry)
Returns the method string of an address entry.
const char * dbus_address_entry_get_value(DBusAddressEntry *entry, const char *key)
Returns a value from a key of an entry.
DBusAuthState _dbus_auth_do_work(DBusAuth *auth)
Analyzes buffered input and moves the auth conversation forward, returning the new state of the auth ...
dbus_bool_t _dbus_auth_encode_data(DBusAuth *auth, const DBusString *plaintext, DBusString *encoded)
Called post-authentication, encodes a block of bytes for sending to the peer.
dbus_bool_t _dbus_auth_needs_encoding(DBusAuth *auth)
Called post-authentication, indicates whether we need to encode the message stream with _dbus_auth_en...
dbus_bool_t _dbus_auth_set_credentials(DBusAuth *auth, DBusCredentials *credentials)
Sets credentials received via reliable means from the operating system.
dbus_bool_t _dbus_auth_get_bytes_to_send(DBusAuth *auth, const DBusString **str)
Gets bytes that need to be sent to the peer we're conversing with.
dbus_bool_t _dbus_auth_decode_data(DBusAuth *auth, const DBusString *encoded, DBusString *plaintext)
Called post-authentication, decodes a block of bytes received from the peer.
void _dbus_auth_set_unix_fd_possible(DBusAuth *auth, dbus_bool_t b)
Sets whether unix fd passing is potentially on the transport and hence shall be negotiated.
void _dbus_auth_return_buffer(DBusAuth *auth, DBusString *buffer)
Returns a buffer with new data read into it.
void _dbus_auth_get_buffer(DBusAuth *auth, DBusString **buffer)
Get a buffer to be used for reading bytes from the peer we're conversing with.
dbus_bool_t _dbus_auth_needs_decoding(DBusAuth *auth)
Called post-authentication, indicates whether we need to decode the message stream with _dbus_auth_de...
void _dbus_auth_bytes_sent(DBusAuth *auth, int bytes_sent)
Notifies the auth conversation object that the given number of bytes of the outgoing buffer have been...
dbus_bool_t _dbus_connection_handle_watch(DBusWatch *watch, unsigned int condition, void *data)
A callback for use with dbus_watch_new() to create a DBusWatch.
dbus_bool_t _dbus_connection_has_messages_to_send_unlocked(DBusConnection *connection)
Checks whether there are messages in the outgoing message queue.
DBUS_PRIVATE_EXPORT void _dbus_connection_unlock(DBusConnection *connection)
Releases the connection lock.
DBUS_PRIVATE_EXPORT void _dbus_connection_lock(DBusConnection *connection)
Acquires the connection lock.
void _dbus_connection_remove_watch_unlocked(DBusConnection *connection, DBusWatch *watch)
Removes a watch using the connection's DBusRemoveWatchFunction if available.
void _dbus_connection_toggle_watch_unlocked(DBusConnection *connection, DBusWatch *watch, dbus_bool_t enabled)
Toggles a watch and notifies app via connection's DBusWatchToggledFunction if available.
dbus_bool_t _dbus_connection_add_watch_unlocked(DBusConnection *connection, DBusWatch *watch)
Adds a watch using the connection's DBusAddWatchFunction if available.
DBusMessage * _dbus_connection_get_message_to_send(DBusConnection *connection)
Gets the next outgoing message.
void _dbus_connection_message_sent_unlocked(DBusConnection *connection, DBusMessage *message)
Notifies the connection that a message has been sent, so the message can be removed from the outgoing...
@ DBUS_WATCH_READABLE
As in POLLIN.
@ DBUS_WATCH_WRITABLE
As in POLLOUT.
@ DBUS_WATCH_HANGUP
As in POLLHUP (can't watch for it, but can be present in current state passed to dbus_watch_handle())...
@ DBUS_WATCH_ERROR
As in POLLERR (can't watch for this, but can be present in current state passed to dbus_watch_handle(...
#define DBUS_ERROR_INIT
Expands to a suitable initializer for a DBusError on the stack.
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError.
void dbus_error_free(DBusError *error)
Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...
dbus_bool_t _dbus_get_is_errno_epipe(int e)
See if errno is EPIPE.
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called.
dbus_bool_t _dbus_get_is_errno_etoomanyrefs(int e)
See if errno is ETOOMANYREFS.
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
dbus_bool_t _dbus_get_is_errno_eintr(int e)
See if errno is EINTR.
dbus_bool_t _dbus_get_is_errno_enomem(int e)
See if errno is ENOMEM.
#define NULL
A null pointer, defined appropriately for C or C++.
#define TRUE
Expands to "1".
#define FALSE
Expands to "0".
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0().
void dbus_message_lock(DBusMessage *message)
Locks a message.
DBUS_PRIVATE_EXPORT void _dbus_message_get_unix_fds(DBusMessage *message, const int **fds, unsigned *n_fds)
Gets the unix fds to be sent over the network for this message.
void _dbus_message_get_network_data(DBusMessage *message, const DBusString **header, const DBusString **body)
Gets the data to be sent over the network for this message.
DBUS_PRIVATE_EXPORT void _dbus_message_loader_get_buffer(DBusMessageLoader *loader, DBusString **buffer, int *max_to_read, dbus_bool_t *may_read_unix_fds)
Gets the buffer to use for reading data from the network.
DBUS_PRIVATE_EXPORT void _dbus_message_loader_return_buffer(DBusMessageLoader *loader, DBusString *buffer)
Returns a buffer obtained from _dbus_message_loader_get_buffer(), indicating to the loader how many b...
#define DBUS_MAXIMUM_MESSAGE_LENGTH
The maximum total message size including header and body; similar rationale to max array size.
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
long _dbus_counter_get_unix_fd_value(DBusCounter *counter)
Gets the current value of the unix fd counter.
long _dbus_counter_get_size_value(DBusCounter *counter)
Gets the current value of the size counter.
dbus_bool_t _dbus_string_set_length(DBusString *str, int length)
Sets the length of a string.
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
void _dbus_string_init_const(DBusString *str, const char *value)
Initializes a constant string.
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(), and fills it with the same contents as _DBUS_STRING_IN...
int _dbus_string_get_length(const DBusString *str)
Gets the length of a string (not including nul termination).
dbus_bool_t _dbus_string_compact(DBusString *str, int max_waste)
Compacts the string to avoid wasted memory.
#define _DBUS_POLLOUT
Writing now will not block.
dbus_bool_t _dbus_get_is_errno_eagain_or_ewouldblock(int e)
See if errno is EAGAIN or EWOULDBLOCK (this has to be done differently for Winsock so is abstracted)
int _dbus_read_socket(DBusSocket fd, DBusString *buffer, int count)
Like _dbus_read(), but only works on sockets so is available on Windows.
#define _DBUS_POLLERR
Error condition.
dbus_bool_t _dbus_socket_can_pass_unix_fd(DBusSocket fd)
Checks whether file descriptors may be passed via the socket.
int _dbus_write_socket(DBusSocket fd, const DBusString *buffer, int start, int len)
Like _dbus_write(), but only supports sockets and is thus available on Windows.
int _dbus_read_socket_with_unix_fds(DBusSocket fd, DBusString *buffer, int count, int *fds, unsigned int *n_fds)
Like _dbus_read_socket() but also tries to read unix fds from the socket.
dbus_bool_t _dbus_read_credentials_socket(DBusSocket client_fd, DBusCredentials *credentials, DBusError *error)
Reads a single byte which must be nul (an error occurs otherwise), and reads unix credentials if avai...
#define _DBUS_POLLIN
There is data to read.
dbus_bool_t _dbus_send_credentials_socket(DBusSocket server_fd, DBusError *error)
Sends a single nul byte with our UNIX credentials as ancillary data.
dbus_bool_t _dbus_close_socket(DBusSocket *fd, DBusError *error)
Closes a socket and invalidates it.
DBusSocket _dbus_connect_unix_socket(const char *path, dbus_bool_t abstract, DBusError *error)
Creates a socket and connects it to the UNIX domain socket at the given path.
int _dbus_poll(DBusPollFD *fds, int n_fds, int timeout_milliseconds)
Wrapper for poll().
int _dbus_write_socket_two(DBusSocket fd, const DBusString *buffer1, int start1, int len1, const DBusString *buffer2, int start2, int len2)
Like _dbus_write_two() but only works on sockets and is thus available on Windows.
DBusTransportOpenResult _dbus_transport_open_socket(DBusAddressEntry *entry, DBusTransport **transport_p, DBusError *error)
Opens a TCP socket transport.
DBusTransportOpenResult _dbus_transport_open_unix_socket(DBusAddressEntry *entry, DBusTransport **transport_p, DBusError *error)
Opens a UNIX socket transport.
DBusTransport * _dbus_transport_new_for_tcp_socket(const char *host, const char *port, const char *family, const char *noncefile, DBusError *error)
Creates a new transport for the given hostname and port.
DBusTransport * _dbus_transport_new_for_socket(DBusSocket fd, const DBusString *server_guid, const DBusString *address)
Creates a new transport for the given socket file descriptor.
DBusTransport * _dbus_transport_new_for_domain_socket(const char *path, dbus_bool_t abstract, DBusError *error)
Creates a new transport for the given Unix domain socket path.
dbus_bool_t _dbus_transport_queue_messages(DBusTransport *transport)
Processes data we've read while handling a watch, potentially converting some of it to messages and q...
DBusTransport * _dbus_transport_ref(DBusTransport *transport)
Increments the reference count for the transport.
void _dbus_transport_disconnect(DBusTransport *transport)
Closes our end of the connection to a remote application.
dbus_bool_t _dbus_transport_init_base(DBusTransport *transport, const DBusTransportVTable *vtable, const DBusString *server_guid, const DBusString *address)
Initializes the base class members of DBusTransport.
void _dbus_transport_unref(DBusTransport *transport)
Decrements the reference count for the transport.
dbus_bool_t _dbus_transport_try_to_authenticate(DBusTransport *transport)
Returns TRUE if we have been authenticated.
dbus_bool_t _dbus_transport_get_is_connected(DBusTransport *transport)
Returns TRUE if the transport has not been disconnected.
void _dbus_transport_finalize_base(DBusTransport *transport)
Finalizes base class members of DBusTransport.
void _dbus_watch_set_handler(DBusWatch *watch, DBusWatchHandler handler, void *data, DBusFreeFunction free_data_function)
Sets the handler for the watch.
DBusWatch * _dbus_watch_new(DBusPollable fd, unsigned int flags, dbus_bool_t enabled, DBusWatchHandler handler, void *data, DBusFreeFunction free_data_function)
Creates a new DBusWatch.
void _dbus_watch_unref(DBusWatch *watch)
Decrements the reference count of a DBusWatch object and finalizes the object if the count reaches ze...
void _dbus_watch_invalidate(DBusWatch *watch)
Clears the file descriptor from a now-invalid watch object so that no one tries to use it.
DBUS_EXPORT dbus_bool_t dbus_watch_get_enabled(DBusWatch *watch)
Returns whether a watch is enabled or not.
Internals of DBusAddressEntry.
Object representing an exception.
const char * message
public error message field
Internals of DBusMessage.
short events
Events to poll for.
short revents
Events that occurred.
DBusPollable fd
File descriptor.
Implementation details of DBusTransportSocket.
DBusWatch * write_watch
Watch for writability.
int message_bytes_written
Number of bytes of current outgoing message that have been written.
int max_bytes_written_per_iteration
To avoid blocking too long.
DBusString encoded_incoming
Encoded version of current incoming data.
DBusString encoded_outgoing
Encoded version of current outgoing message.
DBusSocket fd
File descriptor.
DBusTransport base
Parent instance.
DBusWatch * read_watch
Watch for readability.
int max_bytes_read_per_iteration
To avoid blocking too long.
The virtual table that must be implemented to create a new kind of transport.
Object representing a transport such as a socket.
long max_live_messages_size
Max total size of received messages.
long max_live_messages_unix_fds
Max total unix fds of received messages.
unsigned int disconnected
TRUE if we are disconnected.
unsigned int send_credentials_pending
TRUE if we need to send credentials
DBusConnection * connection
Connection owning this transport.
unsigned int receive_credentials_pending
TRUE if we need to receive credentials
DBusMessageLoader * loader
Message-loading buffer.
DBusCredentials * credentials
Credentials of other end read from the socket.
DBusAuth * auth
Authentication conversation.
DBusCounter * live_messages
Counter for size/unix fds of all live messages.
Implementation of DBusWatch.