/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* 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.
* <p><b>This API is a Sun Microsystems internal API and is subject
* to change without notice.</b></p>
* @since 1.5
*/
/**
* New <CODE>SnmpEngineId</CODE> with an hex string value. Can handle engine Id format <host>:<port>.
* @param hexString Hexa string.
*/
}
/**
* New <CODE>SnmpEngineId</CODE> with a binary value. You can use <CODE> SnmpTools </CODE> to convert from hex string to binary format.
* @param bin Binary value
*/
}
/**
* If a string of the format <address>:<port>:<IANA number> has been provided at creation time, this string is returned.
* @return The Id as a readable string or null if not provided.
*/
return humanString;
}
/**
* Returns a string format engine Id.
* @return String format value.
*/
return hexString;
}
/**
* Returns a binary engine Id.
* @return Binary value.
*/
public byte[] getBytes() {
return engineId;
}
/**
* In order to store the string used to create the engineId.
*/
humanString = val;
}
}
//octet strings with very first bit = 0 and length != 12 octets
throw new IllegalArgumentException("Very first bit = 0 and length != 12 octets");
}
/**
* Generates an engine Id based on the passed array.
* @return The created engine Id or null if given arr is null or its length == 0;
* @exception IllegalArgumentException when:
* <ul>
* <li>octet string lower than 5 bytes.</li>
* <li>octet string greater than 32 bytes.</li>
* <li>octet string = all zeros.</li>
* <li>octet string = all 'ff'H.</li>
* <li>octet strings with very first bit = 0 and length != 12 octets</li>
* </ul>
*/
return new SnmpEngineId(arr);
}
/**
* 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).
* @return The generated engine Id.
*/
byte[] engineid = new byte[13];
int iana = 42;
long mask = 0xFF;
return new SnmpEngineId(engineid);
}
/**
* Translates an engine Id in an SnmpOid format. This is useful when dealing with USM MIB indexes.
* The oid format is : <engine Id length>.<engine Id binary octet1>....<engine Id binary octetn - 1>.<engine Id binary octetn>
* Eg: "0x8000002a05819dcb6e00001f96" ==> 13.128.0.0.42.5.129.157.203.110.0.0.31.150
*
* @return SnmpOid The oid.
*/
}
/**
* <P>Generates a unique engine Id. Hexadecimal strings as well as a textual description are supported. The textual format is as follow:
* <BR> <address>:<port>:<IANA number></P>
* <P>The allowed formats :</P>
* <ul>
* <li> <address>:<port>:<IANA number>
* <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>
* <li> <address>:<port>
* <BR> The IANA number will be the SUN Microsystems one (42). </li>
* <li> address
* <BR> The port 161 will be used to generate the Id. IANA number will be the SUN Microsystems one (42). </li>
* <li> :port
* <BR> The host to use is localhost. IANA number will be the SUN Microsystems one (42). </li>
* <li> ::<IANA number>
* <BR> The port 161 and localhost will be used to generate the Id. </li>
* <li> :<port>:<IANA number>
* <BR> The host to use is localhost. </li>
* <li> <address>::<IANA number>
* <BR> The port 161 will be used to generate the Id. </li>
* <li> ::
* <BR> The port 161, localhost and the SUN Microsystems IANA number will be used to generate the Id. </li>
* </ul>
* @exception UnknownHostException if the host name contained in the textual format is unknown.
* @exception IllegalArgumentException when :
* <ul>
* <li>octet string lower than 5 bytes.</li>
* <li>octet string greater than 32 bytes.</li>
* <li>octet string = all zeros.</li>
* <li>octet string = all 'ff'H.</li>
* <li>octet strings with very first bit = 0 and length != 12 octets</li>
* <li>An IPv6 address format is used in conjonction with the ":" separator</li>
* </ul>
* @param str The string to parse.
* @return The generated engine Id or null if the passed string is null.
*
*/
throws IllegalArgumentException, UnknownHostException {
}
/**
* Idem { @link
* com.sun.jmx.snmp.SnmpEngineId#createEngineId(java.lang.String) }
* with the ability to provide your own separator. This allows IPv6
* address format handling (eg: providing @ as separator).
* @param str The string to parse.
* @param separator the separator to use. If null is provided, the default
* separator ":" is used.
* @return The generated engine Id or null if the passed string is null.
* @exception UnknownHostException if the host name contained in the
* textual format is unknown.
* @exception IllegalArgumentException when :
* <ul>
* <li>octet string lower than 5 bytes.</li>
* <li>octet string greater than 32 bytes.</li>
* <li>octet string = all zeros.</li>
* <li>octet string = all 'ff'H.</li>
* <li>octet strings with very first bit = 0 and length != 12 octets</li>
* <li>An IPv6 address format is used in conjonction with the ":"
* separator</li>
* </ul>
* @since 1.5
*/
throws IllegalArgumentException, UnknownHostException {
return new SnmpEngineId(str);
}
true);
int objPort = 161;
int objIana = 42;
try {
//Deal with address
try {
}catch(NoSuchElementException e) {
}
try {
}catch(NoSuchElementException e) {
//No need to go further, no port.
objIana);
return eng;
}
}
else
//Deal with port
try {
}catch(NoSuchElementException e) {
//No need to go further, no port.
objIana);
return eng;
}
try {
}catch(NoSuchElementException e) {
//No need to go further, no iana.
objIana);
return eng;
}
}
//Deal with iana
try {
}catch(NoSuchElementException e) {
//No need to go further, no port.
objIana);
return eng;
}
objIana);
return eng;
} catch(Exception e) {
throw new IllegalArgumentException("Passed string is invalid : ["+str+"]. Check that the used separator ["+ separator + "] is compatible with IPv6 address format.");
}
}
/**
* Generates a unique engine Id. The engine Id unicity is based on
* the host IP address and port. The IP address used is the
* localhost one. The creation algorithm uses the SUN Microsystems IANA
* number (42).
* @return The generated engine Id.
* @exception UnknownHostException if the local host name
* used to calculate the id is unknown.
*/
throws UnknownHostException {
int suniana = 42;
}
/**
* Generates a unique engine Id. The engine Id unicity is based on
* the host IP address and port. The IP address used is the passed
* one. The creation algorithm uses the SUN Microsystems IANA
* number (42).
* @param address The IP address the SNMPv3 Adaptor Server is listening to.
* @return The generated engine Id.
* @exception UnknownHostException. if the provided address is null.
*/
throws IllegalArgumentException {
int suniana = 42;
throw new IllegalArgumentException("InetAddress is null.");
}
/**
* Generates a unique engine Id. The engine Id unicity is based on
* the host IP address and port. The IP address is the localhost one.
* The creation algorithm uses the passed IANA number.
* @param iana Your enterprise IANA number.
* @exception UnknownHostException if the local host name used to calculate the id is unknown.
* @return The generated engine Id.
*/
}
/**
* 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.
* @param addr The IP address the SNMPv3 Adaptor Server is listening to.
* @param iana Your enterprise IANA number.
* @return The generated engine Id.
* @exception UnknownHostException if the provided <CODE>InetAddress </CODE> is null.
*/
int port,
int iana) {
}
return new SnmpEngineId(engineid);
}
/**
* Generates an engine Id based on an InetAddress. Handles IPv4 and IPv6 addresses. The creation algorithm uses the passed IANA number.
* @param iana Your enterprise IANA number.
* @param addr The IP address the SNMPv3 Adaptor Server is listening to.
* @return The generated engine Id.
* @since 1.5
* @exception UnknownHostException if the provided <CODE>InetAddress </CODE> is null.
*/
{
}
return new SnmpEngineId(engineid);
}
/**
* Generates an engine Id based on an InetAddress. Handles IPv4 and IPv6
* addresses. The creation algorithm uses the sun IANA number (42).
* @param addr The IP address the SNMPv3 Adaptor Server is listening to.
* @return The generated engine Id.
* @since 1.5
* @exception UnknownHostException if the provided
* <CODE>InetAddress</CODE> is null.
*/
}
/**
* Tests <CODE>SnmpEngineId</CODE> instance equality. Two <CODE>SnmpEngineId</CODE> are equal if they have the same value.
* @return <CODE>true</CODE> if the two <CODE>SnmpEngineId</CODE> are equals, <CODE>false</CODE> otherwise.
*/
if(!(a instanceof SnmpEngineId) ) return false;
}
public int hashCode() {
}
}