---
 gweb/gweb.c |   17 +++++++++++++++++
 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);
-- 
1.7.8.rc3

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to