jdk/test/sun/net/sdp/ProbeIB.java
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 6525 56be41b86ef8
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2446
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 6525
diff changeset
     2
 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
2446
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
     4
 *
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
     8
 *
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    13
 * accompanied this code).
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    14
 *
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2446
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2446
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2446
diff changeset
    21
 * questions.
2446
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    22
 */
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    23
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    24
import java.io.File;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    25
import java.io.IOException;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    26
import java.net.NetworkInterface;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    27
import java.net.InetAddress;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    28
import java.util.Scanner;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    29
import java.util.Enumeration;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    30
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    31
/**
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    32
 * Probes for InfiniBand devices plumbed with IP addresses.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    33
 */
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    34
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    35
public class ProbeIB {
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    36
    public static void main(String[] args) throws IOException {
6525
56be41b86ef8 6965072: Need API to create SDP sockets
alanb
parents: 5506
diff changeset
    37
        Scanner s = new Scanner(new File(args[0]));
2446
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    38
        try {
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    39
            while (s.hasNextLine()) {
6525
56be41b86ef8 6965072: Need API to create SDP sockets
alanb
parents: 5506
diff changeset
    40
                String link = s.nextLine();
56be41b86ef8 6965072: Need API to create SDP sockets
alanb
parents: 5506
diff changeset
    41
                NetworkInterface ni = NetworkInterface.getByName(link);
2446
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    42
                if (ni != null) {
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    43
                    Enumeration<InetAddress> addrs = ni.getInetAddresses();
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    44
                    while (addrs.hasMoreElements()) {
6525
56be41b86ef8 6965072: Need API to create SDP sockets
alanb
parents: 5506
diff changeset
    45
                        InetAddress addr = addrs.nextElement();
56be41b86ef8 6965072: Need API to create SDP sockets
alanb
parents: 5506
diff changeset
    46
                        System.out.println(addr.getHostAddress());
2446
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    47
                    }
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    48
                }
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    49
            }
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    50
        } finally {
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    51
            s.close();
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    52
        }
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    53
    }
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    54
}