#include "nslookup.h"
#include <assert.h>
Go to the source code of this file.
|
| BOOL | SendRequest (PCHAR pInBuffer, ULONG InBufferLength, PCHAR pOutBuffer, PULONG pOutBufferLength) |
| |
| void | ReverseIP (PCHAR pIP, PCHAR pReturn) |
| |
| BOOL | IsValidIP (PCHAR pInput) |
| |
| int | ExtractName (PCHAR pBuffer, PCHAR pOutput, USHORT Offset, UCHAR Limit) |
| |
| int | ExtractIP (PCHAR pBuffer, PCHAR pOutput, USHORT Offset) |
| |
| void | PrintD2 (PCHAR pBuffer, DWORD BufferLength) |
| |
| void | PrintDebug (PCHAR pBuffer, DWORD BufferLength) |
| |
| PCHAR | OpcodeIDtoOpcodeName (UCHAR Opcode) |
| |
| PCHAR | RCodeIDtoRCodeName (UCHAR RCode) |
| |
| PCHAR | TypeIDtoTypeName (USHORT TypeID) |
| |
| USHORT | TypeNametoTypeID (PCHAR TypeName) |
| |
| PCHAR | ClassIDtoClassName (USHORT ClassID) |
| |
| USHORT | ClassNametoClassID (PCHAR ClassName) |
| |
◆ ClassIDtoClassName()
Definition at line 839 of file utility.c.
840{
841 switch( ClassID )
842 {
845
848
849 default:
850 return "Unknown";
851 }
852}
Referenced by PrintD2(), and PrintDebug().
◆ ClassNametoClassID()
Definition at line 854 of file utility.c.
855{
858
859 return 0;
860}
_ACRTIMP size_t __cdecl strlen(const char *)
_ACRTIMP int __cdecl strncmp(const char *, const char *, size_t)
Referenced by PerformLookup().
◆ ExtractIP()
Definition at line 403 of file utility.c.
404{
405 int c = 0,
l = 0,
i = 0,
v = 0;
406
408
412
415
419
422
426
429
433
436
438
440}
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
_In_ ULONG _In_ ULONG Offset
Referenced by PerformInternalLookup(), PerformLookup(), and PrintDebug().
◆ ExtractName()
Definition at line 349 of file utility.c.
350{
351 int c = 0,
d = 0,
i = 0,
j = 0,
k = 0,
l = 0,
m = 0;
352
354
355
358
360 {
364
366 {
371 }
372 else
373 {
374 for(
j = 0;
j <
l;
j += 1 )
375 {
377
382 }
383
385
387
390 }
391 };
392
394 {
396 }
397
399
401}
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
_In_ LONG _In_ LONG Limit
Referenced by PerformInternalLookup(), PerformLookup(), PrintD2(), and PrintDebug().
◆ IsValidIP()
◆ OpcodeIDtoOpcodeName()
◆ PrintD2()
Definition at line 442 of file utility.c.
443{
445 UCHAR Header1, Header2;
446 USHORT NumQuestions, NumAnswers, NumAuthority, NumAdditional;
450
453
456
459
462
465
468
471
475 _tprintf(
_T(
" opcode = %s, id = %d, rcode = %s\n"),
479
481 if( Header1 & 0x01 )
_tprintf(
_T(
", want recursion") );
483
485 " authority records = %d, additional = %d\n\n"),
486 (int)NumQuestions,
487 (int)NumAnswers,
488 (int)NumAuthority,
489 (int)NumAdditional );
490
491 if( NumQuestions )
492 {
494
495 for(
k = 0;
k < NumQuestions;
k += 1 )
496 {
498
500
503
506
510 }
511 }
512
514}
PCHAR TypeIDtoTypeName(USHORT TypeID)
PCHAR RCodeIDtoRCodeName(UCHAR RCode)
PCHAR OpcodeIDtoOpcodeName(UCHAR Opcode)
int ExtractName(PCHAR pBuffer, PCHAR pOutput, USHORT Offset, UCHAR Limit)
PCHAR ClassIDtoClassName(USHORT ClassID)
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Referenced by SendRequest().
◆ PrintDebug()
Definition at line 516 of file utility.c.
517{
519 UCHAR Header1, Header2;
520 USHORT NumQuestions, NumAnswers, NumAuthority, NumAdditional;
524 int d = 0,
i = 0,
k = 0;
525
528
531
534
537
540
543
546
550 _tprintf(
_T(
" opcode = %s, id = %d, rcode = %s\n"),
552 (int)ResponseID,
554
556 if( Header1 & 0x01 )
_tprintf(
_T(
", want recursion") );
557 if( Header2 & 0x80 )
_tprintf(
_T(
", recursion avail.") );
559
560 _tprintf(
_T(
" questions = %d, answers = %d, "
561 "authority records = %d, additional = %d\n\n"),
562 (int)NumQuestions,
563 (int)NumAnswers,
564 (int)NumAuthority,
565 (int)NumAdditional );
566
567 if( NumQuestions )
568 {
570
571 for(
k = 0;
k < NumQuestions;
k += 1 )
572 {
574
576
579
582
586 }
587 }
588
589 if( NumAnswers )
590 {
592
593 for(
k = 0;
k < NumAnswers;
k += 1 )
594 {
596
597
599
601
602
605
608
611
614
615 _tprintf(
_T(
" type = %s, class = %s, dlen = %d\n"),
619
620
622 {
624
626 }
627 else
628 {
630
632 }
633
635 }
636 }
637
638 if( NumAuthority )
639 {
641
642 for(
k = 0;
k < NumAuthority;
k += 1 )
643 {
644
646
648
649
652
655
658
661
662 _tprintf(
_T(
" type = %s, class = %s, dlen = %d\n"),
666
667
669 {
670
672
674
676 }
678 {
680
681
683
685
686
688
690
691
698 }
699 }
700 }
701
702 if( NumAdditional )
703 {
705
706 for(
k = 0;
k < NumAdditional;
k += 1 )
707 {
708
710
712
713
716
719
722
725
726 _tprintf(
_T(
" type = %s, class = %s, dlen = %d\n"),
730
731
733 {
734
736
738
740 }
741 }
742 }
743
745}
int ExtractIP(PCHAR pBuffer, PCHAR pOutput, USHORT Offset)
Referenced by SendRequest().
◆ RCodeIDtoRCodeName()
Definition at line 765 of file utility.c.
766{
767 switch( RCode & 0x0F )
768 {
771
774
777
780
783
786
787 default:
789 }
790}
Referenced by PrintD2(), and PrintDebug().
◆ ReverseIP()
Definition at line 250 of file utility.c.
251{
255
257
260
261
262
263
264
265 for( ;
i > 0;
i -= 1 )
if(
'.' == pIP[
i] )
break;
266
270
273
276
277
278 for( ;
i > 0;
i -= 1 )
if(
'.' == pIP[
i] )
break;
279
283
286
289
290
291 for( ;
i > 0;
i -= 1 )
if(
'.' == pIP[
i] )
break;
292
296
299
302
303
304 for( ;
i > 0;
i -= 1 );
305
308
310}
Referenced by PerformInternalLookup(), and PerformLookup().
◆ SendRequest()
Definition at line 12 of file utility.c.
16{
22 int SendAddrLen = sizeof(SendAddr);
23
27
28
30
31
33
34
36
39
40
44
45
49
50
52
53
55 pInBuffer,
56 InBufferLength,
57 0,
59 sizeof(RecAddr) );
61 {
63 {
65 _tprintf(
_T(
"sendto() failed with WSANOTINITIALIZED\n") );
66 break;
68 _tprintf(
_T(
"sendto() failed with WSAENETDOWN\n") );
69 break;
71 _tprintf(
_T(
"sendto() failed with WSAEACCES\n") );
72 break;
74 _tprintf(
_T(
"sendto() failed with WSAEINVAL\n") );
75 break;
77 _tprintf(
_T(
"sendto() failed with WSAEINTR\n") );
78 break;
80 _tprintf(
_T(
"sendto() failed with WSAEINPROGRESS\n") );
81 break;
83 _tprintf(
_T(
"sendto() failed with WSAEFAULT\n") );
84 break;
86 _tprintf(
_T(
"sendto() failed with WSAENETRESET\n") );
87 break;
89 _tprintf(
_T(
"sendto() failed with WSAENOBUFS\n") );
90 break;
92 _tprintf(
_T(
"sendto() failed with WSAENOTCONN\n") );
93 break;
95 _tprintf(
_T(
"sendto() failed with WSAENOTSOCK\n") );
96 break;
98 _tprintf(
_T(
"sendto() failed with WSAEOPNOTSUPP\n") );
99 break;
101 _tprintf(
_T(
"sendto() failed with WSAESHUTDOWN\n") );
102 break;
104 _tprintf(
_T(
"sendto() failed with WSAEWOULDBLOCK\n") );
105 break;
107 _tprintf(
_T(
"sendto() failed with WSAEMSGSIZE\n") );
108 break;
110 _tprintf(
_T(
"sendto() failed with WSAEHOSTUNREACH\n") );
111 break;
113 _tprintf(
_T(
"sendto() failed with WSAECONNABORTED\n") );
114 break;
116 _tprintf(
_T(
"sendto() failed with WSAECONNRESET\n") );
117 break;
119 _tprintf(
_T(
"sendto() failed with WSAEADDRNOTAVAIL\n") );
120 break;
122 _tprintf(
_T(
"sendto() failed with WSAEAFNOSUPPORT\n") );
123 break;
125 _tprintf(
_T(
"sendto() failed with WSAEDESTADDRREQ\n") );
126 break;
128 _tprintf(
_T(
"sendto() failed with WSAENETUNREACH\n") );
129 break;
131 _tprintf(
_T(
"sendto() failed with WSAETIMEDOUT\n") );
132 break;
133 default:
134 _tprintf(
_T(
"sendto() failed with unknown error\n") );
135 }
136
139 }
140
142
143 while( bWait )
144 {
145
147 pOutBuffer,
148 *pOutBufferLength,
149 0,
151 &SendAddrLen );
153 {
155 {
157 _tprintf(
_T(
"recvfrom() failed with WSANOTINITIALIZED\n") );
158 break;
160 _tprintf(
_T(
"recvfrom() failed with WSAENETDOWN\n") );
161 break;
163 _tprintf(
_T(
"recvfrom() failed with WSAEACCES\n") );
164 break;
166 _tprintf(
_T(
"recvfrom() failed with WSAEINVAL\n") );
167 break;
169 _tprintf(
_T(
"recvfrom() failed with WSAEINTR\n") );
170 break;
172 _tprintf(
_T(
"recvfrom() failed with WSAEINPROGRESS\n") );
173 break;
175 _tprintf(
_T(
"recvfrom() failed with WSAEFAULT\n") );
176 break;
178 _tprintf(
_T(
"recvfrom() failed with WSAENETRESET\n") );
179 break;
181 _tprintf(
_T(
"recvfrom() failed with WSAENOBUFS\n") );
182 break;
184 _tprintf(
_T(
"recvfrom() failed with WSAENOTCONN\n") );
185 break;
187 _tprintf(
_T(
"recvfrom() failed with WSAENOTSOCK\n") );
188 break;
190 _tprintf(
_T(
"recvfrom() failed with WSAEOPNOTSUPP\n") );
191 break;
193 _tprintf(
_T(
"recvfrom() failed with WSAESHUTDOWN\n") );
194 break;
196 _tprintf(
_T(
"recvfrom() failed with WSAEWOULDBLOCK\n") );
197 break;
199 _tprintf(
_T(
"recvfrom() failed with WSAEMSGSIZE\n") );
200 break;
202 _tprintf(
_T(
"recvfrom() failed with WSAEHOSTUNREACH\n") );
203 break;
205 _tprintf(
_T(
"recvfrom() failed with WSAECONNABORTED\n") );
206 break;
208 _tprintf(
_T(
"recvfrom() failed with WSAECONNRESET\n") );
209 break;
211 _tprintf(
_T(
"recvfrom() failed with WSAEADDRNOTAVAIL\n") );
212 break;
214 _tprintf(
_T(
"recvfrom() failed with WSAEAFNOSUPPORT\n") );
215 break;
217 _tprintf(
_T(
"recvfrom() failed with WSAEDESTADDRREQ\n") );
218 break;
220 _tprintf(
_T(
"recvfrom() failed with WSAENETUNREACH\n") );
221 break;
223 _tprintf(
_T(
"recvfrom() failed with WSAETIMEDOUT\n") );
224 break;
225 default:
226 _tprintf(
_T(
"recvfrom() failed with unknown error\n") );
227 }
228
231 }
232
234
236 }
237
238
240
241
243
244
245 *pOutBufferLength =
j;
246
248}
ULONG WSAAPI inet_addr(IN CONST CHAR FAR *cp)
void PrintDebug(PCHAR pBuffer, DWORD BufferLength)
void PrintD2(PCHAR pBuffer, DWORD BufferLength)
INT WSAAPI recvfrom(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
INT WSAAPI sendto(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags, IN CONST struct sockaddr *to, IN INT tolen)
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
#define RtlZeroMemory(Destination, Length)
#define WSANOTINITIALISED
int PASCAL FAR WSAGetLastError(void)
Referenced by AddrFileFree(), PerformInternalLookup(), and PerformLookup().
◆ TypeIDtoTypeName()
Definition at line 792 of file utility.c.
793{
794 switch( TypeID )
795 {
798
801
804
807
810
813
816
819
820 default:
821 return "Unknown";
822 }
823}
Referenced by PrintD2(), and PrintDebug().
◆ TypeNametoTypeID()