ReactOS 0.4.16-dev-106-g10b08aa
dnsaddr.c File Reference
#include "precomp.h"
Include dependency graph for dnsaddr.c:

Go to the source code of this file.

Functions

PDNS_ARRAY WINAPI DnsAddrArray_Create (ULONG Count)
 
VOID WINAPI DnsAddrArray_Free (IN PDNS_ARRAY DnsAddrArray)
 
BOOL WINAPI DnsAddrArray_AddIp4 (IN PDNS_ARRAY DnsAddrArray, IN IN_ADDR Address, IN DWORD AddressType)
 
BOOL WINAPI DnsAddrArray_AddAddr (IN PDNS_ARRAY DnsAddrArray, IN PDNS_ADDRESS DnsAddress, IN WORD AddressFamily OPTIONAL, IN DWORD AddressType OPTIONAL)
 
VOID WINAPI DnsAddr_BuildFromIp4 (IN PDNS_ADDRESS DnsAddress, IN IN_ADDR Address, IN WORD Port)
 
VOID WINAPI DnsAddr_BuildFromIp6 (IN PDNS_ADDRESS DnsAddress, IN PIN6_ADDR Address, IN ULONG ScopeId, IN WORD Port)
 
VOID WINAPI DnsAddr_BuildFromAtm (IN PDNS_ADDRESS DnsAddress, IN DWORD AddressType, IN PVOID AddressData)
 
BOOLEAN WINAPI DnsAddr_BuildFromDnsRecord (IN PDNS_RECORD DnsRecord, OUT PDNS_ADDRESS DnsAddr)
 
BOOL WINAPI DnsAddrArray_ContainsAddr (IN PDNS_ARRAY DnsAddrArray, IN PDNS_ADDRESS DnsAddress, IN DWORD AddressType)
 

Function Documentation

◆ DnsAddr_BuildFromAtm()

VOID WINAPI DnsAddr_BuildFromAtm ( IN PDNS_ADDRESS  DnsAddress,
IN DWORD  AddressType,
IN PVOID  AddressData 
)

Definition at line 134 of file dnsaddr.c.

137{
139
140 /* Clear the address */
141 RtlZeroMemory(DnsAddress, sizeof(DNS_ADDRESS));
142
143 /* Build an ATM Address */
144 Address.AddressType = AddressType;
145 Address.NumofDigits = DNS_ATMA_MAX_ADDR_LENGTH;
147
148 /* Write data */
149 DnsAddress->AtmAddress = Address;
150 DnsAddress->AddressLength = sizeof(ATM_ADDRESS);
151}
static WCHAR Address[46]
Definition: ping.c:68
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define DNS_ATMA_MAX_ADDR_LENGTH
Definition: windns.h:105

Referenced by DnsAddr_BuildFromDnsRecord().

◆ DnsAddr_BuildFromDnsRecord()

BOOLEAN WINAPI DnsAddr_BuildFromDnsRecord ( IN PDNS_RECORD  DnsRecord,
OUT PDNS_ADDRESS  DnsAddr 
)

Definition at line 155 of file dnsaddr.c.

