public override bool PreProcess() { if (!base.PreProcess()) { return(false); } DhcpV6ServerIdOption requestedServerIdOption = requestMsg.GetDhcpServerIdOption(); if ((requestedServerIdOption == null)) { log.Warn(("Ignoring Decline message: " + "Requested ServerId option is null")); return(false); } if (!dhcpServerIdOption.Equals(requestedServerIdOption)) { log.Warn(("Ignoring Decline message: " + ("Requested ServerId: " + (requestedServerIdOption + ("My ServerId: " + dhcpServerIdOption))))); return(false); } if ((requestMsg.GetDhcpClientIdOption() == null)) { log.Warn(("Ignoring Decline message: " + "ClientId option is null")); return(false); } return(true); }
private static void V6Release() { DhcpV6Message msg = new DhcpV6Message(IPAddress.Any, new IPEndPoint(serverAddr, serverPort)); msg.SetTransactionId(-1729018559); DhcpV6ClientIdOption dhcpClientId = new DhcpV6ClientIdOption(); dhcpClientId.GetOpaqueData().SetAscii("000100011dd31327001dbac1557b"); msg.PutDhcpOption(dhcpClientId); DhcpV6ServerIdOption dhcpServerId = new DhcpV6ServerIdOption(); dhcpServerId.GetOpaqueData().SetAscii("000100011dd31327001dbac1557b"); msg.PutDhcpOption(dhcpServerId); msg.SetMessageType(DhcpConstants.V6MESSAGE_TYPE_RELEASE); msg.SetIaNaOptions(new List <DhcpV6IaNaOption>() { new DhcpV6IaNaOption(new v6IaNaOption() { iaId = 285220282, t1 = 0, t2 = 0 }) }); var message = DhcpV6MessageHandler.HandleMessage( serverAddr, msg); Console.WriteLine(message.ToString()); }
public DhcpV6ServerIdOption GetDhcpServerIdOption() { if (this.dhcpServerIdOption == null) { if (this.dhcpOptions != null) { this.dhcpServerIdOption = (DhcpV6ServerIdOption)dhcpOptions.Get(DhcpConstants.V6OPTION_SERVERID); } } return(this.dhcpServerIdOption); }
public override bool PreProcess() { if (!base.PreProcess()) { return(false); } // this check enforced by TAHI DHCP server tests if (requestMsg.IsUnicast()) { log.Warn("Ignoring unicast InfoRequest Message"); return(false); } // if the client provided a ServerID option, then it MUST // match our configured ServerID, otherwise ignore the request DhcpV6ServerIdOption requestedServerIdOption = requestMsg.GetDhcpServerIdOption(); if (((requestedServerIdOption != null) && !dhcpServerIdOption.Equals(requestedServerIdOption))) { log.Warn(("Ignoring Info-Request message: " + ("Requested ServerId: " + (requestedServerIdOption + (" My ServerId: " + dhcpServerIdOption))))); return(false); } // if the client message has an IA option (IA_NA, IA_TA) // then the DHCPv6 server must ignore the request if ((requestMsg.GetIaNaOptions() != null && requestMsg.GetIaNaOptions().Count > 0) || ((requestMsg.GetIaTaOptions() != null && requestMsg.GetIaTaOptions().Count > 0) || (requestMsg.GetIaPdOptions() != null && requestMsg.GetIaPdOptions().Count > 0))) { log.Warn(("Ignoring Info-Request message: " + " client message contains IA option(s).")); return(false); } return(true); }