#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
+#include <net/if.h>
#include "giognutls.h"
#include "gresolv.h"
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);