ReactOS 0.4.17-dev-684-ga6524ef
nslookup.c File Reference
#include "nslookup.h"
#include <winbase.h>
#include <iphlpapi.h>
Include dependency graph for nslookup.c:

Go to the source code of this file.

Functions

void PrintState ()
 
void PrintUsage ()
 
void PrintHelp (void)
 
BOOL PerformInternalLookup (PCHAR pAddr, PCHAR pResult)
 
void PerformLookup (PCHAR pAddr)
 
BOOL ParseCommandLine (int argc, char *argv[])
 
void InteractiveMode ()
 
int main (int argc, char *argv[])
 

Variables

STATE State
 
HANDLE ProcessHeap
 
ULONG RequestID
 

Function Documentation

◆ InteractiveMode()

void InteractiveMode ( )

Definition at line 790 of file nslookup.c.

791{
792 CHAR input_line[256];
793 PSTR args_vector[64];
794 DWORD dwArgCount = 0;
795 BOOL bWhiteSpace = TRUE;
796 BOOL bDone = FALSE;
797 BOOL bInQuotes = FALSE;
798 PSTR ptr;
799 DWORD dwValue;
800 PSTR pszEnd, pszValue;
801
802 _tprintf( _T("Default Server: %s\n"), State.DefaultServer );
803 _tprintf( _T("Address: %s\n\n"), State.DefaultServerAddress );
804
805 for (;;)
806 {
807 dwArgCount = 0;
808 memset(args_vector, 0, sizeof(args_vector));
809
810 _tprintf(_T("> "));
811
812 /* Get input from the user. */
813 fgets(input_line, 256, stdin);
814
815 ptr = input_line;
816 while (*ptr != 0)
817 {
818 if (*ptr == _T('\"'))
819 bInQuotes = (bInQuotes) ? FALSE : TRUE;
820
821 if ((_istspace(*ptr) && (bInQuotes == FALSE)) || *ptr == _T('\n'))
822 {
823 *ptr = _T('\0');
824 bWhiteSpace = TRUE;
825 }
826 else
827 {
828 if ((bWhiteSpace != FALSE) && (dwArgCount < 64))
829 {
830 args_vector[dwArgCount] = ptr;
831 dwArgCount++;
832 }
833 bWhiteSpace = FALSE;
834 }
835 ptr++;
836 }
837
838 if (dwArgCount > 0)
839 {
840 if (_stricmp(args_vector[0], "exit") == 0)
841 {
842 bDone = TRUE;
843 }
844 else if ((!_stricmp(args_vector[0], "help")) ||
845 (!_stricmp(args_vector[0], "?")))
846 {
847 PrintHelp();
848 }
849 else if (!_stricmp(args_vector[0], "set"))
850 {
851 if (dwArgCount > 1)
852 {
853 if (!_stricmp(args_vector[1], "all"))
854 {
855 PrintState();
856 }
857 else if (!_stricmp(args_vector[1], "debug"))
858 {
859 State.debug = TRUE;
860 }
861 else if (!_stricmp(args_vector[1], "nodebug"))
862 {
863 State.debug = FALSE;
864 State.d2 = FALSE;
865 }
866 else if (!_stricmp(args_vector[1], "defname"))
867 {
868 State.defname = TRUE;
869 }
870 else if (!_stricmp(args_vector[1], "nodefname"))
871 {
872 State.defname = FALSE;
873 }
874 else if (!_stricmp(args_vector[1], "search"))
875 {
876 State.search = TRUE;
877 }
878 else if (!_stricmp(args_vector[1], "nosearch"))
879 {
880 State.search = FALSE;
881 }
882 else if (!_stricmp(args_vector[1], "recurse"))
883 {
884 State.recurse = TRUE;
885 }
886 else if (!_stricmp(args_vector[1], "norecurse"))
887 {
888 State.recurse = FALSE;
889 }
890 else if (!_stricmp(args_vector[1], "d2"))
891 {
892 State.debug = TRUE;
893 State.d2 = TRUE;
894 }
895 else if (!_stricmp(args_vector[1], "nod2"))
896 {
897 State.d2 = FALSE;
898 }
899 else if (!_stricmp(args_vector[1], "vc"))
900 {
901 State.vc = TRUE;
902 }
903 else if (!_stricmp(args_vector[1], "novc"))
904 {
905 State.vc = FALSE;
906 }
907 else if (!_stricmp(args_vector[1], "msxfr"))
908 {
909 State.MSxfr = TRUE;
910 }
911 else if (!_stricmp(args_vector[1], "nomsxfr"))
912 {
913 State.MSxfr = FALSE;
914 }
915 else if (!_strnicmp(args_vector[1], "retry=", strlen("retry=")))
916 {
917 pszValue = &args_vector[1][strlen("retry=")];
918 dwValue = strtoul(pszValue, &pszEnd, 10);
919 if (pszEnd != pszValue)
920 State.retry = dwValue;
921 }
922 else if (!_strnicmp(args_vector[1], "timeout=", strlen("timeout=")))
923 {
924 pszValue = &args_vector[1][strlen("timeout=")];
925 dwValue = strtoul(pszValue, &pszEnd, 10);
926 if (pszEnd != pszValue)
927 State.timeout = dwValue;
928 }
929 else if (!_strnicmp(args_vector[1], "domain=", strlen("domain=")))
930 {
931 strcpy(State.domain, &args_vector[1][strlen("domain=")]);
932 }
933 else if (!_strnicmp(args_vector[1], "srchlist=", strlen("srchlist=")))
934 {
935 _tprintf(_T("Option not implemented: srchlist\n"));
936 }
937 else if (!_strnicmp(args_vector[1], "root=", strlen("root=")))
938 {
939 _tprintf(_T("Option not implemented: root\n"));
940 }
941 else if (!_strnicmp(args_vector[1], "type=", strlen("type=")))
942 {
943 if (!strncmp(TypeA, &args_vector[1][6], strlen(TypeA)))
944 {
945 State.type = TypeA;
946 }
947 else if (!strncmp(TypeAAAA, &args_vector[1][6], strlen(TypeAAAA)))
948 {
949 State.type = TypeAAAA;
950 }
951 else if (!strncmp(TypeBoth, &args_vector[1][6], strlen(TypeBoth)))
952 {
953 State.type = TypeBoth;
954 }
955 else if (!strncmp(TypeAny, &args_vector[1][6], strlen(TypeAny)))
956 {
957 State.type = TypeAny;
958 }
959 else if (!strncmp(TypeCNAME, &args_vector[1][6], strlen(TypeCNAME)))
960 {
961 State.type = TypeCNAME;
962 }
963 else if (!strncmp(TypeMX, &args_vector[1][6], strlen(TypeMX)))
964 {
965 State.type = TypeMX;
966 }
967 else if (!strncmp(TypeNS, &args_vector[1][6], strlen(TypeNS)))
968 {
969 State.type = TypeNS;
970 }
971 else if (!strncmp(TypePTR, &args_vector[1][6], strlen(TypePTR)))
972 {
973 State.type = TypePTR;
974 }
975 else if (!strncmp(TypeSOA, &args_vector[1][6], strlen(TypeSOA)))
976 {
977 State.type = TypeSOA;
978 }
979 else if (!strncmp(TypeSRV, &args_vector[1][6], strlen(TypeSRV)))
980 {
981 State.type = TypeSRV;
982 }
983 else
984 {
985 _tprintf(_T("unknown query type: %s"), &args_vector[1][6]);
986 }
987 }
988 else if (!_strnicmp(args_vector[1], "querytype=", strlen("querytype=")))
989 {
990 if (!strncmp(TypeA, &args_vector[1][11], strlen(TypeA)))
991 {
992 State.type = TypeA;
993 }
994 else if (!strncmp(TypeAAAA, &args_vector[1][11], strlen(TypeAAAA)))
995 {
996 State.type = TypeAAAA;
997 }
998 else if (!strncmp(TypeBoth, &args_vector[1][11], strlen(TypeBoth)))
999 {
1000 State.type = TypeBoth;
1001 }
1002 else if (!strncmp(TypeAny, &args_vector[1][11], strlen(TypeAny)))
1003 {
1004 State.type = TypeAny;
1005 }
1006 else if (!strncmp(TypeCNAME, &args_vector[1][11], strlen(TypeCNAME)))
1007 {
1008 State.type = TypeCNAME;
1009 }
1010 else if (!strncmp(TypeMX, &args_vector[1][11], strlen(TypeMX)))
1011 {
1012 State.type = TypeMX;
1013 }
1014 else if (!strncmp(TypeNS, &args_vector[1][11], strlen(TypeNS)))
1015 {
1016 State.type = TypeNS;
1017 }
1018 else if (!strncmp(TypePTR, &args_vector[1][11], strlen(TypePTR)))
1019 {
1020 State.type = TypePTR;
1021 }
1022 else if (!strncmp(TypeSOA, &args_vector[1][11], strlen(TypeSOA)))
1023 {
1024 State.type = TypeSOA;
1025 }
1026 else if (!strncmp(TypeSRV, &args_vector[1][11], strlen(TypeSRV)))
1027 {
1028 State.type = TypeSRV;
1029 }
1030 else
1031 {
1032 _tprintf(_T("unknown query type: %s"), &args_vector[1][11]);
1033 }
1034 }
1035 else if (!_strnicmp(args_vector[1], "class=", strlen("class=")))
1036 {
1037 if (!strncmp(ClassIN, &args_vector[1][7], strlen(ClassIN)))
1038 {
1039 State.Class = ClassIN;
1040 }
1041 else if (!strncmp(ClassAny, &args_vector[1][7], strlen(ClassAny)))
1042 {
1043 State.Class = ClassAny;
1044 }
1045 else
1046 {
1047 _tprintf(_T("unknown query class: %s"), &args_vector[1][7]);
1048 }
1049 }
1050 else if (!_strnicmp(args_vector[1], "ixfrver=", strlen("ixfrver=")))
1051 {
1052 _tprintf(_T("Option not implemented: ixfrver\n"));
1053 }
1054 else
1055 {
1056 _tprintf(_T("*** Invalid option: %s.\n"), args_vector[1]);
1057 }
1058 }
1059 }
1060 else if (!_stricmp(args_vector[0], "server"))
1061 {
1062 _tprintf(_T("Command not implemented: server\n"));
1063 }
1064 else if (!_stricmp(args_vector[0], "lserver"))
1065 {
1066 _tprintf(_T("Command not implemented: lserver\n"));
1067 }
1068 else if (!_stricmp(args_vector[0], "finger"))
1069 {
1070 _tprintf(_T("Command not implemented: finger\n"));
1071 }
1072 else if (!_stricmp(args_vector[0], "root"))
1073 {
1074 _tprintf(_T("Command not implemented: root\n"));
1075 }
1076 else if (!_stricmp(args_vector[0], "ls"))
1077 {
1078 _tprintf(_T("Command not implemented: ls\n"));
1079 }
1080 else if (!_stricmp(args_vector[0], "view"))
1081 {
1082 _tprintf(_T("Command not implemented: view\n"));
1083 }
1084 else
1085 {
1086 if (dwArgCount == 1)
1087 {
1088 PerformLookup(args_vector[0]);
1089 }
1090 else if (dwArgCount == 2)
1091 {
1092 CHAR BackupServerAddress[16];
1093 CHAR BackupServer[256];
1094
1095 CopyMemory(BackupServerAddress, State.DefaultServerAddress, sizeof(BackupServerAddress));
1096 CopyMemory(BackupServer, State.DefaultServer, sizeof(BackupServer));
1097
1098 if (IsValidIP(args_vector[1]))
1099 {
1100 strncpy(State.DefaultServerAddress, args_vector[1], min(16, strlen(args_vector[1])));
1101 State.DefaultServerAddress[min(16, strlen(args_vector[1]))] = '\0';
1102
1103 PerformInternalLookup(State.DefaultServerAddress,
1104 State.DefaultServer);
1105 }
1106 else
1107 {
1108 strncpy(State.DefaultServer, args_vector[1], min(255, strlen(args_vector[1])));
1109 State.DefaultServer[min(255, strlen(args_vector[1]))] = '\0';
1110
1111 PerformInternalLookup(State.DefaultServer,
1112 State.DefaultServerAddress);
1113 }
1114
1115 PerformLookup(args_vector[0]);
1116
1117 CopyMemory(State.DefaultServerAddress, BackupServerAddress, sizeof(BackupServerAddress));
1118 CopyMemory(State.DefaultServer, BackupServer, sizeof(BackupServer));
1119 }
1120 else
1121 {
1122 _tprintf(_T("Unrecognized command:"));
1123 for (DWORD i = 0; i < dwArgCount; i++)
1124 _tprintf(_T(" %s"), args_vector[i]);
1125 _tprintf(_T("\n"));
1126 }
1127 }
1128 }
1129
1130 if (bDone)
1131 break;
1132 }
1133
1134}
#define _stricmp
Definition: cat.c:22
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
char *CDECL fgets(char *s, int size, FILE *file)
Definition: file.c:3903
#define stdin
_ACRTIMP __msvcrt_ulong __cdecl strtoul(const char *, char **, int)
Definition: string.c:1864
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
_ACRTIMP int __cdecl strncmp(const char *, const char *, size_t)
Definition: string.c:3335
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define _istspace
Definition: tchar.h:1504
#define _tprintf
Definition: tchar.h:506
#define CopyMemory
Definition: minwinbase.h:29
static PVOID ptr
Definition: dispmode.c:27
#define min(a, b)
Definition: monoChain.cc:55
_In_ LPWSTR _In_ DWORD dwArgCount
Definition: netsh.h:115
void PrintHelp(void)
Definition: nslookup.c:79
void PrintState()
Definition: nslookup.c:18
BOOL PerformInternalLookup(PCHAR pAddr, PCHAR pResult)
Definition: nslookup.c:112
void PerformLookup(PCHAR pAddr)
Definition: nslookup.c:269
#define TypeMX
Definition: nslookup.h:19
#define TypePTR
Definition: nslookup.h:21
#define TypeAAAA
Definition: nslookup.h:15
#define ClassAny
Definition: nslookup.h:35
#define TypeSRV
Definition: nslookup.h:23
#define TypeNS
Definition: nslookup.h:20
#define TypeAny
Definition: nslookup.h:17
BOOL IsValidIP(PCHAR pInput)
Definition: utility.c:312
#define TypeCNAME
Definition: nslookup.h:18
#define TypeA
Definition: nslookup.h:14
#define TypeBoth
Definition: nslookup.h:16
#define ClassIN
Definition: nslookup.h:34
#define TypeSOA
Definition: nslookup.h:22
char CHAR
Definition: pedump.c:57
_In_opt_ LPCSTR _In_opt_ LPCSTR pszValue
Definition: shlwapi.h:783
strncpy
Definition: string.h:335
strcpy
Definition: string.h:131
#define memset(x, y, z)
Definition: compat.h:39
char * PSTR
Definition: typedefs.h:51
#define _T(x)
Definition: vfdio.h:22

