KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jmx > snmp > SnmpPdu


1 /*
2  * @(#)file SnmpPdu.java
3  * @(#)author Sun Microsystems, Inc.
4  * @(#)version 1.10
5  * @(#)date 08/02/09
6  *
7  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
8  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
9  *
10  */

11 package com.sun.jmx.snmp;
12
13
14 import java.io.Serializable JavaDoc;
15 import java.net.InetAddress JavaDoc;
16 /**
17  * Is the fully decoded representation of an SNMP packet.
18  * <P>
19  * Classes are derived from <CODE>SnmpPdu</CODE> to
20  * represent the different forms of SNMP packets
21  * ({@link com.sun.jmx.snmp.SnmpPduPacket SnmpPduPacket},
22  * {@link com.sun.jmx.snmp.SnmpScopedPduPacket SnmpScopedPduPacket})
23  * <BR>The <CODE>SnmpPdu</CODE> class defines the attributes
24  * common to every form of SNMP packets.
25  *
26  *
27  * <p><b>This API is a Sun Microsystems internal API and is subject
28  * to change without notice.</b></p>
29  * @see SnmpMessage
30  * @see SnmpPduFactory
31  *
32  * @since 1.5
33  */

34 public abstract class SnmpPdu implements SnmpDefinitions, Serializable JavaDoc {
35  
36     /**
37      * PDU type. Types are defined in
38      * {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
39      * @serial
40      */

41     public int type=0 ;
42   
43     /**
44      * Protocol version. Versions are defined in
45      * {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
46      * @serial
47      */

48     public int version=0 ;
49   
50     /**
51      * List of variables.
52      * @serial
53      */

54     public SnmpVarBind[] varBindList ;
55
56
57     /**
58      * Request identifier.
59      * Note that this field is not used by <CODE>SnmpPduTrap</CODE>.
60      * @serial
61      */

62     public int requestId=0 ;
63
64     /**
65      * Source or destination address.
66      * <P>For an incoming PDU it's the source.
67      * <BR>For an outgoing PDU it's the destination.
68      * @serial
69      */

70     public InetAddress JavaDoc address ;
71   
72     /**
73      * Source or destination port.
74      * <P>For an incoming PDU it's the source.
75      * <BR>For an outgoing PDU it's the destination.
76      * @serial
77      */

78     public int port=0 ;
79     
80     /**
81      * Returns the <CODE>String</CODE> representation of a PDU type.
82      * For instance, if the PDU type is <CODE>SnmpDefinitions.pduGetRequestPdu</CODE>,
83      * the method will return "SnmpGet".
84      * @param cmd The integer representation of the PDU type.
85      * @return The <CODE>String</CODE> representation of the PDU type.
86      */

87     public static String JavaDoc pduTypeToString(int cmd) {
88     switch (cmd) {
89     case pduGetRequestPdu :
90         return "SnmpGet" ;
91     case pduGetNextRequestPdu :
92         return "SnmpGetNext" ;
93     case pduWalkRequest :
94         return "SnmpWalk(*)" ;
95     case pduSetRequestPdu :
96         return "SnmpSet" ;
97     case pduGetResponsePdu :
98         return "SnmpResponse" ;
99     case pduV1TrapPdu :
100         return "SnmpV1Trap" ;
101     case pduV2TrapPdu :
102         return "SnmpV2Trap" ;
103     case pduGetBulkRequestPdu :
104         return "SnmpGetBulk" ;
105     case pduInformRequestPdu :
106         return "SnmpInform" ;
107     }
108     return "Unknown Command = " + cmd ;
109     }
110 }
111
Popular Tags