1 /* 2 * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved. 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 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 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 * 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. 24 */ 25 package com.sun.jmx.snmp.internal; 26 27 import java.net.InetAddress; 28 import com.sun.jmx.snmp.SnmpPduFactory; 29 import com.sun.jmx.snmp.SnmpSecurityParameters; 30 import com.sun.jmx.snmp.SnmpSecurityException; 31 import com.sun.jmx.snmp.SnmpTooBigException; 32 import com.sun.jmx.snmp.SnmpStatusException; 33 import com.sun.jmx.snmp.SnmpPdu; 34 import com.sun.jmx.snmp.SnmpMsg; 35 36 import com.sun.jmx.snmp.internal.SnmpSecurityCache; 37 import com.sun.jmx.snmp.SnmpBadSecurityLevelException; 38 /** 39 * <P> An <CODE>SnmpIncomingResponse</CODE> handles the unmarshalling of the received response.</P> 40 * <p><b>This API is a Sun Microsystems internal API and is subject 41 * to change without notice.</b></p> 42 * @since 1.5 43 */ 44 45 public interface SnmpIncomingResponse { 46 /** 47 * Returns the source address. 48 * @return The source address. 49 */ 50 public InetAddress getAddress(); 51 52 /** 53 * Returns the source port. 54 * @return The source port. 55 */ 56 public int getPort(); 57 58 /** 59 * Gets the incoming response security parameters. 60 * @return The security parameters. 61 **/ 62 public SnmpSecurityParameters getSecurityParameters(); 63 /** 64 * Call this method in order to reuse <CODE>SnmpOutgoingRequest</CODE> cache. 65 * @param cache The security cache. 66 */ 67 public void setSecurityCache(SnmpSecurityCache cache); 68 /** 69 * Gets the incoming response security level. This level is defined in 70 * {@link com.sun.jmx.snmp.SnmpEngine SnmpEngine}. 71 * @return The security level. 72 */ 73 public int getSecurityLevel(); 74 /** 75 * Gets the incoming response security model. 76 * @return The security model. 77 */ 78 public int getSecurityModel(); 79 /** 80 * Gets the incoming response context name. 81 * @return The context name. 82 */ 83 public byte[] getContextName(); 84 85 /** 86 * Decodes the specified bytes and initializes itself with the received 87 * response. 88 * 89 * @param inputBytes The bytes to be decoded. 90 * 91 * @exception SnmpStatusException If the specified bytes are not a valid encoding. 92 */ 93 public SnmpMsg decodeMessage(byte[] inputBytes, 94 int byteCount, 95 InetAddress address, 96 int port) 97 throws SnmpStatusException, SnmpSecurityException; 98 99 /** 100 * Gets the request PDU encoded in the received response. 101 * <P> 102 * This method decodes the data field and returns the resulting PDU. 103 * 104 * @return The resulting PDU. 105 * @exception SnmpStatusException If the encoding is not valid. 106 */ 107 public SnmpPdu decodeSnmpPdu() 108 throws SnmpStatusException; 109 110 /** 111 * Returns the response request Id. 112 * @param data The flat message. 113 * @return The request Id. 114 */ 115 public int getRequestId(byte[] data) throws SnmpStatusException; 116 117 /** 118 * Returns a stringified form of the message to send. 119 * @return The message state string. 120 */ 121 public String printMessage(); 122 }