protected DhcpPacket SendOffer(DhcpPacket aDiscover) { var xOut = new DhcpPacket(); xOut.Op = DhcpPacket.OpType.Reply; xOut.TxID = aDiscover.TxID; xOut.YourAddr = BitConverter.ToUInt32(mClientIP, 0); xOut.ServerAddr = BitConverter.ToUInt32(mServerIP, 0); xOut.HwAddr = aDiscover.HwAddr; xOut.Flags = aDiscover.Flags; xOut.Msg = DhcpPacket.MsgType.Offer; xOut.Options.Add(1, new byte[] { 255, 255, 255, 0 }); xOut.Options.Add(54, mServerIP); xOut.AddTextOption(60, "PXEClient"); xOut.BootFile = Path.GetFileName(mBootFile); var xFileInfo = new FileInfo(mBootFile); byte xBlockCount = (byte)(xFileInfo.Length / 512); xOut.Options.Add(13, new byte[] { 0, xBlockCount }); Send(xOut); return(xOut); }
protected DhcpPacket Receive(DhcpPacket.MsgType aWaitFor) { while (true) { var xData = mUDP.Receive(ref mRecvEndPoint); var xPacket = new DhcpPacket(xData); if (xPacket.Msg == aWaitFor) { return xPacket; } } }
protected DhcpPacket Receive(DhcpPacket.MsgType aWaitFor) { while (true) { var xData = mUDP.Receive(ref mRecvEndPoint); var xPacket = new DhcpPacket(xData); if (xPacket.Msg == aWaitFor) { return(xPacket); } } }
protected DhcpPacket SendOffer(DhcpPacket aDiscover) { var xOut = new DhcpPacket(); xOut.Op = DhcpPacket.OpType.Reply; xOut.TxID = aDiscover.TxID; xOut.YourAddr = BitConverter.ToUInt32(mClientIP, 0); xOut.ServerAddr = BitConverter.ToUInt32(mServerIP, 0); xOut.HwAddr = aDiscover.HwAddr; xOut.Flags = aDiscover.Flags; xOut.Msg = DhcpPacket.MsgType.Offer; xOut.Options.Add(1, new byte[] { 255, 255, 255, 0 }); xOut.Options.Add(54, mServerIP); xOut.AddTextOption(60, "PXEClient"); xOut.BootFile = Path.GetFileName(mBootFile); var xFileInfo = new FileInfo(mBootFile); byte xBlockCount = (byte)(xFileInfo.Length / 512); xOut.Options.Add(13, new byte[] { 0, xBlockCount }); Send(xOut); return xOut; }
protected DhcpPacket SendAck(DhcpPacket aDiscover, DhcpPacket aRequest) { aDiscover.Msg = DhcpPacket.MsgType.Ack; Send(aDiscover); return(aDiscover); }
protected void Send(DhcpPacket aPacket) { var xBytes = aPacket.GetBytes(); mUDP.Send(xBytes, xBytes.Length, new IPEndPoint(IPAddress.Broadcast, 68)); }
protected DhcpPacket SendAck(DhcpPacket aDiscover, DhcpPacket aRequest) { aDiscover.Msg = DhcpPacket.MsgType.Ack; Send(aDiscover); return aDiscover; }
protected void Send(DhcpPacket aPacket) { var xBytes = aPacket.GetBytes(); mUDP.Send(xBytes, xBytes.Length, new IPEndPoint(IPAddress.Broadcast, 68)); }