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.

172 lines
3.8 KiB

  1. /*++
  2. Copyright (C) 1999 Microsoft Corporation
  3. --*/
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <signal.h>
  8. #include <nt.h>
  9. #include <ntrtl.h>
  10. #include <nturtl.h>
  11. #include <wtypes.h>
  12. #include <fcntl.h>
  13. #include <sys/stropts.h>
  14. #include <ctype.h>
  15. #include <windows.h>
  16. #include <tdi.h>
  17. #include <sys\uio.h>
  18. #include <winsock.h>
  19. #include <wsahelp.h>
  20. #include <sockets\resolv.h>
  21. #include <nb30.h>
  22. #include <nbtioctl.h>
  23. #include "winsintf.h"
  24. #include "common.h"
  25. #define MAX_PATH_LEN 100
  26. #define WINSTEST_FOUND 0
  27. #define WINSTEST_NOT_FOUND 1
  28. #define WINSTEST_NO_RESPONSE 2
  29. #define WINSTEST_VERIFIED 0
  30. #define WINSTEST_OUT_OF_MEMORY 3
  31. #define WINSTEST_BAD_IP_ADDRESS 4
  32. #define WINSTEST_HOST_NOT_FOUND 5
  33. #define WINSTEST_NOT_VERIFIED 6
  34. #define WINSTEST_INVALID_ARG 7
  35. #define WINSTEST_OPEN_FAILED 8
  36. #define _WINS_CFG_PULL_KEY TEXT("System\\CurrentControlSet\\Services\\Wins\\Partners\\Pull")
  37. #define _WINS_CFG_PUSH_KEY TEXT("System\\CurrentControlSet\\Services\\Wins\\Partners\\Push")
  38. #define WINSCNF_ONLY_DYN_RECS_NM TEXT("OnlyDynRecs")
  39. #define _NBT_CFG_ADAPTERS_KEY TEXT("System\\CurrentControlSet\\Services\\NetBT\\Adapters")
  40. #define RPL_E_PULL 0
  41. #define RPL_E_PUSH 1
  42. #define RE_QUERY_REGISTRY_COUNT 10
  43. #define MAX_NB_NAMES 1000
  44. #define MAX_SERVERS 1000
  45. #define BUFF_SIZE 650
  46. #define MY_PRINT0(_continuous, _str) { \
  47. MY_FPRINT(_continuous, _str); \
  48. }
  49. #define MY_PRINT1(_continuous, _str, _v1) { \
  50. UCHAR __str[500]; \
  51. sprintf(__str, _str, _v1); \
  52. MY_FPRINT(_continuous, __str); \
  53. }
  54. #define MY_PRINT2(_continuous, _str, _v1, _v2) { \
  55. UCHAR __str[500]; \
  56. sprintf(__str, _str, _v1, _v2); \
  57. MY_FPRINT(_continuous, __str); \
  58. }
  59. #define MY_PRINT3(_continuous, _str, _v1, _v2, _v3) { \
  60. UCHAR __str[500]; \
  61. sprintf(__str, _str, _v1, _v2, _v3); \
  62. MY_FPRINT(_continuous, __str); \
  63. }
  64. #define MY_PRINT4(_continuous, _str, _v1, _v2, _v3, _v4) { \
  65. UCHAR __str[500]; \
  66. sprintf(__str, _str, _v1, _v2, _v3, _v4); \
  67. MY_FPRINT(_continuous, __str); \
  68. }
  69. #define MY_FPRINT(_continuous, __str_) \
  70. if (_continuous) { \
  71. fprintf (fp1, __str_); \
  72. } else { \
  73. fprintf (fp, __str_); \
  74. if (Interactive) { \
  75. printf (__str_); \
  76. }\
  77. }
  78. typedef struct _PUSH_PULL_ENTRY {
  79. ULONG PE_IpAddr;
  80. UCHAR PE_Name[MAX_PATH_LEN];
  81. struct _PUSH_PULL_ENTRY *PE_Next;
  82. } PUSH_PULL_ENTRY, *PPUSH_PULL_ENTRY;
  83. typedef struct _NODE_INFO {
  84. ULONG NI_IpAddr;
  85. UCHAR NI_Name[MAX_PATH_LEN];
  86. PPUSH_PULL_ENTRY NI_Lists[2]; // 0 - RPL_E_PULL - PULL list; 1 - RPL_E_PUSH - PUSH list
  87. struct _NODE_INFO *NI_Next;
  88. struct _NODE_INFO *NI_DoneNext;
  89. } NODE_INFO, *PNODE_INFO;
  90. PNODE_INFO GlobalListHead=NULL;
  91. PNODE_INFO GlobalListTail=NULL;
  92. PNODE_INFO GlobalDoneListHead=NULL;
  93. PNODE_INFO GlobalDoneListTail=NULL;
  94. ULONG LocalIpAddress;
  95. CHAR pScope[128];
  96. #define PUSH_BUT_NOT_PULL_LOCAL 0
  97. #define PULL_BUT_NOT_PUSH 1
  98. #define PUSH_BUT_NOT_PULL 2
  99. #define PULL_BUT_NOT_PUSH_LOCAL 3
  100. #define MAX_WINS 1000
  101. //
  102. // <Server> - <Owner> Table - [SO] Table
  103. //
  104. //LARGE_INTEGER SO_Table[MAX_WINS][MAX_WINS];
  105. LARGE_INTEGER **SO_Table = NULL;
  106. //
  107. // Lookaside table to map IP addrs to the index into the SO_Table
  108. //
  109. UCHAR LA_Table[MAX_WINS][20];
  110. ULONG LA_TableSize;
  111. #define ME_PULL 0x1
  112. #define ME_PUSH 0x2
  113. //
  114. // Push/Pull matrix
  115. //
  116. typedef struct _MATRIX_ENTRY {
  117. BOOLEAN ME_Down; // 0 - UP; 1 - Down
  118. USHORT ME_Entry; // 1 - Pull; 2 - Push
  119. } MATRIX_ENTRY, *PMATRIX_ENTRY;
  120. MATRIX_ENTRY PP_Matrix[MAX_WINS][MAX_WINS];
  121. VOID
  122. DumpSOTable(
  123. IN DWORD MasterOwners,
  124. IN BOOL fFile,
  125. IN FILE * pFile
  126. );
  127. VOID
  128. DumpLATable(
  129. IN DWORD MasterOwners,
  130. IN BOOL fFile,
  131. IN FILE * pFile
  132. );