From 8ab872589c35bffcf73ba71e2f880f351c02e92b Mon Sep 17 00:00:00 2001 From: femsci Date: Wed, 14 Jun 2023 22:25:27 +0200 Subject: [PATCH] Fix bootp migration --- src/IPMeow.Dhcp/Server/Dhcp4/Bootp.cs | 8 ++++---- src/IPMeow.Dhcp/Server/Dhcp4/DhcpServer.cs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/IPMeow.Dhcp/Server/Dhcp4/Bootp.cs b/src/IPMeow.Dhcp/Server/Dhcp4/Bootp.cs index d500d85..1f4ff59 100644 --- a/src/IPMeow.Dhcp/Server/Dhcp4/Bootp.cs +++ b/src/IPMeow.Dhcp/Server/Dhcp4/Bootp.cs @@ -5,6 +5,7 @@ using System.Net; using System.Text; using System.Threading.Tasks; using IPMeow.Lib; +using IPMeow.Lib.Address; namespace IPMeow.Dhcp.Server.Dhcp4; @@ -31,7 +32,7 @@ public class BootpHeader public override string ToString() { - return $"{Hops}\nXid: {Xid}, Seconds: {Seconds}, Flags: {Flags:x}\nci: {ClientAddress}\nyi: {YourAddress}, ns: {NextServerAddress}, ra: {RelayAgentAddress}\nhw: {MacAddress.Parse(GetMacAddress())}\nhost: {ServerHostName}\nboot: {BootFileName}"; + return $"{Hops}\nXid: {Xid}, Seconds: {Seconds}, Flags: {Flags:x}\nci: {ClientAddress}\nyi: {YourAddress}, ns: {NextServerAddress}, ra: {RelayAgentAddress}\nhw: {MacAddress.Parse(GetMacAddress())}"; } public byte[] GetClientHwAddress() @@ -110,7 +111,7 @@ public class BootpHeader using MemoryStream buffer = new(); BinaryWriter writer = new(buffer); - writer.Write((byte)); + writer.Write((byte)OpType); writer.Write((byte)1); writer.Write((byte)6); writer.Write(Hops); @@ -122,8 +123,7 @@ public class BootpHeader writer.Write(NextServerAddress.GetAddressBytes()); writer.Write(RelayAgentAddress.GetAddressBytes()); writer.Write(GetClientHwAddress()); - writer.Write(GetSnameBytes()); - writer.Write(GetBootFileBytes()); + writer.Write(Enumerable.Repeat((byte)0, 64 + 128).ToArray()); return buffer.GetBuffer(); } diff --git a/src/IPMeow.Dhcp/Server/Dhcp4/DhcpServer.cs b/src/IPMeow.Dhcp/Server/Dhcp4/DhcpServer.cs index 325e0ac..893e504 100644 --- a/src/IPMeow.Dhcp/Server/Dhcp4/DhcpServer.cs +++ b/src/IPMeow.Dhcp/Server/Dhcp4/DhcpServer.cs @@ -49,8 +49,8 @@ public class Dhcp4Server : IDhcpServer, IDisposable DhcpRequestedEvent.Invoke(this, new() { IsV6 = false, - MacAddress = MacAddress.Parse(packet.GetMacAddress()), - RequestOrigin = packet.ClientAddress + MacAddress = MacAddress.Parse(packet.Header.GetMacAddress()), + RequestOrigin = packet.Header.ClientAddress }); //TODO } @@ -71,7 +71,7 @@ public class Dhcp4Server : IDhcpServer, IDisposable return false; } - if (packet.NextServerAddress != IPAddress.Any) + if (packet.Header.NextServerAddress != IPAddress.Any) { return false; }