mirror of
https://github.com/livingcomputermuseum/IFS.git
synced 2026-03-10 12:48:10 +00:00
Changed endian-ness to match 3mbit bridge. (Similar changes also made to ContrAlto)
This commit is contained in:
@@ -46,12 +46,14 @@
|
||||
1007 trek.boot
|
||||
1010 invaders.boot
|
||||
1011 astroroids.boot
|
||||
1012 astroroids.boot
|
||||
1012 1012.boot
|
||||
1013 clock.boot
|
||||
1014 galaxian.boot
|
||||
1015 ppong.boot
|
||||
1016 1006.boot
|
||||
1017 messenger.boot
|
||||
1020 reversi.boot
|
||||
1021 1000.boot
|
||||
1023 missilecommand.boot
|
||||
40000 boggs.boot
|
||||
40002 murray.boot
|
||||
|
||||
@@ -92,10 +92,7 @@ namespace IFS.Transport
|
||||
encapsulatedFrame[5] = (byte)_pupFrameType;
|
||||
|
||||
// Actual data
|
||||
p.RawData.CopyTo(encapsulatedFrame, 6);
|
||||
|
||||
// Byte swap
|
||||
encapsulatedFrame = ByteSwap(encapsulatedFrame);
|
||||
p.RawData.CopyTo(encapsulatedFrame, 6);
|
||||
|
||||
MacAddress destinationMac = _pupToEthernetMap[p.DestinationPort.Host];
|
||||
|
||||
@@ -148,7 +145,7 @@ namespace IFS.Transport
|
||||
data.CopyTo(encapsulatedFrame, 6);
|
||||
|
||||
// Byte swap
|
||||
encapsulatedFrame = ByteSwap(encapsulatedFrame);
|
||||
// encapsulatedFrame = ByteSwap(encapsulatedFrame);
|
||||
|
||||
MacAddress destinationMac;
|
||||
if (destination != 0xff)
|
||||
@@ -199,8 +196,8 @@ namespace IFS.Transport
|
||||
// Filter out encapsulated 3mbit frames and look for PUPs, forward them on.
|
||||
//
|
||||
if ((int)p.Ethernet.EtherType == _3mbitFrameType)
|
||||
{
|
||||
MemoryStream packetStream = ByteSwap(p.Ethernet.Payload.ToMemoryStream());
|
||||
{
|
||||
MemoryStream packetStream = p.Ethernet.Payload.ToMemoryStream();
|
||||
|
||||
// Read the length prefix (in words), convert to bytes.
|
||||
// Subtract off 2 words for the ethernet header
|
||||
@@ -310,37 +307,7 @@ namespace IFS.Transport
|
||||
_pupToEthernetMap.Add(p.SourcePort.Host, e.Ethernet.Source);
|
||||
_ethernetToPupMap.Add(e.Ethernet.Source, p.SourcePort.Host);
|
||||
}
|
||||
}
|
||||
|
||||
private MemoryStream ByteSwap(MemoryStream input)
|
||||
{
|
||||
byte[] buffer = new byte[input.Length];
|
||||
|
||||
input.Read(buffer, 0, buffer.Length);
|
||||
|
||||
for(int i=0;i<buffer.Length;i+=2)
|
||||
{
|
||||
byte temp = buffer[i];
|
||||
buffer[i] = buffer[i + 1];
|
||||
buffer[i + 1] = temp;
|
||||
}
|
||||
|
||||
input.Position = 0;
|
||||
|
||||
return new MemoryStream(buffer);
|
||||
}
|
||||
|
||||
private byte[] ByteSwap(byte[] input)
|
||||
{
|
||||
for (int i = 0; i < input.Length; i += 2)
|
||||
{
|
||||
byte temp = input[i];
|
||||
input[i] = input[i + 1];
|
||||
input[i + 1] = temp;
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PUP<->Ethernet address map
|
||||
|
||||
@@ -23,8 +23,7 @@ namespace IFS.Transport
|
||||
_udpClient = new UdpClient(_udpPort, AddressFamily.InterNetwork);
|
||||
_udpClient.Client.Blocking = true;
|
||||
_udpClient.EnableBroadcast = true;
|
||||
_udpClient.MulticastLoopback = false;
|
||||
|
||||
_udpClient.MulticastLoopback = false;
|
||||
|
||||
//
|
||||
// Grab the broadcast address for the interface so that we know what broadcast address to use
|
||||
@@ -116,10 +115,7 @@ namespace IFS.Transport
|
||||
encapsulatedFrame[5] = (byte)_pupFrameType;
|
||||
|
||||
// Actual data
|
||||
p.RawData.CopyTo(encapsulatedFrame, 6);
|
||||
|
||||
// Byte swap
|
||||
encapsulatedFrame = ByteSwap(encapsulatedFrame);
|
||||
p.RawData.CopyTo(encapsulatedFrame, 6);
|
||||
|
||||
// Send as UDP broadcast.
|
||||
// TODO: this could be done without broadcasts if we kept a table mapping IPs to 3mbit MACs.
|
||||
@@ -152,10 +148,7 @@ namespace IFS.Transport
|
||||
encapsulatedFrame[5] = (byte)frameType;
|
||||
|
||||
// Actual data
|
||||
data.CopyTo(encapsulatedFrame, 6);
|
||||
|
||||
// Byte swap
|
||||
encapsulatedFrame = ByteSwap(encapsulatedFrame);
|
||||
data.CopyTo(encapsulatedFrame, 6);
|
||||
|
||||
// Send as UDP broadcast.
|
||||
// TODO: this could be done without broadcasts if we kept a table mapping IPs to 3mbit MACs.
|
||||
@@ -231,7 +224,7 @@ namespace IFS.Transport
|
||||
// Drop our own UDP packets.
|
||||
if (!groupEndPoint.Address.Equals(_thisIPAddress))
|
||||
{
|
||||
Receive(ByteSwap(new System.IO.MemoryStream(data)));
|
||||
Receive(new System.IO.MemoryStream(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,37 +242,7 @@ namespace IFS.Transport
|
||||
}
|
||||
|
||||
return new IPAddress(broadcastAddress);
|
||||
}
|
||||
|
||||
private MemoryStream ByteSwap(MemoryStream input)
|
||||
{
|
||||
byte[] buffer = new byte[input.Length];
|
||||
|
||||
input.Read(buffer, 0, buffer.Length);
|
||||
|
||||
for (int i = 0; i < buffer.Length; i += 2)
|
||||
{
|
||||
byte temp = buffer[i];
|
||||
buffer[i] = buffer[i + 1];
|
||||
buffer[i + 1] = temp;
|
||||
}
|
||||
|
||||
input.Position = 0;
|
||||
|
||||
return new MemoryStream(buffer);
|
||||
}
|
||||
|
||||
private byte[] ByteSwap(byte[] input)
|
||||
{
|
||||
for (int i = 0; i < input.Length; i += 2)
|
||||
{
|
||||
byte temp = input[i];
|
||||
input[i] = input[i + 1];
|
||||
input[i + 1] = temp;
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
// The ethertype used in the encapsulated 3mbit frame
|
||||
private readonly ushort _pupFrameType = 512;
|
||||
|
||||
Reference in New Issue
Block a user