Search in sources :

Example 1 with FdbEntry

use of org.netxms.client.topology.FdbEntry in project netxms by netxms.

the class TopologyTest method testSwitchForwardingTable.

public void testSwitchForwardingTable() throws Exception {
    final NXCSession session = connect();
    List<FdbEntry> fdb = session.getSwitchForwardingDatabase(TestConstants.NODE_ID);
    for (FdbEntry e : fdb) System.out.println(e.toString());
    session.disconnect();
}
Also used : FdbEntry(org.netxms.client.topology.FdbEntry)

Example 2 with FdbEntry

use of org.netxms.client.topology.FdbEntry in project netxms by netxms.

the class NXCSession method getSwitchForwardingDatabase.

/**
 * Get switch forwarding database (MAC address table) from node
 *
 * @param nodeId node object ID
 * @return list of switch forwarding database entries
 * @throws IOException  if socket or file I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public List<FdbEntry> getSwitchForwardingDatabase(long nodeId) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_SWITCH_FDB);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_ELEMENTS);
    List<FdbEntry> fdb = new ArrayList<FdbEntry>(count);
    long varId = NXCPCodes.VID_ELEMENT_LIST_BASE;
    for (int i = 0; i < count; i++) {
        fdb.add(new FdbEntry(response, varId));
        varId += 10;
    }
    return fdb;
}
Also used : FdbEntry(org.netxms.client.topology.FdbEntry) NXCPMessage(org.netxms.base.NXCPMessage) ArrayList(java.util.ArrayList) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Example 3 with FdbEntry

use of org.netxms.client.topology.FdbEntry in project netxms by netxms.

the class FDBComparator method compare.

/* (non-Javadoc)
    * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
    */
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
    FdbEntry fdb1 = (FdbEntry) e1;
    FdbEntry fdb2 = (FdbEntry) e2;
    int result;
    switch(// $NON-NLS-1$
    (Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
        case SwitchForwardingDatabaseView.COLUMN_INTERFACE:
            result = fdb1.getInterfaceName().compareToIgnoreCase(fdb2.getInterfaceName());
            break;
        case SwitchForwardingDatabaseView.COLUMN_MAC_ADDRESS:
            result = fdb1.getAddress().compareTo(fdb2.getAddress());
            break;
        case SwitchForwardingDatabaseView.COLUMN_NODE:
            // $NON-NLS-1$
            String n1 = (fdb1.getNodeId() != 0) ? session.getObjectName(fdb1.getNodeId()) : "";
            // $NON-NLS-1$
            String n2 = (fdb2.getNodeId() != 0) ? session.getObjectName(fdb2.getNodeId()) : "";
            result = n1.compareToIgnoreCase(n2);
            break;
        case SwitchForwardingDatabaseView.COLUMN_PORT:
            result = fdb1.getPort() - fdb2.getPort();
            break;
        case SwitchForwardingDatabaseView.COLUMN_VLAN:
            result = fdb1.getVlanId() - fdb2.getVlanId();
            break;
        case SwitchForwardingDatabaseView.COLUMN_TYPE:
            result = fdb1.getType() - fdb2.getType();
            break;
        default:
            result = 0;
            break;
    }
    return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
Also used : FdbEntry(org.netxms.client.topology.FdbEntry) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer)

Aggregations

FdbEntry (org.netxms.client.topology.FdbEntry)3 ArrayList (java.util.ArrayList)1 NXCPMessage (org.netxms.base.NXCPMessage)1 AccessPoint (org.netxms.client.objects.AccessPoint)1 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)1 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)1