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 2001,2003 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A// Author: James Kempf 2N/A// Created On: Mon May 11 15:00:23 1998 2N/A// Last Modified By: James Kempf 2N/A// Last Modified On: Thu Mar 11 15:00:58 1999 2N/A * The SunDATable class uses the IPC connection to obtain DA information 2N/A * from the SA server. By convention, the SA server answers service 2N/A * requests for the service type "directory-agent.sun" and including 2N/A * a filter for the scopes formatted as: 2N/A * "(&(|(scopes=<scope1>)(scopes=<scope2>)(scopes=<scope3>)...)(version=2))" 2N/A * with a collection of URLs that fit the request. The scope of the 2N/A * request is the hostname of the local machine, which will not be 2N/A * forwarded to any DAs. The URLs contain the 2N/A * DA IP address in the host field and a list of scopes in the URL 2N/A * part in the form of an attribute value assignment, i.e.: 2N/A * service:directory-agent.sun:// 199.200.200.5/scopes=eng, corp, freeb 2N/A * The DA/scope table is initially obtained for all scopes in the 2N/A * useScopes list, then refreshed periodically when the 2N/A * time stamp runs out. The time stamp is determined as the minimum 2N/A * expiration time of the service URLs. 2N/A * @author James Kempf 2N/A // The scopes identifier. 2N/A // DA version number. 2N/A // The scopes which reside on the SA only. 2N/A // The cached vector of DA equivalence classes. 2N/A // The time when the cache should be refreshed. 2N/A * Construct a DATable. We get a cached table of accessable 2N/A * DAs and scopes and the SA scope names to use for querying. 2N/A // Remove the common scopes from the SA scopes. This will leave 2N/A // the private, SA only scopes. 2N/A // Initialize the cache. We want the scopes that can be dynamically 2N/A // discovered. If we have been configured with scopes, then 2N/A // it will be those. If not, then we want whatever we can discovery. 2N/A // we only want the default version for client side. 2N/A * Return a hashtable of DA equivalence classes and multicast 2N/A * scopes. Multicast scopes are stored in the special hashtable 2N/A * key MULTICAST_KEY. Unicast DA equivalence classes are stored 2N/A * under the key UNICAST_KEY. 2N/A * @param scopes Scope list for DAs needed. 2N/A * @return Hashtable with DA addresses as keys and scopes to contact 2N/A * them with as values. Any scopes not associated with a 2N/A * DA come back stored under the key MULTICAST_KEY. 2N/A * Unicast DA equivalence classes are stored 2N/A * under the key UNICAST_KEY. 2N/A // Refresh the local cache if necessary. 2N/A // Sort through the local cache, matching against the input parameter. 2N/A // Collect multicast scopes. 2N/A // Filter multicast scopes first. Remove any from the multicast 2N/A // scope list that are in daScopes. 2N/A // Now filter daScopes. Remove any from the daScopes that are 2N/A // not in the input scopes. 2N/A // Remove this record if there are none left. 2N/A * Must decrement the index 'i' otherwise the next iteration 2N/A * around the loop will miss the element immediately after 2N/A * the element removed. 2N/A * WARNING: Do not use 'i' again until the loop has 2N/A * iterated as it may, after decrementing, 2N/A // Install the unicast and multicast scopes if any. 2N/A * Remove a DA by address. We only remove it from the wire table 2N/A * so if it's down temporarily, we'll get it back again. 2N/A * @param address The host address of the DA. 2N/A * @param scopes The scopes. 2N/A * @return True if removed, false if not. 2N/A // Sort through the table of equivalence classes in cache. 2N/A // Ignore scopes, delete if there. Scopes will always be the 2N/A // ones for which this DA is to be removed. 2N/A for (j =
0; j < m; j++) {
2N/A // If they are equal, remove it, exit loop. 2N/A // If the cache entry is empty, remove it. 2N/A // Return a vector of DARecord equivalence classes by going out to the 2N/A // wire for them. Merge any that are in the current process' 2N/A // DAAddresses property. 2N/A // Get replies from the SA server. These will be CSrvMsg replies. 2N/A // Process reply into the vector of equivalence classes by adding to 2N/A // to those from the preconfigured DAs. 2N/A for (i =
0; i < n; i++) {
2N/A // Add logical disjunction if there is more than one scope. 2N/A // Add version number restriction. 2N/A // Add closing paren if there were any scopes. 2N/A // Create the message object. Note that if scope vector is 2N/A // empty, the query is the null string, and so all DAs 2N/A // will be returned. 2N/A // Send it down the pipe to the IPC process. It's a bad bug 2N/A // if the reply comes back as not a CSrvMsg. 2N/A // Check error code. 2N/A // Process CSrvMsg reply into DA equivalence class vector 2N/A // Process each service URL. 2N/A for (i =
0; i < n; i++) {
2N/A // If the time to live is less than the current minimum, 2N/A // Get the host name and URL part. 2N/A // Parse URL part into scope list. Be 2N/A // sure not to include the initial `/' in the parse. 2N/A // Convert to an SLP attribute. 2N/A // Depending on the attribute id, do something. 2N/A "loopback_parse_error",
2N/A // Add it to the equivalence class. 2N/A // Reset the timestamp.