OCT 1. DHCP 测试工具Request数据包内容不正确问题
This commit is contained in:
parent
1748a66f83
commit
7e0f1aa8ef
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue