Home | History | Annotate | Download | only in support
      1 /*
      2  * Licensed to the Apache Software Foundation (ASF) under one or more
      3  * contributor license agreements.  See the NOTICE file distributed with
      4  * this work for additional information regarding copyright ownership.
      5  * The ASF licenses this file to You under the Apache License, Version 2.0
      6  * (the "License"); you may not use this file except in compliance with
      7  * the License.  You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  */
     17 package tests.support;
     18 
     19 
     20 import java.net.NetworkInterface;
     21 
     22 public class Support_NetworkInterface {
     23 
     24 	/**
     25 	 * On windows platforms with IPV6 enabled there are a number of pseudo
     26 	 * interfaces which don't work with our tests. This function is called to
     27 	 * make sure we only use the non-pseudo interfaces
     28 	 */
     29 	public static boolean useInterface(NetworkInterface theInterface) {
     30 		boolean result = true;
     31 		String platform = System.getProperty("os.name");
     32 		// only use these on windows platforms
     33 		if (platform.startsWith("Windows")) {
     34 			if ((theInterface.getDisplayName()
     35 					.equals("Teredo Tunneling Pseudo-Interface"))
     36 					|| (theInterface.getDisplayName()
     37 							.equals("6to4 Tunneling Pseudo-Interface"))
     38 					|| (theInterface.getDisplayName()
     39 							.equals("Automatic Tunneling Pseudo-Interface"))
     40 					|| (theInterface.getDisplayName()
     41 							.equals("Loopback Pseudo-Interface"))
     42 					|| (theInterface.getDisplayName().equals("MS TCP Loopback interface"))) {
     43 				result = false;
     44 			}
     45 		}
     46 
     47         if (platform.startsWith("Linux")) {
     48             if ((theInterface.getDisplayName().equals("lo"))
     49                     || (theInterface.getDisplayName().equals("teredo"))) {
     50                 result = false;
     51             }
     52         }
     53         return result;
     54 	}
     55 }
     56