use of org.netxms.client.topology.Route in project netxms by netxms.
the class TopologyTest method testRoutingTable.
public void testRoutingTable() throws Exception {
final NXCSession session = connect();
List<Route> rt = session.getRoutingTable(TestConstants.NODE_ID);
for (Route r : rt) System.out.println(r.toString());
session.disconnect();
}
use of org.netxms.client.topology.Route in project netxms by netxms.
the class NXCSession method getRoutingTable.
/**
* Get routing table from node
*
* @param nodeId node object ID
* @return list of routing table 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<Route> getRoutingTable(long nodeId) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_ROUTING_TABLE);
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<Route> rt = new ArrayList<Route>(count);
long varId = NXCPCodes.VID_ELEMENT_LIST_BASE;
for (int i = 0; i < count; i++) {
rt.add(new Route(response, varId));
varId += 10;
}
return rt;
}
use of org.netxms.client.topology.Route in project netxms by netxms.
the class RoutingTableComparator 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) {
Route r1 = (Route) e1;
Route r2 = (Route) e2;
int result;
switch(// $NON-NLS-1$
(Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
case RoutingTableView.COLUMN_DESTINATION:
result = ComparatorHelper.compareInetAddresses(r1.getDestination(), r2.getDestination());
if (result == 0) {
result = r1.getPrefixLength() - r2.getPrefixLength();
}
break;
case RoutingTableView.COLUMN_NEXT_HOP:
result = ComparatorHelper.compareInetAddresses(r1.getNextHop(), r2.getNextHop());
break;
case RoutingTableView.COLUMN_INTERFACE:
result = r1.getIfName().compareToIgnoreCase(r2.getIfName());
break;
case RoutingTableView.COLUMN_TYPE:
result = r1.getType() - r2.getType();
break;
default:
result = 0;
break;
}
return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
Aggregations