Referenced by main().

◆ main()

int main ( int  argc,
char argv[] 
)

Definition at line 1136 of file nslookup.c.

1137{
1138 int i;
1139 ULONG Status;
1140 PFIXED_INFO pNetInfo = NULL;
1141 ULONG NetBufLen = 0;
1142 WSADATA wsaData;
1143 int ret;
1144
1146 RequestID = 1;
1147
1148 /* Set up the initial state. */
1149 State.debug = FALSE;
1150 State.defname = TRUE;
1151 State.search = TRUE;
1152 State.recurse = TRUE;
1153 State.d2 = FALSE;
1154 State.vc = FALSE;
1155 State.ignoretc = FALSE;
1156 State.port = 53;
1157 State.type = TypeBoth;
1158 State.Class = ClassIN;
1159 State.timeout = 2;
1160 State.retry = 1;
1161 State.MSxfr = TRUE;
1162 State.ixfrver = 1;
1163
1164 RtlZeroMemory( State.root, 256 );
1165 RtlZeroMemory( State.domain, 256 );
1166 for( i = 0; i < 6; i += 1 ) RtlZeroMemory( State.srchlist[i], 256 );
1167 RtlZeroMemory( State.DefaultServer, 256 );
1168 RtlZeroMemory( State.DefaultServerAddress, 16 );
1169
1170 memcpy( State.root, DEFAULT_ROOT, sizeof(DEFAULT_ROOT) );
1171
1172 /* We don't know how long of a buffer it will want to return. So we'll
1173 pass an empty one now and let it fail only once, instead of guessing. */
1174 Status = GetNetworkParams( pNetInfo, &NetBufLen );
1175
1177 {
1178 _tprintf( _T("Error in GetNetworkParams call\n") );
1179
1180 return -2;
1181 }
1182
1183 pNetInfo = (PFIXED_INFO)HeapAlloc( ProcessHeap, 0, NetBufLen );
1184 if( pNetInfo == NULL )
1185 {
1186 _tprintf( _T("ERROR: Out of memory\n") );
1187
1188 return -1;
1189 }
1190
1191 /* For real this time. */
1192 Status = GetNetworkParams( pNetInfo, &NetBufLen );
1193 if( Status != NO_ERROR )
1194 {
1195 _tprintf( _T("Error in GetNetworkParams call\n") );
1196
1197 HeapFree( ProcessHeap, 0, pNetInfo );
1198
1199 return -2;
1200 }
1201
1202 strncpy( State.domain, pNetInfo->DomainName, 255 );
1203 strncpy( State.srchlist[0], pNetInfo->DomainName, 255 );
1204 strncpy( State.DefaultServerAddress,
1205 pNetInfo->DnsServerList.IpAddress.String,
1206 15 );
1207
1208 HeapFree( ProcessHeap, 0, pNetInfo );
1209
1210 ret = WSAStartup( MAKEWORD(2, 2), &wsaData );
1211 if (ret != 0)
1212 {
1213 _tprintf( _T("Winsock initialization failed: %d\n"), ret );
1214 return ret;
1215 }
1216
1217 switch( ParseCommandLine( argc, argv ) )
1218 {
1219 case 0:
1220 /* This means that it was a /? parameter. */
1221 break;
1222
1223 default:
1224 /* Anything else means we enter interactive mode. The only exception
1225 to this is when the host to resolve was provided on the command
1226 line. */
1228 }
1229
1230 WSACleanup();
1231 return 0;
1232}
#define NO_ERROR
Definition: dderror.h:5
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
MonoAssembly int argc
Definition: metahost.c:107
return ret
Definition: mutex.c:147
Status
Definition: gdiplustypes.h:24
DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define argv
Definition: mplay32.c:18
HANDLE ProcessHeap
Definition: nslookup.c:15
BOOL ParseCommandLine(int argc, char *argv[])
Definition: nslookup.c:495
ULONG RequestID
Definition: nslookup.c:16
void InteractiveMode()
Definition: nslookup.c:790
#define DEFAULT_ROOT
Definition: nslookup.h:64
FIXED_INFO_W2KSP1 * PFIXED_INFO
Definition: iptypes.h:86
char DomainName[MAX_DOMAIN_NAME_LEN+4]
Definition: iptypes.h:75
IP_ADDR_STRING DnsServerList
Definition: iptypes.h:77
char String[4 *4]
Definition: iptypes.h:31
IP_ADDRESS_STRING IpAddress
Definition: iptypes.h:36
#define MAKEWORD(a, b)
Definition: typedefs.h:248
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:307
int PASCAL FAR WSACleanup(void)
Definition: startup.c:60

