java.lang.Object
org.cybergarage.upnp.UPnP

public class UPnPextends Object
Global utility class for UPnP framework configuration and operations.

This class provides static methods and constants for configuring the UPnP framework, including network settings, XML parser configuration, and utility functions for UUID generation, server identification, and framework initialization.

The class serves as the main entry point for framework-wide configuration and provides constants used throughout the UPnP implementation.

  • Field Details

    • XML_CLASS_PROPERTTY

      public static final String XML_CLASS_PROPERTTY
      Name of the system properties used to identifies the default XML Parser.
      The value of the properties MUST BE the fully qualified class name of
      XML Parser which CyberLink should use.
      See Also:
    • NAME

      public static final String NAME
      Framework name used in server identification.
      See Also:
    • VERSION

      public static final String VERSION
      Framework version used in server identification.
      See Also:
    • SERVER_RETRY_COUNT

      public static final int SERVER_RETRY_COUNT
      Number of retry attempts for server operations.
      See Also:
    • DEFAULT_EXPIRED_DEVICE_EXTRA_TIME

      public static final int DEFAULT_EXPIRED_DEVICE_EXTRA_TIME
      Default extra time in seconds before considering a device expired.
      See Also:
    • INMPR03

      public static final String INMPR03
      INMPR03 protocol identifier.
      See Also:
    • INMPR03_VERSION

      public static final String INMPR03_VERSION
      INMPR03 protocol version.
      See Also:
    • INMPR03_DISCOVERY_OVER_WIRELESS_COUNT

      public static final int INMPR03_DISCOVERY_OVER_WIRELESS_COUNT
      Number of discovery attempts over wireless interfaces for INMPR03.
      See Also:
    • XML_DECLARATION

      public static final String XML_DECLARATION
      Standard XML declaration for UPnP documents.
      See Also:
    • CONFIGID_UPNP_ORG_MAX

      public static final int CONFIGID_UPNP_ORG_MAX
      Maximum value for UPnP.org configuration IDs.
      See Also:
    • USE_ONLY_IPV6_ADDR

      public static final int USE_ONLY_IPV6_ADDR
      Enable IPv6-only addressing mode.
      See Also:
    • USE_LOOPBACK_ADDR

      public static final int USE_LOOPBACK_ADDR
      Enable loopback address usage.
      See Also:
    • USE_IPV6_SUBNET_SCOPE

      public static final int USE_IPV6_SUBNET_SCOPE
      Enable IPv6 subnet scope addresses.
      See Also:
    • USE_IPV6_ADMINISTRATIVE_SCOPE

      public static final int USE_IPV6_ADMINISTRATIVE_SCOPE
      Enable IPv6 administrative scope addresses.
      See Also:
    • USE_IPV6_SITE_LOCAL_SCOPE

      public static final int USE_IPV6_SITE_LOCAL_SCOPE
      Enable IPv6 site-local scope addresses.
      See Also:
    • USE_IPV6_GLOBAL_SCOPE

      public static final int USE_IPV6_GLOBAL_SCOPE
      Enable IPv6 global scope addresses.
      See Also:
    • USE_SSDP_SEARCHRESPONSE_MULTIPLE_INTERFACES

      public static final int USE_SSDP_SEARCHRESPONSE_MULTIPLE_INTERFACES
      Enable SSDP search responses on multiple interfaces.
      See Also:
    • USE_ONLY_IPV4_ADDR

      public static final int USE_ONLY_IPV4_ADDR
      Enable IPv4-only addressing mode.
      See Also:
    • xmlParser

      private static Parser xmlParser
      /////////////////////////////////////////////
    • DEFAULT_TTL

      public static final int DEFAULT_TTL
      Default time-to-live value for multicast packets.
      See Also:
    • timeToLive

      private static int timeToLive
      Hops a search message may cross.
  • Constructor Details

    • UPnP

      public UPnP()
      Every constant, version string and protocol singleton below is static, so an instance carries nothing.
  • Method Details

    • getServerName

      public static final String getServerName()
      Generates the server identification string for UPnP operations.
      Returns:
      a server identification string in the format "OS/Version UPnP/1.0 FrameworkName/FrameworkVersion"
    • setEnable

      public static final void setEnable(int value)
      Enables a specific UPnP framework feature or configuration option.
      Parameters:
      value - the feature to enable (one of the USE_* constants)
    • setDisable

      public static final void setDisable(int value)
      Disables a specific UPnP framework feature or configuration option.
      Parameters:
      value - the feature to disable (one of the USE_* constants)
    • isEnabled

      public static final boolean isEnabled(int value)
      Checks if a specific UPnP framework feature or configuration option is enabled.
      Parameters:
      value - the feature to check (one of the USE_* constants)
      Returns:
      true if the feature is enabled, false otherwise
    • toUUID

      private static final String toUUID(int seed)
      Formats a seed as a uuid-like string.
      Parameters:
      seed - the number to format
      Returns:
      the uuid string
    • createUUID

      public static final String createUUID()
      Creates a unique UUID for UPnP device identification.
      Returns:
      a UUID string in the standard UPnP format
    • createBootId

      public static final int createBootId()
      Creates a boot ID for UPnP device identification.
      Returns:
      a boot ID based on the current system time in seconds
    • caluculateConfigId

      public static final int caluculateConfigId(String configXml)
      Calculates a configuration ID from the given XML configuration.
      Parameters:
      configXml - the XML configuration string
      Returns:
      the calculated configuration ID
    • setXMLParser

      public static final void setXMLParser(Parser parser)
      Sets the XML parser to be used by the UPnP framework.
      Parameters:
      parser - the XML parser implementation
    • getXMLParser

      public static final Parser getXMLParser()
      Gets the XML parser used by the UPnP framework.
      Returns:
      the XML parser implementation
      Throws:
      RuntimeException - if no XML parser is available
    • loadDefaultXMLParser

      private static Parser loadDefaultXMLParser()
      This method loads the default XML Parser using the following behavior: - First if present loads the parsers specified by the system property XML_CLASS_PROPERTTY
      - Second by a fall-back technique, it tries to load the XMLParser from one
      of the following classes: JaxpParser, kXML2Parser, XercesParser
      Returns:
      Parser which has been loaded successfully or null otherwise
    • setTimeToLive

      public static final void setTimeToLive(int value)
      Sets the time-to-live value for multicast packets.
      Parameters:
      value - the TTL value to set
    • getTimeToLive

      public static final int getTimeToLive()
      Gets the current time-to-live value for multicast packets.
      Returns:
      the current TTL value
    • initialize

      public static final void initialize()
      Initializes the UPnP framework. This method ensures the static initialization block is executed.