summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-12-14 05:08:20 +0100
committerMarcel Holtmann <marcel@holtmann.org>2009-12-14 05:08:20 +0100
commita70633c31fb0525b9411c259a394f67c1f489ab1 (patch)
treedaab0bfaf1b4ba1bba7f76b46a89abe4c0ec107f /plugins
parent2da97f3436db76fcc3024954e24dd9c6264259a8 (diff)
downloadconnman-a70633c31fb0525b9411c259a394f67c1f489ab1.tar.gz
connman-a70633c31fb0525b9411c259a394f67c1f489ab1.tar.bz2
connman-a70633c31fb0525b9411c259a394f67c1f489ab1.zip
Handle cases when provided DNS server has no interface
Diffstat (limited to 'plugins')
-rw-r--r--plugins/dnsproxy.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/plugins/dnsproxy.c b/plugins/dnsproxy.c
index a84707a6..40426c6e 100644
--- a/plugins/dnsproxy.c
+++ b/plugins/dnsproxy.c
@@ -226,12 +226,15 @@ static struct server_data *create_server(const char *interface,
return NULL;
}
- if (setsockopt(sk, SOL_SOCKET, SO_BINDTODEVICE,
+ if (interface != NULL) {
+ if (setsockopt(sk, SOL_SOCKET, SO_BINDTODEVICE,
interface, strlen(interface) + 1) < 0) {
- connman_error("Failed to bind server %s to interface %s",
+ connman_error("Failed to bind server %s "
+ "to interface %s",
server, interface);
- close(sk);
- return NULL;
+ close(sk);
+ return NULL;
+ }
}
memset(&sin, 0, sizeof(sin));
@@ -263,7 +266,7 @@ static struct server_data *create_server(const char *interface,
g_io_channel_set_close_on_unref(data->channel, TRUE);
data->watch = g_io_add_watch(data->channel, G_IO_IN,
- server_event, data);
+ server_event, data);
data->interface = g_strdup(interface);
data->domain = g_strdup(domain);