◆ ParseCommandLine()

BOOL ParseCommandLine ( int  argc,
char argv[] 
)

Definition at line 495 of file nslookup.c.

496{
497 int i;
498 BOOL NoMoreOptions = FALSE;
500 CHAR AddrToResolve[256];
501 CHAR Server[256];
502 DWORD dwValue;
503 PSTR pszEnd, pszValue;
504
505 RtlZeroMemory( AddrToResolve, 256 );
506 RtlZeroMemory( Server, 256 );
507
508 if( 2 == argc )
509 {
510 /* In the Windows nslookup, usage is only displayed if /? is the only
511 option specified on the command line. */
512 if( !strncmp( "/?", argv[1], 2 ) )
513 {
514 PrintUsage();
515 return 0;
516 }
517 }
518
519 if( argc > 1 )
520 {
521 for( i = 1; i < argc; i += 1 )
522 {
523 if( NoMoreOptions )
524 {
525 strncpy( Server, argv[i], 255 );
526
527 /* Determine which one to resolve. This is based on whether the
528 DNS server provided was an IP or an FQDN. */
529 if( IsValidIP( Server ) )
530 {
531 strncpy( State.DefaultServerAddress, Server, 16 );
532
533 PerformInternalLookup( State.DefaultServerAddress,
534 State.DefaultServer );
535 }
536 else
537 {
538 strncpy( State.DefaultServer, Server, 255 );
539
540 PerformInternalLookup( State.DefaultServer,
541 State.DefaultServerAddress );
542 }
543
544 if( Interactive ) return 1;
545
546 PerformLookup( AddrToResolve );
547
548 return 0;
549 }
550 else
551 {
552 if( !strncmp( "-all", argv[i], 4 ) )
553 {
554 PrintState();
555 }
556 else if( !strncmp( "-type=", argv[i], 6 ) )
557 {
558 if( !strncmp( TypeA, &argv[i][6], strlen( TypeA ) ) )
559 {
560 State.type = TypeA;
561 }
562 else if( !strncmp( TypeAAAA, &argv[i][6], strlen( TypeAAAA ) ) )
563 {
564 State.type = TypeAAAA;
565 }
566 else if( !strncmp( TypeBoth, &argv[i][6], strlen( TypeBoth ) ) )
567 {
568 State.type = TypeBoth;
569 }
570 else if( !strncmp( TypeAny, &argv[i][6], strlen( TypeAny ) ) )
571 {
572 State.type = TypeAny;
573 }
574 else if( !strncmp( TypeCNAME, &argv[i][6], strlen( TypeCNAME ) ) )
575 {
576 State.type = TypeCNAME;
577 }
578 else if( !strncmp( TypeMX, &argv[i][6], strlen( TypeMX ) ) )
579 {
580 State.type = TypeMX;
581 }
582 else if( !strncmp( TypeNS, &argv[i][6], strlen( TypeNS ) ) )
583 {
584 State.type = TypeNS;
585 }
586 else if( !strncmp( TypePTR, &argv[i][6], strlen( TypePTR ) ) )
587 {
588 State.type = TypePTR;
589 }
590 else if( !strncmp( TypeSOA, &argv[i][6], strlen( TypeSOA ) ) )
591 {
592 State.type = TypeSOA;
593 }
594 else if( !strncmp( TypeSRV, &argv[i][6], strlen( TypeSRV ) ) )
595 {
596 State.type = TypeSRV;
597 }
598 else
599 {
600 _tprintf( _T("unknown query type: %s"), &argv[i][6] );
601 }
602 }
603 else if( !strncmp( "-domain=", argv[i], 8 ) )
604 {
605 strcpy( State.domain, &argv[i][8] );
606 }
607 else if( !strncmp( "-srchlist=", argv[i], 10 ) )
608 {
609 }
610 else if( !strncmp( "-root=", argv[i], 6 ) )
611 {
612 strcpy( State.root, &argv[i][6] );
613 }
614 else if( !strncmp( "-retry=", argv[i], 7 ) )
615 {
616 pszValue = &argv[i][7];
617 dwValue = strtoul(pszValue, &pszEnd, 10);
618 if (pszEnd != pszValue)
619 State.retry = dwValue;
620 }
621 else if( !strncmp( "-timeout=", argv[i], 9 ) )
622 {
623 pszValue = &argv[i][9];
624 dwValue = strtoul(pszValue, &pszEnd, 10);
625 if (pszEnd != pszValue)
626 State.timeout = dwValue;
627 }
628 else if( !strncmp( "-querytype=", argv[i], 11 ) )
629 {
630 if( !strncmp( TypeA, &argv[i][11], strlen( TypeA ) ) )
631 {
632 State.type = TypeA;
633 }
634 else if( !strncmp( TypeAAAA, &argv[i][11], strlen( TypeAAAA ) ) )
635 {
636 State.type = TypeAAAA;
637 }
638 else if( !strncmp( TypeBoth, &argv[i][11], strlen( TypeBoth ) ) )
639 {
640 State.type = TypeBoth;
641 }
642 else if( !strncmp( TypeAny, &argv[i][11], strlen( TypeAny ) ) )
643 {
644 State.type = TypeAny;
645 }
646 else if( !strncmp( TypeCNAME, &argv[i][11], strlen( TypeCNAME ) ) )
647 {
648 State.type = TypeCNAME;
649 }
650 else if( !strncmp( TypeMX, &argv[i][11], strlen( TypeMX ) ) )
651 {
652 State.type = TypeMX;
653 }
654 else if( !strncmp( TypeNS, &argv[i][11], strlen( TypeNS ) ) )
655 {
656 State.type = TypeNS;
657 }
658 else if( !strncmp( TypePTR, &argv[i][11], strlen( TypePTR ) ) )
659 {
660 State.type = TypePTR;
661 }
662 else if( !strncmp( TypeSOA, &argv[i][11], strlen( TypeSOA ) ) )
663 {
664 State.type = TypeSOA;
665 }
666 else if( !strncmp( TypeSRV, &argv[i][11], strlen( TypeSRV ) ) )
667 {
668 State.type = TypeSRV;
669 }
670 else
671 {
672 _tprintf( _T("unknown query type: %s"), &argv[i][11] );
673 }
674 }
675 else if( !strncmp( "-class=", argv[i], 7 ) )
676 {
677 if( !strncmp( ClassIN, &argv[i][7], strlen( ClassIN ) ) )
678 {
679 State.Class = ClassIN;
680 }
681 else if( !strncmp( ClassAny, &argv[i][7], strlen( ClassAny ) ) )
682 {
683 State.Class = ClassAny;
684 }
685 else
686 {
687 _tprintf( _T("unknown query class: %s"), &argv[i][7] );
688 }
689 }
690 else if( !strncmp( "-ixfrver=", argv[i], 9 ) )
691 {
692 }
693 else if( !strncmp( "-debug", argv[i], 6 ) )
694 {
695 State.debug = TRUE;
696 }
697 else if( !strncmp( "-nodebug", argv[i], 8 ) )
698 {
699 State.debug = FALSE;
700 State.d2 = FALSE;
701 }
702 else if( !strncmp( "-d2", argv[i], 3 ) )
703 {
704 State.d2 = TRUE;
705 State.debug = TRUE;
706 }
707 else if( !strncmp( "-nod2", argv[i], 5 ) )
708 {
709 if( State.debug ) _tprintf( _T("d2 mode disabled; still in debug mode\n") );
710
711 State.d2 = FALSE;
712 }
713 else if( !strncmp( "-defname", argv[i], 8 ) )
714 {
715 State.defname = TRUE;
716 }
717 else if( !strncmp( "-noddefname", argv[i], 10 ) )
718 {
719 State.defname = FALSE;
720 }
721 else if( !strncmp( "-recurse", argv[i], 8 ) )
722 {
723 State.recurse = TRUE;
724 }
725 else if( !strncmp( "-norecurse", argv[i], 10 ) )
726 {
727 State.recurse = FALSE;
728 }
729 else if( !strncmp( "-search", argv[i], 7 ) )
730 {
731 State.search = TRUE;
732 }
733 else if( !strncmp( "-nosearch", argv[i], 9 ) )
734 {
735 State.search = FALSE;
736 }
737 else if( !strncmp( "-vc", argv[i], 3 ) )
738 {
739 State.vc = TRUE;
740 }
741 else if( !strncmp( "-novc", argv[i], 5 ) )
742 {
743 State.vc = FALSE;
744 }
745 else if( !strncmp( "-msxfr", argv[i], 6 ) )
746 {
747 State.MSxfr = TRUE;
748 }
749 else if( !strncmp( "-nomsxfr", argv[i], 8 ) )
750 {
751 State.MSxfr = FALSE;
752 }
753 else if( !strncmp( "-", argv[i], 1 ) && (strlen( argv[i] ) == 1) )
754 {
755 /* Since we received just the plain - switch, we are going
756 to be entering interactive mode. We also will not be
757 parsing any more options. */
758 NoMoreOptions = TRUE;
760 }
761 else
762 {
763 /* Grab the address to resolve. No more options accepted
764 past this point. */
765 strncpy( AddrToResolve, argv[i], 255 );
766 NoMoreOptions = TRUE;
767 }
768 }
769 }
770
771 if( NoMoreOptions && !Interactive )
772 {
773 /* Get the FQDN of the DNS server. */
774 PerformInternalLookup( State.DefaultServerAddress,
775 State.DefaultServer );
776
777 PerformLookup( AddrToResolve );
778
779 return 0;
780 }
781 }
782
783 /* Get the FQDN of the DNS server. */
784 PerformInternalLookup( State.DefaultServerAddress,
785 State.DefaultServer );
786
787 return 1;
788}
void PrintUsage()
Definition: nslookup.c:70
@ Interactive
Definition: ntsecapi.h:289
static void Server(int port)
Definition: srltest.c:69

