Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/jmx/snmp/SnmpPdu.java
38924 views
/*1* Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package com.sun.jmx.snmp;252627import java.io.Serializable;28import java.net.InetAddress;29/**30* Is the fully decoded representation of an SNMP packet.31* <P>32* Classes are derived from <CODE>SnmpPdu</CODE> to33* represent the different forms of SNMP packets34* ({@link com.sun.jmx.snmp.SnmpPduPacket SnmpPduPacket},35* {@link com.sun.jmx.snmp.SnmpScopedPduPacket SnmpScopedPduPacket})36* <BR>The <CODE>SnmpPdu</CODE> class defines the attributes37* common to every form of SNMP packets.38*39*40* <p><b>This API is a Sun Microsystems internal API and is subject41* to change without notice.</b></p>42* @see SnmpMessage43* @see SnmpPduFactory44*45* @since 1.546*/47public abstract class SnmpPdu implements SnmpDefinitions, Serializable {4849/**50* PDU type. Types are defined in51* {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.52* @serial53*/54public int type=0 ;5556/**57* Protocol version. Versions are defined in58* {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.59* @serial60*/61public int version=0 ;6263/**64* List of variables.65* @serial66*/67public SnmpVarBind[] varBindList ;686970/**71* Request identifier.72* Note that this field is not used by <CODE>SnmpPduTrap</CODE>.73* @serial74*/75public int requestId=0 ;7677/**78* Source or destination address.79* <P>For an incoming PDU it's the source.80* <BR>For an outgoing PDU it's the destination.81* @serial82*/83public InetAddress address ;8485/**86* Source or destination port.87* <P>For an incoming PDU it's the source.88* <BR>For an outgoing PDU it's the destination.89* @serial90*/91public int port=0 ;9293/**94* Returns the <CODE>String</CODE> representation of a PDU type.95* For instance, if the PDU type is <CODE>SnmpDefinitions.pduGetRequestPdu</CODE>,96* the method will return "SnmpGet".97* @param cmd The integer representation of the PDU type.98* @return The <CODE>String</CODE> representation of the PDU type.99*/100public static String pduTypeToString(int cmd) {101switch (cmd) {102case pduGetRequestPdu :103return "SnmpGet" ;104case pduGetNextRequestPdu :105return "SnmpGetNext" ;106case pduWalkRequest :107return "SnmpWalk(*)" ;108case pduSetRequestPdu :109return "SnmpSet" ;110case pduGetResponsePdu :111return "SnmpResponse" ;112case pduV1TrapPdu :113return "SnmpV1Trap" ;114case pduV2TrapPdu :115return "SnmpV2Trap" ;116case pduGetBulkRequestPdu :117return "SnmpGetBulk" ;118case pduInformRequestPdu :119return "SnmpInform" ;120}121return "Unknown Command = " + cmd ;122}123}124125126