10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7298SMark.J.Nelson@Sun.COM * Common Development and Distribution License (the "License"). 6*7298SMark.J.Nelson@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 220Sstevel@tonic-gate * Copyright (c) 2001 by Sun Microsystems, Inc. 230Sstevel@tonic-gate * All rights reserved. 240Sstevel@tonic-gate * 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate // Defaults.java : Defaults for SLP Locator, Advertiser and slpd. 280Sstevel@tonic-gate // Author: Erik Guttman 290Sstevel@tonic-gate // 300Sstevel@tonic-gate 310Sstevel@tonic-gate package com.sun.slp; 320Sstevel@tonic-gate 330Sstevel@tonic-gate import java.util.*; 340Sstevel@tonic-gate import java.net.*; 350Sstevel@tonic-gate 360Sstevel@tonic-gate /** 370Sstevel@tonic-gate * This class gathers all constants used in the package into one place. 380Sstevel@tonic-gate * 390Sstevel@tonic-gate * @author James Kempf 400Sstevel@tonic-gate */ 410Sstevel@tonic-gate 420Sstevel@tonic-gate class Defaults { 430Sstevel@tonic-gate 440Sstevel@tonic-gate // Default header class name for server. 450Sstevel@tonic-gate 460Sstevel@tonic-gate static final String DEFAULT_SERVER_HEADER_CLASS = 470Sstevel@tonic-gate "com.sun.slp.SLPServerHeaderV2"; 480Sstevel@tonic-gate 490Sstevel@tonic-gate // Default DA table implementation. 500Sstevel@tonic-gate 510Sstevel@tonic-gate static final String SUN_DATABLE = "com.sun.slp.SunDATable"; 520Sstevel@tonic-gate 530Sstevel@tonic-gate // Character set. 540Sstevel@tonic-gate 550Sstevel@tonic-gate static final String UTF8 = "UTF8"; 560Sstevel@tonic-gate 570Sstevel@tonic-gate // Service prefix. 580Sstevel@tonic-gate 590Sstevel@tonic-gate final static String SERVICE_PREFIX = "service"; 600Sstevel@tonic-gate 610Sstevel@tonic-gate // Restricted type for DA table information. 620Sstevel@tonic-gate 630Sstevel@tonic-gate static final ServiceType SUN_DA_SERVICE_TYPE = 640Sstevel@tonic-gate new ServiceType("service:directory-agent.sun"); 650Sstevel@tonic-gate 660Sstevel@tonic-gate // Restricted type for SA table information. 670Sstevel@tonic-gate 680Sstevel@tonic-gate static final ServiceType SUN_SA_SERVICE_TYPE = 690Sstevel@tonic-gate new ServiceType("service:service-agent.sun"); 700Sstevel@tonic-gate 710Sstevel@tonic-gate // Directory agent URL type. 720Sstevel@tonic-gate 730Sstevel@tonic-gate static final ServiceType DA_SERVICE_TYPE = 740Sstevel@tonic-gate new ServiceType("service:directory-agent"); 750Sstevel@tonic-gate 760Sstevel@tonic-gate // Service agent URL type. 770Sstevel@tonic-gate 780Sstevel@tonic-gate static final ServiceType SA_SERVICE_TYPE = 790Sstevel@tonic-gate new ServiceType("service:service-agent"); 800Sstevel@tonic-gate 810Sstevel@tonic-gate // Service type attribute tag. 820Sstevel@tonic-gate 830Sstevel@tonic-gate static final String SERVICE_TYPE_ATTR_ID = "service-type"; 840Sstevel@tonic-gate 850Sstevel@tonic-gate // Minimum refresh interval attribute tag. 860Sstevel@tonic-gate 870Sstevel@tonic-gate static final String MIN_REFRESH_INTERVAL_ATTR_ID = "min-refresh-interval"; 880Sstevel@tonic-gate 890Sstevel@tonic-gate // These constants are involved in refreshing URLs or aging them out. 900Sstevel@tonic-gate 910Sstevel@tonic-gate final static long lMaxSleepTime = 64800000L; // 18 hrs in milliseconds 920Sstevel@tonic-gate final static float fRefreshGranularity = (float)0.1; 930Sstevel@tonic-gate 940Sstevel@tonic-gate // Special naming authority names. 950Sstevel@tonic-gate 960Sstevel@tonic-gate protected static final String ALL_AUTHORITIES = "*"; 970Sstevel@tonic-gate 980Sstevel@tonic-gate // Default scope name. 990Sstevel@tonic-gate 1000Sstevel@tonic-gate static final String DEFAULT_SCOPE = "default"; 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate // Default DA attributes. 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate static final Vector defaultDAAttributes = new Vector(); 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate // Default SA attributes. 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate static final Vector defaultSAAttributes = new Vector(); 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate // DA attribute names. 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate static final String minDALifetime = "min-lifetime"; 1130Sstevel@tonic-gate static final String maxDALifetime = "max-lifetime"; 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate // Loopback address and name. 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate static final String LOOPBACK_ADDRESS = "127.0.0.1"; 1180Sstevel@tonic-gate static final String LOOPBACK_NAME = "localhost"; 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate // Solaris default config file 1210Sstevel@tonic-gate static final String SOLARIS_CONF = "file:/etc/inet/slp.conf"; 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate static final int version = 2; 1240Sstevel@tonic-gate static final int iSocketQueueLength = 10; 1250Sstevel@tonic-gate static final int iMulticastRadius = 255; 1260Sstevel@tonic-gate static final int iHeartbeat = 10800; 1270Sstevel@tonic-gate static final int iActiveDiscoveryInterval = 900; 1280Sstevel@tonic-gate static final int iActiveDiscoveryGranularity = 900; 1290Sstevel@tonic-gate static final int iRandomWaitBound = 1000; 1300Sstevel@tonic-gate static final int iMulticastMaxWait = 15000; 1310Sstevel@tonic-gate static final int iMaximumResults = Integer.MAX_VALUE; 1320Sstevel@tonic-gate static final Locale locale = new Locale("en", ""); 1330Sstevel@tonic-gate static final int iMTU = 1400; 1340Sstevel@tonic-gate static final int iReadMaxMTU = 8192; 1350Sstevel@tonic-gate static final int iSLPPort = 427; 1360Sstevel@tonic-gate static final String sGeneralSLPMCAddress = "239.255.255.253"; 1370Sstevel@tonic-gate static final String sBroadcast = "255.255.255.255"; 1380Sstevel@tonic-gate static final int iTCPTimeout = 20000; 1390Sstevel@tonic-gate static final int[] a_iDatagramTimeout = {1000, 2000, 3000}; 1400Sstevel@tonic-gate static final int[] a_iConvergeTimeout = 1410Sstevel@tonic-gate {3000, 3000, 3000, 3000, 3000}; 1420Sstevel@tonic-gate static final int[] a_iDADiscoveryTimeout = 1430Sstevel@tonic-gate {2000, 2000, 2000, 2000, 3000, 4000}; 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate static Vector restrictedTypes; 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate static { 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate InetAddress iaLocal = null; 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate // Get local host. Note that we just use this for the scope 1520Sstevel@tonic-gate // name, so it doesn't matter if that interface isn't 1530Sstevel@tonic-gate // taking any requests. 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate try { 1560Sstevel@tonic-gate iaLocal = InetAddress.getLocalHost(); 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate } catch (UnknownHostException ex) { 1590Sstevel@tonic-gate Assert.slpassert(false, 1600Sstevel@tonic-gate "resolve_failed", 1610Sstevel@tonic-gate new Object[] {"localhost"}); 1620Sstevel@tonic-gate } 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate // Normalize the hostname into just the nodename (as 1650Sstevel@tonic-gate // opposed to the fully-qualified host name). 1660Sstevel@tonic-gate String localHostName = iaLocal.getHostName(); 1670Sstevel@tonic-gate int dot = localHostName.indexOf('.'); 1680Sstevel@tonic-gate if (dot != -1) { 1690Sstevel@tonic-gate localHostName = localHostName.substring(0, dot); 1700Sstevel@tonic-gate } 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate // Set default DA table and SA only scopes. On Solaris, 1730Sstevel@tonic-gate // the SA only scopes consist of the local machine 1740Sstevel@tonic-gate // name, and the default DA table is SolarisDATable. 1750Sstevel@tonic-gate // If this were C, there would be an #ifdef SOLARIS 1760Sstevel@tonic-gate // around this code. 1770Sstevel@tonic-gate 1780Sstevel@tonic-gate Properties props = System.getProperties(); props.put(DATable.SA_ONLY_SCOPES_PROP, localHostName)1790Sstevel@tonic-gate props.put(DATable.SA_ONLY_SCOPES_PROP, localHostName); props.put(DATable.DA_TABLE_CLASS_PROP, SUN_DATABLE)1800Sstevel@tonic-gate props.put(DATable.DA_TABLE_CLASS_PROP, SUN_DATABLE); 1810Sstevel@tonic-gate System.setProperties(props); 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate // Set up the vector of restricted types. Restricted types 1840Sstevel@tonic-gate // are only allowed to be added or deleted through the 1850Sstevel@tonic-gate // slpd process. They also have no authentication information, 1860Sstevel@tonic-gate // even if the network is authenticated. This is because 1870Sstevel@tonic-gate // slpd is running as root and so unless root is compromised 1880Sstevel@tonic-gate // the information can be trusted. 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate restrictedTypes = new Vector(); 1910Sstevel@tonic-gate restrictedTypes.addElement(SUN_DA_SERVICE_TYPE); 1920Sstevel@tonic-gate 1930Sstevel@tonic-gate } 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate } 196