157{
158 /* Check what kind of record this is */
159 switch(DnsRecord->wType)
160 {
161 /* IPv4 */
162 case DNS_TYPE_A:
163 /* Create the DNS Address */
164 DnsAddr_BuildFromIp4(DnsAddr,
165 *(PIN_ADDR)&DnsRecord->Data.A.IpAddress,
166 0);
167 break;
168
169 /* IPv6 */
170 case DNS_TYPE_AAAA:
171 /* Create the DNS Address */
172 DnsAddr_BuildFromIp6(DnsAddr,
173 (PIN6_ADDR)&DnsRecord->Data.AAAA.Ip6Address,
174 DnsRecord->dwReserved,
175 0);
176 break;
177
178 /* ATM */
179 case DNS_TYPE_ATMA:
180 /* Create the DNS Address */
181 DnsAddr_BuildFromAtm(DnsAddr,
182 DnsRecord->Data.Atma.AddressType,
183 &DnsRecord->Data.Atma.Address);
184 break;
185 }
186
187 /* Done! */
188 return TRUE;
189}
#define TRUE
Definition: types.h:120
VOID WINAPI DnsAddr_BuildFromIp4(IN PDNS_ADDRESS DnsAddress, IN IN_ADDR Address, IN WORD Port)
Definition: dnsaddr.c:100
VOID WINAPI DnsAddr_BuildFromAtm(IN PDNS_ADDRESS DnsAddress, IN DWORD AddressType, IN PVOID AddressData)
Definition: dnsaddr.c:134
VOID WINAPI DnsAddr_BuildFromIp6(IN PDNS_ADDRESS DnsAddress, IN PIN6_ADDR Address, IN ULONG ScopeId, IN WORD Port)
Definition: dnsaddr.c:116
Definition: tcpip.h:126
#define DNS_TYPE_ATMA
Definition: windns.h:74
#define DNS_TYPE_AAAA
Definition: windns.h:68
#define DNS_TYPE_A
Definition: windns.h:41

Referenced by SaBlob_WriteRecords().

◆ DnsAddr_BuildFromIp4()

VOID WINAPI DnsAddr_BuildFromIp4 ( IN PDNS_ADDRESS  DnsAddress,
IN IN_ADDR  Address,
IN WORD  Port 
)

Definition at line 100 of file dnsaddr.c.

103{
104 /* Clear the address */
105 RtlZeroMemory(DnsAddress, sizeof(DNS_ADDRESS));
106
107 /* Write data */
108 DnsAddress->Ip4Address.sin_family = AF_INET;
109 DnsAddress->Ip4Address.sin_port = Port;
110 DnsAddress->Ip4Address.sin_addr = Address;
111 DnsAddress->AddressLength = sizeof(SOCKADDR_IN);
112}
#define AF_INET
Definition: tcpip.h:117
CPPORT Port[4]
Definition: headless.c:35
struct sockaddr_in SOCKADDR_IN
Definition: winsock.h:487

Referenced by Dns_StringToDnsAddrEx(), DnsAddr_BuildFromDnsRecord(), and DnsAddrArray_AddIp4().

◆ DnsAddr_BuildFromIp6()

VOID WINAPI DnsAddr_BuildFromIp6 ( IN PDNS_ADDRESS  DnsAddress,
IN PIN6_ADDR  Address,
IN ULONG  ScopeId,
IN WORD  Port 
)

Definition at line 116 of file dnsaddr.c.

120{
121 /* Clear the address */
122 RtlZeroMemory(DnsAddress, sizeof(DNS_ADDRESS));
123
124 /* Write data */
125 DnsAddress->Ip6Address.sin6_family = AF_INET6;
126 DnsAddress->Ip6Address.sin6_port = Port;
127 DnsAddress->Ip6Address.sin6_addr = *Address;
128 DnsAddress->Ip6Address.sin6_scope_id = ScopeId;
129 DnsAddress->AddressLength = sizeof(SOCKADDR_IN6);
130}
#define AF_INET6
Definition: winsock.h:369
SOCKADDR_IN6_LH SOCKADDR_IN6
Definition: ws2ipdef.h:199

Referenced by Dns_StringToDnsAddrEx(), and DnsAddr_BuildFromDnsRecord().

◆ DnsAddrArray_AddAddr()

BOOL WINAPI DnsAddrArray_AddAddr ( IN PDNS_ARRAY  DnsAddrArray,
IN PDNS_ADDRESS  DnsAddress,
IN WORD AddressFamily  OPTIONAL,
IN DWORD AddressType  OPTIONAL 
)

Definition at line 57 of file dnsaddr.c.

