summaryrefslogtreecommitdiffstats
path: root/avahi-daemon
diff options
context:
space:
mode:
authorSebastien Estienne <sebastien.estienne@gmail.com>2005-10-19 22:12:28 +0000
committerSebastien Estienne <sebastien.estienne@gmail.com>2005-10-19 22:12:28 +0000
commit4d2e029918b96dd61ace73ea6ad0de556ea3f293 (patch)
tree8710ef75d6a2c14c644b1b6b06f6c09a4460ffa6 /avahi-daemon
parenta26b065238debb81e25106b573addb323e529bce (diff)
* replaced some ioctl by if_nametoindex and if_indextoname
* cosmetic fix in socket.c git-svn-id: file:///home/lennart/svn/public/avahi/trunk@829 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-daemon')
-rw-r--r--avahi-daemon/dbus-protocol.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c
index 8994a25..965ffd5 100644
--- a/avahi-daemon/dbus-protocol.c
+++ b/avahi-daemon/dbus-protocol.c
@@ -1791,7 +1791,8 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetNetworkInterfaceNameByIndex")) {
int32_t idx;
int fd;
- struct ifreq ifr;
+ char name[IF_NAMESIZE];
+
if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INT32, &idx, DBUS_TYPE_INVALID))) {
avahi_log_warn("Error parsing Server::GetNetworkInterfaceNameByIndex message");
@@ -1809,11 +1810,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void
return respond_error(c, m, AVAHI_ERR_OS, txt);
}
- memset(&ifr, 0, sizeof(ifr));
-
- ifr.ifr_ifindex = idx;
-
- if (ioctl(fd, SIOCGIFNAME, &ifr) < 0) {
+ if ((!if_indextoname(idx, name))) {
char txt[256];
snprintf(txt, sizeof(txt), "OS Error: %s", strerror(errno));
close(fd);
@@ -1822,13 +1819,13 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void
close(fd);
- return respond_string(c, m, ifr.ifr_name);
+ return respond_string(c, m, name);
#endif
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetNetworkInterfaceIndexByName")) {
char *n;
int fd;
- struct ifreq ifr;
+ int32_t idx;
if (!(dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &n, DBUS_TYPE_INVALID)) || !n) {
avahi_log_warn("Error parsing Server::GetNetworkInterfaceIndexByName message");
@@ -1845,10 +1842,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void
return respond_error(c, m, AVAHI_ERR_OS, txt);
}
- memset(&ifr, 0, sizeof(ifr));
- snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", n);
-
- if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) {
+ if (!(idx = if_nametoindex(n))) {
char txt[256];
snprintf(txt, sizeof(txt), "OS Error: %s", strerror(errno));
close(fd);
@@ -1857,7 +1851,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void
close(fd);
- return respond_int32(c, m, ifr.ifr_ifindex);
+ return respond_int32(c, m, idx);
#endif
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetAlternativeHostName")) {