Translation strings in Packet

This commit is contained in:
Tim Young 2015-11-18 15:00:05 -05:00
parent eaf3a46376
commit b0fc5d323b

View File

@ -122,7 +122,7 @@ namespace EduNetworkBuilder
destMAC = dest; destMAC = dest;
OutboundDestMAC = dest; OutboundDestMAC = dest;
Tracking.AddMessage(DebugLevel.info, start, theType.ToString() + "Packet Created"); Tracking.AddMessage(DebugLevel.info, start, theType.ToString() + "Packet Created");
Tracking.AddMessage(DebugLevel.routing, start, " MAC:" + source + " -> " + dest); Tracking.AddMessage(DebugLevel.routing, start, string.Format(" MAC: {0} -> {1}", source, dest));
} }
else else
{ {
@ -135,8 +135,8 @@ namespace EduNetworkBuilder
OutboundDestMAC = destMAC; OutboundDestMAC = destMAC;
} }
Tracking.AddMessage(DebugLevel.info, start, "Packet Created"); Tracking.AddMessage(DebugLevel.info, start, "Packet Created");
Tracking.AddMessage(DebugLevel.routing, start, " IP:" + source + " -> " + dest); Tracking.AddMessage(DebugLevel.routing, start, string.Format(" IP: {0} -> {1}", source, dest));
Tracking.AddMessage(DebugLevel.debug, start, " IPs Translated to" + sourceIP.GetIP.ToIpString() + " -> " + destIP.GetIP.ToIpString()); Tracking.AddMessage(DebugLevel.debug, start, string.Format(" IPs Translated {0} -> {1}",sourceIP.GetIP.ToIpString(), destIP.GetIP.ToIpString()));
} }
isFresh = true; isFresh = true;
} }
@ -154,7 +154,7 @@ namespace EduNetworkBuilder
if (destIP != null && destIP.BroadcastAddress == destIP.GetIP) if (destIP != null && destIP.BroadcastAddress == destIP.GetIP)
destMAC = NB.BroadcastMACString; destMAC = NB.BroadcastMACString;
Tracking.AddMessage(DebugLevel.info, start, "Packet Created"); Tracking.AddMessage(DebugLevel.info, start, "Packet Created");
Tracking.AddMessage(DebugLevel.routing, start, " IP:" + sourceIP.GetIP.ToIpString() + " -> " + dest.GetIP.ToIpString()); Tracking.AddMessage(DebugLevel.routing, start, string.Format(" IP:{0} -> {1}", sourceIP.GetIP.ToIpString(), dest.GetIP.ToIpString()));
} }
else else
{ {
@ -261,8 +261,8 @@ namespace EduNetworkBuilder
if(MyNet.CountPackets(PacketType.arp_answer) + MyNet.CountPackets(PacketType.arp_request) == 0) if(MyNet.CountPackets(PacketType.arp_answer) + MyNet.CountPackets(PacketType.arp_request) == 0)
{ {
//No more arps going. We do not have an answer! //No more arps going. We do not have an answer!
Tracking.AddMessage(DebugLevel.info, WhereAmI, "Unable to find a mac address for the IP address: " + dest.GetIP.ToIpString()); Tracking.AddMessage(DebugLevel.info, WhereAmI, string.Format("Unable to find a mac address for the IP address: {0}", dest.GetIP.ToIpString()));
Tracking.Status = WhereAmI.hostname + " Failed: Unable to find a MAC address for the specified IP."; Tracking.Status = string.Format("{0} Failed: Unable to find a MAC address for the specified IP.", WhereAmI.hostname );
MyStatus = PacketStatus.finished_failed; MyStatus = PacketStatus.finished_failed;
} }
return; return;
@ -278,7 +278,7 @@ namespace EduNetworkBuilder
if (WhereAmI == null) if (WhereAmI == null)
{ {
AddMessage(DebugLevel.debug, "The packet was dropped because we lost where it was. WhereAmI == null!"); AddMessage(DebugLevel.debug, "The packet was dropped because we lost where it was. WhereAmI == null!");
Tracking.Status = "NO_Host" + " Lost location of packet.."; Tracking.Status = "NO_Host Lost location of packet..";
MyStatus = PacketStatus.finished_failed; MyStatus = PacketStatus.finished_failed;
return; //We cannot process the packet return; //We cannot process the packet
} }
@ -298,7 +298,7 @@ namespace EduNetworkBuilder
if (WhereAmI == null) if (WhereAmI == null)
{ {
AddMessage(DebugLevel.debug, "The packet was dropped because we lost where it was. WhereAmI == null!"); AddMessage(DebugLevel.debug, "The packet was dropped because we lost where it was. WhereAmI == null!");
Tracking.Status = "NO_Host" + " Lost location of packet.."; Tracking.Status = "NO_Host Lost location of packet..";
MyStatus = PacketStatus.finished_failed; MyStatus = PacketStatus.finished_failed;
return; //We cannot process the packet return; //We cannot process the packet
} }
@ -310,7 +310,7 @@ namespace EduNetworkBuilder
if (WhereAmI == null) if (WhereAmI == null)
{ {
AddMessage(DebugLevel.debug, "The packet was dropped because we lost where it was. WhereAmI == null!"); AddMessage(DebugLevel.debug, "The packet was dropped because we lost where it was. WhereAmI == null!");
Tracking.Status = "NO_Host" + " Lost location of packet.."; Tracking.Status = "NO_Host Lost location of packet..";
MyStatus = PacketStatus.finished_failed; MyStatus = PacketStatus.finished_failed;
return; //We cannot process the packet return; //We cannot process the packet
} }
@ -340,7 +340,7 @@ namespace EduNetworkBuilder
myDirection = nb_direction.to_dst; myDirection = nb_direction.to_dst;
else else
myDirection = nb_direction.to_src; myDirection = nb_direction.to_src;
Console.WriteLine("Starting on link. SMAC: " + sourceMAC + " DMAC: " + destMAC); Console.WriteLine(string.Format("Starting on link. SMAC: {0} DMAC: {1}",sourceMAC,destMAC));
AddMessage(DebugLevel.debug, " Starting on link"); AddMessage(DebugLevel.debug, " Starting on link");
} }
@ -366,8 +366,9 @@ namespace EduNetworkBuilder
} }
if(MyType == PacketType.arp_request && MyStatus == PacketStatus.finished_failed) if(MyType == PacketType.arp_request && MyStatus == PacketStatus.finished_failed)
{ {
Tracking.AddMessage(DebugLevel.info, "Packet", "Packet failed to reach any IP. No such IP on network: " + destIP.GetIPString); Tracking.AddMessage(DebugLevel.info, "Packet",
Tracking.Status = "Packet failed to reach IP: " + destIP.GetIPString; string.Format("Packet failed to reach any IP. No such IP on network: {0}", destIP.GetIPString));
Tracking.Status = string.Format("Packet failed to reach IP: {0}",destIP.GetIPString);
MyStatus = PacketStatus.finished_failed; MyStatus = PacketStatus.finished_failed;
} }
if (MyStatus != PacketStatus.finished) if (MyStatus != PacketStatus.finished)
@ -435,15 +436,12 @@ namespace EduNetworkBuilder
} }
if ((WhatIsSet & DebugPausePoint.dump) == DebugPausePoint.dump) if ((WhatIsSet & DebugPausePoint.dump) == DebugPausePoint.dump)
{ {
Console.WriteLine(hostname + ": " + MyType.ToString()); Console.WriteLine(string.Format("{0}: {1} PACKET: dstIP: {2} destMAC: {3}", hostname, position, dIP, destMAC));
Console.Write(hostname + ": " + position + " PACKET: dstIP:" + dIP); Console.WriteLine(string.Format("{0}: {1} PACKET: srcIP: {2} srcMAC: {3}", hostname, position, sIP, sourceMAC));
Console.WriteLine(" dstMAC:" + destMAC);
Console.Write(hostname + ": " + position + " PACKET: srcIP:" + sIP);
Console.WriteLine(" srcMAC:" + sourceMAC);
Console.WriteLine("---"); Console.WriteLine("---");
} }
AddMessage(DebugLevel.packet, hostname + ": " + position + " PACKET: dstIP:" + dIP + " dstMAC:" + destMAC); AddMessage(DebugLevel.packet, string.Format("{0}: {1} PACKET: dstIP: {2} destMAC: {3}", hostname, position, dIP, destMAC));
AddMessage(DebugLevel.packet, hostname + ": " + position + " PACKET: srcIP:" + sIP + " srcMAC:" + sourceMAC); AddMessage(DebugLevel.packet, string.Format("{0}: {1} PACKET: srcIP: {2} srcMAC: {3}", hostname,position,sIP,sourceMAC));
} }
public static T Clone<T>(T source) public static T Clone<T>(T source)