diff options
author | Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com> | 2011-11-25 13:03:03 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-11-28 15:55:21 +0100 |
commit | efad0f971ef1ae6417976051d8ee1c8a5a592f56 (patch) | |
tree | 0756089b89f88c3b2560ed04a8f3d74c0e3690cb /gweb | |
parent | 16772e3e82c641949c5016c2cc74705524c31e61 (diff) | |
download | connman-efad0f971ef1ae6417976051d8ee1c8a5a592f56.tar.gz connman-efad0f971ef1ae6417976051d8ee1c8a5a592f56.tar.bz2 connman-efad0f971ef1ae6417976051d8ee1c8a5a592f56.zip |
gweb: Bind socket to the right interface
Diffstat (limited to 'gweb')
-rw-r--r-- | gweb/gweb.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gweb/gweb.c b/gweb/gweb.c index 5c3305ef..14613465 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); |