summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-03-31 16:46:21 +0200
committerLennart Poettering <lennart@poettering.net>2013-03-31 16:46:21 +0200
commit98178d3947d951ca001eaf400b5f362f458dceb5 (patch)
treea4345b294f68d22bd3eb84ca066420652e767d2f /src
parent52f3ba915bdce4d7476c3ea53b8371deff5f567d (diff)
bus: rename sd_bus_get_peer() to sd_bus_get_server_id()
This function always returns the server side ID. The name suggested it was actually always the peer's ID, but that's not correct if the call is called on a server bus context. Hence, let's correct the name a bit.
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd-bus/bus-internal.h2
-rw-r--r--src/libsystemd-bus/bus-socket.c8
-rw-r--r--src/libsystemd-bus/sd-bus.c16
-rw-r--r--src/libsystemd-bus/sd-bus.h4
-rw-r--r--src/libsystemd-bus/test-bus-chat.c4
5 files changed, 17 insertions, 17 deletions
diff --git a/src/libsystemd-bus/bus-internal.h b/src/libsystemd-bus/bus-internal.h
index a11dc8c876..0149604d2a 100644
--- a/src/libsystemd-bus/bus-internal.h
+++ b/src/libsystemd-bus/bus-internal.h
@@ -112,7 +112,7 @@ struct sd_bus {
} sockaddr;
socklen_t sockaddr_size;
- sd_id128_t peer;
+ sd_id128_t server_id;
char *address;
unsigned address_index;
diff --git a/src/libsystemd-bus/bus-socket.c b/src/libsystemd-bus/bus-socket.c
index cb1e942833..fed1971ec7 100644
--- a/src/libsystemd-bus/bus-socket.c
+++ b/src/libsystemd-bus/bus-socket.c
@@ -146,11 +146,11 @@ static int bus_socket_auth_verify_client(sd_bus *b) {
peer.bytes[i/2] = ((uint8_t) x << 4 | (uint8_t) y);
}
- if (!sd_id128_equal(b->peer, SD_ID128_NULL) &&
- !sd_id128_equal(b->peer, peer))
+ if (!sd_id128_equal(b->server_id, SD_ID128_NULL) &&
+ !sd_id128_equal(b->server_id, peer))
return -EPERM;
- b->peer = peer;
+ b->server_id = peer;
/* And possibly check the second line, too */
@@ -286,7 +286,7 @@ static int bus_socket_auth_write_ok(sd_bus *b) {
assert(b);
- snprintf(t, sizeof(t), "OK " SD_ID128_FORMAT_STR "\r\n", SD_ID128_FORMAT_VAL(b->peer));
+ snprintf(t, sizeof(t), "OK " SD_ID128_FORMAT_STR "\r\n", SD_ID128_FORMAT_VAL(b->server_id));
char_array_0(t);
return bus_socket_auth_write(b, t);
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 9b9281dde3..a71d7b5d77 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -200,16 +200,16 @@ int sd_bus_set_negotiate_fds(sd_bus *bus, int b) {
return 0;
}
-int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server) {
+int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id) {
if (!bus)
return -EINVAL;
- if (!b && !sd_id128_equal(server, SD_ID128_NULL))
+ if (!b && !sd_id128_equal(server_id, SD_ID128_NULL))
return -EINVAL;
if (bus->state != BUS_UNSET)
return -EPERM;
bus->is_server = !!b;
- bus->peer = server;
+ bus->server_id = server_id;
return 0;
}
@@ -604,7 +604,7 @@ static void bus_reset_parsed_address(sd_bus *b) {
free(b->exec_path);
b->exec_path = NULL;
b->exec_argv = NULL;
- b->peer = SD_ID128_NULL;
+ b->server_id = SD_ID128_NULL;
}
static int bus_parse_next_address(sd_bus *b) {
@@ -664,7 +664,7 @@ static int bus_parse_next_address(sd_bus *b) {
}
if (guid) {
- r = sd_id128_from_string(guid, &b->peer);
+ r = sd_id128_from_string(guid, &b->server_id);
if (r < 0)
return r;
}
@@ -907,19 +907,19 @@ int sd_bus_can_send(sd_bus *bus, char type) {
return bus_type_is_valid(type);
}
-int sd_bus_get_peer(sd_bus *bus, sd_id128_t *peer) {
+int sd_bus_get_server_id(sd_bus *bus, sd_id128_t *server_id) {
int r;
if (!bus)
return -EINVAL;
- if (!peer)
+ if (!server_id)
return -EINVAL;
r = bus_ensure_running(bus);
if (r < 0)
return r;
- *peer = bus->peer;
+ *server_id = bus->server_id;
return 0;
}
diff --git a/src/libsystemd-bus/sd-bus.h b/src/libsystemd-bus/sd-bus.h
index 413b7dcee2..f792bfaf6c 100644
--- a/src/libsystemd-bus/sd-bus.h
+++ b/src/libsystemd-bus/sd-bus.h
@@ -60,9 +60,9 @@ int sd_bus_set_address(sd_bus *bus, const char *address);
int sd_bus_set_fd(sd_bus *bus, int fd);
int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[]);
int sd_bus_set_bus_client(sd_bus *bus, int b);
-int sd_bus_set_negotiate_fds(sd_bus *bus, int b);
int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id);
int sd_bus_set_anonymous(sd_bus *bus, int b);
+int sd_bus_set_negotiate_fds(sd_bus *bus, int b);
int sd_bus_start(sd_bus *ret);
void sd_bus_close(sd_bus *bus);
@@ -72,7 +72,7 @@ sd_bus *sd_bus_unref(sd_bus *bus);
int sd_bus_is_open(sd_bus *bus);
int sd_bus_can_send(sd_bus *bus, char type);
-int sd_bus_get_peer(sd_bus *bus, sd_id128_t *peer);
+int sd_bus_get_server_id(sd_bus *bus, sd_id128_t *peer);
int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *serial);
int sd_bus_send_with_reply(sd_bus *bus, sd_bus_message *m, sd_bus_message_handler_t callback, void *userdata, uint64_t usec, uint64_t *serial);
diff --git a/src/libsystemd-bus/test-bus-chat.c b/src/libsystemd-bus/test-bus-chat.c
index 2dd30912cf..459d39fdee 100644
--- a/src/libsystemd-bus/test-bus-chat.c
+++ b/src/libsystemd-bus/test-bus-chat.c
@@ -85,9 +85,9 @@ static int server_init(sd_bus **_bus) {
goto fail;
}
- r = sd_bus_get_peer(bus, &id);
+ r = sd_bus_get_server_id(bus, &id);
if (r < 0) {
- log_error("Failed to get peer ID: %s", strerror(-r));
+ log_error("Failed to get server ID: %s", strerror(-r));
goto fail;
}