Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

960 lines
20 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. dconvert.c
  5. Abstract:
  6. Domain Name System (DNS) Server -- Admin Client Library
  7. RPC record conversion routines.
  8. Convert DNS_RECORD records into RPC buffer.
  9. Author:
  10. Jing Chen (t-jingc) June, 1998
  11. reverse functions of rconvert.c
  12. Revision History:
  13. --*/
  14. #include "dnsclip.h"
  15. //
  16. // size of string in RPC format
  17. //
  18. // JBUGBUG: may have to do (-1) for terminating NULL
  19. //
  20. #define STRING_UTF8_BUF_SIZE( string, fUnicode ) \
  21. Dns_GetBufferLengthForStringCopy( \
  22. (string), \
  23. 0, \
  24. ((fUnicode) ? DnsCharSetUnicode : DnsCharSetUtf8), \
  25. DnsCharSetUtf8 )
  26. #if 0
  27. // with comments
  28. Dns_GetBufferLengthForStringCopy( \
  29. (string), \ // string
  30. 0, \ // unknown length
  31. ((fUnicode) ? DnsCharSetUnicode : DnsCharSetUtf8), \ // in string
  32. DnsCharSetUtf8 ) // RPC string always UTF8
  33. #endif
  34. //
  35. // Writing strings to RPC buffer format
  36. //
  37. #define WRITE_STRING_TO_RPC_BUF(buf, psz, len, funicode) \
  38. Dns_StringCopy( \
  39. (buf), \
  40. NULL, \
  41. (psz), \
  42. (len), \
  43. ((funicode) ? DnsCharSetUnicode : DnsCharSetUtf8), \
  44. DnsCharSetUtf8 )
  45. #if 0
  46. // with commments
  47. Dns_StringCopy( \
  48. (buf), \ // buffer
  49. NULL, \ // adequate buffer length
  50. (psz), \ // string
  51. (len), \ // string length (if known)
  52. ((funicode) ? DnsCharSetUnicode : DnsCharSet), \ // input format
  53. DnsCharSetUtf8 ) // RPC buffer always in UTF8
  54. #endif
  55. //
  56. // size of name in RPC format
  57. //
  58. // JBUGBUG: may have to do (-1) for terminating NULL
  59. //
  60. #define NAME_UTF8_BUF_SIZE( string, fUnicode ) \
  61. Dns_GetBufferLengthForStringCopy( \
  62. (string), \
  63. 0, \
  64. ((fUnicode) ? DnsCharSetUnicode : DnsCharSetUtf8), \
  65. DnsCharSetUtf8 )
  66. #if 0
  67. // with comments
  68. Dns_GetBufferLengthForStringCopy( \
  69. (string), \ // string
  70. 0, \ // unknown length
  71. ((fUnicode) ? DnsCharSetUnicode : DnsCharSetUtf8), \ // in string
  72. DnsCharSetUtf8 ) // RPC string always UTF8
  73. #endif
  74. //
  75. // Writing names to RPC buffer format
  76. //
  77. #define WRITE_NAME_TO_RPC_BUF(buf, psz, len, funicode) \
  78. Dns_StringCopy( \
  79. (buf), \
  80. NULL, \
  81. (psz), \
  82. (len), \
  83. ((funicode) ? DnsCharSetUnicode : DnsCharSetUtf8), \
  84. DnsCharSetUtf8 )
  85. #if 0
  86. // with commments
  87. Dns_StringCopy( \
  88. (buf), \ // buffer
  89. NULL, \ // adequate buffer length
  90. (psz), \ // string
  91. (len), \ // string length (if known)
  92. ((funicode) ? DnsCharSetUnicode : DnsCharSet), \ // input format
  93. DnsCharSetUtf8 ) // RPC buffer always in UTF8
  94. #endif
  95. //
  96. // Private protos
  97. //
  98. PDNS_RPC_RECORD
  99. Rpc_AllocateRecord(
  100. IN DWORD BufferLength
  101. );
  102. //
  103. // RPC buffer conversion functions
  104. //
  105. PDNS_RPC_RECORD
  106. ADnsRecordConvert(
  107. IN PDNS_RECORD pRR
  108. )
  109. /*++
  110. Routine Description:
  111. Convert A record from DNS Record to RPC buffer.
  112. Arguments:
  113. pRR - record being read
  114. Return Value:
  115. Ptr to new RPC buffer if successful.
  116. NULL on failure.
  117. --*/
  118. {
  119. PDNS_RPC_RECORD prpcRR;
  120. DNS_ASSERT( pRR->wDataLength == sizeof(IP_ADDRESS) );
  121. prpcRR = Rpc_AllocateRecord( sizeof(IP_ADDRESS) );
  122. if ( !prpcRR )
  123. {
  124. return( NULL );
  125. }
  126. prpcRR->Data.A.ipAddress = pRR->Data.A.IpAddress;
  127. return( prpcRR);
  128. }
  129. PDNS_RPC_RECORD
  130. PtrDnsRecordConvert(
  131. IN PDNS_RECORD pRR
  132. )
  133. /*++
  134. Routine Description:
  135. Process PTR compatible record from wire.
  136. Includes: NS, PTR, CNAME, MB, MR, MG, MD, MF
  137. Arguments:
  138. pRR - record being read
  139. Return Value:
  140. Ptr to new RPC buffer if successful.
  141. NULL on failure.
  142. --*/
  143. {
  144. PDNS_RPC_RECORD prpcRR;
  145. DWORD length;
  146. BOOL funicode = IS_UNICODE_RECORD( pRR );
  147. //
  148. // PTR data is another domain name
  149. //
  150. // determine required buffer length and allocate
  151. //
  152. length = NAME_UTF8_BUF_SIZE(pRR->Data.PTR.pNameHost, funicode);
  153. prpcRR = Rpc_AllocateRecord( sizeof(DNS_RPC_NAME) + length );
  154. if ( !prpcRR )
  155. {
  156. return( NULL );
  157. }
  158. //
  159. // write hostname into buffer, immediately following PTR data struct
  160. //
  161. prpcRR->Data.PTR.nameNode.cchNameLength = (UCHAR)length;
  162. WRITE_NAME_TO_RPC_BUF(
  163. prpcRR->Data.PTR.nameNode.achName, // buffer
  164. pRR->Data.PTR.pNameHost,
  165. 0,
  166. funicode );
  167. return( prpcRR );
  168. }
  169. PDNS_RPC_RECORD
  170. SoaDnsRecordConvert(
  171. IN PDNS_RECORD pRR
  172. )
  173. /*++
  174. Routine Description:
  175. Convert SOA record from DNS Record to RPC buffer.
  176. Arguments:
  177. pRR - ptr to record being read
  178. Return Value:
  179. Ptr to new RPC buffer if successful.
  180. NULL on failure.
  181. --*/
  182. {
  183. PDNS_RPC_RECORD prpcRR;
  184. DWORD length1;
  185. DWORD length2;
  186. PDNS_RPC_NAME pnamePrimary;
  187. PDNS_RPC_NAME pnameAdmin;
  188. BOOL funicode = IS_UNICODE_RECORD( pRR );
  189. //
  190. // determine required buffer length and allocate
  191. //
  192. length1 = NAME_UTF8_BUF_SIZE( pRR->Data.SOA.pNamePrimaryServer, funicode );
  193. length2 = NAME_UTF8_BUF_SIZE( pRR->Data.SOA.pNameAdministrator, funicode );
  194. prpcRR = Rpc_AllocateRecord(
  195. SIZEOF_SOA_FIXED_DATA + sizeof(DNS_RPC_NAME) * 2 +
  196. length1 + length2 );
  197. if ( !prpcRR )
  198. {
  199. return( NULL );
  200. }
  201. //
  202. // copy fixed fields
  203. //
  204. RtlCopyMemory(
  205. (PCHAR) & prpcRR->Data.SOA.dwSerialNo,
  206. (PCHAR) & pRR->Data.SOA.dwSerialNo,
  207. SIZEOF_SOA_FIXED_DATA );
  208. //
  209. // copy names into RR buffer
  210. // - primary server immediately follows SOA data struct
  211. // - responsible party follows primary server
  212. //
  213. pnamePrimary = &prpcRR->Data.SOA.namePrimaryServer;
  214. pnamePrimary->cchNameLength = (UCHAR) length1;
  215. pnameAdmin = DNS_GET_NEXT_NAME( pnamePrimary );
  216. pnameAdmin->cchNameLength = (UCHAR) length2;
  217. WRITE_NAME_TO_RPC_BUF(
  218. pnamePrimary->achName,
  219. pRR->Data.Soa.pNamePrimaryServer,
  220. 0,
  221. funicode );
  222. WRITE_NAME_TO_RPC_BUF(
  223. pnameAdmin->achName,
  224. pRR->Data.Soa.pNameAdministrator,
  225. 0,
  226. funicode );
  227. return( prpcRR );
  228. }
  229. PDNS_RPC_RECORD
  230. TxtDnsRecordConvert(
  231. IN PDNS_RECORD pRR
  232. )
  233. /*++
  234. Routine Description:
  235. Read TXT compatible record from wire.
  236. Includes: TXT, X25, HINFO, ISDN
  237. Arguments:
  238. pRR - record being read
  239. Return Value:
  240. Ptr to new RPC buffer if successful.
  241. NULL on failure.
  242. --*/
  243. {
  244. PDNS_RPC_RECORD prpcRR;
  245. DWORD bufLength;
  246. DWORD length;
  247. INT count;
  248. PCHAR pch;
  249. PCHAR * ppstring;
  250. BOOL funicode = IS_UNICODE_RECORD( pRR );
  251. //
  252. // determine required buffer length and allocate
  253. // - allocate space for each string
  254. // - and ptr for each string
  255. //
  256. bufLength = 0;
  257. count = pRR->Data.TXT.dwStringCount;
  258. ppstring = pRR->Data.TXT.pStringArray;
  259. while ( count-- )
  260. {
  261. length = STRING_UTF8_BUF_SIZE( *ppstring++, funicode );
  262. bufLength += sizeof(DNS_RPC_NAME) + length;
  263. }
  264. // allocate
  265. prpcRR = Rpc_AllocateRecord( bufLength );
  266. if ( !prpcRR )
  267. {
  268. return( NULL );
  269. }
  270. //
  271. // go back through list copying strings to buffer
  272. // - ptrs to strings are saved to argv like data section
  273. // ppstring walks through this section
  274. // - first string written immediately following data section
  275. // - each subsequent string immediately follows predecessor
  276. // pchbuffer keeps ptr to position to write strings
  277. //
  278. // JBUGBUG: a mess
  279. //
  280. pch = (PCHAR) &prpcRR->Data.TXT;
  281. ppstring = pRR->Data.TXT.pStringArray;
  282. count = pRR->Data.TXT.dwStringCount;
  283. while ( count-- )
  284. {
  285. length = STRING_UTF8_BUF_SIZE( *ppstring, funicode );
  286. (UCHAR) *pch++ += (UCHAR) length; //+1 for TXT type only
  287. length = WRITE_STRING_TO_RPC_BUF(
  288. pch,
  289. *ppstring++,
  290. 0,
  291. funicode
  292. );
  293. pch += length;
  294. #if DBG
  295. DNS_PRINT((
  296. "Read text string %s\n",
  297. * (ppstring - 1)
  298. ));
  299. #endif
  300. }
  301. return( prpcRR );
  302. }
  303. PDNS_RPC_RECORD
  304. MinfoDnsRecordConvert(
  305. IN PDNS_RECORD pRR
  306. )
  307. /*++
  308. Routine Description:
  309. Read MINFO record from wire.
  310. Arguments:
  311. pRR - record being read
  312. Return Value:
  313. Ptr to new RPC buffer if successful.
  314. NULL on failure.
  315. --*/
  316. {
  317. PDNS_RPC_RECORD prpcRR;
  318. DWORD length1;
  319. DWORD length2;
  320. PDNS_RPC_NAME prpcName1;
  321. PDNS_RPC_NAME prpcName2;
  322. BOOL funicode = IS_UNICODE_RECORD( pRR );
  323. //
  324. // determine required buffer length and allocate
  325. //
  326. length1 = NAME_UTF8_BUF_SIZE( pRR->Data.MINFO.pNameMailbox, funicode );
  327. length2 = NAME_UTF8_BUF_SIZE( pRR->Data.MINFO.pNameErrorsMailbox, funicode );
  328. prpcRR = Rpc_AllocateRecord( sizeof(DNS_RPC_NAME) * 2 + length1 + length2 );
  329. if ( !prpcRR )
  330. {
  331. return( NULL );
  332. }
  333. //
  334. // copy names into RR buffer
  335. // - mailbox immediately follows MINFO data struct
  336. // - errors mailbox immediately follows primary server
  337. //
  338. prpcName1 = &prpcRR->Data.MINFO.nameMailBox;
  339. prpcName1->cchNameLength = (UCHAR) length1;
  340. prpcName2 = DNS_GET_NEXT_NAME( prpcName1);
  341. prpcName2->cchNameLength = (UCHAR) length2;
  342. WRITE_NAME_TO_RPC_BUF(
  343. prpcName1->achName,
  344. pRR->Data.MINFO.pNameMailbox,
  345. 0,
  346. funicode );
  347. WRITE_NAME_TO_RPC_BUF(
  348. prpcName2->achName,
  349. pRR->Data.MINFO.pNameErrorsMailbox,
  350. 0,
  351. funicode );
  352. return( prpcRR );
  353. }
  354. PDNS_RPC_RECORD
  355. MxDnsRecordConvert(
  356. IN PDNS_RECORD pRR
  357. )
  358. /*++
  359. Routine Description:
  360. convert MX compatible record.
  361. Includes: MX, RT, AFSDB
  362. Arguments:
  363. pRR - record being read
  364. Return Value:
  365. Ptr to new RPC buffer if successful.
  366. NULL on failure.
  367. --*/
  368. {
  369. PDNS_RPC_RECORD prpcRR;
  370. PDNS_RPC_NAME prpcName;
  371. DWORD length;
  372. BOOL funicode = IS_UNICODE_RECORD( pRR );
  373. //
  374. // determine required buffer length and allocate
  375. //
  376. length = NAME_UTF8_BUF_SIZE( pRR->Data.MX.pNameExchange, funicode );
  377. prpcRR = Rpc_AllocateRecord(
  378. SIZEOF_MX_FIXED_DATA + sizeof(DNS_RPC_NAME) + length );
  379. if ( !prpcRR )
  380. {
  381. return( NULL );
  382. }
  383. //
  384. // copy preference
  385. //
  386. prpcRR->Data.MX.wPreference = pRR->Data.MX.wPreference;
  387. //
  388. // write hostname into buffer, immediately following MX struct
  389. //
  390. prpcName = &prpcRR->Data.MX.nameExchange;
  391. prpcName->cchNameLength = (UCHAR) length;
  392. WRITE_NAME_TO_RPC_BUF(
  393. prpcName->achName,
  394. pRR->Data.MX.pNameExchange,
  395. 0,
  396. funicode );
  397. return( prpcRR );
  398. }
  399. PDNS_RPC_RECORD
  400. FlatDnsRecordConvert(
  401. IN PDNS_RECORD pRR
  402. )
  403. /*++
  404. Routine Description:
  405. Convert memory copy compatible record.
  406. Includes AAAA and WINS types.
  407. Arguments:
  408. pRR - record being read
  409. Return Value:
  410. Ptr to new RPC buffer if successful.
  411. NULL on failure.
  412. --*/
  413. {
  414. PDNS_RPC_RECORD prpcRR;
  415. DWORD bufLength;
  416. //
  417. // determine required buffer length and allocate
  418. //
  419. bufLength = pRR->wDataLength;
  420. prpcRR = Rpc_AllocateRecord( bufLength );
  421. if ( !prpcRR )
  422. {
  423. return( NULL );
  424. }
  425. //
  426. // copy packet data to record
  427. //
  428. RtlCopyMemory(
  429. & prpcRR->Data,
  430. & pRR->Data,
  431. bufLength );
  432. return( prpcRR );
  433. }
  434. PDNS_RPC_RECORD
  435. SrvDnsRecordConvert(
  436. IN PDNS_RECORD pRR
  437. )
  438. /*++
  439. Routine Description:
  440. convert SRV record.
  441. Arguments:
  442. pRR - record being read
  443. Return Value:
  444. Ptr to new RPC buffer if successful.
  445. NULL on failure.
  446. --*/
  447. {
  448. PDNS_RPC_RECORD prpcRR;
  449. PDNS_RPC_NAME prpcName;
  450. DWORD length;
  451. BOOL funicode = IS_UNICODE_RECORD( pRR );
  452. //
  453. // determine required buffer length and allocate
  454. //
  455. length = NAME_UTF8_BUF_SIZE( pRR->Data.SRV.pNameTarget, funicode );
  456. prpcRR = Rpc_AllocateRecord(
  457. SIZEOF_SRV_FIXED_DATA + sizeof(DNS_RPC_NAME) + length );
  458. if ( !prpcRR )
  459. {
  460. return( NULL );
  461. }
  462. //
  463. // copy SRV fixed fields
  464. //
  465. prpcRR->Data.SRV.wPriority = pRR->Data.SRV.wPriority;
  466. prpcRR->Data.SRV.wWeight = pRR->Data.SRV.wWeight;
  467. prpcRR->Data.SRV.wPort = pRR->Data.SRV.wPort;
  468. //
  469. // write hostname into buffer, immediately following SRV struct
  470. //
  471. prpcName = &prpcRR->Data.SRV.nameTarget;
  472. prpcName->cchNameLength = (UCHAR) length;
  473. WRITE_NAME_TO_RPC_BUF(
  474. prpcName->achName,
  475. pRR->Data.SRV.pNameTarget,
  476. 0,
  477. funicode );
  478. return( prpcRR );
  479. }
  480. PDNS_RPC_RECORD
  481. NbstatDnsRecordConvert(
  482. IN PDNS_RECORD pRR
  483. )
  484. /*++
  485. Routine Description:
  486. Read WINSR record from wire.
  487. Arguments:
  488. pRR - record being read
  489. Return Value:
  490. Ptr to new RPC buffer if successful.
  491. NULL on failure.
  492. --*/
  493. {
  494. PDNS_RPC_RECORD prpcRR;
  495. PDNS_RPC_NAME prpcName;
  496. DWORD length;
  497. BOOL funicode = IS_UNICODE_RECORD( pRR );
  498. //
  499. // determine required buffer length and allocate
  500. //
  501. length = NAME_UTF8_BUF_SIZE( pRR->Data.WINSR.pNameResultDomain, funicode );
  502. prpcRR = Rpc_AllocateRecord(
  503. SIZEOF_NBSTAT_FIXED_DATA + sizeof(DNS_RPC_NAME) + length );
  504. if ( !prpcRR )
  505. {
  506. return( NULL );
  507. }
  508. //
  509. // copy WINSR fixed fields
  510. //
  511. prpcRR->Data.WINSR.dwMappingFlag = pRR->Data.WINSR.dwMappingFlag;
  512. prpcRR->Data.WINSR.dwLookupTimeout = pRR->Data.WINSR.dwLookupTimeout;
  513. prpcRR->Data.WINSR.dwCacheTimeout = pRR->Data.WINSR.dwCacheTimeout;
  514. //
  515. // write hostname into buffer, immediately following WINSR struct
  516. //
  517. prpcName = &prpcRR->Data.WINSR.nameResultDomain;
  518. prpcName->cchNameLength = (UCHAR) length;
  519. WRITE_NAME_TO_RPC_BUF(
  520. prpcName->achName,
  521. pRR->Data.WINSR.pNameResultDomain,
  522. 0,
  523. funicode );
  524. return( prpcRR );
  525. }
  526. //
  527. // Jump table for DNS_RECORD => RPC buffer conversion.
  528. //
  529. typedef PDNS_RPC_RECORD (* RECORD_TO_RPC_CONVERT_FUNCTION)( PDNS_RECORD );
  530. RECORD_TO_RPC_CONVERT_FUNCTION RecordToRpcConvertTable[] =
  531. {
  532. NULL, // ZERO
  533. ADnsRecordConvert, // A
  534. PtrDnsRecordConvert, // NS
  535. PtrDnsRecordConvert, // MD
  536. PtrDnsRecordConvert, // MF
  537. PtrDnsRecordConvert, // CNAME
  538. SoaDnsRecordConvert, // SOA
  539. PtrDnsRecordConvert, // MB
  540. PtrDnsRecordConvert, // MG
  541. PtrDnsRecordConvert, // MR
  542. NULL, // NULL
  543. FlatDnsRecordConvert, // WKS
  544. PtrDnsRecordConvert, // PTR
  545. TxtDnsRecordConvert, // HINFO
  546. MinfoDnsRecordConvert, // MINFO
  547. MxDnsRecordConvert, // MX
  548. TxtDnsRecordConvert, // TXT
  549. MinfoDnsRecordConvert, // RP
  550. MxDnsRecordConvert, // AFSDB
  551. TxtDnsRecordConvert, // X25
  552. TxtDnsRecordConvert, // ISDN
  553. MxDnsRecordConvert, // RT
  554. NULL, // NSAP
  555. NULL, // NSAPPTR
  556. NULL, // SIG
  557. NULL, // KEY
  558. NULL, // PX
  559. NULL, // GPOS
  560. FlatDnsRecordConvert, // AAAA
  561. NULL, // 29
  562. NULL, // 30
  563. NULL, // 31
  564. NULL, // 32
  565. SrvDnsRecordConvert, // SRV
  566. //
  567. // NOTE: last type indexed by type ID MUST be set
  568. // as MAX_SELF_INDEXED_TYPE #define in record.h
  569. // (see note above in record info table)
  570. // note these follow, but require OFFSET_TO_WINS_RR subtraction
  571. // from actual type value
  572. NULL, // DNS_TYPE_ATMA
  573. NULL, // 0x0023
  574. NULL, // 0x0024
  575. NULL, // 0x0025
  576. NULL, // 0x0026
  577. NULL, // 0x0027
  578. NULL, // 0x0028
  579. NULL, // DNS_TYPE_TKEY
  580. NULL, // DNS_TYPE_TSIG
  581. FlatDnsRecordConvert, // WINS
  582. NbstatDnsRecordConvert // WINS-R
  583. };
  584. PDNS_RPC_RECORD
  585. Rpc_AllocateRecord(
  586. IN DWORD BufferLength
  587. )
  588. /*++
  589. Routine Description:
  590. Allocate RPC record structure.
  591. Arguments:
  592. wBufferLength - desired buffer length (beyond structure header)
  593. Return Value:
  594. Ptr to buffer.
  595. NULL on error.
  596. --*/
  597. {
  598. PDNS_RPC_RECORD prr;
  599. if ( BufferLength > MAXWORD )
  600. {
  601. return( NULL );
  602. }
  603. prr = ALLOCATE_HEAP( SIZEOF_DNS_RPC_RECORD_HEADER + BufferLength );
  604. if ( !prr )
  605. {
  606. SetLastError( ERROR_NOT_ENOUGH_MEMORY );
  607. return( NULL );
  608. }
  609. // set datalength to buffer length
  610. prr->wDataLength = (WORD) BufferLength;
  611. return( prr );
  612. }
  613. PDNS_RPC_RECORD
  614. DnsConvertRecordToRpcBuffer(
  615. IN PDNS_RECORD pRecord
  616. )
  617. /*++
  618. Routine Description:
  619. Convert standard DNS record to RPC buffer.
  620. Arguments:
  621. pRecord -- DNS Record to be converted.
  622. //fUnicode -- flag, write records into unicode
  623. Return Value:
  624. Ptr to new RPC buffer if successful.
  625. NULL on failure.
  626. --*/
  627. {
  628. PDNS_RPC_RECORD prpcRecord;
  629. WORD index;
  630. WORD type;
  631. RECORD_TO_RPC_CONVERT_FUNCTION pFunc;
  632. DNS_ASSERT( DNS_IS_DWORD_ALIGNED(pRecord) );
  633. IF_DNSDBG( RPC2 )
  634. {
  635. DNS_PRINT((
  636. "Enter DnsConvertRecordToRpcBuffer()\n"
  637. "\tpRecord = %p\n",
  638. pRecord ));
  639. }
  640. //DNS_RRSET_INIT( rrset );
  641. //
  642. // convert record
  643. // set unicode flag if converting
  644. //
  645. //if ( fUnicode )
  646. //{
  647. //SET_RPC_UNICODE( pRecord );
  648. //}
  649. type = pRecord->wType;
  650. index = INDEX_FOR_TYPE( type );
  651. DNS_ASSERT( index <= MAX_RECORD_TYPE_INDEX );
  652. if ( !index || !(pFunc = RecordToRpcConvertTable[ index ]) )
  653. {
  654. // if unknown type try flat record copy -- best we can
  655. // do to protect if server added new types since admin built
  656. DNS_PRINT((
  657. "ERROR: no DNS_RECORD to RPC conversion routine for type %d.\n"
  658. "\tusing flat conversion routine.\n",
  659. type ));
  660. pFunc = FlatDnsRecordConvert;
  661. }
  662. prpcRecord = (*pFunc)( pRecord );
  663. if ( ! prpcRecord )
  664. {
  665. DNS_PRINT((
  666. "ERROR: Record build routine failure for record type %d.\n"
  667. "\tstatus = %p\n\n",
  668. type,
  669. GetLastError() ));
  670. return(NULL);
  671. }
  672. //
  673. // fill out record structure
  674. //
  675. prpcRecord->wType = type;
  676. prpcRecord->dwTtlSeconds = pRecord->dwTtl;
  677. //
  678. // JBUGBUG: data types (root hint, glue set)
  679. // - need way to default that works for NT4
  680. //
  681. /*
  682. if ( prpcRecord->dwFlags & DNS_RPC_RECORD_FLAG_CACHE_DATA )
  683. {
  684. precord->Flags.S.Section = DNSREC_CACHE_DATA;
  685. }
  686. else
  687. {
  688. precord->Flags.S.Section = DNSREC_ZONE_DATA;
  689. }
  690. */
  691. IF_DNSDBG( INIT )
  692. {
  693. DNS_PRINT((
  694. "New RPC buffer built\n"
  695. ));
  696. }
  697. IF_DNSDBG( RPC2 )
  698. {
  699. /*
  700. DnsDbg_RecordSet(
  701. "Finished DnsConvertRpcBufferToRecords() ",
  702. rrset.pFirstRR );
  703. */
  704. DNS_PRINT((
  705. "Finished DnsConvertRpcBufferToRecords() "
  706. ));
  707. }
  708. return(prpcRecord);
  709. }
  710. //
  711. // End dconvert.c
  712. //