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

/**
 * Table entry class
 */
public class IfXEntry extends SnmpTableEntry
{
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.1
    protected String _ifName = "";
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.2
    protected SnmpCounter32 _ifInMulticastPkts = new SnmpCounter32();
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.3
    protected SnmpCounter32 _ifInBroadcastPkts = new SnmpCounter32();
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.4
    protected SnmpCounter32 _ifOutMulticastPkts = new SnmpCounter32();
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.5
    protected SnmpCounter32 _ifOutBroadcastPkts = new SnmpCounter32();
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.6
    protected SnmpCounter64 _ifHCInOctets = new SnmpCounter64();
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.7
    protected SnmpCounter64 _ifHCInUcastPkts = new SnmpCounter64();
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.8
    protected SnmpCounter64 _ifHCInMulticastPkts = new SnmpCounter64();
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.9
    protected SnmpCounter64 _ifHCInBroadcastPkts = new SnmpCounter64();
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.10
    protected SnmpCounter64 _ifHCOutOctets = new SnmpCounter64();
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.11
    protected SnmpCounter64 _ifHCOutUcastPkts = new SnmpCounter64();
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.12
    protected SnmpCounter64 _ifHCOutMulticastPkts = new SnmpCounter64();
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.13
    protected SnmpCounter64 _ifHCOutBroadcastPkts = new SnmpCounter64();
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.14
    protected int _ifLinkUpDownTrapEnable = 0;
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.15
    protected SnmpGauge32 _ifHighSpeed = new SnmpGauge32();
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.16
    protected int _ifPromiscuousMode = 0;
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.17
    protected int _ifConnectorPresent = 0;
    // SnmpOID: .1.3.6.1.2.1.31.1.1.1.18
    protected String _ifAlias = "";
    
    /**
     * Constructor
     * @param table the Table which contains this table entry class
     */
    public IfXEntry(SnmpTable table)
    {
        super(table);
    }
    
    //New code
    public IfXEntry( SnmpTable table, String ifName)
    {
        super(table);
        
        this._ifName = ifName;
    }
    
    /**
     * Constructor. Initializes member variables
     * @param table the Table which contains this table entry class
     */
    public IfXEntry( SnmpTable table, String ifName, SnmpCounter32 ifInMulticastPkts, SnmpCounter32 ifInBroadcastPkts, SnmpCounter32 ifOutMulticastPkts, SnmpCounter32 ifOutBroadcastPkts, SnmpCounter64 ifHCInOctets, SnmpCounter64 ifHCInUcastPkts, SnmpCounter64 ifHCInMulticastPkts, SnmpCounter64 ifHCInBroadcastPkts, SnmpCounter64 ifHCOutOctets, SnmpCounter64 ifHCOutUcastPkts, SnmpCounter64 ifHCOutMulticastPkts, SnmpCounter64 ifHCOutBroadcastPkts, int ifLinkUpDownTrapEnable, SnmpGauge32 ifHighSpeed, int ifPromiscuousMode, int ifConnectorPresent, String ifAlias)
    {
        super(table);
        
        this._ifName = ifName;
        this._ifInMulticastPkts = ifInMulticastPkts;
        this._ifInBroadcastPkts = ifInBroadcastPkts;
        this._ifOutMulticastPkts = ifOutMulticastPkts;
        this._ifOutBroadcastPkts = ifOutBroadcastPkts;
        this._ifHCInOctets = ifHCInOctets;
        this._ifHCInUcastPkts = ifHCInUcastPkts;
        this._ifHCInMulticastPkts = ifHCInMulticastPkts;
        this._ifHCInBroadcastPkts = ifHCInBroadcastPkts;
        this._ifHCOutOctets = ifHCOutOctets;
        this._ifHCOutUcastPkts = ifHCOutUcastPkts;
        this._ifHCOutMulticastPkts = ifHCOutMulticastPkts;
        this._ifHCOutBroadcastPkts = ifHCOutBroadcastPkts;
        this._ifLinkUpDownTrapEnable = ifLinkUpDownTrapEnable;
        this._ifHighSpeed = ifHighSpeed;
        this._ifPromiscuousMode = ifPromiscuousMode;
        this._ifConnectorPresent = ifConnectorPresent;
        this._ifAlias = ifAlias;
        
    }
    
    /**
     * This table is a augmenting table. This method returns its base table
     */
    private SnmpTable getBaseTable()
    {
        // Gets the base table reference
        IfTable table = AgentMib.getIfTable();
        return table;
    }
    
    /**
     * Returns the base table's row at specified index
     */
    private SnmpTableEntry getBaseTableEntry(int index)
    {
        SnmpTable table = getBaseTable();
        return table.getRow(index);
    }
    
    /**
     * Returns the index string for this row
     * @return the index string for this row. Return null to indicate that this row will not be added
     */
    public String getIndexSuffix()
    {
        if(_suffix.length() == 0)
        {
            SnmpTable baseTable = getBaseTable();
            int count = baseTable.getRowCount();
            int currentNumOfRows = _table.getRowCount();
            if(currentNumOfRows > count - 1)
            {
                // This table can not have more rows than base table. So this row won't be added
                return null;
            }
            SnmpTableEntry baseEntry = getBaseTableEntry(currentNumOfRows);
            
            // Important: Add this row to the base table's dependents list
            baseEntry.addDependentRow(_table, this);
            _suffix = baseEntry.getIndexSuffix();
        }
        return _suffix;
    }
    
    /**
     * Sets column value at specified index
     * @param index the index of column to be set new value
     * @param value new value of the column
     */
    public void set(int index, SnmpDataType value)
    {
        switch(index)
        {
            case 0 :
            _ifName = value.toString();
            break;
            case 1 :
            _ifInMulticastPkts = (SnmpCounter32) value;
            break;
            case 2 :
            _ifInBroadcastPkts = (SnmpCounter32) value;
            break;
            case 3 :
            _ifOutMulticastPkts = (SnmpCounter32) value;
            break;
            case 4 :
            _ifOutBroadcastPkts = (SnmpCounter32) value;
            break;
            case 5 :
            _ifHCInOctets = (SnmpCounter64) value;
            break;
            case 6 :
            _ifHCInUcastPkts = (SnmpCounter64) value;
            break;
            case 7 :
            _ifHCInMulticastPkts = (SnmpCounter64) value;
            break;
            case 8 :
            _ifHCInBroadcastPkts = (SnmpCounter64) value;
            break;
            case 9 :
            _ifHCOutOctets = (SnmpCounter64) value;
            break;
            case 10 :
            _ifHCOutUcastPkts = (SnmpCounter64) value;
            break;
            case 11 :
            _ifHCOutMulticastPkts = (SnmpCounter64) value;
            break;
            case 12 :
            _ifHCOutBroadcastPkts = (SnmpCounter64) value;
            break;
            case 13 :
            _ifLinkUpDownTrapEnable = ((SnmpInt) value).getValue();
            break;
            case 14 :
            _ifHighSpeed = (SnmpGauge32) value;
            break;
            case 15 :
            _ifPromiscuousMode = ((SnmpInt) value).getValue();
            break;
            case 16 :
            _ifConnectorPresent = ((SnmpInt) value).getValue();
            break;
            case 17 :
            _ifAlias = value.toString();
            break;
        }
    }
    
}