1
0
mirror of https://github.com/livingcomputermuseum/ContrAlto.git synced 2026-02-11 18:45:28 +00:00

Fixed clumsy handling of network device selection. Things are more uniform now (at last). Updated readme to include VC++ 2010 redistributable requirement for raw ethernet.

This commit is contained in:
JoshD
2016-07-19 13:07:30 -07:00
parent 5580a8a7a8
commit f8f085464d
6 changed files with 45 additions and 38 deletions

View File

@@ -57,7 +57,7 @@ namespace Contralto.IO
public override string ToString()
{
return Description;
return String.Format("{0} ({1})", Name, Description);
}
public string Name;
@@ -72,26 +72,22 @@ namespace Contralto.IO
/// </summary>
public class HostEthernetEncapsulation : IPacketEncapsulation
{
public HostEthernetEncapsulation(EthernetInterface iface)
{
AttachInterface(iface);
}
public HostEthernetEncapsulation(string name)
{
// Find the specified device by name
List<EthernetInterface> interfaces = EthernetInterface.EnumerateDevices();
foreach (EthernetInterface i in interfaces)
foreach (LivePacketDevice device in LivePacketDevice.AllLocalMachine)
{
if (name == i.Description)
if (device.GetNetworkInterface().Name.ToLowerInvariant() == Configuration.HostPacketInterfaceName.ToLowerInvariant())
{
AttachInterface(i);
return;
AttachInterface(device);
break;
}
}
throw new InvalidOperationException("Specified ethernet interface does not exist or is not compatible with WinPCAP.");
if (_interface == null)
{
throw new InvalidOperationException("Specified ethernet interface does not exist or is not compatible with WinPCAP.");
}
}
public void RegisterReceiveCallback(ReceivePacketDelegate callback)
@@ -205,19 +201,9 @@ namespace Contralto.IO
}
}
private void AttachInterface(EthernetInterface iface)
private void AttachInterface(LivePacketDevice iface)
{
_interface = null;
// Find the specified device by name
foreach (LivePacketDevice device in LivePacketDevice.AllLocalMachine)
{
if (device.Description == iface.Description)
{
_interface = device;
break;
}
}
_interface = iface;
if (_interface == null)
{

View File

@@ -50,7 +50,7 @@ namespace Contralto.IO
IPInterfaceProperties props = null;
foreach(NetworkInterface nic in nics)
{
if (nic.Description == interfaceName)
if (nic.Name == interfaceName)
{
props = nic.GetIPProperties();
break;

View File

@@ -112,7 +112,7 @@ namespace Contralto
}
catch
{
Configuration.HostRawEthernetInterfacesAvailable = false;
Configuration.HostRawEthernetInterfacesAvailable = false;
}
}

View File

@@ -16,6 +16,8 @@
*/
using Contralto.IO;
using PcapDotNet.Core;
using PcapDotNet.Core.Extensions;
using System;
using System.Collections.Generic;
using System.Net.NetworkInformation;
@@ -131,12 +133,10 @@ namespace Contralto.UI
// Add all interfaces that PCAP knows about.
case PacketInterfaceType.EthernetEncapsulation:
{
List<EthernetInterface> ifaces = EthernetInterface.EnumerateDevices();
foreach (EthernetInterface iface in ifaces)
{
EthernetInterfaceListBox.Items.Add(iface);
}
foreach (LivePacketDevice device in LivePacketDevice.AllLocalMachine)
{
EthernetInterfaceListBox.Items.Add(new EthernetInterface(device.GetNetworkInterface().Name, device.GetNetworkInterface().Description));
}
}
break;
@@ -157,7 +157,7 @@ namespace Contralto.UI
{
EthernetInterface iface = (EthernetInterface)EthernetInterfaceListBox.Items[i];
if (iface.Description == Configuration.HostPacketInterfaceName)
if (iface.Name == Configuration.HostPacketInterfaceName)
{
EthernetInterfaceListBox.SelectedIndex = i;
break;
@@ -231,7 +231,7 @@ namespace Contralto.UI
// First warn the user of changes that require a restart.
//
if ((!(String.IsNullOrEmpty(Configuration.HostPacketInterfaceName) && EthernetInterfaceListBox.SelectedIndex == 0) &&
(Configuration.HostPacketInterfaceName != iface.Description ||
(Configuration.HostPacketInterfaceName != iface.Name ||
Configuration.HostPacketInterfaceType != _selectedInterfaceType)) ||
Configuration.SystemType != _selectedSystemType)
{
@@ -243,7 +243,7 @@ namespace Contralto.UI
// Ethernet
Configuration.HostAddress = Convert.ToByte(AltoEthernetAddressTextBox.Text, 8);
Configuration.HostPacketInterfaceName = iface.Description;
Configuration.HostPacketInterfaceName = iface.Name;
Configuration.HostPacketInterfaceType = _selectedInterfaceType;
// Display

View File

@@ -1,4 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is part of ContrAlto.
ContrAlto is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ContrAlto is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ContrAlto. If not, see <http://www.gnu.org/licenses/>.
-->
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">

View File

@@ -245,8 +245,13 @@ encapsulation. ContrAlto can encapsulate the Alto's 3mbit ("experimental")
Ethernet packets in either UDP datagrams or raw Ethernet packets on a network
interface on the "host" computer (the computer running ContrAlto).
Raw packet encapsulation requires WinPCAP to be installed; this can be acquired
from http://www.winpcap.org/.
Raw packet encapsulation requires WinPCAP and the Microsoft Visual C++ 2010
redistributable to be installed; these can be acquired from:
http://www.winpcap.org/
and
http://www.microsoft.com/en-us/download/details.aspx?id=5555
4.2.1 Host Address
------------------