summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-transport-socket.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2006-09-16 19:24:08 +0000
committerHavoc Pennington <hp@redhat.com>2006-09-16 19:24:08 +0000
commitfe4715b656237b89767b5dc0cba4c107541b6e0d (patch)
tree8defca3126803c37043110e7edb81dfa5476fceb /dbus/dbus-transport-socket.c
parente001455a0300cc1df17684a028049c8c33e4f575 (diff)
2006-09-16 Havoc Pennington <hp@redhat.com>
* dbus/dbus-transport.c (_dbus_transport_open): modify to delegate to _dbus_transport_open_platform_specific, _dbus_transport_open_socket, and _dbus_transport_open_debug_pipe * dbus/dbus-transport-protected.h: add _dbus_transport_open_platform_specific
Diffstat (limited to 'dbus/dbus-transport-socket.c')
-rw-r--r--dbus/dbus-transport-socket.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/dbus/dbus-transport-socket.c b/dbus/dbus-transport-socket.c
index 64991181..1e9fdc70 100644
--- a/dbus/dbus-transport-socket.c
+++ b/dbus/dbus-transport-socket.c
@@ -1251,5 +1251,59 @@ error:
return NULL;
}
+DBusTransportOpenResult
+_dbus_transport_open_socket(DBusAddressEntry *entry,
+ DBusTransport **transport_p,
+ DBusError *error)
+{
+ const char *method;
+
+ method = dbus_address_entry_get_method (entry);
+ _dbus_assert (method != NULL);
+
+ if (strcmp (method, "tcp") == 0)
+ {
+ const char *host = dbus_address_entry_get_value (entry, "host");
+ const char *port = dbus_address_entry_get_value (entry, "port");
+ DBusString str;
+ long lport;
+ dbus_bool_t sresult;
+
+ if (port == NULL)
+ {
+ _dbus_set_bad_address (error, "tcp", "port", NULL);
+ return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
+ }
+
+ _dbus_string_init_const (&str, port);
+ sresult = _dbus_string_parse_int (&str, 0, &lport, NULL);
+ _dbus_string_free (&str);
+
+ if (sresult == FALSE || lport <= 0 || lport > 65535)
+ {
+ _dbus_set_bad_address (error, NULL, NULL,
+ "Port is not an integer between 0 and 65535");
+ return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
+ }
+
+ *transport_p = _dbus_transport_new_for_tcp_socket (host, lport, error);
+ if (*transport_p == NULL)
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
+ }
+ else
+ {
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+ return DBUS_TRANSPORT_OPEN_OK;
+ }
+ }
+ else
+ {
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+ return DBUS_TRANSPORT_OPEN_NOT_HANDLED;
+ }
+}
+
/** @} */