0

So apparently the Winsock2 equivalents of ioctl(), which are ioctlsocket() and WSAIoctl(), do not accept the ifreq structure as a parameter or have a clear option for attaching a socket to an interface. I am writing a p2p IM program that uses ISATAP tunneling. I used netsh to enable the ISATAP tunnel interface but not sure how to issue a command to WSAIoctl() to set the sockets to the IPv6 ISATAP Tunnel interface.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Mr X
  • 336
  • 1
  • 6
  • 22
  • Which `ioctl()` operation(s) are you trying to port to WinSock exactly? Chances are that WinSock may have its own equivalents of them. – Remy Lebeau Jun 12 '13 at 00:45
  • I'm trying to port SIOCADDTUNNEL. I used the ipconfig command on the Win8 powershell and enabled the isatap adapter interface but I am not sure how to associate the socket with that specific interface. – Mr X Jun 12 '13 at 01:49

1 Answers1

1

Do not forget that WinSock sockets are bindable to specific interfaces via bind(), and are also configurable via setsockopt(). For instance, there is an ip_mreq structure (defined for the IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP socket options), and an ip_mreq_source structure (defined for the IP_ADD_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP, IP_BLOCK_SOURCE, and IP_UNBLOCK_SOURCE socket options), which contain interface-related fields.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • The bind() function binds a socket to an IP address. In Linux sockets, the setsockopt() and ioctl() can be used to associate a socket with a specific Adapter network interface. Windows seems to make this process MUCH trickier. – Mr X Jun 12 '13 at 01:48
  • WinSock doesn't distinquish between adapters and IP addresses as much as other platforms do. Since an adapter is assigned an IP anyway, binding a socket to an IP also binds it to the adapter that the IP is assigned to. However, there are APIs for getting adapter interface information, and some socket operations, like multicasting, do make use of adapter interfaces. – Remy Lebeau Jun 12 '13 at 04:15