Referenced by main().

◆ PerformInternalLookup()

BOOL PerformInternalLookup ( PCHAR  pAddr,
PCHAR  pResult 
)

Definition at line 112 of file nslookup.c.

113{
114 /* Needed to issue DNS packets and parse them. */
115 PCHAR Buffer = NULL, RecBuffer = NULL;
116 CHAR pResolve[256];
117 ULONG BufferLength = 0, RecBufferLength = 512;
118 int i = 0, j = 0, k = 0, d = 0;
119 BOOL bOk = FALSE;
120
121 /* Makes things easier when parsing the response packet. */
122 USHORT NumQuestions;
123 USHORT Type;
124
125 if( (strlen( pAddr ) + 1) > 255 ) return FALSE;
126
127 Type = TYPE_A;
128 if( IsValidIP( pAddr ) ) Type = TYPE_PTR;
129
130 /* If it's a PTR lookup then append the ARPA sig to the end. */
131 if( Type == TYPE_PTR )
132 {
133 ReverseIP( pAddr, pResolve );
134 strcat( pResolve, ARPA_SIG );
135 }
136 else
137 {
138 strcpy( pResolve, pAddr );
139 }
140
141 /* Base header length + length of QNAME + length of QTYPE and QCLASS */
142 BufferLength = 12 + (strlen( pResolve ) + 2) + 4;
143
144 /* Allocate memory for the buffer. */
146 if( !Buffer )
147 {
148 _tprintf( _T("ERROR: Out of memory\n") );
149 goto cleanup;
150 }
151
152 /* Allocate the receiving buffer. */
153 RecBuffer = HeapAlloc( ProcessHeap, 0, RecBufferLength );
154 if( !RecBuffer )
155 {
156 _tprintf( _T("ERROR: Out of memory\n") );
157 goto cleanup;
158 }
159
160 /* Insert the ID field. */
161 ((PSHORT)&Buffer[i])[0] = htons( RequestID );
162 i += 2;
163
164 /* Bits 0-7 of the second 16 are all 0, except for when recursion is
165 desired. */
166 Buffer[i] = 0x00;
167 if( State.recurse) Buffer[i] |= 0x01;
168 i += 1;
169
170 /* Bits 8-15 of the second 16 are 0 for a query. */
171 Buffer[i] = 0x00;
172 i += 1;
173
174 /* Only 1 question. */
175 ((PSHORT)&Buffer[i])[0] = htons( 1 );
176 i += 2;
177
178 /* We aren't sending a response, so 0 out the rest of the header. */
179 Buffer[i] = 0x00;
180 Buffer[i + 1] = 0x00;
181 Buffer[i + 2] = 0x00;
182 Buffer[i + 3] = 0x00;
183 Buffer[i + 4] = 0x00;
184 Buffer[i + 5] = 0x00;
185 i += 6;
186
187 /* Walk through the query address. Split each section delimited by '.'.
188 Format of the QNAME section is length|data, etc. Last one is null */
189 j = i;
190 i += 1;
191
192 for( k = 0; k < strlen( pResolve ); k += 1 )
193 {
194 if( pResolve[k] != '.' )
195 {
196 Buffer[i] = pResolve[k];
197 i += 1;
198 }
199 else
200 {
201 Buffer[j] = (i - j) - 1;
202 j = i;
203 i += 1;
204 }
205 }
206
207 Buffer[j] = (i - j) - 1;
208 Buffer[i] = 0x00;
209 i += 1;
210
211 /* QTYPE */
212 ((PSHORT)&Buffer[i])[0] = htons( Type );
213 i += 2;
214
215 /* QCLASS */
216 ((PSHORT)&Buffer[i])[0] = htons( CLASS_IN );
217
218 /* Ship the request off to the DNS server. */
219 bOk = SendRequest( Buffer,
221 RecBuffer,
222 &RecBufferLength );
223 if( !bOk ) goto cleanup;
224
225 /* Start parsing the received packet. */
226 NumQuestions = ntohs( ((PSHORT)&RecBuffer[4])[0] );
227
228 k = 12;
229
230 /* We don't care about the questions section, blow through it. */
231 if( NumQuestions )
232 {
233 for( i = 0; i < NumQuestions; i += 1 )
234 {
235 /* Quick way to skip the domain name section. */
236 k += ExtractName( RecBuffer, pResult, k, 0 );
237 k += 4;
238 }
239 }
240
241 /* Skip the answer name. */
242 k += ExtractName( RecBuffer, pResult, k, 0 );
243
244 Type = ntohs( ((PUSHORT)&RecBuffer[k])[0] );
245 k += 8;
246
247 d = ntohs( ((PUSHORT)&RecBuffer[k])[0] );
248 k += 2;
249
250 if( TYPE_PTR == Type )
251 {
252 k += ExtractName( RecBuffer, pResult, k, d );
253 }
254 else if( TYPE_A == Type )
255 {
256 k += ExtractIP( RecBuffer, pResult, k );
257 }
258
259cleanup:
260 /* Free memory. */
261 if( Buffer ) HeapFree( ProcessHeap, 0, Buffer );
262 if( RecBuffer ) HeapFree( ProcessHeap, 0, RecBuffer );
263
264 RequestID += 1;
265
266 return bOk;
267}
Type
Definition: Type.h:7
Definition: bufpool.h:45
static void cleanup(void)
Definition: main.c:1335
#define TYPE_A
Definition: ftp_var.h:36
PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER pAddr
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define d
Definition: ke_i.h:81
#define htons(x)
Definition: module.h:215
#define ntohs(x)
Definition: module.h:210
int k
Definition: mpi.c:3369
#define TYPE_PTR
Definition: nslookup.h:30
int ExtractIP(PCHAR pBuffer, PCHAR pOutput, USHORT Offset)
Definition: utility.c:403
#define CLASS_IN
Definition: nslookup.h:37
BOOL SendRequest(PCHAR pInBuffer, ULONG InBufferLength, PCHAR pOutBuffer, PULONG pOutBufferLength)
Definition: utility.c:12
void ReverseIP(PCHAR pIP, PCHAR pReturn)
Definition: utility.c:250
int ExtractName(PCHAR pBuffer, PCHAR pOutput, USHORT Offset, UCHAR Limit)
Definition: utility.c:349
#define ARPA_SIG
Definition: nslookup.h:65
unsigned short USHORT
Definition: pedump.c:61
strcat
Definition: string.h:92
int16_t * PSHORT
Definition: typedefs.h:55
uint16_t * PUSHORT
Definition: typedefs.h:56
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3777

