// 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.ifmib;
import java.io.*;
import java.util.*;
import com.ireasoning.util.*;
import com.ireasoning.protocol.snmp.*;
import javax.management.*;

/**
 * Class represents ifRcvAddressTable MIB object in IF_MIB
 */
public class IfRcvAddressTable extends SnmpTable implements IfRcvAddressTableMBean
{
    /**
     * 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 IfRcvAddressTable (OIDTreeNode root, String oid, Object[] args)
    {
        super(root, oid);
        // TODO: Add your implementation

        //New code
        addEntries();
    }
    
    private void addEntries()
    {
        ArrayList netifs = Util.ipconfig();
        int size = netifs.size();
        for (int i = 0; i < size ; i++) 
        {
            NetInterface netif = (NetInterface) netifs.get(i);
            if(netif.physAddress == null || netif.physAddress.length() == 0) continue;
            //public IfRcvAddressEntry( SnmpTable table, String ifRcvAddressAddress, int ifRcvAddressStatus, int ifRcvAddressType)
            IfRcvAddressEntry entry = new IfRcvAddressEntry(this, netif.physAddress, SnmpRowStatus.ACTIVE, 3);
            entry.addRow();
        }
    }
    
    /**
     * Creates a new instance of table entry object
     */
    public SnmpTableEntry newEntryInstance()
    {
        return new IfRcvAddressEntry (this);
    }
    
    /**
     * Gets ifRcvAddressAddress value
     * @param ifRcvAddressEntry table entry object
     * @param pdu the received SnmpPdu object
     */
    public String getIfRcvAddressAddress(SnmpTableEntry ifRcvAddressEntry, SnmpPdu pdu)
    {
        // This MIB node is not readable, so IfRcvAddressTableMBean does not have this method
        synchronized (ifRcvAddressEntry)
        {
            IfRcvAddressEntry entry = (IfRcvAddressEntry) ifRcvAddressEntry;
            // TODO: Add your implementation
            return entry._ifRcvAddressAddress;
        }
    }
    
    /**
     * Sets new ifRcvAddressAddress value
     * @param ifRcvAddressEntry table entry object
     * @param newValue new value to be set
     * @param pdu the received SnmpPdu object
     */
    public void setIfRcvAddressAddressValue(SnmpTableEntry ifRcvAddressEntry, Object newValue, SnmpPdu pdu)
    {
        // This MIB node is not writeable, so IfRcvAddressTableMBean does not have this method
        synchronized (ifRcvAddressEntry)
        {
            IfRcvAddressEntry entry = (IfRcvAddressEntry) ifRcvAddressEntry;
            entry._ifRcvAddressAddress = (String) newValue;
            // TODO: Add your implementation
        }
    }
    
    /**
     * Gets ifRcvAddressStatus value
     * @param ifRcvAddressEntry table entry object
     * @param pdu the received SnmpPdu object
     */
    public int getIfRcvAddressStatus(SnmpTableEntry ifRcvAddressEntry, SnmpPdu pdu)
    {
        synchronized (ifRcvAddressEntry)
        {
            IfRcvAddressEntry entry = (IfRcvAddressEntry) ifRcvAddressEntry;
            // TODO: Add your implementation
            return entry._ifRcvAddressStatus;
        }
    }
    
    /**
     * Sets new ifRcvAddressStatus value
     * @param ifRcvAddressEntry table entry object
     * @param newValue new value to be set
     * @param pdu the received SnmpPdu object
     */
    public void setIfRcvAddressStatusValue(SnmpTableEntry ifRcvAddressEntry, Object newValue, SnmpPdu pdu)
    {
        synchronized (ifRcvAddressEntry)
        {
            IfRcvAddressEntry entry = (IfRcvAddressEntry) ifRcvAddressEntry;
            entry._ifRcvAddressStatus = ( (Integer) newValue).intValue() ;
            // TODO: Add your implementation
        }
    }
    
    /**
     * Gets ifRcvAddressType value
     * @param ifRcvAddressEntry table entry object
     * @param pdu the received SnmpPdu object
     */
    public int getIfRcvAddressType(SnmpTableEntry ifRcvAddressEntry, SnmpPdu pdu)
    {
        synchronized (ifRcvAddressEntry)
        {
            IfRcvAddressEntry entry = (IfRcvAddressEntry) ifRcvAddressEntry;
            // TODO: Add your implementation
            return entry._ifRcvAddressType;
        }
    }
    
    /**
     * Sets new ifRcvAddressType value
     * @param ifRcvAddressEntry table entry object
     * @param newValue new value to be set
     * @param pdu the received SnmpPdu object
     */
    public void setIfRcvAddressTypeValue(SnmpTableEntry ifRcvAddressEntry, Object newValue, SnmpPdu pdu)
    {
        synchronized (ifRcvAddressEntry)
        {
            IfRcvAddressEntry entry = (IfRcvAddressEntry) ifRcvAddressEntry;
            entry._ifRcvAddressType = ( (Integer) newValue).intValue() ;
            // TODO: Add your implementation
        }
    }
    
}