1 /*
   2  * Copyright (c) 2001, 2006, 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 
  26 package com.sun.jmx.snmp.internal;
  27 
  28 import java.net.InetAddress;
  29 
  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.SnmpUnknownSecModelException;
  38 import com.sun.jmx.snmp.SnmpBadSecurityLevelException;
  39 /**
  40  * <P> An <CODE>SnmpOutgoingRequest</CODE> handles the marshalling of the message to send.</P>
  41  * <p><b>This API is a Sun Microsystems internal API  and is subject
  42  * to change without notice.</b></p>
  43  * @since 1.5
  44  */
  45 
  46 public interface SnmpOutgoingRequest {
  47     /**
  48      * Returns the cached security data used when marshalling the call as a secure one.
  49      * @return The cached data.
  50      */
  51     public SnmpSecurityCache getSecurityCache();
  52     /**
  53      * Encodes the message to send and puts the result in the specified byte array.
  54      *
  55      * @param outputBytes An array to receive the resulting encoding.
  56      *
  57      * @exception ArrayIndexOutOfBoundsException If the result does not fit
  58      *                                           into the specified array.
  59      */
  60     public int encodeMessage(byte[] outputBytes)
  61         throws SnmpStatusException,
  62                SnmpTooBigException, SnmpSecurityException,
  63                SnmpUnknownSecModelException, SnmpBadSecurityLevelException;
  64   /**
  65      * Initializes the message to send with the passed Pdu.
  66      * <P>
  67      * If the encoding length exceeds <CODE>maxDataLength</CODE>,
  68      * the method throws an exception.</P>
  69      *
  70      * @param p The PDU to be encoded.
  71      * @param maxDataLength The maximum length permitted for the data field.
  72      *
  73      * @exception SnmpStatusException If the specified PDU <CODE>p</CODE> is
  74      *    not valid.
  75      * @exception SnmpTooBigException If the resulting encoding does not fit
  76      *    into <CODE>maxDataLength</CODE> bytes.
  77      * @exception ArrayIndexOutOfBoundsException If the encoding exceeds
  78      *    <CODE>maxDataLength</CODE>.
  79      */
  80     public SnmpMsg encodeSnmpPdu(SnmpPdu p,
  81                                  int maxDataLength)
  82         throws SnmpStatusException, SnmpTooBigException;
  83     /**
  84      * Returns a stringified form of the message to send.
  85      * @return The message state string.
  86      */
  87     public String printMessage();
  88 }