diff --git a/EduNetworkBuilder/IPAddress.cs b/EduNetworkBuilder/IPAddress.cs
index b2ed9f0..3c92bdd 100644
--- a/EduNetworkBuilder/IPAddress.cs
+++ b/EduNetworkBuilder/IPAddress.cs
@@ -24,11 +24,13 @@ namespace EduNetworkBuilder
private IPAddress theNetmask;
private IPAddress theGateway;
+ private bool Unset = true;
+
public NB_IPAddress() { } //used for reflection
///
/// Duplicate an IP address structure
///
- ///
+ /// The IP to clone from
public NB_IPAddress(NB_IPAddress Orig)
{
_ip = Orig._ip;
@@ -38,22 +40,42 @@ namespace EduNetworkBuilder
theIP = Orig.theIP;
theNetmask = Orig.theNetmask;
theGateway = Orig.theGateway;
+ Unset = false;
}
+
+ ///
+ /// Make a simple IP address with netmask
+ ///
+ /// The new IP
+ /// The new netmask
+ ///
public NB_IPAddress(string ip, string mask, IPAddressType WhatType)
{
myType = WhatType;
_ip = ip.ParseIp();
_mask = mask.ParseIp();
+ Unset = false;
}
+ ///
+ /// Make a new IP address, netmask, with gateway.
+ ///
+ /// The IP address
+ /// The netmask
+ /// The gateway to use
public NB_IPAddress(string ip, string mask, string gw)
{
myType = IPAddressType.route;
_ip = ip.ParseIp();
_mask = mask.ParseIp();
_gw = gw.ParseIp();
+ Unset = false;
}
+ ///
+ /// Load an IP address from the XML file
+ ///
+ /// The XmlNode to load from
public NB_IPAddress(XmlNode theNode)
{
foreach (XmlNode Individual in theNode.ChildNodes)
@@ -65,12 +87,15 @@ namespace EduNetworkBuilder
{
case "ip":
_ip = Individual.InnerText.ParseIp();
+ Unset = false;
break;
case "mask":
_mask = Individual.InnerText.ParseIp();
+ Unset = false;
break;
case "gateway":
_gw = Individual.InnerText.ParseIp();
+ Unset = false;
break;
case "type":
myType = NB.ParseEnum(Individual.InnerText);
@@ -82,7 +107,8 @@ namespace EduNetworkBuilder
public void SetIP(UInt32 newIP)
{
- _ip = newIP;
+ _ip = newIP;
+ Unset = false;
}
public bool Equals(NB_IPAddress CompareWith)
@@ -109,11 +135,13 @@ namespace EduNetworkBuilder
_ip = ip.ParseIp();
_mask = mask.ParseIp();
_gw = gw.ParseIp();
+ Unset = false;
}
public void Reparse(string ip, string mask)
{
_ip = ip.ParseIp();
_mask = mask.ParseIp();
+ Unset = false;
}
public IPAddressType GetAddressType
@@ -298,6 +326,53 @@ namespace EduNetworkBuilder
return false;
}
+ #region IP Status Funcs
+ ///
+ /// If the IP address has not yet been assigned
+ ///
+ public bool IsUnassigned() { return Unset; }
+
+ ///
+ /// If the IP address is the same as the broadcast address
+ ///
+ public bool IsBroadcast()
+ {
+ uint BA = BroadcastAddress;
+ if (_ip == BA) return true;
+ return false;
+ }
+
+
+ ///
+ /// If the IP address is the same as the network address
+ ///
+ public bool IsNetwork()
+ {
+ uint NA = NetworkAddress;
+ if (_ip == NA) return true;
+ return false;
+ }
+
+ ///
+ /// If the IP address is the loopback address. Different for IPv4 than IPv6
+ ///
+ public bool IsLoopback()
+ {
+ if (GetIPString == "127.0.0.1") return true;
+ return false;
+ }
+
+
+ ///
+ /// If the IP address is 0.0.0.0 or the equavelent
+ ///
+ /// true if it is zeroes could be unset or anywhere
+ public bool IsZeroString() {
+ if (_ip == 0) return true;
+ return false;
+ }
+
+ #endregion
#region Break an IP
public string GenRandomIPOrMask()