author | martin |
Tue, 15 Sep 2015 21:56:04 -0700 | |
changeset 32649 | 2ee9017c7597 |
parent 25859 | 3317bb8137f4 |
permissions | -rw-r--r-- |
22341
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
1 |
/* |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
4 |
* |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
10 |
* |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
15 |
* accompanied this code). |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
16 |
* |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
20 |
* |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
23 |
* questions. |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
24 |
*/ |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
25 |
|
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
26 |
package sun.net; |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
27 |
|
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
28 |
import java.security.AccessController; |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
29 |
|
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
30 |
/** |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
31 |
* Determines the ephemeral port range in use on this system. |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
32 |
* If this cannot be determined, then the default settings |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
33 |
* of the OS are returned. |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
34 |
*/ |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
35 |
|
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
36 |
public final class PortConfig { |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
37 |
|
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
38 |
private static int defaultUpper, defaultLower; |
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
25859
diff
changeset
|
39 |
private static final int upper, lower; |
22341
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
40 |
|
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
41 |
static { |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
42 |
AccessController.doPrivileged( |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
43 |
new java.security.PrivilegedAction<Void>() { |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
44 |
public Void run() { |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
45 |
System.loadLibrary("net"); |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
46 |
return null; |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
47 |
} |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
48 |
}); |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
49 |
|
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
50 |
int v = getLower0(); |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
51 |
if (v == -1) { |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
52 |
v = defaultLower; |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
53 |
} |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
54 |
lower = v; |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
55 |
|
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
56 |
v = getUpper0(); |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
57 |
if (v == -1) { |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
58 |
v = defaultUpper; |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
59 |
} |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
60 |
upper = v; |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
61 |
} |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
62 |
|
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
63 |
static native int getLower0(); |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
64 |
static native int getUpper0(); |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
65 |
|
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
66 |
public static int getLower() { |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
67 |
return lower; |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
68 |
} |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
69 |
|
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
70 |
public static int getUpper() { |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
71 |
return upper; |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
72 |
} |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
diff
changeset
|
73 |
} |