VLANs cannot go on vpns, tunnels, wireless, etc. Start of help

This commit is contained in:
Tim Young 2016-10-11 12:46:29 -05:00
parent 14bcc075a3
commit 077560227a
5 changed files with 51 additions and 3 deletions

View File

@ -51,7 +51,7 @@ namespace EduNetworkBuilder
None, DHCP, DHCPServer, Firewall, Gateway, Help, IPAddress, Link, Subnet, Ping, None, DHCP, DHCPServer, Firewall, Gateway, Help, IPAddress, Link, Subnet, Ping,
VPN, Hub, Switch, ARP, StaticRoute, Subnetting, WhenToSubnet, ComparingAddresses, MACAddress, VPN, Hub, Switch, ARP, StaticRoute, Subnetting, WhenToSubnet, ComparingAddresses, MACAddress,
Network, Packet, NIC, Interface, Router, PacketCorruption, GeneralWireless, WirelessSSID, WirelessKey, Network, Packet, NIC, Interface, Router, PacketCorruption, GeneralWireless, WirelessSSID, WirelessKey,
WirelessAP, WirelessRouter, WirelessRepeater, WirelessBridge WirelessAP, WirelessRouter, WirelessRepeater, WirelessBridge, VLAN
} }
public enum PuzzleNames public enum PuzzleNames
{ {

View File

@ -75,6 +75,17 @@ namespace EduNetworkBuilder
public void SetVLANTag(int id, VLANTagType Tag) public void SetVLANTag(int id, VLANTagType Tag)
{ {
bool foundit = false; bool foundit = false;
Network theNet = NB.GetNetwork();
NetworkDevice ND = theNet.GetDeviceFromID(AttachedToHostNic);
NetworkCard NC = ND.NicFromID(AttachedToHostNic);
NicType NT = NC.GetNicType;
bool isPort = NT == NicType.port;
//Ports (switches) can have multiple tagged ports.
//WAN, ETH0, etc, can only have one tagged or untagged per interface
//nothing can have multiple untagged ports
// If something is untagged, everything else is forbidden
foreach (VLANInfo one in VLANs) foreach (VLANInfo one in VLANs)
{ {
if (one.ID == id) if (one.ID == id)
@ -84,8 +95,10 @@ namespace EduNetworkBuilder
} }
else else
{ {
if (Tag == VLANTagType.Untagged && one.Tag == VLANTagType.Untagged) if (Tag == VLANTagType.Untagged)
one.Tag = VLANTagType.Tagged; one.Tag = VLANTagType.Forbidden;
if (Tag == VLANTagType.Tagged && !isPort) //Ports can have multiple tags on one interface
one.Tag = VLANTagType.Forbidden;
} }
} }
if (!foundit) if (!foundit)

View File

@ -1529,4 +1529,12 @@
<value>Packed forbidden to go out this port</value> <value>Packed forbidden to go out this port</value>
<comment>NI_VLANOut = Packed forbidden to go out this port</comment> <comment>NI_VLANOut = Packed forbidden to go out this port</comment>
</data> </data>
<data name="H_VLAN_Key" xml:space="preserve">
<value>VLANs:</value>
<comment>Text from the help document that we jump to</comment>
</data>
<data name="H_VLAN_Title" xml:space="preserve">
<value>VLANs</value>
<comment>Text used in the program on buttons and the like</comment>
</data>
</root> </root>

View File

@ -50,6 +50,7 @@
this.dgv_VLANAssignments.Size = new System.Drawing.Size(313, 195); this.dgv_VLANAssignments.Size = new System.Drawing.Size(313, 195);
this.dgv_VLANAssignments.TabIndex = 0; this.dgv_VLANAssignments.TabIndex = 0;
this.dgv_VLANAssignments.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgv_VLANAssignments_CellValueChanged); this.dgv_VLANAssignments.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgv_VLANAssignments_CellValueChanged);
this.dgv_VLANAssignments.CurrentCellDirtyStateChanged += new System.EventHandler(this.dgv_VLANAssignments_CurrentCellDirtyStateChanged);
// //
// dgv_VLANNames // dgv_VLANNames
// //

View File

@ -42,6 +42,13 @@ namespace EduNetworkBuilder
processing = true; processing = true;
//Bind the vlan names //Bind the vlan names
Network theNet = NB.GetNetwork(); Network theNet = NB.GetNetwork();
int selectedrow = -1;
int selectedcol = -1;
if (dgv_VLANAssignments.CurrentCell != null)
{
selectedrow = dgv_VLANAssignments.CurrentCell.RowIndex;
selectedcol = dgv_VLANAssignments.CurrentCell.ColumnIndex;
}
//theNet.VlanNames.Sort((x, y) => x.ID.CompareTo(y.ID)); //theNet.VlanNames.Sort((x, y) => x.ID.CompareTo(y.ID));
List<VLANName> tList = theNet.VlanNames.OrderBy(x => x.ID).ToList(); List<VLANName> tList = theNet.VlanNames.OrderBy(x => x.ID).ToList();
@ -65,6 +72,13 @@ namespace EduNetworkBuilder
NetworkCard NIC = TheDevice.NicFromName(oneNic); NetworkCard NIC = TheDevice.NicFromName(oneNic);
if (NIC.GetNicType == NicType.lo) continue; if (NIC.GetNicType == NicType.lo) continue;
if (NIC.GetNicType == NicType.management_interface) continue; if (NIC.GetNicType == NicType.management_interface) continue;
if (NIC.GetNicType == NicType.wport) continue;
if (NIC.GetNicType == NicType.wlan) continue;
if (NIC.GetNicType == NicType.vpn) continue;
if (NIC.GetNicType == NicType.none) continue;
if (NIC.GetNicType == NicType.tun) continue;
for (int i = 0; i < NIC.IFCount; i++) for (int i = 0; i < NIC.IFCount; i++)
{ {
NetworkInterface nif = NIC.GetInterface(i); NetworkInterface nif = NIC.GetInterface(i);
@ -111,6 +125,9 @@ namespace EduNetworkBuilder
int checksize = 50 + 120 + (many * 80) + 25; //the record indicator, and the size of the name. + width of each item int checksize = 50 + 120 + (many * 80) + 25; //the record indicator, and the size of the name. + width of each item
if (Width < checksize) Width = checksize; //Make it fit better if (Width < checksize) Width = checksize; //Make it fit better
processing = false; processing = false;
if (selectedcol >=0 && selectedcol < dgv_VLANAssignments.Columns.Count && selectedrow < dgv_VLANAssignments.Rows.Count)
dgv_VLANAssignments.CurrentCell = dgv_VLANAssignments.Rows[selectedrow].Cells[selectedcol];
} }
bool NamesGridHasID(int id) bool NamesGridHasID(int id)
@ -289,5 +306,14 @@ namespace EduNetworkBuilder
SetIFVLAN(Which, ID, VTT); SetIFVLAN(Which, ID, VTT);
UpdateForm(); UpdateForm();
} }
private void dgv_VLANAssignments_CurrentCellDirtyStateChanged(object sender, EventArgs e)
{
if (dgv_VLANAssignments.IsCurrentCellDirty)
{
// This fires the cell value changed handler below
dgv_VLANAssignments.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
}
} }
} }