Referenced by InteractiveMode(), and ParseCommandLine().

◆ PerformLookup()

void PerformLookup ( PCHAR  pAddr)

Definition at line 269 of file nslookup.c.

270{
271 /* Needed to issue DNS packets and parse them. */
272 PCHAR Buffer = NULL, RecBuffer = NULL;
273 CHAR pResolve[256];
274 CHAR pResult[256];
275 ULONG BufferLength = 0, RecBufferLength = 512;
276 int i = 0, j = 0, k = 0, d = 0;
277 BOOL bOk = FALSE;
278
279 /* Makes things easier when parsing the response packet. */
280 UCHAR Header2;
281 USHORT NumQuestions;
282 USHORT NumAnswers;
283 USHORT NumAuthority;
284 USHORT Type;
285
286 if( (strlen( pAddr ) + 1) > 255 ) return;
287
288 _tprintf( _T("Server: %s\n"), State.DefaultServer );
289 _tprintf( _T("Address: %s\n\n"), State.DefaultServerAddress );
290
291 if( !strcmp( TypeA, State.type )
292 || !strcmp( TypeAAAA, State.type )
293 || !strcmp( TypeBoth, State.type ) )
294 {
295 Type = TYPE_A;
296 if( IsValidIP( pAddr ) ) Type = TYPE_PTR;
297 }
298 else
299 Type = TypeNametoTypeID( State.type );
300
301 /* If it's a PTR lookup then append the ARPA sig to the end. */
302 if( (Type == TYPE_PTR) && IsValidIP( pAddr ) )
303 {
304 ReverseIP( pAddr, pResolve );
305 strcat( pResolve, ARPA_SIG );
306 }
307 else
308 {
309 strcpy( pResolve, pAddr );
310 }
311
312 /* Base header length + length of QNAME + length of QTYPE and QCLASS */
313 BufferLength = 12 + (strlen( pResolve ) + 2) + 4;
314
315 /* Allocate memory for the buffer. */
317 if( !Buffer )
318 {
319 _tprintf( _T("ERROR: Out of memory\n") );
320 goto cleanup;
321 }
322
323 /* Allocate memory for the return buffer. */
324 RecBuffer = HeapAlloc( ProcessHeap, 0, RecBufferLength );
325 if( !RecBuffer )
326 {
327 _tprintf( _T("ERROR: Out of memory\n") );
328 goto cleanup;
329 }
330
331 /* Insert the ID field. */
332 ((PSHORT)&Buffer[i])[0] = htons( RequestID );
333 i += 2;
334
335 /* Bits 0-7 of the second 16 are all 0, except for when recursion is
336 desired. */
337 Buffer[i] = 0x00;
338 if( State.recurse) Buffer[i] |= 0x01;
339 i += 1;
340
341 /* Bits 8-15 of the second 16 are 0 for a query. */
342 Buffer[i] = 0x00;
343 i += 1;
344
345 /* Only 1 question. */
346 ((PSHORT)&Buffer[i])[0] = htons( 1 );
347 i += 2;
348
349 /* We aren't sending a response, so 0 out the rest of the header. */
350 Buffer[i] = 0x00;
351 Buffer[i + 1] = 0x00;
352 Buffer[i + 2] = 0x00;
353 Buffer[i + 3] = 0x00;
354 Buffer[i + 4] = 0x00;
355 Buffer[i + 5] = 0x00;
356 i += 6;
357
358 /* Walk through the query address. Split each section delimited by '.'.
359 Format of the QNAME section is length|data, etc. Last one is null */
360 j = i;
361 i += 1;
362
363 for( k = 0; k < strlen( pResolve ); k += 1 )
364 {
365 if( pResolve[k] != '.' )
366 {
367 Buffer[i] = pResolve[k];
368 i += 1;
369 }
370 else
371 {
372 Buffer[j] = (i - j) - 1;
373 j = i;
374 i += 1;
375 }
376 }
377
378 Buffer[j] = (i - j) - 1;
379 Buffer[i] = 0x00;
380 i += 1;
381
382 /* QTYPE */
383 ((PSHORT)&Buffer[i])[0] = htons( Type );
384 i += 2;
385
386 /* QCLASS */
387 ((PSHORT)&Buffer[i])[0] = htons( ClassNametoClassID( State.Class ) );
388
389 /* Ship off the request to the DNS server. */
390 bOk = SendRequest( Buffer,
392 RecBuffer,
393 &RecBufferLength );
394 if( !bOk ) goto cleanup;
395
396 /* Start parsing the received packet. */
397 Header2 = RecBuffer[3];
398 NumQuestions = ntohs( ((PSHORT)&RecBuffer[4])[0] );
399 NumAnswers = ntohs( ((PSHORT)&RecBuffer[6])[0] );
400 NumAuthority = ntohs( ((PUSHORT)&RecBuffer[8])[0] );
401 Type = 0;
402
403 /* Check the RCODE for failure. */
404 d = Header2 & 0x0F;
405 if( d != RCODE_NOERROR )
406 {
407 switch( d )
408 {
409 case RCODE_NXDOMAIN:
410 _tprintf( _T("*** %s can't find %s: Non-existant domain\n"), State.DefaultServer, pAddr );
411 break;
412
413 case RCODE_REFUSED:
414 _tprintf( _T("*** %s can't find %s: Query refused\n"), State.DefaultServer, pAddr );
415 break;
416
417 default:
418 _tprintf( _T("*** %s can't find %s: Unknown RCODE\n"), State.DefaultServer, pAddr );
419 }
420
421 goto cleanup;
422 }
423
424 k = 12;
425
426 if( NumQuestions )
427 {
428 /* Blow through the questions section since we don't care about it. */
429 for( i = 0; i < NumQuestions; i += 1 )
430 {
431 k += ExtractName( RecBuffer, pResult, k, 0 );
432 k += 4;
433 }
434 }
435
436 if( NumAnswers )
437 {
438 /* Skip the name. */
439 k += ExtractName( RecBuffer, pResult, k, 0 );
440
441 Type = ntohs( ((PUSHORT)&RecBuffer[k])[0] );
442 k += 8;
443
444 d = ntohs( ((PUSHORT)&RecBuffer[k])[0] );
445 k += 2;
446
447 if( TYPE_PTR == Type )
448 {
449 k += ExtractName( RecBuffer, pResult, k, d );
450 }
451 else if( TYPE_A == Type )
452 {
453 k += ExtractIP( RecBuffer, pResult, k );
454 }
455 }
456
457 /* FIXME: This'll need to support more than PTR and A at some point. */
458 if( !strcmp( State.type, TypePTR ) )
459 {
460 if( TYPE_PTR == Type )
461 {
462 _tprintf( _T("%s name = %s\n"), pResolve, pResult );
463 }
464 else
465 {
466 }
467 }
468 else if( !strcmp( State.type, TypeA )
469 || !strcmp( State.type, TypeAAAA )
470 || !strcmp( State.type, TypeBoth ) )
471 {
472 if( (TYPE_A == Type) /*|| (TYPE_AAAA == Type)*/ )
473 {
474 if( 0 == NumAuthority )
475 _tprintf( _T("Non-authoritative answer:\n") );
476
477 _tprintf( _T("Name: %s\n"), pAddr );
478 _tprintf( _T("Address: %s\n\n"), pResult );
479 }
480 else
481 {
482 _tprintf( _T("Name: %s\n"), pResult );
483 _tprintf( _T("Address: %s\n\n"), pAddr );
484 }
485 }
486
487cleanup:
488 /* Free memory. */
489 if( Buffer ) HeapFree( ProcessHeap, 0, Buffer );
490 if( RecBuffer ) HeapFree( ProcessHeap, 0, RecBuffer );
491
492 RequestID += 1;
493}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
USHORT ClassNametoClassID(PCHAR ClassName)
Definition: utility.c:854
#define RCODE_NOERROR
Definition: nslookup.h:49
#define RCODE_REFUSED
Definition: nslookup.h:54
USHORT TypeNametoTypeID(PCHAR TypeName)
Definition: utility.c:825
#define RCODE_NXDOMAIN
Definition: nslookup.h:52
unsigned char UCHAR
Definition: typedefs.h:53

