1
0
mirror of https://github.com/livingcomputermuseum/ContrAlto.git synced 2026-02-02 14:51:42 +00:00

Added configuration UI. Implemented ethernet encapsulation over UDP. A few minor tweaks.

This commit is contained in:
Josh Dersch
2016-02-26 17:46:50 -08:00
parent 209dea8052
commit c73fb66dee
30 changed files with 1784 additions and 242 deletions

View File

@@ -1,6 +1,7 @@
using Contralto.CPU;
using Contralto.IO;
using System;
using System.Net;
using System.Collections.Generic;
namespace Contralto
@@ -12,11 +13,9 @@ namespace Contralto
{
// Handle command-line args
PrintHerald();
// See if WinPCap is installed and working
TestPCap();
ParseCommandLine(args);
// See if WinPCap is installed and working
TestPCap();
AltoSystem system = new AltoSystem();
@@ -44,99 +43,7 @@ namespace Contralto
Console.WriteLine("ContrAlto v0.1 (c) 2015, 2016 Living Computer Museum.");
Console.WriteLine("Bug reports to joshd@livingcomputermuseum.org");
Console.WriteLine();
}
private static void ParseCommandLine(string[] args)
{
// At the moment, options start with a "-" and are one of:
// "-hostaddress <address>" : specifies ethernet host address in octal (1-377)
// "-hostinterface <name>" : specifies the name of the host ethernet interface to use
// "-listinterfaces" : lists ethernet interfaces known by pcap
// "-drive0 <image>" : attaches disk image to drive 0
// "-drive1 <image>" : attaches disk image to drive 1
int index = 0;
// TODO: this parsing needs to be made not terrible.
while(index < args.Length)
{
switch (args[index++].ToLower())
{
case "-hostaddress":
if (index < args.Length)
{
Configuration.HostAddress = Convert.ToByte(args[index++], 8);
}
else
{
PrintUsage();
}
break;
case "-hostinterface":
if (index < args.Length)
{
if (!Configuration.HostEthernetAvailable)
{
Console.WriteLine("Ethernet functionality is disabled, host interface cannot be specified.");
}
else
{
Configuration.HostEthernetInterfaceName = args[index++];
}
}
else
{
PrintUsage();
}
break;
case "-listinterfaces":
if (!Configuration.HostEthernetAvailable)
{
Console.WriteLine("Ethernet functionality is disabled, interfaces cannot be enumerated.");
}
else
{
List<EthernetInterface> interfaces = EthernetInterface.EnumerateDevices();
foreach (EthernetInterface i in interfaces)
{
Console.WriteLine("Name: '{0}'\n Description: '{1}'\n MAC '{2}'", i.Name, i.Description, i.MacAddress);
}
}
break;
case "-drive0":
if (index < args.Length)
{
Configuration.Drive0Image = args[index++];
}
else
{
PrintUsage();
}
break;
case "-drive1":
if (index < args.Length)
{
Configuration.Drive1Image = args[index++];
}
else
{
PrintUsage();
}
break;
}
}
}
private static void PrintUsage()
{
// TODO: make more useful.
Console.WriteLine("Something is wrong, try again.");
}
}
private static void TestPCap()
{
@@ -145,7 +52,7 @@ namespace Contralto
try
{
List<EthernetInterface> interfaces = EthernetInterface.EnumerateDevices();
Configuration.HostEthernetAvailable = true;
Configuration.HostRawEthernetInterfacesAvailable = true;
}
catch
{
@@ -153,7 +60,7 @@ namespace Contralto
Console.WriteLine(" Ethernet functionality is disabled.");
Console.WriteLine(" Please install WinPCAP from: http://www.winpcap.org/");
Configuration.HostEthernetAvailable = false;
Configuration.HostRawEthernetInterfacesAvailable = false;
}
}
}