KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)file SnmpPduFactory.java
3  * @(#)author Sun Microsystems, Inc.
4  * @(#)version 4.23
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
12
13 package com.sun.jmx.snmp;
14
15
16
17
18 /**
19  * Defines the interface of the object in charge of encoding and decoding SNMP packets.
20  * <P>
21  * You will not usually need to use this interface, except if you
22  * decide to replace the default implementation <CODE>SnmpPduFactoryBER</CODE>.
23  * <P>
24  * An <CODE>SnmpPduFactory</CODE> object is attached to an
25  * {@link com.sun.jmx.snmp.daemon.SnmpAdaptorServer SNMP protocol adaptor}
26  * or an {@link com.sun.jmx.snmp.SnmpPeer SnmpPeer}.
27  * It is used each time an SNMP packet needs to be encoded or decoded.
28  * <BR>{@link com.sun.jmx.snmp.SnmpPduFactoryBER SnmpPduFactoryBER} is the default
29  * implementation.
30  * It simply applies the standard ASN.1 encoding and decoding
31  * on the bytes of the SNMP packet.
32  * <P>
33  * It's possible to implement your own <CODE>SnmpPduFactory</CODE>
34  * object and to add authentication and/or encryption to the
35  * default encoding/decoding process.
36  *
37  * <p><b>This API is a Sun Microsystems internal API and is subject
38  * to change without notice.</b></p>
39  * @see SnmpPduFactory
40  * @see SnmpPduPacket
41  * @see SnmpMessage
42  *
43  * @version 1.8 08/13/98
44  * @author Sun Microsystems, Inc
45  */

46
47 public interface SnmpPduFactory {
48
49     /**
50      * Decodes the specified <CODE>SnmpMsg</CODE> and returns the
51      * resulting <CODE>SnmpPdu</CODE>. If this method returns
52      * <CODE>null</CODE>, the message will be considered unsafe
53      * and will be dropped.
54      *
55      * @param msg The <CODE>SnmpMsg</CODE> to be decoded.
56      * @return Null or a fully initialized <CODE>SnmpPdu</CODE>.
57      * @exception SnmpStatusException If the encoding is invalid.
58      *
59      * @since 1.5
60      */

61     public SnmpPdu decodeSnmpPdu(SnmpMsg msg) throws SnmpStatusException ;
62
63     /**
64      * Encodes the specified <CODE>SnmpPdu</CODE> and
65      * returns the resulting <CODE>SnmpMsg</CODE>. If this
66      * method returns null, the specified <CODE>SnmpPdu</CODE>
67      * will be dropped and the current SNMP request will be
68      * aborted.
69      *
70      * @param p The <CODE>SnmpPdu</CODE> to be encoded.
71      * @param maxDataLength The size limit of the resulting encoding.
72      * @return Null or a fully encoded <CODE>SnmpMsg</CODE>.
73      * @exception SnmpStatusException If <CODE>pdu</CODE> contains
74      * illegal values and cannot be encoded.
75      * @exception SnmpTooBigException If the resulting encoding does not
76      * fit into <CODE>maxPktSize</CODE> bytes.
77      *
78      * @since 1.5
79      */

80     public SnmpMsg encodeSnmpPdu(SnmpPdu p, int maxDataLength)
81     throws SnmpStatusException, SnmpTooBigException ;
82 }
83
Popular Tags