summaryrefslogtreecommitdiff
path: root/gweb
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2011-11-25 11:03:03 (GMT)
committerSamuel Ortiz <sameo@linux.intel.com>2011-11-28 14:55:21 (GMT)
commitefad0f971ef1ae6417976051d8ee1c8a5a592f56 (patch)
tree0756089b89f88c3b2560ed04a8f3d74c0e3690cb /gweb
parent16772e3e82c641949c5016c2cc74705524c31e61 (diff)
downloadconnman-efad0f971ef1ae6417976051d8ee1c8a5a592f56.zip
connman-efad0f971ef1ae6417976051d8ee1c8a5a592f56.tar.gz
connman-efad0f971ef1ae6417976051d8ee1c8a5a592f56.tar.bz2
gweb: Bind socket to the right interface
Diffstat (limited to 'gweb')
-rw-r--r--gweb/gweb.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/gweb/gweb.c b/gweb/gweb.c
index 5c3305e..1461346 100644
--- a/gweb/gweb.c
+++ b/gweb/gweb.c
@@ -32,6 +32,7 @@
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
+#include <net/if.h>
#include "giognutls.h"
#include "gresolv.h"
@@ -910,6 +911,22 @@ static int connect_session_transport(struct web_session *session)
if (sk < 0)
return -EIO;
+ if (session->web->index > 0) {
+ char interface[IF_NAMESIZE];
+
+ memset(interface, 0, IF_NAMESIZE);
+
+ if (if_indextoname(session->web->index, interface) != NULL) {
+ if (setsockopt(sk, SOL_SOCKET, SO_BINDTODEVICE,
+ interface, IF_NAMESIZE) < 0) {
+ close(sk);
+ return -EIO;
+ }
+
+ debug(session->web, "Use interface %s", interface);
+ }
+ }
+
if (session->flags & SESSION_FLAG_USE_TLS) {
debug(session->web, "using TLS encryption");
session->transport_channel = g_io_channel_gnutls_new(sk);