Finally got bastard Intel PXE ROM to acknowledge us....

This commit is contained in:
kudzu_cp 2012-06-23 07:14:19 +00:00
parent 19a59962eb
commit 8a477f4f31
2 changed files with 17 additions and 10 deletions

View file

@ -30,25 +30,28 @@ namespace Cosmos.Deploy.Pixie {
xOut.YourAddr = BitConverter.ToUInt32(new byte[] { 192, 168, 42, 2 }, 0); xOut.YourAddr = BitConverter.ToUInt32(new byte[] { 192, 168, 42, 2 }, 0);
xOut.ServerAddr = BitConverter.ToUInt32(new byte[] { 192, 168, 42, 1 }, 0); xOut.ServerAddr = BitConverter.ToUInt32(new byte[] { 192, 168, 42, 1 }, 0);
xOut.HwAddr = xIn.HwAddr; xOut.HwAddr = xIn.HwAddr;
xOut.Flags = xIn.Flags;
xOut.Msg = DhcpPacket.MsgType.Offer; xOut.Msg = DhcpPacket.MsgType.Offer;
xOut.Options.Add(1, new byte[] { 255, 255, 255, 0 }); xOut.Options.Add(1, new byte[] { 255, 255, 255, 0 });
xOut.Options.Add(51, new byte[] { 0, 0, 255, 255 }); xOut.Options.Add(51, new byte[] { 0, 0, 255, 255 });
xOut.Options.Add(54, new byte[] { 192, 168, 42, 1 }); xOut.Options.Add(54, new byte[] { 192, 168, 42, 1 });
xOut.Options.Add(13, new byte[] { 4, 255 });
var xOutBytes = xOut.GetBytes(); var xOutBytes = xOut.GetBytes();
var xBroadcastIP = new IPAddress(new byte[] { 192, 168, 42, 255 }); var xBroadcastIP = new IPAddress(new byte[] { 192, 168, 42, 255 });
mUDP.Send(xOutBytes, xOutBytes.Length, new IPEndPoint(xBroadcastIP, 68)); mUDP.Send(xOutBytes, xOutBytes.Length, new IPEndPoint(IPAddress.Broadcast, 68));
while (true) { while (true) {
xData = mUDP.Receive(ref xEndpoint); xData = mUDP.Receive(ref xEndpoint);
xIn = new DhcpPacket(xData); xIn = new DhcpPacket(xData);
if (xIn.Msg != DhcpPacket.MsgType.Discover) { if (xIn.Msg == DhcpPacket.MsgType.Discover) {
int i = 0; break;
} } else if (xIn.Msg != DhcpPacket.MsgType.Request) {
if (xIn.Msg != DhcpPacket.MsgType.Request) { throw new Exception("Unexpected DHCP message.")
//throw new Exception("Expected Request");
} }
} }
} }
} }

View file

@ -27,8 +27,7 @@ namespace Cosmos.Deploy.Pixie {
//secs 2 filled in by client, seconds elapsed since client started trying to boot. //secs 2 filled in by client, seconds elapsed since client started trying to boot.
xReader.ReadUInt16(); xReader.ReadUInt16();
//flags 2 Flags = xReader.ReadUInt16();
xReader.ReadUInt16();
// Dont reverse IP Addresses, byte arrays end up big endian as we write them back // Dont reverse IP Addresses, byte arrays end up big endian as we write them back
ClientAddr = xReader.ReadUInt32(); ClientAddr = xReader.ReadUInt32();
@ -83,14 +82,18 @@ namespace Cosmos.Deploy.Pixie {
xWriter.Write((byte)0); xWriter.Write((byte)0);
xWriter.Write(TxID); xWriter.Write(TxID);
xWriter.Write(0); xWriter.Write((UInt16)0);
xWriter.Write(Flags);
xWriter.Write(0); xWriter.Write(0);
xWriter.Write(YourAddr); xWriter.Write(YourAddr);
xWriter.Write(ServerAddr); xWriter.Write(ServerAddr);
xWriter.Write(0); xWriter.Write(0);
xWriter.Write(HwAddr); xWriter.Write(HwAddr);
xWriter.Write(new byte[64]); xWriter.Write(new byte[64]);
xWriter.Write(new byte[128]);
xWriter.Write(ASCIIEncoding.ASCII.GetBytes("TEST"));
xWriter.Write(new byte[124]);
xWriter.Write(mMagicCookie); xWriter.Write(mMagicCookie);
xWriter.Write((byte)53); xWriter.Write((byte)53);
@ -120,6 +123,7 @@ namespace Cosmos.Deploy.Pixie {
public byte HwLength; public byte HwLength;
public byte Hops; public byte Hops;
public UInt32 TxID; public UInt32 TxID;
public UInt16 Flags;
public UInt32 ClientAddr; public UInt32 ClientAddr;
public UInt32 YourAddr; public UInt32 YourAddr;
public UInt32 ServerAddr; public UInt32 ServerAddr;