Referenced by InteractiveMode(), and ParseCommandLine().

◆ PrintHelp()

void PrintHelp ( void  )

Definition at line 79 of file nslookup.c.

80{
81 _tprintf(_T("Commands: (identifiers are shown in uppercase, [] means optional)\n"));
82 _tprintf(_T("NAME1 - print info about host/domain NAME using default server\n"));
83 _tprintf(_T("NAME1 NAME2 - as above, but use NAME2 as server\n"));
84 _tprintf(_T("help or ? - print info on common commands\n"));
85 _tprintf(_T("set OPTION - set an option\n"));
86 _tprintf(_T(" all - print options, current server and host\n"));
87 _tprintf(_T(" [no]debug - print debugging information\n"));
88 _tprintf(_T(" [no]d2 - print exhaustive debugging information\n"));
89 _tprintf(_T(" [no]defname - apend domain name to each query\n"));
90 _tprintf(_T(" [no]recurse - ask for recursive answer to query\n"));
91 _tprintf(_T(" [no]search - use domain list query\n"));
92 _tprintf(_T(" [no]vc - always use virtual circuit\n"));
93 _tprintf(_T(" domain=NAME - set default domain name to NAME\n"));
94 _tprintf(_T(" srchlist=N1[/N2/.../N6] - set domain to N1 and search list to N1,N2 etc.\n"));
95 _tprintf(_T(" root=NAME - set root server to NAME\n"));
96 _tprintf(_T(" retry=X - set number of retries to X\n"));
97 _tprintf(_T(" timeout=X - set initial time-out interval to X seconds\n"));
98 _tprintf(_T(" type=X - set query type (ex. A,ANY,CNAME,MX,NS,PTR,SOA,SRV)\n"));
99 _tprintf(_T(" querytype=X - same as type\n"));
100 _tprintf(_T(" class=X - set query type (ex. IN (Internet), ANY)\n"));
101 _tprintf(_T(" [no]msxfr - use MS fast zone transfer\n"));
102 _tprintf(_T(" ixfrver=X - current version to use in IXFR transfer request\n"));
103 _tprintf(_T("server NAME - set default server to NAME, using current default server\n"));
104 _tprintf(_T("lserver NAME - set default server to NAME, using initial server\n"));
105 _tprintf(_T("finger [USER] - finger the optional NAME at the current default host\n"));
106 _tprintf(_T("root - set current default server too the root\n"));
107
108 _tprintf(_T("exit - exit the program\n"));
109 _tprintf(_T("\n"));
110}

