17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*9a70fc3bSMark J. Nelson * Common Development and Distribution License (the "License"). 6*9a70fc3bSMark J. Nelson * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 227c478bd9Sstevel@tonic-gate * Copyright (c) 2001 by Sun Microsystems, Inc. 237c478bd9Sstevel@tonic-gate * All rights reserved. 247c478bd9Sstevel@tonic-gate * 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate // Defaults.java : Defaults for SLP Locator, Advertiser and slpd. 287c478bd9Sstevel@tonic-gate // Author: Erik Guttman 297c478bd9Sstevel@tonic-gate // 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate package com.sun.slp; 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate import java.util.*; 347c478bd9Sstevel@tonic-gate import java.net.*; 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate /** 377c478bd9Sstevel@tonic-gate * This class gathers all constants used in the package into one place. 387c478bd9Sstevel@tonic-gate * 397c478bd9Sstevel@tonic-gate * @author James Kempf 407c478bd9Sstevel@tonic-gate */ 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate class Defaults { 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate // Default header class name for server. 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate static final String DEFAULT_SERVER_HEADER_CLASS = 477c478bd9Sstevel@tonic-gate "com.sun.slp.SLPServerHeaderV2"; 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate // Default DA table implementation. 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate static final String SUN_DATABLE = "com.sun.slp.SunDATable"; 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate // Character set. 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate static final String UTF8 = "UTF8"; 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate // Service prefix. 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate final static String SERVICE_PREFIX = "service"; 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate // Restricted type for DA table information. 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate static final ServiceType SUN_DA_SERVICE_TYPE = 647c478bd9Sstevel@tonic-gate new ServiceType("service:directory-agent.sun"); 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate // Restricted type for SA table information. 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate static final ServiceType SUN_SA_SERVICE_TYPE = 697c478bd9Sstevel@tonic-gate new ServiceType("service:service-agent.sun"); 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate // Directory agent URL type. 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate static final ServiceType DA_SERVICE_TYPE = 747c478bd9Sstevel@tonic-gate new ServiceType("service:directory-agent"); 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate // Service agent URL type. 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate static final ServiceType SA_SERVICE_TYPE = 797c478bd9Sstevel@tonic-gate new ServiceType("service:service-agent"); 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate // Service type attribute tag. 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate static final String SERVICE_TYPE_ATTR_ID = "service-type"; 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate // Minimum refresh interval attribute tag. 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate static final String MIN_REFRESH_INTERVAL_ATTR_ID = "min-refresh-interval"; 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate // These constants are involved in refreshing URLs or aging them out. 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate final static long lMaxSleepTime = 64800000L; // 18 hrs in milliseconds 927c478bd9Sstevel@tonic-gate final static float fRefreshGranularity = (float)0.1; 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate // Special naming authority names. 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate protected static final String ALL_AUTHORITIES = "*"; 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate // Default scope name. 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate static final String DEFAULT_SCOPE = "default"; 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate // Default DA attributes. 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate static final Vector defaultDAAttributes = new Vector(); 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate // Default SA attributes. 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate static final Vector defaultSAAttributes = new Vector(); 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate // DA attribute names. 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate static final String minDALifetime = "min-lifetime"; 1137c478bd9Sstevel@tonic-gate static final String maxDALifetime = "max-lifetime"; 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate // Loopback address and name. 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate static final String LOOPBACK_ADDRESS = "127.0.0.1"; 1187c478bd9Sstevel@tonic-gate static final String LOOPBACK_NAME = "localhost"; 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate // Solaris default config file 1217c478bd9Sstevel@tonic-gate static final String SOLARIS_CONF = "file:/etc/inet/slp.conf"; 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate static final int version = 2; 1247c478bd9Sstevel@tonic-gate static final int iSocketQueueLength = 10; 1257c478bd9Sstevel@tonic-gate static final int iMulticastRadius = 255; 1267c478bd9Sstevel@tonic-gate static final int iHeartbeat = 10800; 1277c478bd9Sstevel@tonic-gate static final int iActiveDiscoveryInterval = 900; 1287c478bd9Sstevel@tonic-gate static final int iActiveDiscoveryGranularity = 900; 1297c478bd9Sstevel@tonic-gate static final int iRandomWaitBound = 1000; 1307c478bd9Sstevel@tonic-gate static final int iMulticastMaxWait = 15000; 1317c478bd9Sstevel@tonic-gate static final int iMaximumResults = Integer.MAX_VALUE; 1327c478bd9Sstevel@tonic-gate static final Locale locale = new Locale("en", ""); 1337c478bd9Sstevel@tonic-gate static final int iMTU = 1400; 1347c478bd9Sstevel@tonic-gate static final int iReadMaxMTU = 8192; 1357c478bd9Sstevel@tonic-gate static final int iSLPPort = 427; 1367c478bd9Sstevel@tonic-gate static final String sGeneralSLPMCAddress = "239.255.255.253"; 1377c478bd9Sstevel@tonic-gate static final String sBroadcast = "255.255.255.255"; 1387c478bd9Sstevel@tonic-gate static final int iTCPTimeout = 20000; 1397c478bd9Sstevel@tonic-gate static final int[] a_iDatagramTimeout = {1000, 2000, 3000}; 1407c478bd9Sstevel@tonic-gate static final int[] a_iConvergeTimeout = 1417c478bd9Sstevel@tonic-gate {3000, 3000, 3000, 3000, 3000}; 1427c478bd9Sstevel@tonic-gate static final int[] a_iDADiscoveryTimeout = 1437c478bd9Sstevel@tonic-gate {2000, 2000, 2000, 2000, 3000, 4000}; 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate static Vector restrictedTypes; 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate static { 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate InetAddress iaLocal = null; 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate // Get local host. Note that we just use this for the scope 1527c478bd9Sstevel@tonic-gate // name, so it doesn't matter if that interface isn't 1537c478bd9Sstevel@tonic-gate // taking any requests. 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate try { 1567c478bd9Sstevel@tonic-gate iaLocal = InetAddress.getLocalHost(); 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate } catch (UnknownHostException ex) { 1597c478bd9Sstevel@tonic-gate Assert.slpassert(false, 1607c478bd9Sstevel@tonic-gate "resolve_failed", 1617c478bd9Sstevel@tonic-gate new Object[] {"localhost"}); 1627c478bd9Sstevel@tonic-gate } 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate // Normalize the hostname into just the nodename (as 1657c478bd9Sstevel@tonic-gate // opposed to the fully-qualified host name). 1667c478bd9Sstevel@tonic-gate String localHostName = iaLocal.getHostName(); 1677c478bd9Sstevel@tonic-gate int dot = localHostName.indexOf('.'); 1687c478bd9Sstevel@tonic-gate if (dot != -1) { 1697c478bd9Sstevel@tonic-gate localHostName = localHostName.substring(0, dot); 1707c478bd9Sstevel@tonic-gate } 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate // Set default DA table and SA only scopes. On Solaris, 1737c478bd9Sstevel@tonic-gate // the SA only scopes consist of the local machine 1747c478bd9Sstevel@tonic-gate // name, and the default DA table is SolarisDATable. 1757c478bd9Sstevel@tonic-gate // If this were C, there would be an #ifdef SOLARIS 1767c478bd9Sstevel@tonic-gate // around this code. 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate Properties props = System.getProperties(); props.put(DATable.SA_ONLY_SCOPES_PROP, localHostName)1797c478bd9Sstevel@tonic-gate props.put(DATable.SA_ONLY_SCOPES_PROP, localHostName); props.put(DATable.DA_TABLE_CLASS_PROP, SUN_DATABLE)1807c478bd9Sstevel@tonic-gate props.put(DATable.DA_TABLE_CLASS_PROP, SUN_DATABLE); 1817c478bd9Sstevel@tonic-gate System.setProperties(props); 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate // Set up the vector of restricted types. Restricted types 1847c478bd9Sstevel@tonic-gate // are only allowed to be added or deleted through the 1857c478bd9Sstevel@tonic-gate // slpd process. They also have no authentication information, 1867c478bd9Sstevel@tonic-gate // even if the network is authenticated. This is because 1877c478bd9Sstevel@tonic-gate // slpd is running as root and so unless root is compromised 1887c478bd9Sstevel@tonic-gate // the information can be trusted. 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate restrictedTypes = new Vector(); 1917c478bd9Sstevel@tonic-gate restrictedTypes.addElement(SUN_DA_SERVICE_TYPE); 1927c478bd9Sstevel@tonic-gate 1937c478bd9Sstevel@tonic-gate } 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate } 196