SetOutgoingIf.java revision 1720
/*
* Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 4742177
* @summary Re-test IPv6 (and specifically MulticastSocket) with latest Linux & USAGI code
*/
public class SetOutgoingIf {
private static int PORT = 9001;
static boolean isWindows() {
}
if (addr instanceof Inet6Address)
return true;
}
}
return false;
}
if (isWindows()) {
return;
}
if (!hasIPv6()) {
return;
}
// We need 2 or more network interfaces to run the test
//
int index = 1;
// we should use only network interfaces with multicast support which are in "up" state
// now determine what (if any) type of addresses are assigned to this interface
if (addr instanceof Inet4Address) {
netIf.ipv4Address(true);
} else if (addr instanceof Inet6Address) {
netIf.ipv6Address(true);
}
}
}
}
}
return;
}
// We will send packets to one ipv4, and one ipv6
// multicast group using each network interface :-
// 224.1.1.1 --|
// ff02::1:1 --|--> using network interface #1
// 224.1.2.1 --|
// ff02::1:2 --|--> using network interface #2
// and so on.
//
if (netIf.ipv4Address()) {
}
if (netIf.ipv6Address()) {
}
// use a separated thread to send to those 2 groups
PORT));
}
// try to receive on each group, then check if the packet comes
// from the expected network interface
//
byte[] buf = new byte[1024];
// the interface supports the IP multicast group
try {
} catch (Exception e) {
// test failed if any exception
throw new RuntimeException(e);
}
// now check which network interface this packet comes from
+ group + " should come from "
//throw new RuntimeException("Test failed.");
}
}
}
}
private static boolean debug = true;
if (debug)
}
}
private int port;
int port) {
}
public void run() {
try {
}
for (;;) {
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
class NetIf {
private boolean ipv4Address; //false
private boolean ipv6Address; //false
private int index;
private final NetworkInterface nic;
}
}
NetworkInterface nic() {
return nic;
}
boolean ipv4Address() {
return ipv4Address;
}
void ipv4Address(boolean ipv4Address) {
this.ipv4Address = ipv4Address;
}
boolean ipv6Address() {
return ipv6Address;
}
void ipv6Address(boolean ipv6Address) {
this.ipv6Address = ipv6Address;
}
int index() {
return index;
}
}
return groups;
}
}
}