Class DiscoveryHelper


  • public class DiscoveryHelper
    extends java.lang.Object
    A helper class for the device discovery Javascript host code. It handles execution of the ping and arp commands and returns device information to the accessor.
    Since:
    Ptolemy II 11.0
    Version:
    $Id$
    Author:
    Elizabeth Latronico, contributor: Christopher Brooks
    Pt.AcceptedRating:
    Red (ltrnc)
    Pt.ProposedRating:
    Red (ltrnc)
    • Constructor Summary

      Constructors 
      Constructor Description
      DiscoveryHelper()
      Construct a new DiscoveryHelper.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String discoverDevices​(java.lang.String IPAddress, java.lang.String discoveryMethod)
      Discover all devices that reply to a ping on the class-C local area network connected to the given IP address A class-C network has a netmask of /24, or 255.255.255.0.
      java.lang.String getHostAddress()
      Return the IP address of the host machine.
      java.lang.String getMacAddress()
      Get the MAC (Media Access Control) address of the first non-loopback, non-multicast address.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DiscoveryHelper

        public DiscoveryHelper()
        Construct a new DiscoveryHelper.
    • Method Detail

      • discoverDevices

        public java.lang.String discoverDevices​(java.lang.String IPAddress,
                                                java.lang.String discoveryMethod)
        Discover all devices that reply to a ping on the class-C local area network connected to the given IP address A class-C network has a netmask of /24, or 255.255.255.0. Returns a string representation of a JSON array of devices. Note that returning the JSONArray directly does not work properly - for some reason, the JSONArray of device objects is not converted into a Javascript array of device objects.
        Parameters:
        IPAddress - The IP address whose subnet should be scanned. E.g., for IP address 192.168.5.7, scan 192.168.5.0 to 192.168.5.255.
        discoveryMethod - The discovery method to be used, e.g. nmap.
        Returns:
        A String containing a JSON representation of devices found.
      • getHostAddress

        public java.lang.String getHostAddress()
        Return the IP address of the host machine.
        Returns:
        The IP address of the host machine.
      • getMacAddress

        public java.lang.String getMacAddress()
                                       throws java.net.SocketException
        Get the MAC (Media Access Control) address of the first non-loopback, non-multicast address.
        Returns:
        the MAC address
        Throws:
        java.net.SocketException - If thrown while finding the address.