// Home | Go Back //

/*
 * Copyright (c) 2002-2003 iReasoning Inc. All Rights Reserved.
 * 
 * This SOURCE CODE FILE, which has been provided by iReasoning Inc. as part
 * of an iReasoning Software product for use ONLY by licensed users of the product,
 * includes CONFIDENTIAL and PROPRIETARY information of iReasoning Inc.  
 *
 * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS 
 * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
 * THE PRODUCT.
 *
 * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD IREASONING SOFTWARE, ITS
 * RELATED COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY
 * CLAIMS OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR
 * DISTRIBUTION OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES
 * ARISING OUT OF OR RESULTING FROM THE USE, MODIFICATION, OR
 * DISTRIBUTION OF PROGRAMS OR FILES CREATED FROM, BASED ON, AND/OR
 * DERIVED FROM THIS SOURCE CODE FILE.
 */

package agent.subagent;
import java.io.*;
import java.util.*;
import com.ireasoning.util.*;
import com.ireasoning.protocol.snmp.*;
import javax.management.*;

/**
 * Class represents subagentTable MIB object in SubagentModule
 */
public class SubagentTable extends SnmpTable implements SubagentTableMBean
{
    /**
     * Constructor
     * @param root SnmpOID tree root
     * @param oid the SnmpOID of this table. For example, ".1.3.6.1.2.1.2.2" for IfTable in RFC1213  
     * @param args the objects passed from caller for Initialization purpose
     */
    public SubagentTable (OIDTreeNode root, String oid, Object[] args)
    {
        super(root, oid);
        // TODO: Add your implementation

        //public SubagentEntry( SnmpTable table, int subagentIndex, SnmpIpAddress subagentAddress, String subagentDescr, SnmpTimeTicks subagentUpTime, int subagentStatus)
        SubagentEntry entry = new SubagentEntry(this, 1, new SnmpIpAddress("192.168.2.3"), "test subagent descr1", new SnmpTimeTicks(0), 1);
        entry.addRow();
        entry = new SubagentEntry(this, 2, new SnmpIpAddress( "192.168.2.5" ), "test subagent descr2", new SnmpTimeTicks(0), 1);
        entry.addRow();
    }
    
    /**
     * Creates a new instance of table entry object
     */
    public SnmpTableEntry newEntryInstance()
    {
        return new SubagentEntry (this);
    }
    
    /**
     * Gets subagentIndex value
     * @param subagentEntry table entry object
     * @param pdu the received SnmpPdu object
     */
    public int getSubagentIndex(SnmpTableEntry subagentEntry, SnmpPdu pdu)
    {
        // This MIB node is not readable, so SubagentTableMBean does not have this method
        synchronized (subagentEntry)
        {
            SubagentEntry entry = (SubagentEntry) subagentEntry;
            // TODO: Add your implementation
            return entry._subagentIndex;
        }
    }
    
    /**
     * Sets new subagentIndex value
     * @param subagentEntry table entry object
     * @param newValue new value to be set
     * @param pdu the received SnmpPdu object
     */
    public void setSubagentIndexValue(SnmpTableEntry subagentEntry, Object newValue, SnmpPdu pdu)
    {
        // This MIB node is not writeable, so SubagentTableMBean does not have this method
        synchronized (subagentEntry)
        {
            SubagentEntry entry = (SubagentEntry) subagentEntry;
            entry._subagentIndex = ( (Integer) newValue).intValue() ;
            // TODO: Add your implementation
        }
    }
    
    /**
     * Gets subagentAddress value
     * @param subagentEntry table entry object
     * @param pdu the received SnmpPdu object
     */
    public SnmpIpAddress getSubagentAddress(SnmpTableEntry subagentEntry, SnmpPdu pdu)
    {
        synchronized (subagentEntry)
        {
            SubagentEntry entry = (SubagentEntry) subagentEntry;
            // TODO: Add your implementation
            return entry._subagentAddress;
        }
    }
    
    /**
     * Sets new subagentAddress value
     * @param subagentEntry table entry object
     * @param newValue new value to be set
     * @param pdu the received SnmpPdu object
     */
    public void setSubagentAddressValue(SnmpTableEntry subagentEntry, Object newValue, SnmpPdu pdu)
    {
        synchronized (subagentEntry)
        {
            SubagentEntry entry = (SubagentEntry) subagentEntry;
            entry._subagentAddress = (SnmpIpAddress) newValue;
            // TODO: Add your implementation
        }
    }
    
    /**
     * Gets subagentDescr value
     * @param subagentEntry table entry object
     * @param pdu the received SnmpPdu object
     */
    public String getSubagentDescr(SnmpTableEntry subagentEntry, SnmpPdu pdu)
    {
        synchronized (subagentEntry)
        {
            SubagentEntry entry = (SubagentEntry) subagentEntry;
            // TODO: Add your implementation
            return entry._subagentDescr;
        }
    }
    
    /**
     * Sets new subagentDescr value
     * @param subagentEntry table entry object
     * @param newValue new value to be set
     * @param pdu the received SnmpPdu object
     */
    public void setSubagentDescrValue(SnmpTableEntry subagentEntry, Object newValue, SnmpPdu pdu)
    {
        synchronized (subagentEntry)
        {
            SubagentEntry entry = (SubagentEntry) subagentEntry;
            entry._subagentDescr = (String) newValue;
            // TODO: Add your implementation
        }
    }
    
    /**
     * Gets subagentUpTime value
     * @param subagentEntry table entry object
     * @param pdu the received SnmpPdu object
     */
    public SnmpTimeTicks getSubagentUpTime(SnmpTableEntry subagentEntry, SnmpPdu pdu)
    {
        synchronized (subagentEntry)
        {
            SubagentEntry entry = (SubagentEntry) subagentEntry;
            // TODO: Add your implementation
            //return entry._subagentUpTime;
            return new SnmpTimeTicks(SnmpBaseAgent.getSysUpTime());
        }
    }
    
    /**
     * Sets new subagentUpTime value
     * @param subagentEntry table entry object
     * @param newValue new value to be set
     * @param pdu the received SnmpPdu object
     */
    public void setSubagentUpTimeValue(SnmpTableEntry subagentEntry, Object newValue, SnmpPdu pdu)
    {
        // This MIB node is not writeable, so SubagentTableMBean does not have this method
        synchronized (subagentEntry)
        {
            SubagentEntry entry = (SubagentEntry) subagentEntry;
            entry._subagentUpTime = (SnmpTimeTicks) newValue;
            // TODO: Add your implementation
        }
    }
    
    /**
     * Gets subagentStatus value
     * @param subagentEntry table entry object
     * @param pdu the received SnmpPdu object
     */
    public int getSubagentStatus(SnmpTableEntry subagentEntry, SnmpPdu pdu)
    {
        synchronized (subagentEntry)
        {
            SubagentEntry entry = (SubagentEntry) subagentEntry;
            // TODO: Add your implementation
            return entry._subagentStatus;
        }
    }
    
    /**
     * Sets new subagentStatus value
     * @param subagentEntry table entry object
     * @param newValue new value to be set
     * @param pdu the received SnmpPdu object
     */
    public void setSubagentStatusValue(SnmpTableEntry subagentEntry, Object newValue, SnmpPdu pdu)
    {
        synchronized (subagentEntry)
        {
            SubagentEntry entry = (SubagentEntry) subagentEntry;
            entry._subagentStatus = ( (Integer) newValue).intValue() ;
            // TODO: Add your implementation
        }
    }
    
}