|
1 /* |
|
2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package jdk.dns.client.internal; |
|
27 |
|
28 final class PortConfig { |
|
29 /** |
|
30 * Determines the ephemeral port range in use on this system. |
|
31 * If this cannot be determined, then the default settings |
|
32 * of the OS are returned. |
|
33 */ |
|
34 private static int defaultUpper, defaultLower; |
|
35 private static final int upper, lower; |
|
36 |
|
37 private PortConfig() { |
|
38 } |
|
39 |
|
40 static { |
|
41 String os = System.getProperty("os.name"); |
|
42 if (os.startsWith("Linux")) { |
|
43 defaultLower = 32768; |
|
44 defaultUpper = 61000; |
|
45 } else if (os.startsWith("SunOS")) { |
|
46 defaultLower = 32768; |
|
47 defaultUpper = 65535; |
|
48 } else if (os.contains("OS X")) { |
|
49 defaultLower = 49152; |
|
50 defaultUpper = 65535; |
|
51 } else if (os.startsWith("AIX")) { |
|
52 // The ephemeral port is OS version dependent on AIX: |
|
53 // http://publib.boulder.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.rsct315.admin/bl503_ephport.htm |
|
54 // However, on AIX 5.3 / 6.1 / 7.1 we always see the |
|
55 // settings below by using: |
|
56 // /usr/sbin/no -a | fgrep ephemeral |
|
57 defaultLower = 32768; |
|
58 defaultUpper = 65535; |
|
59 } else { |
|
60 throw new InternalError( |
|
61 "sun.net.PortConfig: unknown OS"); |
|
62 } |
|
63 |
|
64 lower = defaultLower; |
|
65 upper = defaultUpper; |
|
66 } |
|
67 |
|
68 public static int getLower() { |
|
69 return lower; |
|
70 } |
|
71 |
|
72 public static int getUpper() { |
|
73 return upper; |
|
74 } |
|
75 } |