Changeset 22651b8eef8efab9462ee9b2a2d70cd7a564de62
- Timestamp:
- 13/08/05 21:15:17
(3 years ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1123960517 +0000
- git-parent:
[fb4297bd14e577dd6857cd47f9c99ed04ba53cec]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1123960517 +0000
- Message:
[Win32] Attempt to guess best interface for multicast
may close #163
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r331d097 |
r22651b8 |
|
| 54 | 54 | # include <winsock2.h> |
|---|
| 55 | 55 | # include <ws2tcpip.h> |
|---|
| | 56 | # include <iphlpapi.h> |
|---|
| 56 | 57 | # define close closesocket |
|---|
| 57 | 58 | # if defined(UNDER_CE) |
|---|
| … | … | |
| 334 | 335 | struct ip_mreq imr; |
|---|
| 335 | 336 | |
|---|
| | 337 | imr.imr_interface.s_addr = INADDR_ANY; |
|---|
| 336 | 338 | imr.imr_multiaddr.s_addr = sock.sin_addr.s_addr; |
|---|
| 337 | 339 | if( psz_if_addr != NULL && *psz_if_addr |
|---|
| … | … | |
| 340 | 342 | imr.imr_interface.s_addr = inet_addr(psz_if_addr); |
|---|
| 341 | 343 | } |
|---|
| | 344 | #if defined (WIN32) || defined (UNDER_CE) |
|---|
| 342 | 345 | else |
|---|
| 343 | 346 | { |
|---|
| 344 | | imr.imr_interface.s_addr = INADDR_ANY; |
|---|
| 345 | | } |
|---|
| | 347 | DWORD i_index; |
|---|
| | 348 | if( GetBestInterface( sock.sin_addr.s_addr, |
|---|
| | 349 | &i_index ) == NO_ERROR ) |
|---|
| | 350 | { |
|---|
| | 351 | PMIB_IPADDRTABLE p_table; |
|---|
| | 352 | DWORD i = 0; |
|---|
| | 353 | |
|---|
| | 354 | msg_Dbg( p_this, "Winsock best interface is %lu", |
|---|
| | 355 | (unsigned long)i_index ); |
|---|
| | 356 | GetIpAddrTable( NULL, &i, 0 ); |
|---|
| | 357 | |
|---|
| | 358 | p_table = (PMIB_IPADDRTABLE)malloc( i ); |
|---|
| | 359 | if( p_table != NULL ) |
|---|
| | 360 | { |
|---|
| | 361 | if( GetIpAddrTable( p_table, &i, 0 ) == NO_ERROR) |
|---|
| | 362 | { |
|---|
| | 363 | for( i = 0; i < p_table->dwNumEntries; i-- ) |
|---|
| | 364 | { |
|---|
| | 365 | if( p_table->table[i].dwIndex == i_index ) |
|---|
| | 366 | { |
|---|
| | 367 | imr.imr_interface.s_addr = |
|---|
| | 368 | p_table->table[i].dwAddr; |
|---|
| | 369 | msg_Dbg( p_this, "using interface 0x%08x", |
|---|
| | 370 | p_table->table[i].dwAddr ); |
|---|
| | 371 | } |
|---|
| | 372 | } |
|---|
| | 373 | } |
|---|
| | 374 | else |
|---|
| | 375 | msg_Warn( p_this, "GetIpAddrTable failed" ); |
|---|
| | 376 | free( p_table ); |
|---|
| | 377 | } |
|---|
| | 378 | } |
|---|
| | 379 | else |
|---|
| | 380 | msg_Dbg( p_this, "GetBestInterface failed" ); |
|---|
| | 381 | } |
|---|
| | 382 | #endif |
|---|
| 346 | 383 | if( psz_if_addr != NULL ) free( psz_if_addr ); |
|---|
| 347 | 384 | |
|---|