//Process the client request. Find appropriate configuration based on any //criteria in the request message that can be matched against the server's //configuration, then formulate a response message containing the options //to be sent to the client. //@return a Reply DhcpMessage public DhcpV4Message ProcessMessage(IPAddress localAddress) { Monitor.Enter(_lock); try { //設定ServerId為管理IP _dhcpV4ServerIdOption.SetIpAddress(localAddress.ToString()); if (!PreProcess()) { return(null); } // build a reply message using the local and remote sockets from the request _replyMsg = new DhcpV4Message(_requestMsg.GetLocalAddress(), _requestMsg.GetRemoteAddress()); _replyMsg.SetOp(DhcpConstants.V4_OP_REPLY); // copy fields from request to reply _replyMsg.SetHtype(_requestMsg.GetHtype()); _replyMsg.SetHlen(_requestMsg.GetHlen()); _replyMsg.SetTransactionId(_requestMsg.GetTransactionId()); _replyMsg.SetFlags(_requestMsg.GetFlags()); _replyMsg.SetGiAddr(_requestMsg.GetGiAddr()); _replyMsg.SetChAddr(_requestMsg.GetChAddr()); // MUST put Server Identifier in REPLY message _replyMsg.PutDhcpOption(_dhcpV4ServerIdOption); if (!Process()) { log.Warn("Message dropped by processor"); return(null); } } catch (Exception ex) { log.WarnFormat("BaseDhcpV4Processor ProcessMessage Faile. exMessage:{0} exStackTrace:{1}", ex.Message, ex.StackTrace); return(null); } finally { if (!PostProcess()) { log.Warn("Message dropped by postProcess"); _replyMsg = null; } Monitor.Exit(_lock); } return(_replyMsg); }