public bool PrepAdapters() { bool reply1 = false; bool reply2 = false; foreach (var nic in IcsManager.GetIPv4EthernetAndWirelessInterfaces()) { if (nic.Id == AModel.Adapter1 || nic.Id == AModel.Adapter2) { if (nic.OperationalStatus == OperationalStatus.Up) { if (nic.Id == AModel.Adapter1) { reply1 = A1Finalize(nic.Name); } if (nic.Id == AModel.Adapter2) { reply2 = A2Finalize(nic.Name); } } else { reply1 = false; reply2 = false; } } } return(reply1 && reply2); }
//shared and home are in the format : nic.id static void EnableICS(string shared, string home, bool force) { var connectionToShare = IcsManager.FindConnectionByIdOrName(shared); if (connectionToShare == null) { Console.WriteLine("Connection not found: {0}", shared); return; } var homeConnection = IcsManager.FindConnectionByIdOrName(home); if (homeConnection == null) { Console.WriteLine("Connection not found: {0}", home); return; } var currentShare = IcsManager.GetCurrentlySharedConnections(); if (currentShare.Exists) { Console.WriteLine("Internet Connection Sharing is already enabled:"); Console.WriteLine(currentShare); if (!force) { Console.WriteLine("Please disable it if you want to configure sharing for other connections"); return; } Console.WriteLine("Sharing will be disabled first."); } IcsManager.ShareConnection(connectionToShare, homeConnection); }
private bool PrepNetworks() { bool reply1 = false; bool reply2 = false; bool reply = false; var someException = new System.Exception(); String SharedAdap = ""; foreach (var nic in IcsManager.GetIPv4EthernetAndWirelessInterfaces()) { if (nic.Id == AModel.Adapter1 || nic.Id == AModel.Adapter2) { if (nic.OperationalStatus == OperationalStatus.Up) { if (nic.Id == AModel.Adapter1) { reply1 = true; } if (nic.Id == AModel.Adapter2) { reply2 = true; } try { String netResp = IdToNetworkPrivatise(nic.Id); if (netResp == "No Network") { throw someException; } } catch { if (reply1) { reply1 = false; } if (reply2) { reply2 = false; } } } else { // this adapter is down???? } } else { //found Shared/Internet network if (nic.OperationalStatus == OperationalStatus.Up) { SharedAdap = nic.Id; } } } if (reply1 && reply2 && SharedAdap != "") { EnableICS(SharedAdap, AModel.Adapter1, true); } return(reply1 && reply2); }