61{
62 /* Make sure we have an array */
63 if (!DnsAddrArray) return FALSE;
64
65 /* Check if we should validate the Address Family */
66 if (AddressFamily)
67 {
68 /* Validate it */
69 if (AddressFamily != DnsAddress->AddressFamily) return TRUE;
70 }
71
72 /* Check if we should validate the Address Type */
73 if (AddressType)
74 {
75 /* Make sure that this array contains this type of addresses */
76 if (!DnsAddrArray_ContainsAddr(DnsAddrArray, DnsAddress, AddressType))
77 {
78 /* Won't be adding it */
79 return TRUE;
80 }
81 }
82
83 /* Make sure we have space in the array */
84 if (DnsAddrArray->AllocatedAddresses < DnsAddrArray->UsedAddresses)
85 {
86 return FALSE;
87 }
88
89 /* Now add the address */
90 RtlCopyMemory(&DnsAddrArray->Addresses[DnsAddrArray->UsedAddresses],
91 DnsAddress,
92 sizeof(DNS_ADDRESS));
93
94 /* Return success */
95 return TRUE;
96}
#define FALSE
Definition: types.h:117
BOOL WINAPI DnsAddrArray_ContainsAddr(IN PDNS_ARRAY DnsAddrArray, IN PDNS_ADDRESS DnsAddress, IN DWORD AddressType)
Definition: dnsaddr.c:193
IN PCO_ADDRESS_FAMILY AddressFamily
Definition: ndis.h:1906

Referenced by DnsAddrArray_AddIp4(), and SaBlob_WriteAddress().

◆ DnsAddrArray_AddIp4()

BOOL WINAPI DnsAddrArray_AddIp4 ( IN PDNS_ARRAY  DnsAddrArray,
IN IN_ADDR  Address,
IN DWORD  AddressType 
)

Definition at line 42 of file dnsaddr.c.

45{
46 DNS_ADDRESS DnsAddress;
47
48 /* Build the DNS Address */
49 DnsAddr_BuildFromIp4(&DnsAddress, Address, 0);
50
51 /* Add it to the array */
52 return DnsAddrArray_AddAddr(DnsAddrArray, &DnsAddress, 0, AddressType);
53}
BOOL WINAPI DnsAddrArray_AddAddr(IN PDNS_ARRAY DnsAddrArray, IN PDNS_ADDRESS DnsAddress, IN WORD AddressFamily OPTIONAL, IN DWORD AddressType OPTIONAL)
Definition: dnsaddr.c:57

Referenced by SaBlob_CreateFromIp4().

◆ DnsAddrArray_ContainsAddr()

BOOL WINAPI DnsAddrArray_ContainsAddr ( IN PDNS_ARRAY  DnsAddrArray,
IN PDNS_ADDRESS  DnsAddress,
IN DWORD  AddressType 
)

Definition at line 193 of file dnsaddr.c.

196{
197 /* FIXME */
198 return TRUE;
199}

Referenced by DnsAddrArray_AddAddr().

◆ DnsAddrArray_Create()

PDNS_ARRAY WINAPI DnsAddrArray_Create ( ULONG  Count)

Definition at line 17 of file dnsaddr.c.

18{
19 PDNS_ARRAY DnsAddrArray;
20
21 /* Allocate space for the array and the addresses within it */
22 DnsAddrArray = Dns_AllocZero(sizeof(DNS_ARRAY) +
23 (Count * sizeof(DNS_ADDRESS)));
24
25 /* Write the allocated address count */
26 if (DnsAddrArray) DnsAddrArray->AllocatedAddresses = Count;
27
28 /* Return it */
29 return DnsAddrArray;
30}
PVOID WINAPI Dns_AllocZero(IN SIZE_T Size)
Definition: memory.c:42
int Count
Definition: noreturn.cpp:7
ULONG AllocatedAddresses
Definition: dnslib.h:57

Referenced by SaBlob_Create(), and SaBlob_WriteAddress().

◆ DnsAddrArray_Free()

VOID WINAPI DnsAddrArray_Free ( IN PDNS_ARRAY  DnsAddrArray)

Definition at line 34 of file dnsaddr.c.

35{
36 /* Just free the entire array */
37 Dns_Free(DnsAddrArray);
38}
VOID WINAPI Dns_Free(IN PVOID Address)
Definition: memory.c:25

Referenced by SaBlob_Free().