summaryrefslogtreecommitdiff
path: root/usr/src/lib/libslp/javalib/com/sun/slp/Defaults.java
blob: 215148fce8a25ee347a861e2c5616e53ed3777ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 2001 by Sun Microsystems, Inc.
 * All rights reserved.
 *
 */

// Defaults.java : Defaults for SLP Locator, Advertiser and slpd.
// Author:   Erik Guttman
//

package com.sun.slp;

import java.util.*;
import java.net.*;

/**
 * This class gathers all constants used in the package into one place.
 *
 * @author James Kempf
 */

class Defaults {

    // Default header class name for server.

    static final String DEFAULT_SERVER_HEADER_CLASS =
	"com.sun.slp.SLPServerHeaderV2";

    // Default DA table implementation.

    static final String SUN_DATABLE = "com.sun.slp.SunDATable";

    // Character set.

    static final String UTF8 = "UTF8";

    // Service prefix.

    final static String SERVICE_PREFIX = "service";

    // Restricted type for DA table information.

    static final ServiceType SUN_DA_SERVICE_TYPE =
	new ServiceType("service:directory-agent.sun");

    // Restricted type for SA table information.

    static final ServiceType SUN_SA_SERVICE_TYPE =
	new ServiceType("service:service-agent.sun");

    // Directory agent URL type.

    static final ServiceType DA_SERVICE_TYPE =
	new ServiceType("service:directory-agent");

    // Service agent URL type.

    static final ServiceType SA_SERVICE_TYPE =
	new ServiceType("service:service-agent");

    // Service type attribute tag.

    static final String SERVICE_TYPE_ATTR_ID = "service-type";

    // Minimum refresh interval attribute tag.

    static final String MIN_REFRESH_INTERVAL_ATTR_ID = "min-refresh-interval";

    // These constants are involved in refreshing URLs or aging them out.

    final static long lMaxSleepTime = 64800000L;  // 18 hrs in milliseconds
    final static float fRefreshGranularity = (float)0.1;

    // Special naming authority names.

    protected static final String ALL_AUTHORITIES = "*";

    // Default scope name.

    static final String DEFAULT_SCOPE = "default";

    // Default DA attributes.

    static final Vector defaultDAAttributes = new Vector();

    // Default SA attributes.

    static final Vector defaultSAAttributes = new Vector();

    // DA attribute names.

    static final String minDALifetime = "min-lifetime";
    static final String maxDALifetime = "max-lifetime";

    // Loopback address and name.

    static final String LOOPBACK_ADDRESS = "127.0.0.1";
    static final String LOOPBACK_NAME = "localhost";

    // Solaris default config file
    static final String SOLARIS_CONF = "file:/etc/inet/slp.conf";

    static final int         version = 2;
    static final int	   iSocketQueueLength = 10;
    static final int         iMulticastRadius = 255;
    static final int         iHeartbeat = 10800;
    static final int	   iActiveDiscoveryInterval = 900;
    static final int	   iActiveDiscoveryGranularity = 900;
    static final int	   iRandomWaitBound = 1000;
    static final int         iMulticastMaxWait = 15000;
    static final int         iMaximumResults = Integer.MAX_VALUE;
    static final Locale      locale = new Locale("en", "");
    static final int         iMTU = 1400;
    static final int         iReadMaxMTU = 8192;
    static final int         iSLPPort = 427;
    static final String      sGeneralSLPMCAddress = "239.255.255.253";
    static final String      sBroadcast           = "255.255.255.255";
    static final int         iTCPTimeout          = 20000;
    static final int[]       a_iDatagramTimeout = {1000, 2000, 3000};
    static final int[]       a_iConvergeTimeout =
					{3000, 3000, 3000, 3000, 3000};
    static final int[]	   a_iDADiscoveryTimeout =
					{2000, 2000, 2000, 2000, 3000, 4000};

    static Vector restrictedTypes;

    static {

	InetAddress iaLocal = null;

	// Get local host. Note that we just use this for the scope
	//  name, so it doesn't matter if that interface isn't
	//  taking any requests.

	try {
	    iaLocal =  InetAddress.getLocalHost();

	}  catch (UnknownHostException ex) {
	    Assert.slpassert(false,
			  "resolve_failed",
			  new Object[] {"localhost"});
	}

	// Normalize the hostname into just the nodename (as
	//  opposed to the fully-qualified host name).
	String localHostName = iaLocal.getHostName();
	int dot = localHostName.indexOf('.');
	if (dot != -1) {
	    localHostName = localHostName.substring(0, dot);
	}

	// Set default DA table and SA only scopes. On Solaris,
	//  the SA only scopes consist of the local machine
	//  name, and the default DA table is SolarisDATable.
	//  If this were C, there would be an #ifdef SOLARIS
	//  around this code.

	Properties props = System.getProperties();
	props.put(DATable.SA_ONLY_SCOPES_PROP, localHostName);
	props.put(DATable.DA_TABLE_CLASS_PROP, SUN_DATABLE);
	System.setProperties(props);

	// Set up the vector of restricted types. Restricted types
	//  are only allowed to be added or deleted through the
	//  slpd process. They also have no authentication information,
	//  even if the network is authenticated. This is because
	//  slpd is running as root and so unless root is compromised
	//  the information can be trusted.

	restrictedTypes = new Vector();
	restrictedTypes.addElement(SUN_DA_SERVICE_TYPE);

    }

}