2362N/A * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This class is handling an <CODE>SnmpEngineId</CODE> data. It copes with binary as well as <CODE>String</CODE> representation of an engine Id. A string format engine is an hex string starting with 0x. 0N/A * <p><b>This API is a Sun Microsystems internal API and is subject 0N/A * to change without notice.</b></p> 0N/A * New <CODE>SnmpEngineId</CODE> with an hex string value. Can handle engine Id format <host>:<port>. 0N/A * @param hexString Hexa string. 0N/A * New <CODE>SnmpEngineId</CODE> with a binary value. You can use <CODE> SnmpTools </CODE> to convert from hex string to binary format. 0N/A * @param bin Binary value 0N/A * If a string of the format <address>:<port>:<IANA number> has been provided at creation time, this string is returned. 0N/A * @return The Id as a readable string or null if not provided. 0N/A * Returns a string format engine Id. 0N/A * @return String format value. 0N/A * Returns a binary engine Id. 0N/A * @return Binary value. 0N/A * In order to store the string used to create the engineId. 0N/A //octet strings with very first bit = 0 and length != 12 octets 0N/A * Generates an engine Id based on the passed array. 0N/A * @return The created engine Id or null if given arr is null or its length == 0; 0N/A * @exception IllegalArgumentException when: 0N/A * <li>octet string lower than 5 bytes.</li> 0N/A * <li>octet string greater than 32 bytes.</li> 0N/A * <li>octet string = all zeros.</li> 0N/A * <li>octet string = all 'ff'H.</li> 0N/A * <li>octet strings with very first bit = 0 and length != 12 octets</li> 0N/A * Generates an engine Id that is unique to the host the agent is running on. The engine Id unicity is system time based. The creation algorithm uses the SUN Microsystems IANA number (42). 0N/A * @return The generated engine Id. 0N/A * Translates an engine Id in an SnmpOid format. This is useful when dealing with USM MIB indexes. 0N/A * The oid format is : <engine Id length>.<engine Id binary octet1>....<engine Id binary octetn - 1>.<engine Id binary octetn> 0N/A * Eg: "0x8000002a05819dcb6e00001f96" ==> 13.128.0.0.42.5.129.157.203.110.0.0.31.150 0N/A * @return SnmpOid The oid. 0N/A * <P>Generates a unique engine Id. Hexadecimal strings as well as a textual description are supported. The textual format is as follow: 0N/A * <BR> <address>:<port>:<IANA number></P> 0N/A * <P>The allowed formats :</P> 0N/A * <li> <address>:<port>:<IANA number> 0N/A * <BR> All these parameters are used to generate the Id. WARNING, this method is not compliant with IPv6 address format. Use { @link com.sun.jmx.snmp.SnmpEngineId#createEngineId(java.lang.String,java.lang.String) } instead.</li> 0N/A * <li> <address>:<port> 0N/A * <BR> The IANA number will be the SUN Microsystems one (42). </li> 0N/A * <BR> The port 161 will be used to generate the Id. IANA number will be the SUN Microsystems one (42). </li> 0N/A * <BR> The host to use is localhost. IANA number will be the SUN Microsystems one (42). </li> 0N/A * <li> ::<IANA number> 0N/A * <BR> The port 161 and localhost will be used to generate the Id. </li> 0N/A * <li> :<port>:<IANA number> 0N/A * <BR> The host to use is localhost. </li> 0N/A * <li> <address>::<IANA number> 0N/A * <BR> The port 161 will be used to generate the Id. </li> 0N/A * <li> :: 0N/A * <BR> The port 161, localhost and the SUN Microsystems IANA number will be used to generate the Id. </li> 0N/A * @exception UnknownHostException if the host name contained in the textual format is unknown. 0N/A * @exception IllegalArgumentException when : 0N/A * <li>octet string lower than 5 bytes.</li> 0N/A * <li>octet string greater than 32 bytes.</li> 0N/A * <li>octet string = all zeros.</li> 0N/A * <li>octet string = all 'ff'H.</li> 0N/A * <li>octet strings with very first bit = 0 and length != 12 octets</li> 0N/A * <li>An IPv6 address format is used in conjonction with the ":" separator</li> 0N/A * @param str The string to parse. 0N/A * @return The generated engine Id or null if the passed string is null. 0N/A * com.sun.jmx.snmp.SnmpEngineId#createEngineId(java.lang.String) } 0N/A * with the ability to provide your own separator. This allows IPv6 0N/A * address format handling (eg: providing @ as separator). 0N/A * @param str The string to parse. 0N/A * @param separator the separator to use. If null is provided, the default 0N/A * separator ":" is used. 0N/A * @return The generated engine Id or null if the passed string is null. 0N/A * @exception UnknownHostException if the host name contained in the 0N/A * textual format is unknown. 0N/A * @exception IllegalArgumentException when : 0N/A * <li>octet string lower than 5 bytes.</li> 0N/A * <li>octet string greater than 32 bytes.</li> 0N/A * <li>octet string = all zeros.</li> 0N/A * <li>octet string = all 'ff'H.</li> 0N/A * <li>octet strings with very first bit = 0 and length != 12 octets</li> 0N/A * <li>An IPv6 address format is used in conjonction with the ":" 0N/A //No need to go further, no port. 0N/A //No need to go further, no port. 0N/A //No need to go further, no iana. 0N/A //No need to go further, no port. 0N/A * Generates a unique engine Id. The engine Id unicity is based on 0N/A * the host IP address and port. The IP address used is the 0N/A * localhost one. The creation algorithm uses the SUN Microsystems IANA 0N/A * @param port The TCP/IP port the SNMPv3 Adaptor Server is listening to. 0N/A * @return The generated engine Id. 0N/A * @exception UnknownHostException if the local host name 0N/A * used to calculate the id is unknown. 0N/A * Generates a unique engine Id. The engine Id unicity is based on 0N/A * the host IP address and port. The IP address used is the passed 0N/A * one. The creation algorithm uses the SUN Microsystems IANA 0N/A * @param address The IP address the SNMPv3 Adaptor Server is listening to. 0N/A * @param port The TCP/IP port the SNMPv3 Adaptor Server is listening to. 0N/A * @return The generated engine Id. 0N/A * @exception UnknownHostException. if the provided address is null. 0N/A * Generates a unique engine Id. The engine Id unicity is based on 0N/A * the host IP address and port. The IP address is the localhost one. 0N/A * The creation algorithm uses the passed IANA number. 0N/A * @param port The TCP/IP port the SNMPv3 Adaptor Server is listening to. 0N/A * @param iana Your enterprise IANA number. 0N/A * @exception UnknownHostException if the local host name used to calculate the id is unknown. 0N/A * @return The generated engine Id. 0N/A * Generates a unique engine Id. The engine Id unicity is based on the host IP address and port. The IP address is the passed one, it handles IPv4 and IPv6 hosts. The creation algorithm uses the passed IANA number. 0N/A * @param addr The IP address the SNMPv3 Adaptor Server is listening to. 0N/A * @param port The TCP/IP port the SNMPv3 Adaptor Server is listening to. 0N/A * @param iana Your enterprise IANA number. 0N/A * @return The generated engine Id. 0N/A * @exception UnknownHostException if the provided <CODE>InetAddress </CODE> is null. 0N/A * Generates an engine Id based on an InetAddress. Handles IPv4 and IPv6 addresses. The creation algorithm uses the passed IANA number. 0N/A * @param iana Your enterprise IANA number. 0N/A * @param addr The IP address the SNMPv3 Adaptor Server is listening to. 0N/A * @return The generated engine Id. 0N/A * @exception UnknownHostException if the provided <CODE>InetAddress </CODE> is null. 0N/A * Generates an engine Id based on an InetAddress. Handles IPv4 and IPv6 0N/A * addresses. The creation algorithm uses the sun IANA number (42). 0N/A * @param addr The IP address the SNMPv3 Adaptor Server is listening to. 0N/A * @return The generated engine Id. 0N/A * @exception UnknownHostException if the provided 0N/A * <CODE>InetAddress</CODE> is null. 0N/A * Tests <CODE>SnmpEngineId</CODE> instance equality. Two <CODE>SnmpEngineId</CODE> are equal if they have the same value. 0N/A * @return <CODE>true</CODE> if the two <CODE>SnmpEngineId</CODE> are equals, <CODE>false</CODE> otherwise.