2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A// Author: Erik Guttman 2N/A * The slpd class is the main class for the slpd directory agent/ 2N/A * service agent server of SLP. Slpd can run in two possible modes, 2N/A * depending on the configuration of the classes with which it was shipped 2N/A * and information read from the optional configuration file argument: 2N/A * <li> <b> Service Agent server </b> 2N/A * In this mode, slpd functions as a service agent server only. 2N/A * Directory agent functionality is disabled. Service agent 2N/A * clients on the local machine register and deregister services 2N/A * with slpd, and slpd responds to multicast requests for 2N/A * services. It passively and actively listens for directory agent 2N/A * advertisements, caches them, and forwards them to both 2N/A * user agent and service agent clients. A file of serialized 2N/A * proxy registrations can be read at startup. 2N/A * This mode is normally default. 2N/A * In this mode, slpd functions as a directory agent 2N/A * for port 427 on the local machine. The directory agent 2N/A * caches service advertisements, makes directory agent 2N/A * advertisements of its services, and responds to requests 2N/A * for TCP connections with service agents and user agents. 2N/A * In addition, slpd functions in the first mode, as a 2N/A * service agent server, for SAs and UAs on the local host. 2N/A * The slpd is invoked as follows:<br> 2N/A * java com.sun.slpd [monitor] [stop] [-f <config file name>] 2N/A * The optional monitor argument specifies that a GUI monitor should be 2N/A * brought up. The optional stop argument indicates that slpd should 2N/A * signal a running slpd to stop. The optional <config file name> argument 2N/A * specifies that the named file should be used as the configuration file. 2N/A * for more information on proxy registration file syntax. 2N/A * @author Erik Guttman, James Kempf 2N/A// Note that the inheritance is *only* so slpd can initialize the 2N/A// internals of SLP config. 2N/A // Server bundle. Set the parent. 2N/A // fallthru to default location 2N/A }
// No locales in slpd.jar, so propagate the 2N/A // MissingResourceException 2N/A * Log object for SLP to write to GUI. This class follows the 2N/A * semantics of the other SLP logging classes: 2N/A * This class does not actually write anything until the flush() method 2N/A * in invoked; this will write the concatenation of all messages 2N/A * passed to the write() method since the last invocation of flush(). 2N/A * The actual logging class used can be controlled via the 2N/A * sun.net.slp.loggerClass property. 2N/A * See also the StderrLog and Syslog classes. 2N/A // Write to the StringBuffer 2N/A // Write to the Frame. 2N/A // Called by the slpd and subclasses only. 2N/A * Usage: slpd [monitor] [stop] [-f config-file name]<br> 2N/A * String arguments are: 2N/A * <b> monitor </b> Puts up a rudimentary GUI for the slpd.<br> 2N/A * <b>stop <b> Bring down a running slpd and exit. 2N/A * <b> config-file name </b> Reads the specified configuration file.<br> 2N/A * The default running mode is to have no GUI and to use SLP 2N/A * defined configuration. 2N/A for (i =
0; i < n; i++) {
2N/A // Argument is a config file. 2N/A // Make sure we can open it. 2N/A // Read message bundle file, load config file into properties. 2N/A // Create a new SLP Config object from the config file. 2N/A // Create a GUI if the user asked for one. 2N/A // Either start or stop the server, depending on what was 2N/A * @param bMon True if initializing with GUI monitor. 2N/A * @exception ServiceLocationException Internal error or network 2N/A * initialization error or 2N/A * internal networking error. 2N/A // Initialize the service table. 2N/A // Initialize the class name for the DA table to the Sun-specific 2N/A // If there is a request on stdin, process it now 2N/A // Start a StreamListener on loopback to start accepting locals regs 2N/A // Create a ServerDATable from the class. This will initialize 2N/A // active discovery. Note that we need to record our own presence 2N/A // in the DA table because we are not yet listening for requests. 2N/A // We do this after deserialization so that if we discover any 2N/A // DAs, we can perform registrations of the serialized advertisements. 2N/A // Deserialize any serialized advertisements and do them now. 2N/A // Waiting until here allows any error messages to appear in 2N/A // the GUI log, if any, and at this point the DA table is ready. 2N/A // Need to create datagram and stream listeners, and a 2N/A // DAAdvertiser on all network interfaces. 2N/A for (i =
0; i < n; i++) {
2N/A // interface. This includes a datagram listener, a DAAdvertiser 2N/A // (which shares the same socket as the datagram listener), and 2N/A // a stream listener. 2N/A // If we've been configured as a DA, then create a DA advertiser to 2N/A // periodically advertise our presence on this interface. This 2N/A // is only done on the default interface. 2N/A // Report scopes and whether DA or SA. 2N/A // Report that we are running if tracing is on 2N/A // If V1 is supported, crank up V1 support as well. 2N/A // Stop a running server by sending a DAAdvert or SAAdvert. 2N/A // Determine whether the daemon running on this machine is a DA 2N/A // Get a DA table with available DAs. 2N/A // If no DAs, then simply return. 2N/A // Find our address in the list, if it exists. 2N/A for (i =
0; i < n; i++) {
2N/A for (j =
0; j < m; j++) {
2N/A // Stop a DA by multicasting the DAAdvert with boot timestamp 0. 2N/A // Make the DA URL and the DAAdvert. Note that we only need signal 2N/A // on the default local host interface because that is the only 2N/A // one on which the server is listening. 2N/A (
short)
0x0,
// sez we're unsolicited... 2N/A 0L,
// sez we're going down... 2N/A new Vector());
// no attributes needed to go down... 2N/A // Make the DAAdvertiser. 2N/A // Send out unsolicted "going down" message. 2N/A // That's it! No need for any messages here. 2N/A // Stop an SA server by unicasting an SA advert with xid 0. 2N/A // We signal for stop on the local host, which is guaranteed 2N/A // to have an SA listener. 2N/A (
short)
0x0,
// sez we're going down... 2N/A // don't care about attrs.., 2N/A // Send it TCP. We ignore NETWORK_ERROR because it only means 2N/A // that the daemon didn't send us a reply, which is expected. 2N/A // Print error message, exit. 2N/A // Make a new SLPConfig object of the right class type. 2N/A // The server *always* runs as an SA. It may also run as a DA. 2N/A // set default logging class for slpd to syslog 2N/A // slpd is the server side config. 2N/A // Extensions to sldp for server side only. 2N/A // Determine whether V1 is supported. Default is no. 2N/A // Load server message bundle. 2N/A // Get the parent bundle first. 2N/A // We need this in case we get an error before the config object is 2N/A // Now create a server subclass. 2N/A // We can't print out to the log, because we may be in the 2N/A // process of trying to. 2N/A // Hosed if the default locale is missing. 2N/A // Otherwise, return the default locale.