1 #ifndef _NSLOOKUP_H 2 #define _NSLOOKUP_H 3 4 #include <stdarg.h> 5 6 #define WIN32_NO_STATUS 7 #include <windef.h> 8 #define _INC_WINDOWS 9 #include <winsock2.h> 10 #include <tchar.h> 11 #include <stdio.h> 12 13 #define TypeA "A" 14 #define TypeAAAA "AAAA" 15 #define TypeBoth "A+AAAA" 16 #define TypeAny "ANY" 17 #define TypeCNAME "CNAME" 18 #define TypeMX "MX" 19 #define TypeNS "NS" 20 #define TypePTR "PTR" 21 #define TypeSOA "SOA" 22 #define TypeSRV "SRV" 23 24 #define TYPE_A 0x01 25 #define TYPE_NS 0x02 26 #define TYPE_CNAME 0x05 27 #define TYPE_SOA 0x06 28 #define TYPE_WKS 0x0B 29 #define TYPE_PTR 0x0C 30 #define TYPE_MX 0x0F 31 #define TYPE_ANY 0xFF 32 33 #define ClassIN "IN" 34 #define ClassAny "ANY" 35 36 #define CLASS_IN 0x01 37 #define CLASS_ANY 0xFF 38 39 #define OPCODE_QUERY 0x00 40 #define OPCODE_IQUERY 0x01 41 #define OPCODE_STATUS 0x02 42 43 #define OpcodeQuery "QUERY" 44 #define OpcodeIQuery "IQUERY" 45 #define OpcodeStatus "STATUS" 46 #define OpcodeReserved "RESERVED" 47 48 #define RCODE_NOERROR 0x00 49 #define RCODE_FORMERR 0x01 50 #define RCODE_FAILURE 0x02 51 #define RCODE_NXDOMAIN 0x03 52 #define RCODE_NOTIMP 0x04 53 #define RCODE_REFUSED 0x05 54 55 #define RCodeNOERROR "NOERROR" 56 #define RCodeFORMERR "FORMERR" 57 #define RCodeFAILURE "FAILURE" 58 #define RCodeNXDOMAIN "NXDOMAIN" 59 #define RCodeNOTIMP "NOTIMP" 60 #define RCodeREFUSED "REFUSED" 61 #define RCodeReserved "RESERVED" 62 63 #define DEFAULT_ROOT "A.ROOT-SERVERS.NET." 64 #define ARPA_SIG ".in-addr.arpa" 65 66 typedef struct _STATE 67 { 68 BOOL debug; 69 BOOL defname; 70 BOOL d2; 71 BOOL recurse; 72 BOOL search; 73 BOOL vc; 74 BOOL ignoretc; 75 BOOL MSxfr; 76 CHAR domain[256]; 77 CHAR srchlist[6][256]; 78 CHAR root[256]; 79 DWORD retry; 80 DWORD timeout; 81 DWORD ixfrver; 82 PCHAR type; 83 PCHAR Class; 84 USHORT port; 85 CHAR DefaultServer[256]; 86 CHAR DefaultServerAddress[16]; 87 } STATE, *PSTATE; 88 89 /* nslookup.c */ 90 91 extern STATE State; 92 extern HANDLE ProcessHeap; 93 94 /* utility.c */ 95 96 BOOL SendRequest( PCHAR pInBuffer, 97 ULONG InBufferLength, 98 PCHAR pOutBuffer, 99 PULONG pOutBufferLength ); 100 101 int ExtractName( PCHAR pBuffer, 102 PCHAR pOutput, 103 USHORT Offset, 104 UCHAR Limit ); 105 106 void ReverseIP( PCHAR pIP, PCHAR pReturn ); 107 BOOL IsValidIP( PCHAR pInput ); 108 int ExtractIP( PCHAR pBuffer, PCHAR pOutput, USHORT Offset ); 109 void PrintD2( PCHAR pBuffer, DWORD BufferLength ); 110 void PrintDebug( PCHAR pBuffer, DWORD BufferLength ); 111 PCHAR OpcodeIDtoOpcodeName( UCHAR Opcode ); 112 PCHAR RCodeIDtoRCodeName( UCHAR RCode ); 113 PCHAR TypeIDtoTypeName( USHORT TypeID ); 114 USHORT TypeNametoTypeID( PCHAR TypeName ); 115 PCHAR ClassIDtoClassName( USHORT ClassID ); 116 USHORT ClassNametoClassID( PCHAR ClassName ); 117 118 #endif /* _NSLOOKUP_H */ 119