package cnetmap;

import java.net.Inet4Address;

/**
 *
 * @author Dominik Janura
 */
public class NetInterface {

  private boolean AlreadyConnected;
  private NetNode ConnectedNode;
  private NetInterface ConnectedInterface;

  private String Id;
  private String Name;
  private Inet4Address IpAddress;
  private Inet4Address IpMask;
  private Inet4Address IpNetwork;
  private String HwAddress = null;
  private String Gateway = null;

  public NetInterface(String id, String name, Inet4Address ipAddress, Inet4Address ipMask,
          Inet4Address ipNetwork, String hwAddress, String gateway) {
    super();
    Id = id;
    Name = name;
    IpAddress = ipAddress;
    IpMask = ipMask;
    IpNetwork = ipNetwork;
    HwAddress = hwAddress;
    Gateway = gateway;
    ConnectedNode = null;
    ConnectedInterface = null;
    AlreadyConnected = false;
  }
  
  public boolean getAlreadyConnected() {
    return this.AlreadyConnected;
  }
  
  public void setAlreadyConnected(boolean alreadyConnected) {
    this.AlreadyConnected = alreadyConnected;
  }

  public NetNode getConnectedNode() {
    return this.ConnectedNode;
  }

  public void setConnectedNode(NetNode connectedNode) {
    this.ConnectedNode = connectedNode;
  }

  public NetInterface getConnectedInterface() {
    return this.ConnectedInterface;
  }

  public void setConnectedInterface(NetInterface connectedInterface) {
    this.ConnectedInterface = connectedInterface;
  }

  public String getId() {
    return this.Id;
  }

  public void setId(String id) {
    this.Id = id;
  }

  public String getName() {
    return this.Name;
  }

  public void setName(String name) {
    this.Name = name;
  }

  public Inet4Address getIpAddress() {
    return this.IpAddress;
  }

  public void setIpAddress(Inet4Address ipAddress) {
    this.IpAddress = ipAddress;
  }

  public Inet4Address getIpMask() {
    return this.IpMask;
  }

  public void setIpMask(Inet4Address ipMask) {
    this.IpMask = ipMask;
  }

  public Inet4Address getIpNetwork() {
    return this.IpNetwork;
  }

  public void setIpNetwork(Inet4Address ipNetwork) {
    this.IpNetwork = ipNetwork;
  }

  public String getHwAddress() {
    return this.HwAddress;
  }

  public void setHwAddress(String hwAddress) {
    this.HwAddress = hwAddress;
  }

  public String getGateway() {
    return this.Gateway;
  }

  public void setGateway(String gateway) {
    this.Gateway = gateway;
  }
  
  @Override
  public String toString() {
    if (this.IpAddress != null) {
      return this.Name + " " + this.IpAddress.getHostAddress() + " " + this.IpNetwork.getHostAddress();
    } else if (this.HwAddress != null) {
      return this.Name + " " + this.HwAddress + " " + this.Gateway;
    } else {
      return CNetMap.ERR_INTERFACE_UNDEFINED;
    }
  }

}