Package ch.rakudave.jnetmap.model.IF

Examples of ch.rakudave.jnetmap.model.IF.PhysicalIF


  @Override
  public void execute(Device d) {
    String ip = SwingHelper.interfaceSelector(d);
    if (ip == null) return;
    try {
      PhysicalIF nif = null;
      for (NetworkIF n : d.getInterfaces()) {
        if (ip.equals(n.getAddress().getHostAddress()))
          nif = (PhysicalIF) n;
      }
      if (nif == null) return;
      wake(InetAddress.getByName(nif.getSubnet().getInfo().getBroadcastAddress()), nif.getMacAddress());
    } catch (Exception e) {
      Logger.error("Unable to WakeOnLAN "+ip, e);
    }
  }
View Full Code Here


    } catch (UnknownHostException ex) {
      Logger.debug("Unable to find gateway-interface", ex);
    }
    if (gatewayIF == null) { // create a gateway if none was found
      gateway = new Host(Type.Router);
      gatewayIF = new PhysicalIF(gateway, gToS, subnet.getInfo().getLowAddress());
      map.addVertex(gateway);
      gateway.addInterface(gatewayIF);
    } else {
      gateway = gatewayIF.getDevice();
    }
    try { // try to find the switch attached to the gateway
      aSwitch = map.getOpposite(gateway, gatewayIF.getConnection());
      // if the opposite is not a switch, reset
      if (aSwitch != null && !aSwitch.getType().toString().toLowerCase().contains("switch")) aSwitch = null;
    } catch (Exception e) {
      Logger.debug("Unable to find opposite", e);
    }
    if (aSwitch == null) { // create a switch if necessary
      aSwitch = new Host(Type.Switch);
      map.addVertex(aSwitch);
      aSwitch.addInterface(new TransparentIF(aSwitch, gToS, gatewayIF));
      map.addEdge(gToS, gateway, aSwitch);
    }
    final Device gw = gateway, sw = aSwitch;
    final NetworkIF gif = gatewayIF;
    for (final InetAddress address : hosts.keySet()) {
      Scheduler.execute(new Runnable() {
        @Override
        public void run() {
          try {
            if (!address.equals(gif.getAddress())) {
              if (tryFindIP(map, address) != null) return;
              Logger.debug("Adding Interface "+address);
              Connection c = new Connection();
              Device d = new Host();
                d.setName(address.getHostName());
                PhysicalIF pif = new PhysicalIF(d, c, address.getHostAddress());
                  pif.setPingMethod(hosts.get(address));
                  pif.setSubnet(subnet.getInfo().getNetmask());
                  pif.setGateway(subnet.getInfo().getLowAddress());
                d.addInterface(pif);
                SNMP.inferProperties(d);
              sw.addInterface(new TransparentIF(sw, c, pif));
              map.addVertex(d);
              map.addEdge(c, d, sw);
View Full Code Here

        String t = arg1.getType().toString() + "";
        NetworkIF nif;
        if (t.contains("Switch") || t.contains("Hub") || t.contains("Wireless")) {
          nif = new TransparentIF(arg1, arg0, arg2.getInterfaceFor(arg0));
        } else {
          nif = new PhysicalIF(arg1, arg0, "");
        }
        arg1.addInterface(nif);
        NetworkIF counterpart = arg2.getInterfaceFor(arg0);
        if (counterpart != null && counterpart instanceof TransparentIF) {
          ((TransparentIF) counterpart).setCounterpart(nif);
View Full Code Here

          NetworkIF newIF = null;
         
          @Override
          public Object undo() {
            if (isPhysical && !addressCheckbox.isSelected()) {
              PhysicalIF pif = new PhysicalIF(parent, connection, oldAddress);
                pif.setSubnet(oldSubnet);
                pif.setGateway(oldGateway);
                pif.setMacAddress(oldMac);
                pif.setPingMethod(oldMethod);
                pif.setName(oldName);
              parent.addInterface(pif);
              parent.removeInterface(newIF);
            } else if (isTransparent && addressCheckbox.isSelected()) {
              TransparentIF tif = new TransparentIF(parent, connection, Controller.getCurrentMap().
                getOpposite(parent, i.getConnection()).getInterfaceFor(connection));
                tif.setName(oldName);
              parent.addInterface(tif);
              parent.removeInterface(newIF);
            } else {
              i.setAddress(oldAddress);
              i.setSubnet(oldSubnet);
              i.setGateway(oldGateway);
              i.setName(oldName);
              if (isPhysical) {
                ((PhysicalIF)i).setMacAddress(oldMac);
                ((PhysicalIF)i).setPingMethod(oldMethod);
              }
            }
            return null;
          }
         
          @Override
          public Object redo() {
            NetworkIF counterpart = Controller.getCurrentMap().
              getOpposite(parent, i.getConnection()).getInterfaceFor(connection);
            if (isPhysical && !addressCheckbox.isSelected()) {
              newIF = new TransparentIF(parent, connection, counterpart);
                newIF.setName(newName);
              parent.addInterface(newIF);
              parent.removeInterface(i);
            } else if (isTransparent && addressCheckbox.isSelected()) {
              PhysicalIF pif = new PhysicalIF(parent, connection, newAddress);
                pif.setSubnet(newSubnet);
                pif.setGateway(newGateway);
                pif.setMacAddress(newMac);
                pif.setPingMethod(newMethod);
                pif.setName(newName);
              newIF = pif;
              parent.addInterface(pif);
              parent.removeInterface(i);
              if (counterpart instanceof TransparentIF) ((TransparentIF) counterpart).setCounterpart(pif);
            } else {
View Full Code Here

    args = args.replaceAll("%mp", m.getFilePath());
    Device d;
    if (Type.STATUS_CHANGED.equals(e.getType())) {
      d = (Device) e.getSource();
    } else {
      PhysicalIF nif = (PhysicalIF) e.getSubject();
      d = nif.getDevice();
      args = args.replaceAll("%is", nif.getStatus().toString());
      args = args.replaceAll("%in", nif.getName());
      args = args.replaceAll("%ia", nif.getAddress().getHostAddress());
      args = args.replaceAll("%iu", nif.getSubnet().getInfo().getBroadcastAddress());
      args = args.replaceAll("%ig", nif.getGateway().getHostAddress());
      args = args.replaceAll("%im", nif.getMacAddress());
    }
    args = args.replaceAll("%ds", d.getStatus().toString());
    args = args.replaceAll("%dn", d.getName());
    args = args.replaceAll("%dl", d.getLocation());
    args = args.replaceAll("%di", new File(IO.userDir, "cisco/"+d.getType().toString().toLowerCase()+".png").getAbsolutePath());
View Full Code Here

    c = new Connection();
    c.setBandwidth(100);
    c.setType(Type.Ethernet);
    c.setStatus(i, Status.UP);
    h = new Host();
    i = new PhysicalIF(h, c, "192.168.0.35");
    ii = new LogicalIF(h, new Connection(), "127.0.0.1");
    iii = null;
    interfaces = new LinkedList<NetworkIF>();
    ifs = new LinkedList<NetworkIF>();
    interfaces.add(0, i);
View Full Code Here

TOP

Related Classes of ch.rakudave.jnetmap.model.IF.PhysicalIF

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.