diff --git a/EduNetworkBuilder/IPAddress.cs b/EduNetworkBuilder/IPAddress.cs index 9d0b1b7..26fe044 100644 --- a/EduNetworkBuilder/IPAddress.cs +++ b/EduNetworkBuilder/IPAddress.cs @@ -341,7 +341,8 @@ namespace EduNetworkBuilder public bool IsBroadcast() { uint BA = BroadcastAddress; - if (_ip == BA) return true; + if (_ip == BA) return true; //the actual broadcast for the network + if (GetIPString == NB.BroadcastIPString) return true; //The special broadcast 255.255.255.255 return false; } diff --git a/EduNetworkBuilder/NetworkCard.cs b/EduNetworkBuilder/NetworkCard.cs index 0f32875..8e7183a 100644 --- a/EduNetworkBuilder/NetworkCard.cs +++ b/EduNetworkBuilder/NetworkCard.cs @@ -45,7 +45,7 @@ namespace EduNetworkBuilder myID = new HostNicID(HostID, UniqueIdentifier, hostname, _nic_name); NetworkInterface nInterface = new NetworkInterface(NicName(), NB.ZeroIPString, NB.ZeroIPString, myID); if(theType == NicType.lo) - nInterface = new NetworkInterface(NicName(), "127.0.0.1", "255.0.0.0", myID); + nInterface = new NetworkInterface(NicName(), NB.LoopbackIPString, "255.0.0.0", myID); interfaces.Add(nInterface); ApplyNicRules(); SetIPForDHCP(); @@ -313,7 +313,7 @@ namespace EduNetworkBuilder if (iface.myIP.BroadcastAddress == 0) continue; //a netmask of 0.0.0.0 causes grief if (iface.myIP.BroadcastAddress == dest.GetIP) return true;//If they are pinging the broadcast IP - if (iface.myIP.GetIPString == NB.BroadcastIPString) + if (iface.myIP.IsBroadcast()) return true; } return false; @@ -435,7 +435,7 @@ namespace EduNetworkBuilder if (UsesDHCP && CanUseDHCP) { bool doIt = true; - if (interfaces.Count > 0 && interfaces[0].myIP.GetIPString == NB.ZeroIPString) + if (interfaces.Count > 0 && interfaces[0].myIP.IsZeroString()) { doIt = true; } @@ -568,15 +568,15 @@ namespace EduNetworkBuilder nf.ProcessOutboundPacket(nPacket); if (nPacket.MyStatus == PacketStatus.finished || nPacket.MyStatus == PacketStatus.finished_failed || nPacket.MyStatus == PacketStatus.finished_ok) continue; //If the packet cannot be sent out (VLAN stuff) - if (tPacket.OutboundIP == null || (nf.isLocal(tPacket.OutboundIP) || (tPacket.OutboundIP.GetIPString == NB.BroadcastIPString && tPacket.isFresh))) + if (tPacket.OutboundIP == null || (nf.isLocal(tPacket.OutboundIP) || (tPacket.OutboundIP.IsBroadcast() && tPacket.isFresh))) { - if ((nf != null && nf.myIP.GetIPString != NB.ZeroIPString) || nPacket.MyType == PacketType.dhcp_request) + if ((nf != null && !nf.myIP.IsZeroString()) || nPacket.MyType == PacketType.dhcp_request) { //this means we have a local interface to send it out of //if(nPacket.sourceMAC == null || nPacket.sourceMAC == "" || nPacket.isFresh) nPacket.sourceMAC = MAC; //If the source IP is empty then it is a new packet. We set the source to be us - if (nPacket.sourceIP == null || nPacket.sourceIP.GetIPString == NB.ZeroIPString) + if (nPacket.sourceIP == null || nPacket.sourceIP.IsZeroString()) nPacket.sourceIP = nf.myIP; nPacket.TsourceIP = nf.myIP; if (nPacket.destMAC == null || nPacket.destMAC == "") @@ -627,14 +627,14 @@ namespace EduNetworkBuilder if (nPacket.MyStatus == PacketStatus.finished || nPacket.MyStatus == PacketStatus.finished_failed || nPacket.MyStatus == PacketStatus.finished_ok) continue; //If the packet cannot be sent out (VLAN stuff) - if (tPacket.OutboundIP != null && (nf.isLocal(tPacket.OutboundIP) || tPacket.OutboundIP.GetIPString == NB.BroadcastIPString)) + if (tPacket.OutboundIP != null && (nf.isLocal(tPacket.OutboundIP) || tPacket.OutboundIP.IsBroadcast())) { - if ((nf != null && nf.myIP != null && nf.myIP.GetIPString != NB.ZeroIPString) || nPacket.MyType == PacketType.dhcp_request) + if ((nf != null && nf.myIP != null && !nf.myIP.IsZeroString()) || nPacket.MyType == PacketType.dhcp_request) { //this means we have a local interface to send it out of nPacket.sourceMAC = MAC; //If the source IP is empty then it originated from here. We set the source to be us - if (nPacket.sourceIP == null || nPacket.sourceIP.GetIPString == NB.ZeroIPString) + if (nPacket.sourceIP == null || nPacket.sourceIP.IsZeroString()) { nPacket.sourceIP = nf.myIP; WhereFrom.StoreOutgoingPacketInfo(nPacket); //the packet is not masqueraded, just accepted @@ -701,10 +701,10 @@ namespace EduNetworkBuilder } } } - if (nf != null && nf.myIP != null && nf.myIP.GetIPString != NB.ZeroIPString) + if (nf != null && nf.myIP != null && !nf.myIP.IsZeroString()) { //If the source IP is empty then it originated from here. We set the source to be us - if (tPacket.sourceIP == null || tPacket.sourceIP.GetIPString == NB.ZeroIPString) + if (tPacket.sourceIP == null || tPacket.sourceIP.IsZeroString()) { tPacket.sourceIP = nf.myIP; WhereFrom.StoreOutgoingPacketInfo(tPacket); //the packet is not yet tunneled @@ -785,7 +785,7 @@ namespace EduNetworkBuilder //Need to find the managament interface MAC nPacket.sourceMAC = WhereFrom.HubManagementMAC(); } - if ((nPacket.sourceIP == null || nPacket.sourceIP.GetIPString == NB.ZeroIPString) && nPacket.MyType != PacketType.dhcp_request) + if ((nPacket.sourceIP == null || nPacket.sourceIP.IsZeroString()) && nPacket.MyType != PacketType.dhcp_request) { //set it to be the ip of management interface nPacket.sourceIP = WhereFrom.HubManagementIP(); @@ -800,7 +800,7 @@ namespace EduNetworkBuilder nl = myNet.GetLinkFromID(ConnectedLink); if (nl == null) break; - if ((nPacket.sourceIP == null || nPacket.sourceIP.GetIPString == NB.ZeroIPString) && tPacket.MyType != PacketType.dhcp_request) return false; //We still have no IP. Do not send the packet out. + if ((nPacket.sourceIP == null || nPacket.sourceIP.IsZeroString()) && tPacket.MyType != PacketType.dhcp_request) return false; //We still have no IP. Do not send the packet out. nPacket.StartOnLink(nl, WhereFrom); //This sends the packet down the link. myNet.addPacket(nPacket); if (tPacket.isFresh)