public Stack(OptionNetworkInterface aOption) { iStatus = new StackStatus(EStackState.eStopped, null); iStackStarted = false; iInterface = null; iOption = aOption; iOption.EventValueChanged += InterfaceChanged; }
public Helper(string[] aArgs) { iAssemblyAttributes = Linn.AssemblyInfo.GetAssemblyInfo(); iLock = new object(); iErrorThrown = false; // create the data and exe paths iDataPath = SystemInfo.DataPathForApp(Title); if (!iDataPath.Exists) { try { iDataPath.Create(); } catch (IOException e) { Console.WriteLine(e.Message + "\n"); } } iExePath = SystemInfo.ExePathForApp(Title); // add the unhandled exception handler - this should catch all unhandled // exceptions in all threads #if !DEBUG && !TRACE AppDomain.CurrentDomain.UnhandledException += UnhandledException; #endif // initialise crash log dumpers iCrashLogDumpers = new List <ICrashLogDumper>(); iCrashLogDumpers.Add(new CrashLogDumperStdout()); // only add 1 crash file for several instances of the app string[] filenames = System.IO.Directory.GetFiles(".", "*.crash"); if (filenames.Length == 0) { string exeNoExt = Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName); string crashFile = Path.Combine(iDataPath.FullName, exeNoExt) + ".crash"; iCrashLogDumpers.Add(new CrashLogDumperFile(crashFile)); } // add trace listeners Trace.AddListener(new TraceListenerConsole()); // remove unused log files filenames = System.IO.Directory.GetFiles(iDataPath.FullName, "*.log"); foreach (string file in filenames) { try { // delete the file and ignore exceptions - file may be in use File.Delete(file); } catch (IOException) { } } iTraceFile = new TraceListenerFile(iDataPath.FullName); Trace.AddListener(iTraceFile); // add user log listener try { iUserLogFile = new UserLogFile(iDataPath.FullName); UserLog.AddListener(iUserLogFile); } catch (IOException) { } UserLog.WriteLine(Product + " v" + Version + " (" + Family + ")"); // log the mono version if being used Type t = Type.GetType("Mono.Runtime"); if (t != null) { MethodInfo displayName = t.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); if (displayName != null) { UserLog.WriteLine("Mono Version: " + displayName.Invoke(null, null)); } } // create option parser iOptionParser = new OptionParser(aArgs); iOptionParser.Usage = "usage: " + Title; // add the trace level option iOptionTraceLevel = new OptionParser.OptionString("-t", "--tracelevel", "kNone", "Set the trace level for the application. Multiple levels specified in quotes.", "LEVEL1 [LEVEL2 LEVEL3 ...]"); iOptionParser.AddOption(iOptionTraceLevel); iOptionNic = new OptionParser.OptionString("-i", "--interface", "0.0.0.0", "Sets the interface to bind to", "INTERFACE"); iOptionParser.AddOption(iOptionNic); ServicePointManager.DefaultConnectionLimit = 50; ServicePointManager.UseNagleAlgorithm = false; ServicePointManager.Expect100Continue = false; iOptionPages = new List <IOptionPage>(); iOptionManager = new OptionManager(Path.Combine(iDataPath.FullName, "Options.xml")); iOptionPage = new OptionPage("Network"); iOptionNetworkInterface = new OptionNetworkInterface("interface"); iOptionPage.Add(iOptionNetworkInterface); // create the network stack iStack = new Stack(iOptionNetworkInterface); }