Referenced by AssocQ(), InteractiveMode(), and wmain().

◆ PrintState()

void PrintState ( )

Definition at line 18 of file nslookup.c.

19{
20 _tprintf( _T("Default Server: %s\n"), State.DefaultServer );
21 _tprintf( _T("Address: %s\n\n"), State.DefaultServerAddress );
22
23 _tprintf( _T("Set options:\n") );
24
25 _tprintf( _T(" ") );
26 if( !State.debug ) _tprintf( _T("no") );
27 _tprintf( _T("debug\n") );
28
29 _tprintf( _T(" ") );
30 if( !State.defname ) _tprintf( _T("no") );
31 _tprintf( _T("defname\n") );
32
33 _tprintf( _T(" ") );
34 if( !State.search ) _tprintf( _T("no") );
35 _tprintf( _T("search\n") );
36
37 _tprintf( _T(" ") );
38 if( !State.recurse ) _tprintf( _T("no") );
39 _tprintf( _T("recurse\n") );
40
41 _tprintf( _T(" ") );
42 if( !State.d2 ) _tprintf( _T("no") );
43 _tprintf( _T("d2\n") );
44
45 _tprintf( _T(" ") );
46 if( !State.vc ) _tprintf( _T("no") );
47 _tprintf( _T("vc\n") );
48
49 _tprintf( _T(" ") );
50 if( !State.ignoretc ) _tprintf( _T("no") );
51 _tprintf( _T("ignoretc\n") );
52
53 _tprintf( _T(" port=%d\n"), State.port );
54 _tprintf( _T(" type=%s\n"), State.type );
55 _tprintf( _T(" class=%s\n"), State.Class );
56 _tprintf( _T(" timeout=%d\n"), (int)State.timeout );
57 _tprintf( _T(" retry=%d\n"), (int)State.retry );
58 _tprintf( _T(" root=%s\n"), State.root );
59 _tprintf( _T(" domain=%s\n"), State.domain );
60
61 _tprintf( _T(" ") );
62 if( !State.MSxfr ) _tprintf( _T("no") );
63 _tprintf( _T("MSxfr\n") );
64
65 _tprintf( _T(" IXFRversion=%d\n"), (int)State.ixfrver );
66
67 _tprintf( _T(" srchlist=%s\n\n"), State.srchlist[0] );
68}

Referenced by InteractiveMode(), and ParseCommandLine().

◆ PrintUsage()

void PrintUsage ( void  )

Definition at line 70 of file nslookup.c.

71{
72 _tprintf( _T("Usage:\n"
73 " nslookup [-opt ...] # interactive mode using default server\n"
74 " nslookup [-opt ...] - server # interactive mode using 'server'\n"
75 " nslookup [-opt ...] host # just look up 'host' using default server\n"
76 " nslookup [-opt ...] host server # just look up 'host' using 'server'\n") );
77}

Referenced by _tmain(), DirtyMain(), FsInfoMain(), HardLinkMain(), main(), ParseCommandLine(), and VolumeMain().

Variable Documentation

◆ ProcessHeap

HANDLE ProcessHeap
  • Internal Headers *‍/

Definition at line 15 of file nslookup.c.

Referenced by main(), PerformInternalLookup(), and PerformLookup().

◆ RequestID

ULONG RequestID

Definition at line 16 of file nslookup.c.

Referenced by main(), PerformInternalLookup(), PerformLookup(), PrintD2(), and SendRequest().

◆ State

Definition at line 14 of file nslookup.c.