From 7e0f1aa8ef6b831cdff09b930cfaba7dd6477c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=95?= Date: Mon, 15 May 2023 17:34:15 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20DHCP=20=E6=B5=8B=E8=AF=95=E5=B7=A5?= =?UTF-8?q?=E5=85=B7Request=E6=95=B0=E6=8D=AE=E5=8C=85=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dhcp_tools/uv_rawsocket.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/dhcp_tools/uv_rawsocket.c b/dhcp_tools/uv_rawsocket.c index 3a2df91..29df04b 100644 --- a/dhcp_tools/uv_rawsocket.c +++ b/dhcp_tools/uv_rawsocket.c @@ -161,6 +161,7 @@ U8 *dhcp_create_discover_req(PDHCP_INFO pInfo, int *pOutSize) { } static void on_dhcp_recv(uv_work_t *req) { + int status = 0; PDHCP_INFO pInfo; DHCP_RSP rspDhcp; DHCP_OPT optMsg, opt; @@ -168,6 +169,7 @@ static void on_dhcp_recv(uv_work_t *req) { PPKG_PROCESS_INFO pWork = (PPKG_PROCESS_INFO)req->data; PDHCP_PACKAGE pkg = (PDHCP_PACKAGE)pWork->pPkgBase; U32 optSize = pWork->nSize - sizeof(DHCP_PACKAGE); + U32 id = DHCP_XID(pkg->dhcp.xid); // Check op flag if (pkg->dhcp.op != BOOTP_REPLY) { @@ -182,7 +184,7 @@ static void on_dhcp_recv(uv_work_t *req) { return; } - pInfo = get_dhcp_info_by_id(DHCP_XID(pkg->dhcp.xid)); + pInfo = get_dhcp_info_by_id(id); if (pInfo == NULL) { LOG_MOD(error, ZM_DHCP_NET, "Unknown Client %d\n", DHCP_XID(pkg->dhcp.xid) & 0xFFFFFF); @@ -190,7 +192,7 @@ static void on_dhcp_recv(uv_work_t *req) { } memset(&rspDhcp, 0, sizeof(DHCP_RSP)); - rspDhcp.xid = DHCP_XID(pkg->dhcp.xid); + rspDhcp.xid = id; rspDhcp.ipAddr = ntohl(pkg->dhcp.yiaddr); memcpy(rspDhcp.cliMac, pkg->dhcp.chaddr, ETH_ALEN); memcpy(rspDhcp.svrHostname, pkg->dhcp.sname, 64); @@ -232,27 +234,25 @@ static void on_dhcp_recv(uv_work_t *req) { strncpy(rspDhcp.domainName, (char *)opt.pValue, MIN((int)opt.len, 64)); } - pInfo->step = STEP_OFFER; - pInfo->status = STA_RECV_RSP; - cacheDhcpOfferBuffer(pInfo, pWork->pPkgBase, pWork->nSize); memcpy(&pInfo->offerRsp, &rspDhcp, sizeof(DHCP_RSP)); - gettimeofday(&pInfo->pOfferBuf.tm, NULL); + + pInfo->step = STEP_OFFER; + pInfo->status = STA_RECV_RSP; break; case DHCP_MSG_ACK: + cacheDhcpAckBuffer(pInfo, pWork->pPkgBase, pWork->nSize); + memcpy(&pInfo->ackRsp, &rspDhcp, sizeof(DHCP_RSP)); + gettimeofday(&pInfo->pAckBuf.tm, NULL); pInfo->step = STEP_ACK; pInfo->status = STA_RECV_RSP; - - cacheDhcpAckBuffer(pInfo, pWork->pPkgBase, pWork->nSize); - memcpy(&pInfo->ackRsp, &rspDhcp, sizeof(DHCP_RSP)); - gettimeofday(&pInfo->pAckBuf.tm, NULL); break; case DHCP_MSG_NAK: - pInfo->status = STA_RECV_NACK; cacheDhcpAckBuffer(pInfo, pWork->pPkgBase, pWork->nSize); memcpy(&pInfo->ackRsp, &rspDhcp, sizeof(DHCP_RSP)); gettimeofday(&pInfo->pAckBuf.tm, NULL); + pInfo->status = STA_RECV_NACK; break; } }