diff --git a/EduNetworkBuilder/Network.cs b/EduNetworkBuilder/Network.cs index 1aee811..b2536b0 100644 --- a/EduNetworkBuilder/Network.cs +++ b/EduNetworkBuilder/Network.cs @@ -27,6 +27,7 @@ namespace EduNetworkBuilder public bool OptionShowLabels = false; public bool ShowLabelsHere = false; public bool VLANsEnabled = false; + public bool VLANPacketColors = false; public LanguageStrings NetMessage; public LanguageStrings NetTitle; List NetComponents = new List(); @@ -136,6 +137,11 @@ namespace EduNetworkBuilder case "vlansenabled": bool.TryParse(Individual.InnerText, out VLANsEnabled); break; + case "vlanpacketcolors": + bool.TryParse(Individual.InnerText, out VLANPacketColors); + if (VLANPacketColors) + VLANsEnabled = true; //If we do colors, we need to do vlans + break; case "itemsize": int.TryParse(Individual.InnerText, out itemsize); break; @@ -282,6 +288,7 @@ namespace EduNetworkBuilder writer.WriteElementString("uniqueidentifier", UniqueIdentifier.ToString()); writer.WriteElementString("startinghelplevel", StartingHelpLevel.ToString()); writer.WriteElementString("vlansenabled", VLANsEnabled.ToString()); + writer.WriteElementString("VLANPacketColors", VLANPacketColors.ToString()); //Save all the devices for (int loop = 0; loop < NetComponents.Count; loop++) { @@ -1441,6 +1448,7 @@ namespace EduNetworkBuilder public Color ColorFromPacketVLAN(int id) { + if (!VLANPacketColors) return Color.Blue; //If we are not set up to do vlan colors. foreach(VLANName VN in VlanNames) { if (VN.ID == id) diff --git a/EduNetworkBuilder/NetworkCard.cs b/EduNetworkBuilder/NetworkCard.cs index 60fd069..c1c8d4b 100644 --- a/EduNetworkBuilder/NetworkCard.cs +++ b/EduNetworkBuilder/NetworkCard.cs @@ -39,10 +39,10 @@ namespace EduNetworkBuilder { myNicType = theType; _nic_name = myNicType.ToString() + index.ToString(); + 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); - myID = new HostNicID(HostID, UniqueIdentifier,hostname,nInterface.nic_name); interfaces.Add(nInterface); ApplyNicRules(); SetIPForDHCP(); diff --git a/EduNetworkBuilder/OptionsWindow.Designer.cs b/EduNetworkBuilder/OptionsWindow.Designer.cs index 7393abd..7157a9c 100644 --- a/EduNetworkBuilder/OptionsWindow.Designer.cs +++ b/EduNetworkBuilder/OptionsWindow.Designer.cs @@ -50,6 +50,7 @@ this.cbStartingHelpLevel = new System.Windows.Forms.ComboBox(); this.lblStartingHelp = new System.Windows.Forms.Label(); this.cbVLANs = new System.Windows.Forms.CheckBox(); + this.cb_ColoredPackets = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // btnDone @@ -239,12 +240,23 @@ // cbVLANs // this.cbVLANs.AutoSize = true; - this.cbVLANs.Location = new System.Drawing.Point(341, 44); + this.cbVLANs.Location = new System.Drawing.Point(519, 247); this.cbVLANs.Name = "cbVLANs"; this.cbVLANs.Size = new System.Drawing.Size(129, 21); this.cbVLANs.TabIndex = 21; this.cbVLANs.Text = "VLANs Enabled"; this.cbVLANs.UseVisualStyleBackColor = true; + this.cbVLANs.CheckedChanged += new System.EventHandler(this.cbVLANs_CheckedChanged); + // + // cb_ColoredPackets + // + this.cb_ColoredPackets.AutoSize = true; + this.cb_ColoredPackets.Location = new System.Drawing.Point(519, 274); + this.cb_ColoredPackets.Name = "cb_ColoredPackets"; + this.cb_ColoredPackets.Size = new System.Drawing.Size(173, 21); + this.cb_ColoredPackets.TabIndex = 22; + this.cb_ColoredPackets.Text = "VLAN Colored Packets"; + this.cb_ColoredPackets.UseVisualStyleBackColor = true; // // OptionsWindow // @@ -252,6 +264,7 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(836, 307); + this.Controls.Add(this.cb_ColoredPackets); this.Controls.Add(this.cbVLANs); this.Controls.Add(this.lblStartingHelp); this.Controls.Add(this.cbStartingHelpLevel); @@ -305,5 +318,6 @@ private System.Windows.Forms.ComboBox cbStartingHelpLevel; private System.Windows.Forms.Label lblStartingHelp; private System.Windows.Forms.CheckBox cbVLANs; + private System.Windows.Forms.CheckBox cb_ColoredPackets; } } \ No newline at end of file diff --git a/EduNetworkBuilder/OptionsWindow.cs b/EduNetworkBuilder/OptionsWindow.cs index e27ecd7..6b64f81 100644 --- a/EduNetworkBuilder/OptionsWindow.cs +++ b/EduNetworkBuilder/OptionsWindow.cs @@ -46,6 +46,7 @@ namespace EduNetworkBuilder myToolTip.SetToolTip(lblSortOrder, NB.Translate("OW_OWSort")); myToolTip.SetToolTip(tbSortOrder, NB.Translate("OW_OWSort")); myToolTip.SetToolTip(cbVLANs, NB.Translate("OW_OWVLANs")); + myToolTip.SetToolTip(cb_ColoredPackets, NB.Translate("OW_OWVLANColoredPacketsTT")); LoadValuesFromNetwork(); } @@ -63,6 +64,7 @@ namespace EduNetworkBuilder lblSortOrder.Text = NB.Translate("OW_lblSortOrder"); lblStartingHelp.Text = NB.Translate("OW_lblStartingHelp"); cbVLANs.Text = NB.Translate("OW_cbVLANs"); + cb_ColoredPackets.Text = NB.Translate("OW_OWVLANColoredPackets"); Text = NB.Translate("OW_Form"); } @@ -74,6 +76,7 @@ namespace EduNetworkBuilder tbNetworkTitle.Text = myNet.NetTitle.GetText(); cbDisplayTitles.Checked = myNet.OptionShowLabels; cbVLANs.Checked = myNet.VLANsEnabled; + cb_ColoredPackets.Checked = myNet.VLANPacketColors; tbNetworkX.Text = myNet.myWidth.ToString(); tbNetworkY.Text = myNet.myHeight.ToString(); tbLevel.Text = myNet.Level.ToString(); @@ -111,6 +114,7 @@ namespace EduNetworkBuilder myNet.NetTitle.Add(tbNetworkTitle.Text); myNet.OptionShowLabels = cbDisplayTitles.Checked; myNet.VLANsEnabled = cbVLANs.Checked; + myNet.VLANPacketColors = cb_ColoredPackets.Checked; myNet.ShowLabelsHere = myNet.OptionShowLabels; int.TryParse(tbNetworkX.Text, out myNet.myWidth); int.TryParse(tbNetworkY.Text, out myNet.myHeight); @@ -375,5 +379,18 @@ namespace EduNetworkBuilder int.TryParse(tbLevel.Text, out value); tbLevel.Text = value.ToString(); } + + private void cbVLANs_CheckedChanged(object sender, EventArgs e) + { + if(cbVLANs.Checked) + { + cb_ColoredPackets.Visible = true; + } + else + { + cb_ColoredPackets.Visible = false; + cb_ColoredPackets.Checked = false; + } + } } } diff --git a/EduNetworkBuilder/Resources/languages/edustrings.resx b/EduNetworkBuilder/Resources/languages/edustrings.resx index 721b07b..d8d1134 100644 --- a/EduNetworkBuilder/Resources/languages/edustrings.resx +++ b/EduNetworkBuilder/Resources/languages/edustrings.resx @@ -1601,4 +1601,12 @@ The Interface needs an Untagged VLAN NT_TstDiscriptNeedsUntaggedVLAN + + VLAN Colored Packets + OW_OWVLANColoredPackets = VLAN Colored Packets + + + When packets are passing across a VLAN link, color the packets so we can visualize them better. + OW_OWVLANColoredPacketsTT = When packets are passing across a VLAN link, color the packets so we can visualize them better. + \ No newline at end of file diff --git a/EduNetworkBuilder/Resources/level6_UntaggedAndDHCP.enbx b/EduNetworkBuilder/Resources/level6_UntaggedAndDHCP.enbx index 022a0f8..6910c96 100644 --- a/EduNetworkBuilder/Resources/level6_UntaggedAndDHCP.enbx +++ b/EduNetworkBuilder/Resources/level6_UntaggedAndDHCP.enbx @@ -14,6 +14,7 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL 169 full True + True firewall0 100 @@ -40,6 +41,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL lo 134 False + + lo0 @@ -64,6 +67,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL wan 137 False + + wan0 @@ -88,6 +93,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL eth 135 False + + eth0 @@ -138,6 +145,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL eth 136 False + + eth1 @@ -207,6 +216,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL lo 144 False + + lo0 @@ -231,6 +242,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL eth 145 False + + eth0 @@ -260,10 +273,10 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL wlan2 - 192.168.2.5 - 255.255.255.0 - 192.168.2.1 - route + 0.0.0.0 + 0.0.0.0 + 0.0.0.0 + ip Untagged @@ -296,6 +309,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL lo 148 False + + lo0 @@ -320,6 +335,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL eth 149 True + + eth0 @@ -344,6 +361,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL wlan 150 False + + wlan2 @@ -383,6 +402,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL lo 101 False + + lo0 @@ -407,6 +428,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL management_interface 102 False + + management_interface0 @@ -431,6 +454,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL port 103 False + + port1 @@ -459,6 +484,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL port 104 False + + port2 @@ -487,6 +514,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL port 105 False + + port3 @@ -515,6 +544,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL port 106 False + + port4 @@ -543,6 +574,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL port 107 False + + port5 @@ -571,6 +604,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL port 108 False + + port6 @@ -599,6 +634,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL port 109 False + + port7 @@ -642,6 +679,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL lo 156 False + + lo0 @@ -666,6 +705,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL management_interface 157 False + + management_interface0 @@ -690,6 +731,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL port 158 False + + port1 @@ -718,6 +761,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL port 159 False + + port2 @@ -746,6 +791,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL port 160 False + + port3 @@ -774,6 +821,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL port 161 False + + port4 @@ -802,6 +851,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL port 162 False + + port5 @@ -830,6 +881,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL port 163 False + + port6 @@ -858,6 +911,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL port 164 False + + port7 @@ -902,6 +957,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL lo 111 False + + lo0 @@ -926,6 +983,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL eth 112 False + + eth0 @@ -966,6 +1025,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL lo 114 False + + lo0 @@ -990,6 +1051,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL eth 115 False + + eth0 @@ -1030,6 +1093,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL lo 117 False + + lo0 @@ -1054,6 +1119,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL eth 118 False + + eth0 @@ -1093,6 +1160,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL lo 122 False + + lo0 @@ -1117,6 +1186,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL eth 123 False + + eth1 diff --git a/EduNetworkBuilder/VLANConfig.cs b/EduNetworkBuilder/VLANConfig.cs index 180cc39..75684c7 100644 --- a/EduNetworkBuilder/VLANConfig.cs +++ b/EduNetworkBuilder/VLANConfig.cs @@ -50,8 +50,16 @@ namespace EduNetworkBuilder void NamesDataBindingComplete(object Sender, EventArgs e) { - dgv_VLANNames.Columns[0].ReadOnly = LockedNames; - dgv_VLANNames.Columns[1].ReadOnly = LockedNames; + Network theNet = NB.GetNetwork(); + if (dgv_VLANNames.Columns.Count > 0) + { + dgv_VLANNames.Columns[0].ReadOnly = LockedNames; + dgv_VLANNames.Columns[1].ReadOnly = LockedNames; + if(theNet.VLANPacketColors && dgv_VLANNames.Columns.Count > 2) + { + dgv_VLANNames.Columns[2].ReadOnly = LockedNames; + } + } } private void UpdateForm() @@ -70,6 +78,7 @@ namespace EduNetworkBuilder UpdateNamesFromForm(); //Read in any changes so far processing = true; + //******************** //Bind the vlan names Network theNet = NB.GetNetwork(); int selectedrow = -1; @@ -84,8 +93,44 @@ namespace EduNetworkBuilder List tList = theNet.VlanNames.OrderBy(x => x.ID).ToList(); StashedVLANNameList = new BindingList(tList); + dgv_VLANNames.AutoGenerateColumns = false; + dgv_VLANNames.Columns.Clear(); dgv_VLANNames.DataSource = StashedVLANNameList; dgv_VLANNames.AllowUserToAddRows = true; + + //The VLAN ID + DataGridViewTextBoxColumn DGVTB = new DataGridViewTextBoxColumn(); + DGVTB.ValueType = typeof(string); + DGVTB.DataPropertyName = "ID"; + DGVTB.Name = "ID"; + DGVTB.HeaderText = "ID"; + dgv_VLANNames.Columns.Add(DGVTB); + + //The VLAN name + DGVTB = new DataGridViewTextBoxColumn(); + DGVTB.ValueType = typeof(string); + DGVTB.DataPropertyName = "Name"; + DGVTB.Name = "Name"; + DGVTB.HeaderText = "Name"; + dgv_VLANNames.Columns.Add(DGVTB); + + if (theNet.VLANPacketColors) + { + //The VLAN color. (optional) + DataGridViewComboBoxColumn DGVCBC = new DataGridViewComboBoxColumn(); + DGVCBC.ValueType = typeof(string); + DGVCBC.DataPropertyName = "PacketColorString"; + DGVCBC.Name = "Color"; + DGVCBC.HeaderText = "Color"; + DGVCBC.Items.Add("Blue"); + DGVCBC.Items.Add("Purple"); + DGVCBC.Items.Add("Yellow"); + DGVCBC.Items.Add("Green"); + DGVCBC.Items.Add("Orange"); + DGVCBC.Items.Add("Cyan"); + dgv_VLANNames.Columns.Add(DGVCBC); + } + if (TheDevice != null) { if (theNet.ItemIsLocked(hostname, "", NetTestType.LockVLANNames) || @@ -94,6 +139,9 @@ namespace EduNetworkBuilder else LockedNames = false; } + + //************************************** + //Start building the VLAN/Interface list VlanBindings.Columns.Clear(); VlanBindings.Columns.Add("IF", typeof(string)); foreach (VLANName vn in theNet.VlanNames) @@ -234,7 +282,8 @@ namespace EduNetworkBuilder { if (!VLANNamesHasID(theNet.VlanNames, id)) { - Color tColor = oList[theNet.VlanNames.Count].PacketColor; + Color tColor = Color.Blue; + if(theNet.VlanNames.Count < oList.Count ) tColor = oList[theNet.VlanNames.Count].PacketColor; if (DR.Cells["Name"].Value == null) //When we are still adding theNet.VlanNames.Add(new VLANName(id, "----", tColor)); else @@ -283,8 +332,8 @@ namespace EduNetworkBuilder private void dgv_VLANNames_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { - string headerText = - dgv_VLANNames.Columns[e.ColumnIndex].HeaderText; + //return; + string headerText = dgv_VLANNames.Columns[e.ColumnIndex].Name; if (processing) return; dgv_VLANNames.Rows[e.RowIndex].ErrorText = ""; //clear the old one out @@ -325,9 +374,13 @@ namespace EduNetworkBuilder } } //MessageBox.Show(e.RowIndex.ToString() + " out of " + StashedVLANNameList.Count); - } } + if (headerText.Equals("Color")) + { + //Checking the color + Console.WriteLine("Here "+ e.RowIndex); + } } private void dgv_VLANNames_UserDeletedRow(object sender, DataGridViewRowEventArgs e) diff --git a/EduNetworkBuilder/VLANStuff.cs b/EduNetworkBuilder/VLANStuff.cs index f6cee86..a35bbee 100644 --- a/EduNetworkBuilder/VLANStuff.cs +++ b/EduNetworkBuilder/VLANStuff.cs @@ -11,16 +11,16 @@ namespace EduNetworkBuilder [Serializable] public class VLANName { - public int _ID; + public int _ID = 0; [DisplayName("ID")] public int ID { get { return _ID; } set { _ID = value; } } - public string _Name; + public string _Name = "----"; [DisplayName("Name")] public string Name { get { return _Name; } set { _Name = value; } } - Color _Color = Color.Empty; + Color _Color = Color.Blue; [DisplayName("ColorString")] public string PacketColorString { get { return _Color.Name; } set { _Color = Color.FromName(value); } } public Color PacketColor { get { return _Color; } set { _Color = value; } }