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-2002 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A// Author: James Kempf 2N/A// Created On: Thu Sep 10 15:12:14 1998 2N/A// Last Modified By: James Kempf 2N/A// Last Modified On: Wed Jan 20 15:38:07 1999 2N/A * The SLPHeaderV1 class models the SLPv1 server side header. 2N/A * @author James Kempf 2N/A // Function code for message reply. 2N/A // Various header flags. 2N/A protected static final int FRESH =
0x08;
2N/A // Characters to escape. 2N/A // Used to construct a header in SrvLocHeader.newInstance(). 2N/A // Assign reply code based on function code type, then use superclass 2N/A // method to parse header. 2N/A // We ignore the error case here. 2N/A fresh =
false;
// fresh gets set on output in SLPv1 2N/A // Security not handled for SLPv1. 2N/A // Dialect must be zero. 2N/A "v1_nonzero_dialect",
2N/A // Parse an incoming V1 message and return the SrvLocMsg object. 2N/A // If this is a *multicast* request, we reject it except for DAAdvert. 2N/A // Multicast requests are only taken by SA servers. 2N/A // Switch and convert according to function code. 2N/A "function_code_error",
2N/A // Check for size overflow. 2N/A // Externalize the message by converting it to bytes and writing 2N/A // it to the output stream. 2N/A // Need to put in the error code or previous responders. 2N/A // Parse out previous responders. Note there will only be some 2N/A // if the error code is not put out. 2N/A // Parse payload out if error code is OK and payload is nonnull. 2N/A // Don't touch payload here, somebody may put in a previousResponder 2N/A // and resend the message. 2N/A // Set overflow flag if buffer is too large and this isn't going out 2N/A "v1_unsupported_encoding",
2N/A // Create an error reply using the reply code. Calculate the 2N/A // error code using the exception. 2N/A // If this is a DAAdvert, then no error reply is returned 2N/A // because V1 doesn't support unicast SrvRqst for DAAdvert. 2N/A // Clone the header to make sure that everything else is the same. 2N/A // We don't want to use the same header because it may be tested 2N/A // We know we support it. 2N/A // We should *not* be getting a null exception down this path! 2N/A // Handle monolingual bit here. If the exception is 2N/A // LANGUAGE_NOT_SUPPORTED and the message type is 2N/A // either SrvRqst or AttrRqst, then we simply return an 2N/A // empty message unless the monolingual flag is on. 2N/A // Otherwise, we just ignore it. 2N/A // Anything over AUTHENTICATION_FAILED is an internal error in V1. 2N/A // Construct header description. 2N/A // Return a reply header with flags properly set. 2N/A // We know that we support it. 2N/A // Return display string. 2N/A // Validation Utilities. 2N/A * Validate the scope name to be sure it doesn't contain forbidden 2N/A * chars and isn't one of the reserved scope names. 2N/A "v1_scope_char_res",
2N/A // Check against reserved scope names. 2N/A "v1_scope_name_res",
2N/A * Remove IANA from the service type name. 2N/A * @param serviceType The service type and naming authority. 2N/A * @return The service type name with IANA removed. 2N/A // Substitute null string for IANA. 2N/A // Check whether this is a vaild SLPv1 service type. Also remove 2N/A // Check for trailing colon and remove it. 2N/A "v1_service_type_format",
2N/A // Reject if abstract type. SLPv1 doesn't handle 2N/A // Reject if not a service: type. SLPv1 doesn't handle 2N/A // nonservice: types. 2N/A // Parsing Utilities. 2N/A // Parse string, bump byte count. 2N/A // If the encoding type is Unicode, then figure out first 2N/A // whether it's big or little endian from byte header. Future 2N/A // calls won't have to go through this grief unless the byte header 2N/A // If we are still just Unicode by this point, then we need to 2N/A // add the big endian bytes to the beginning of the array. 2N/A // Otherwise, Java won't parse it. Note that we don't change 2N/A // the flag in the header, since we will need to convert the 2N/A // next time around as well. 2N/A // Convert the bytes into a string. 2N/A // Parse out string, bump byte count. Use header encoding. 2N/A // If the charCode is UNICODE, arbirtarily change to big or little, 2N/A // while Java will parse. 2N/A // Parse in a service URL including lifetime if necessary. 2N/A // Parse out a service URL including lifetime if required. 2N/A // Parse in a list of attributes, returing a vector of 2N/A // ServiceLocationAttribute objects. 2N/A // Parse the list into ServiceLocationAttribute objects. 2N/A for (i =
0; i < n; i++) {
2N/A // Parse out a V1 attribute vector. 2N/A // Convert the attributes to strings, escaping characters to 2N/A // Make an SLPv1 attribute out of it, so we can 2N/A // externalize it with the v1 encoding scheme. 2N/A // Parse in previous responders. 2N/A // Put out a vector of strings. 2N/A // Put out the total number of strings. 2N/A // Put out the strings. 2N/A for (i =
0; i < n; i++) {
2N/A // Return an SLPv1 DAAdvert. 2N/A // If scopes vector is null, then return all scopes for this 2N/A // Reimplement clone() to get the header size right.