DWORD DNSUnmarshallRRHeader( HANDLE hRecvBuffer, PDNS_RR_HEADER pRRHeader ) { DWORD dwError = 0; DWORD dwRead = 0; WORD wnType = 0; WORD wnClass = 0; WORD wnRDataSize = 0; DWORD dwnTTL = 0; dwError = DNSUnmarshallDomainName( hRecvBuffer, &pRRHeader->pDomainName); BAIL_ON_LWDNS_ERROR(dwError); dwError = DNSUnmarshallBuffer( hRecvBuffer, (PBYTE)&wnType, sizeof(WORD), &dwRead); BAIL_ON_LWDNS_ERROR(dwError); pRRHeader->wType = ntohs(wnType); dwError = DNSUnmarshallBuffer( hRecvBuffer, (PBYTE)&wnClass, sizeof(WORD), &dwRead); BAIL_ON_LWDNS_ERROR(dwError); pRRHeader->wClass = ntohs(wnClass); dwError = DNSUnmarshallBuffer( hRecvBuffer, (PBYTE)&dwnTTL, sizeof(DWORD), &dwRead); BAIL_ON_LWDNS_ERROR(dwError); pRRHeader->dwTTL = ntohl(dwnTTL); dwError = DNSUnmarshallBuffer( hRecvBuffer, (PBYTE)&wnRDataSize, sizeof(WORD), &dwRead); BAIL_ON_LWDNS_ERROR(dwError); pRRHeader->wRDataSize = htons(wnRDataSize); error: return dwError; }
static DWORD DNSStdUnmarshallQuestionSection( HANDLE hReceiveBuffer, WORD wQuestions, PDNS_QUESTION_RECORD ** pppDNSQuestionRecords ) { DWORD dwError = 0; DWORD i = 0; PDNS_QUESTION_RECORD pDNSQuestionRecord = NULL; PDNS_QUESTION_RECORD * ppDNSQuestionRecords = NULL; dwError = DNSAllocateMemory( wQuestions * sizeof(PDNS_QUESTION_RECORD), (PVOID *)&ppDNSQuestionRecords); BAIL_ON_LWDNS_ERROR(dwError); for (i = 0; i < wQuestions; i++) { DWORD dwRead = 0; WORD wnQueryClass = 0; WORD wnQueryType = 0; dwError = DNSAllocateMemory( sizeof(DNS_QUESTION_RECORD), (PVOID *)&pDNSQuestionRecord); BAIL_ON_LWDNS_ERROR(dwError); dwError = DNSUnmarshallDomainName( hReceiveBuffer, &pDNSQuestionRecord->pDomainName); BAIL_ON_LWDNS_ERROR(dwError); dwError = DNSUnmarshallBuffer( hReceiveBuffer, (PBYTE)&wnQueryType, (DWORD)sizeof(WORD), &dwRead); BAIL_ON_LWDNS_ERROR(dwError); pDNSQuestionRecord->wQueryType = ntohs(wnQueryType); dwError = DNSUnmarshallBuffer( hReceiveBuffer, (PBYTE)&wnQueryClass, (DWORD)sizeof(WORD), &dwRead); BAIL_ON_LWDNS_ERROR(dwError); pDNSQuestionRecord->wQueryClass = ntohs(wnQueryClass); *(ppDNSQuestionRecords + i) = pDNSQuestionRecord; pDNSQuestionRecord = NULL; } *pppDNSQuestionRecords = ppDNSQuestionRecords; cleanup: return dwError; error: if (ppDNSQuestionRecords) { DNSFreeQuestionRecordList( ppDNSQuestionRecords, wQuestions); } if (pDNSQuestionRecord) { DNSFreeQuestionRecord(pDNSQuestionRecord); } *pppDNSQuestionRecords = NULL; goto cleanup; }
DWORD DNSUpdateUnmarshallZoneSection( HANDLE hReceiveBuffer, WORD wZones, PDNS_ZONE_RECORD ** pppDNSZoneRecords ) { DWORD dwError = 0; DWORD i = 0; PDNS_ZONE_RECORD pDNSZoneRecord = NULL; PDNS_ZONE_RECORD * ppDNSZoneRecords = NULL; dwError = DNSAllocateMemory( wZones * sizeof(PDNS_ZONE_RECORD), (PVOID *)&ppDNSZoneRecords); BAIL_ON_LWDNS_ERROR(dwError); for (i = 0; i < wZones; i++) { DWORD dwRead = 0; WORD wnZoneClass = 0; WORD wnZoneType = 0; dwError = DNSAllocateMemory( sizeof(DNS_ZONE_RECORD), (PVOID *)&pDNSZoneRecord); BAIL_ON_LWDNS_ERROR(dwError); dwError = DNSUnmarshallDomainName( hReceiveBuffer, &pDNSZoneRecord->pDomainName); BAIL_ON_LWDNS_ERROR(dwError); dwError = DNSUnmarshallBuffer( hReceiveBuffer, (PBYTE)&wnZoneType, (DWORD)sizeof(WORD), &dwRead); BAIL_ON_LWDNS_ERROR(dwError); pDNSZoneRecord->wZoneType = ntohs(wnZoneType); dwError = DNSUnmarshallBuffer( hReceiveBuffer, (PBYTE)&wnZoneClass, (DWORD)sizeof(WORD), &dwRead); BAIL_ON_LWDNS_ERROR(dwError); pDNSZoneRecord->wZoneClass = ntohs(wnZoneClass); *(ppDNSZoneRecords + i) = pDNSZoneRecord; pDNSZoneRecord = NULL; } *pppDNSZoneRecords = ppDNSZoneRecords; cleanup: return(dwError); error: if (pDNSZoneRecord) { DNSFreeZoneRecord(pDNSZoneRecord); } if (ppDNSZoneRecords) { DNSFreeZoneRecordList( ppDNSZoneRecords, wZones); } *pppDNSZoneRecords = NULL; goto cleanup; }