2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
5506
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
package com.sun.jmx.snmp;
|
|
26 |
|
|
27 |
|
|
28 |
import java.io.Serializable;
|
|
29 |
import java.net.InetAddress;
|
|
30 |
/**
|
|
31 |
* Is the fully decoded representation of an SNMP packet.
|
|
32 |
* <P>
|
|
33 |
* Classes are derived from <CODE>SnmpPdu</CODE> to
|
|
34 |
* represent the different forms of SNMP packets
|
|
35 |
* ({@link com.sun.jmx.snmp.SnmpPduPacket SnmpPduPacket},
|
|
36 |
* {@link com.sun.jmx.snmp.SnmpScopedPduPacket SnmpScopedPduPacket})
|
|
37 |
* <BR>The <CODE>SnmpPdu</CODE> class defines the attributes
|
|
38 |
* common to every form of SNMP packets.
|
|
39 |
*
|
|
40 |
*
|
|
41 |
* <p><b>This API is a Sun Microsystems internal API and is subject
|
|
42 |
* to change without notice.</b></p>
|
|
43 |
* @see SnmpMessage
|
|
44 |
* @see SnmpPduFactory
|
|
45 |
*
|
|
46 |
* @since 1.5
|
|
47 |
*/
|
|
48 |
public abstract class SnmpPdu implements SnmpDefinitions, Serializable {
|
|
49 |
|
|
50 |
/**
|
|
51 |
* PDU type. Types are defined in
|
|
52 |
* {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
|
|
53 |
* @serial
|
|
54 |
*/
|
|
55 |
public int type=0 ;
|
|
56 |
|
|
57 |
/**
|
|
58 |
* Protocol version. Versions are defined in
|
|
59 |
* {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
|
|
60 |
* @serial
|
|
61 |
*/
|
|
62 |
public int version=0 ;
|
|
63 |
|
|
64 |
/**
|
|
65 |
* List of variables.
|
|
66 |
* @serial
|
|
67 |
*/
|
|
68 |
public SnmpVarBind[] varBindList ;
|
|
69 |
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Request identifier.
|
|
73 |
* Note that this field is not used by <CODE>SnmpPduTrap</CODE>.
|
|
74 |
* @serial
|
|
75 |
*/
|
|
76 |
public int requestId=0 ;
|
|
77 |
|
|
78 |
/**
|
|
79 |
* Source or destination address.
|
|
80 |
* <P>For an incoming PDU it's the source.
|
|
81 |
* <BR>For an outgoing PDU it's the destination.
|
|
82 |
* @serial
|
|
83 |
*/
|
|
84 |
public InetAddress address ;
|
|
85 |
|
|
86 |
/**
|
|
87 |
* Source or destination port.
|
|
88 |
* <P>For an incoming PDU it's the source.
|
|
89 |
* <BR>For an outgoing PDU it's the destination.
|
|
90 |
* @serial
|
|
91 |
*/
|
|
92 |
public int port=0 ;
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Returns the <CODE>String</CODE> representation of a PDU type.
|
|
96 |
* For instance, if the PDU type is <CODE>SnmpDefinitions.pduGetRequestPdu</CODE>,
|
|
97 |
* the method will return "SnmpGet".
|
|
98 |
* @param cmd The integer representation of the PDU type.
|
|
99 |
* @return The <CODE>String</CODE> representation of the PDU type.
|
|
100 |
*/
|
|
101 |
public static String pduTypeToString(int cmd) {
|
|
102 |
switch (cmd) {
|
|
103 |
case pduGetRequestPdu :
|
|
104 |
return "SnmpGet" ;
|
|
105 |
case pduGetNextRequestPdu :
|
|
106 |
return "SnmpGetNext" ;
|
|
107 |
case pduWalkRequest :
|
|
108 |
return "SnmpWalk(*)" ;
|
|
109 |
case pduSetRequestPdu :
|
|
110 |
return "SnmpSet" ;
|
|
111 |
case pduGetResponsePdu :
|
|
112 |
return "SnmpResponse" ;
|
|
113 |
case pduV1TrapPdu :
|
|
114 |
return "SnmpV1Trap" ;
|
|
115 |
case pduV2TrapPdu :
|
|
116 |
return "SnmpV2Trap" ;
|
|
117 |
case pduGetBulkRequestPdu :
|
|
118 |
return "SnmpGetBulk" ;
|
|
119 |
case pduInformRequestPdu :
|
|
120 |
return "SnmpInform" ;
|
|
121 |
}
|
|
122 |
return "Unknown Command = " + cmd ;
|
|
123 |
}
|
|
124 |
}
|