1
0
mirror of https://github.com/livingcomputermuseum/IFS.git synced 2026-02-12 02:49:04 +00:00
Files
livingcomputermuseum.IFS/PUP/Boot/BreathOfLife.cs
2016-02-15 11:01:23 -08:00

96 lines
5.2 KiB
C#

using IFS.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace IFS
{
/// <summary>
/// Implements the BreathOfLife services.
/// It spins up a worker thread that wakes up every few seconds and broadcasts
/// a BreathOfLife packet.
/// </summary>
public class BreathOfLife
{
public BreathOfLife()
{
Log.Write(LogType.Verbose, LogComponent.BreathOfLife, "Breath Of Life service starting. Broadcast interval is {0} milliseconds.", _bolPacketDelay);
_bolThread = new Thread(BreathOfLifeThread);
_bolThread.Start();
}
private void BreathOfLifeThread()
{
while (true)
{
//
// Send BOL
//
PUPProtocolDispatcher.Instance.Send(_bolPacket, DirectoryServices.Instance.LocalHost, _bolAddress, _bolPacketType);
Log.Write(LogType.Verbose, LogComponent.BreathOfLife, "Breath Of Life packet sent.");
//
// Go to sleep.
//
Thread.Sleep(_bolPacketDelay);
//
// That's it. Go home, do it again.
//
}
}
private Thread _bolThread;
private const ushort _bolPacketType = 0x182; // 602B
private const byte _bolAddress = 0xff; // 377B (boot address)
private const int _bolPacketDelay = 5000; // 5 seconds
/// <summary>
/// The gold-standard BOL packet, containing the Alto ethernet bootstrap code.
/// Note that this does not contain padding for the ethernet header, the dispatcher adds those two words.
/// </summary>
private byte[] _bolPacket =
{
0x25, 0x7c, 0x80, 0x00, 0x41, 0x1f, 0x84, 0x00, 0x39, 0x19, 0xe8, 0x00,
0x62, 0x05, 0x85, 0x30, 0x29, 0x77, 0x39, 0x7a, 0x62, 0x06, 0x29, 0x75, 0x39, 0x78, 0x62, 0x06,
0x29, 0x74, 0x39, 0x76, 0x62, 0x06, 0x21, 0x75, 0x39, 0x75, 0x62, 0x05, 0xaa, 0x90, 0x4d, 0x7b,
0x21, 0x7e, 0x62, 0x04, 0xa7, 0x00, 0x31, 0x69, 0x42, 0x89, 0x09, 0x0e, 0x00, 0x00, 0x02, 0x00,
0x00, 0x16, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
0x00, 0x00, 0x00, 0x10, 0xff, 0xff, 0x5a, 0x88, 0x2b, 0x00, 0x8e, 0x00, 0x4b, 0x00, 0x43, 0x09,
0x21, 0x67, 0x42, 0x87, 0x21, 0x64, 0x62, 0x04, 0x0d, 0x59, 0x39, 0x4f, 0x31, 0x64, 0x53, 0x86,
0x21, 0x48, 0x43, 0x85, 0x45, 0x56, 0x85, 0x30, 0x43, 0x81, 0x21, 0x58, 0x62, 0x04, 0x23, 0x81,
0x82, 0x0c, 0x01, 0x0c, 0x62, 0x10, 0x19, 0xdf, 0x01, 0xfb, 0x19, 0x4f, 0x01, 0xec, 0x21, 0x4f,
0x62, 0x04, 0x31, 0x02, 0x05, 0x02, 0x00, 0x00, 0x01, 0xda, 0x39, 0x4c, 0xe5, 0x0c, 0x01, 0xe6,
0x22, 0x01, 0x29, 0x49, 0x8d, 0x0c, 0x01, 0xe2, 0x22, 0x03, 0xe7, 0x00, 0x3a, 0x05, 0x29, 0x41,
0x8d, 0x0d, 0xfa, 0x0c, 0x01, 0xdb, 0x22, 0x00, 0x45, 0x35, 0x39, 0x2f, 0x5d, 0x25, 0x5b, 0xfd,
0x5b, 0xfe, 0x82, 0xc0, 0x43, 0x00, 0x21, 0x37, 0x43, 0x01, 0x21, 0x1a, 0x43, 0x02, 0xa3, 0x00,
0x43, 0x03, 0x22, 0x06, 0x43, 0x09, 0x22, 0x07, 0x43, 0x0a, 0x22, 0x08, 0x43, 0x0b, 0x22, 0x09,
0x43, 0x06, 0x22, 0x0a, 0x43, 0x07, 0x22, 0x0b, 0x43, 0x08, 0x1b, 0x0c, 0x0d, 0x17, 0x15, 0x1c,
0x0d, 0x16, 0x21, 0x11, 0x29, 0x1f, 0xb8, 0x00, 0x31, 0x0f, 0x05, 0x12, 0xfe, 0x1d, 0x00, 0x16,
0x01, 0x0d, 0x01, 0x17, 0x01, 0x77, 0x01, 0x87, 0x01, 0xff, 0xff, 0xe9, 0xff, 0xa1, 0xff, 0x80,
0x00, 0x95, 0xff, 0x94, 0x02, 0x0b, 0x01, 0xf4, 0x01, 0x19, 0x01, 0xca, 0x01, 0x9c, 0x01, 0xdd,
0x01, 0x89, 0x01, 0x77, 0x01, 0x74, 0x01, 0x76, 0x00, 0x1e, 0x00, 0x02, 0x00, 0x03, 0x00, 0x0d,
0x00, 0x18, 0x00, 0xff, 0x02, 0x00, 0xff, 0xf4, 0x01, 0x1e, 0x59, 0xd9, 0x51, 0xe8, 0x21, 0xeb,
0x41, 0xe5, 0x85, 0x30, 0x41, 0xdf, 0x21, 0xf2, 0x62, 0x04, 0x21, 0xdc, 0x8a, 0xc4, 0x01, 0x06,
0x21, 0xe3, 0x82, 0x0c, 0x19, 0xe1, 0x01, 0xfa, 0x05, 0xca, 0x39, 0xec, 0xef, 0xc0, 0x9d, 0x0d,
0x29, 0xea, 0x22, 0x01, 0x8d, 0x0c, 0x01, 0xec, 0x22, 0x00, 0x29, 0xc3, 0x8d, 0x0c, 0x01, 0xe8,
0x22, 0x03, 0xe7, 0x00, 0x29, 0xde, 0x8d, 0x05, 0x01, 0x04, 0xa3, 0x00, 0x83, 0x04, 0x01, 0xe0,
0x49, 0xcc, 0x22, 0x05, 0x45, 0xda, 0x29, 0xb4, 0xa5, 0x05, 0x01, 0x04, 0x83, 0x05, 0x09, 0x04,
0x01, 0xd7, 0x11, 0xae, 0x39, 0xac, 0x29, 0x03, 0xa1, 0x40, 0x83, 0x04, 0x01, 0xff, 0x41, 0xb2,
0x41, 0xb4, 0x41, 0xb4, 0x85, 0x50, 0x62, 0x04, 0x21, 0xad, 0x82, 0x0d, 0x01, 0xfe, 0x8d, 0x0d,
0x03, 0x00, 0x19, 0x9c, 0x01, 0xf1, 0x21, 0xbb, 0x62, 0x04, 0x01, 0x00, 0x62, 0x05, 0x84, 0x00,
0xc6, 0x00, 0x39, 0xba, 0x29, 0xb7, 0xed, 0x00, 0x62, 0x05, 0x09, 0xb8, 0x21, 0xb3, 0x39, 0xb4,
0xe8, 0x00, 0xce, 0x00, 0x62, 0x05, 0x29, 0xf2, 0xb5, 0x0c, 0xb6, 0x00, 0x21, 0x9e, 0x39, 0x0e,
0x82, 0x0d, 0xdd, 0x0d, 0xb2, 0x01, 0x01, 0xec, 0x29, 0xa3, 0x49, 0x95, 0x82, 0x0d, 0x01, 0xe8,
0x19, 0x93, 0x09, 0xa4, 0x21, 0x9c, 0x62, 0x04, 0x04, 0x00, 0xfd, 0xf4, 0x03, 0x01, 0x42, 0x02,
};
}
}