mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-20 04:48:53 +00:00
Finally got bastard Intel PXE ROM to acknowledge us....
This commit is contained in:
parent
19a59962eb
commit
8a477f4f31
2 changed files with 17 additions and 10 deletions
|
|
@ -30,25 +30,28 @@ namespace Cosmos.Deploy.Pixie {
|
|||
xOut.YourAddr = BitConverter.ToUInt32(new byte[] { 192, 168, 42, 2 }, 0);
|
||||
xOut.ServerAddr = BitConverter.ToUInt32(new byte[] { 192, 168, 42, 1 }, 0);
|
||||
xOut.HwAddr = xIn.HwAddr;
|
||||
xOut.Flags = xIn.Flags;
|
||||
xOut.Msg = DhcpPacket.MsgType.Offer;
|
||||
xOut.Options.Add(1, new byte[] { 255, 255, 255, 0 });
|
||||
xOut.Options.Add(51, new byte[] { 0, 0, 255, 255 });
|
||||
xOut.Options.Add(54, new byte[] { 192, 168, 42, 1 });
|
||||
xOut.Options.Add(13, new byte[] { 4, 255 });
|
||||
|
||||
var xOutBytes = xOut.GetBytes();
|
||||
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) {
|
||||
xData = mUDP.Receive(ref xEndpoint);
|
||||
xIn = new DhcpPacket(xData);
|
||||
if (xIn.Msg != DhcpPacket.MsgType.Discover) {
|
||||
int i = 0;
|
||||
}
|
||||
if (xIn.Msg != DhcpPacket.MsgType.Request) {
|
||||
//throw new Exception("Expected Request");
|
||||
if (xIn.Msg == DhcpPacket.MsgType.Discover) {
|
||||
break;
|
||||
} else if (xIn.Msg != DhcpPacket.MsgType.Request) {
|
||||
throw new Exception("Unexpected DHCP message.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,7 @@ namespace Cosmos.Deploy.Pixie {
|
|||
|
||||
//secs 2 filled in by client, seconds elapsed since client started trying to boot.
|
||||
xReader.ReadUInt16();
|
||||
//flags 2
|
||||
xReader.ReadUInt16();
|
||||
Flags = xReader.ReadUInt16();
|
||||
|
||||
// Dont reverse IP Addresses, byte arrays end up big endian as we write them back
|
||||
ClientAddr = xReader.ReadUInt32();
|
||||
|
|
@ -83,14 +82,18 @@ namespace Cosmos.Deploy.Pixie {
|
|||
xWriter.Write((byte)0);
|
||||
|
||||
xWriter.Write(TxID);
|
||||
xWriter.Write(0);
|
||||
xWriter.Write((UInt16)0);
|
||||
xWriter.Write(Flags);
|
||||
xWriter.Write(0);
|
||||
xWriter.Write(YourAddr);
|
||||
xWriter.Write(ServerAddr);
|
||||
xWriter.Write(0);
|
||||
xWriter.Write(HwAddr);
|
||||
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((byte)53);
|
||||
|
|
@ -120,6 +123,7 @@ namespace Cosmos.Deploy.Pixie {
|
|||
public byte HwLength;
|
||||
public byte Hops;
|
||||
public UInt32 TxID;
|
||||
public UInt16 Flags;
|
||||
public UInt32 ClientAddr;
|
||||
public UInt32 YourAddr;
|
||||
public UInt32 ServerAddr;
|
||||
|
|
|
|||
Loading…
Reference in a new issue