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