xref: /illumos-gate/usr/src/lib/libslp/javalib/com/sun/slp/Defaults.java (revision 24da5b34f49324ed742a340010ed5bd3d4e06625)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * ident	"%Z%%M%	%I%	%E% SMI"
24  *
25  * Copyright (c) 2001 by Sun Microsystems, Inc.
26  * All rights reserved.
27  *
28  */
29 
30 // SCCS Status:
31 // Defaults.java : Defaults for SLP Locator, Advertiser and slpd.
32 // Author:   Erik Guttman
33 //
34 
35 package com.sun.slp;
36 
37 import java.util.*;
38 import java.net.*;
39 
40 /**
41  * This class gathers all constants used in the package into one place.
42  *
43  * @version %R%.%L% %D%
44  * @author James Kempf
45  */
46 
47 class Defaults {
48 
49     // Default header class name for server.
50 
51     static final String DEFAULT_SERVER_HEADER_CLASS =
52 	"com.sun.slp.SLPServerHeaderV2";
53 
54     // Default DA table implementation.
55 
56     static final String SUN_DATABLE = "com.sun.slp.SunDATable";
57 
58     // Character set.
59 
60     static final String UTF8 = "UTF8";
61 
62     // Service prefix.
63 
64     final static String SERVICE_PREFIX = "service";
65 
66     // Restricted type for DA table information.
67 
68     static final ServiceType SUN_DA_SERVICE_TYPE =
69 	new ServiceType("service:directory-agent.sun");
70 
71     // Restricted type for SA table information.
72 
73     static final ServiceType SUN_SA_SERVICE_TYPE =
74 	new ServiceType("service:service-agent.sun");
75 
76     // Directory agent URL type.
77 
78     static final ServiceType DA_SERVICE_TYPE =
79 	new ServiceType("service:directory-agent");
80 
81     // Service agent URL type.
82 
83     static final ServiceType SA_SERVICE_TYPE =
84 	new ServiceType("service:service-agent");
85 
86     // Service type attribute tag.
87 
88     static final String SERVICE_TYPE_ATTR_ID = "service-type";
89 
90     // Minimum refresh interval attribute tag.
91 
92     static final String MIN_REFRESH_INTERVAL_ATTR_ID = "min-refresh-interval";
93 
94     // These constants are involved in refreshing URLs or aging them out.
95 
96     final static long lMaxSleepTime = 64800000L;  // 18 hrs in milliseconds
97     final static float fRefreshGranularity = (float)0.1;
98 
99     // Special naming authority names.
100 
101     protected static final String ALL_AUTHORITIES = "*";
102 
103     // Default scope name.
104 
105     static final String DEFAULT_SCOPE = "default";
106 
107     // Default DA attributes.
108 
109     static final Vector defaultDAAttributes = new Vector();
110 
111     // Default SA attributes.
112 
113     static final Vector defaultSAAttributes = new Vector();
114 
115     // DA attribute names.
116 
117     static final String minDALifetime = "min-lifetime";
118     static final String maxDALifetime = "max-lifetime";
119 
120     // Loopback address and name.
121 
122     static final String LOOPBACK_ADDRESS = "127.0.0.1";
123     static final String LOOPBACK_NAME = "localhost";
124 
125     // Solaris default config file
126     static final String SOLARIS_CONF = "file:/etc/inet/slp.conf";
127 
128     static final int         version = 2;
129     static final int	   iSocketQueueLength = 10;
130     static final int         iMulticastRadius = 255;
131     static final int         iHeartbeat = 10800;
132     static final int	   iActiveDiscoveryInterval = 900;
133     static final int	   iActiveDiscoveryGranularity = 900;
134     static final int	   iRandomWaitBound = 1000;
135     static final int         iMulticastMaxWait = 15000;
136     static final int         iMaximumResults = Integer.MAX_VALUE;
137     static final Locale      locale = new Locale("en", "");
138     static final int         iMTU = 1400;
139     static final int         iReadMaxMTU = 8192;
140     static final int         iSLPPort = 427;
141     static final String      sGeneralSLPMCAddress = "239.255.255.253";
142     static final String      sBroadcast           = "255.255.255.255";
143     static final int         iTCPTimeout          = 20000;
144     static final int[]       a_iDatagramTimeout = {1000, 2000, 3000};
145     static final int[]       a_iConvergeTimeout =
146 					{3000, 3000, 3000, 3000, 3000};
147     static final int[]	   a_iDADiscoveryTimeout =
148 					{2000, 2000, 2000, 2000, 3000, 4000};
149 
150     static Vector restrictedTypes;
151 
152     static {
153 
154 	InetAddress iaLocal = null;
155 
156 	// Get local host. Note that we just use this for the scope
157 	//  name, so it doesn't matter if that interface isn't
158 	//  taking any requests.
159 
160 	try {
161 	    iaLocal =  InetAddress.getLocalHost();
162 
163 	}  catch (UnknownHostException ex) {
164 	    Assert.slpassert(false,
165 			  "resolve_failed",
166 			  new Object[] {"localhost"});
167 	}
168 
169 	// Normalize the hostname into just the nodename (as
170 	//  opposed to the fully-qualified host name).
171 	String localHostName = iaLocal.getHostName();
172 	int dot = localHostName.indexOf('.');
173 	if (dot != -1) {
174 	    localHostName = localHostName.substring(0, dot);
175 	}
176 
177 	// Set default DA table and SA only scopes. On Solaris,
178 	//  the SA only scopes consist of the local machine
179 	//  name, and the default DA table is SolarisDATable.
180 	//  If this were C, there would be an #ifdef SOLARIS
181 	//  around this code.
182 
183 	Properties props = System.getProperties();
184 	props.put(DATable.SA_ONLY_SCOPES_PROP, localHostName);
185 	props.put(DATable.DA_TABLE_CLASS_PROP, SUN_DATABLE);
186 	System.setProperties(props);
187 
188 	// Set up the vector of restricted types. Restricted types
189 	//  are only allowed to be added or deleted through the
190 	//  slpd process. They also have no authentication information,
191 	//  even if the network is authenticated. This is because
192 	//  slpd is running as root and so unless root is compromised
193 	//  the information can be trusted.
194 
195 	restrictedTypes = new Vector();
196 	restrictedTypes.addElement(SUN_DA_SERVICE_TYPE);
197 
198     }
199 
200 }
201