Leaked source code of windows server 2003
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.

342 lines
8.4 KiB

  1. #ifndef _NMSMSGF_
  2. #define _NMSMSGF_
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /*++
  7. Copyright (c) 1989 Microsoft Corporation
  8. Module Name:
  9. nmsmsgf.h
  10. Abstract:
  11. This is the header file to be used for calling nmsmsgf.c functions
  12. Functions:
  13. Portability:
  14. This header is portable.
  15. Author:
  16. Pradeep Bahl (PradeepB) Jan-1993
  17. Revision History:
  18. Modification Date Person Description of Modification
  19. ------------------ ------- ---------------------------
  20. --*/
  21. /*
  22. includes
  23. */
  24. #include "wins.h"
  25. #include "comm.h"
  26. #include "assoc.h"
  27. #include "nmsdb.h"
  28. /*
  29. defines
  30. */
  31. //
  32. // Max. length of name in an RFC packet
  33. //
  34. #define NMSMSGF_RFC_MAX_NAM_LEN NMSDB_MAX_NAM_LEN
  35. /*
  36. macros
  37. */
  38. //
  39. // Inserts an IP address in an RFC pkt
  40. //
  41. #define NMSMSGF_INSERT_IPADD_M(pTmpB, IPAdd) \
  42. { \
  43. *(pTmpB)++ = (BYTE)((IPAdd) >> 24); \
  44. *(pTmpB)++ = (BYTE)(((IPAdd) >> 16) % 256);\
  45. *(pTmpB)++ = (BYTE)(((IPAdd) >> 8) % 256); \
  46. *(pTmpB)++ = (BYTE)((IPAdd) % 256); \
  47. }
  48. //
  49. // Currently IP addresses are same length as ULONG. When that changes
  50. // change this macro
  51. //
  52. FUTURES("Change when sizeof(COMM_IP_ADD_T) != sizeof(ULONG)")
  53. #define NMSMSGF_INSERT_ULONG_M(pTmpB, x) NMSMSGF_INSERT_IPADD_M(pTmpB, x)
  54. //
  55. // Retrieves an IP address from an RFC pkt
  56. //
  57. #define NMSMSGF_RETRIEVE_IPADD_M(pTmpB, IPAdd) \
  58. { \
  59. (IPAdd) = *(pTmpB)++ << 24; \
  60. (IPAdd) |= *(pTmpB)++ << 16; \
  61. (IPAdd) |= *(pTmpB)++ << 8; \
  62. (IPAdd) |= *(pTmpB)++; \
  63. }
  64. //
  65. // Currently IP addresses are same length as ULONG. When that changes
  66. // change this macro
  67. //
  68. FUTURES("Change when sizeof(COMM_IP_ADD_T) != sizeof(ULONG)")
  69. #define NMSMSGF_RETRIEVE_ULONG_M(pTmpB, x) NMSMSGF_RETRIEVE_IPADD_M(pTmpB, x)
  70. //
  71. // Max number of multihomed addresses
  72. //
  73. #define NMSMSGF_MAX_NO_MULTIH_ADDS NMSDB_MAX_MEMS_IN_GRP
  74. //
  75. // Used for swapping bytes (to support the browser)
  76. //
  77. #define NMSMSGF_MODIFY_NAME_IF_REQD_M(pName) \
  78. { \
  79. if (*((pName) + 15) == 0x1B) \
  80. { \
  81. WINS_SWAP_BYTES_M((pName), (pName) + 15);\
  82. } \
  83. }
  84. /*
  85. externs
  86. */
  87. /*
  88. typedef definitions
  89. */
  90. /*
  91. NMSMSGF_ERR_CODE_E - The various Rcode values returned in responses to
  92. the various name requests received.
  93. Note: CFT_ERR is never returned in a negative name release response.
  94. ACT_ERR code in a negative name release response means that the
  95. WINS server will not allow a node to release the name owned by another
  96. node.o
  97. */
  98. typedef enum _NMSMSGF_ERR_CODE_E {
  99. NMSMSGF_E_SUCCESS = 0, //Success
  100. NMSMSGF_E_FMT_ERR = 1, //Format error. Req. was invalidly formatted
  101. NMSMSGF_E_SRV_ERR = 2, //Server failure. Problem with WINS. Can not
  102. //service name
  103. CHECK("Check this one out. Would WINS ever return this ?")
  104. NMSMSGF_E_NAM_ERR = 3, //Name does not exist in the directory
  105. NMSMSGF_E_IMP_ERR = 4, //Unsupported req. error. Allowable only for
  106. //challenging NBNS when gets an Update type
  107. //registration request
  108. NMSMSGF_E_RFS_ERR = 5, //Refused error. For policy reasons WINS
  109. //will not register this namei from this host
  110. NMSMSGF_E_ACT_ERR = 6, //Active error. Name is owned by another node
  111. NMSMSGF_E_CFT_ERR = 7 //Name in conflict error. A unique name is
  112. //owned by more than one node
  113. } NMSMSGF_ERR_CODE_E, *PNMSMSGF_ERR_CODE_E;
  114. /*
  115. NMSMSGF_NODE_TYP_E -- Node type of node that sent the name registration
  116. message
  117. Values assigned to the enumrators are those specified in RFC 1002
  118. Bnode value will be set by Proxy
  119. NOTE NOTE NOTE
  120. WINS will never get a registration from a B node since we decided
  121. that B node registrations will not be passed to WINS by the
  122. proxy.
  123. */
  124. typedef enum _NMSMSGF_NODE_TYP_E {
  125. NMSMSGF_E_BNODE = 0, //RFC 1002 specified value
  126. NMSMSGF_E_PNODE = 1, // RFC 1002 specified value
  127. NMSMSGF_E_MODE = 2 //RFC 1002 specified value
  128. } NMSMSGF_NODE_TYP_E, *PNMSMSGF_NODE_TYP_E;
  129. //
  130. // Information required to send a response to an NBT node
  131. //
  132. typedef struct _NMSMSGF_RSP_INFO_T {
  133. NMSMSGF_ERR_CODE_E Rcode_e;
  134. MSG_T pMsg;
  135. MSG_LEN_T MsgLen;
  136. PNMSDB_NODE_ADDS_T pNodeAdds;
  137. DWORD QuesNamSecLen;
  138. NMSMSGF_NODE_TYP_E NodeTyp_e;
  139. BYTE EntTyp;
  140. DWORD RefreshInterval;
  141. } NMSMSGF_RSP_INFO_T, *PNMSMSGF_RSP_INFO_T;
  142. /*
  143. NMSMSGF_NAM_REQ_TYP_E
  144. Type of name request that the WINS deals with
  145. Values assigned to the enumrators are those specified in RFC 1002
  146. Used by NmsProcNbtReq and NmsNmhNamRegRsp.
  147. */
  148. CHECK("RFC 1002 is inconsistent in its specification of the opcode for ")
  149. CHECK("Name Refresh. AT one place it specifies 8 and at another 9")
  150. CHECK("8 seems more likely since it follows in sequeence to the value")
  151. CHECK("for WACK")
  152. typedef enum _NMSMSGF_NAM_REQ_TYP_E {
  153. NMSMSGF_E_NAM_QUERY = 0,
  154. NMSMSGF_E_NAM_REG = 5,
  155. NMSMSGF_E_NAM_REL = 6,
  156. NMSMSGF_E_NAM_WACK = 7,
  157. NMSMSGF_E_NAM_REF = 8, /*RFC 1002 specifies 8 and 9.Which one is
  158. *correct (page 9 and page 15)?
  159. */
  160. NMSMSGF_E_NAM_REF_UB = 9, //Netbt in Daytona release will use 9 for
  161. //compatibility with UB NBNS. So, I
  162. //need to support this too
  163. NMSMSGF_E_MULTIH_REG = 0xF, //not in RFC. For supporting multi-homed
  164. //hosts
  165. NMSMSGF_E_INV_REQ = 10 // invalid name request
  166. } NMSMSGF_NAM_REQ_TYP_E, *PNMSMSGF_NAM_REQ_TYP_E;
  167. //
  168. // Counted array of addresses. The array size is big enough to hold the
  169. // max. number of addresses that can be sent in a UDP packet.
  170. //
  171. // We need to get all the addresses when a query response is received
  172. // by WINS (to a challenge). This is so that it can handle mh nodes
  173. // with > 25 addresses.
  174. //
  175. // Since a UDP packet can not be > 512, assuming a name size of 16 (32 bytes
  176. // encoded), the packet size apart from Ip address is around 60. So the
  177. // max. number of addresses there can be is (512-60 - 2)/4 = around 112.
  178. //
  179. //#define NMSMSGF_MAX_ADDRESSES_IN_UDP_PKT 100
  180. //
  181. // We will never take more than 25 addresses from a packet. Netbt will also
  182. // never send more than 25. Even if it does, we will stop at the 26th address
  183. // The count is being kept at 25 so as to avoid a buffer overflow problem
  184. // in NmsMsgfUfmNamRsp.
  185. //
  186. // If the max name size is used - 255 and using 60 bytes for the other contents\// of the packet, we have (512-315 -2 = 195 bytes for the ip address). This
  187. // will accept 195/4 = around 48 addresses. No chance for overflow when we
  188. // use a limit of 25.
  189. //
  190. #define NMSMSGF_MAX_ADDRESSES_IN_UDP_PKT 25
  191. FUTURES("when we start supportng tcp connections. this array size may not")
  192. FUTURES("be sufficient")
  193. typedef struct _NMSMSGF_CNT_ADD_T {
  194. DWORD NoOfAdds;
  195. COMM_ADD_T Add[NMSMSGF_MAX_ADDRESSES_IN_UDP_PKT];
  196. } NMSMSGF_CNT_ADD_T, *PNMSMSGF_CNT_ADD_T;
  197. /*
  198. function definitions
  199. */
  200. extern
  201. STATUS
  202. NmsMsgfProcNbtReq(
  203. PCOMM_HDL_T pDlgHdl,
  204. MSG_T pMsg,
  205. MSG_LEN_T MsgLen
  206. );
  207. extern
  208. STATUS
  209. NmsMsgfFrmNamRspMsg(
  210. PCOMM_HDL_T pDlgHdl,
  211. NMSMSGF_NAM_REQ_TYP_E NamRspTyp_e,
  212. PNMSMSGF_RSP_INFO_T pRspInfo
  213. );
  214. extern
  215. VOID
  216. NmsMsgfFrmNamQueryReq(
  217. IN DWORD TransId,
  218. IN MSG_T pMsg,
  219. OUT PMSG_LEN_T pMsgLen,
  220. IN LPBYTE pNameToFormat,
  221. IN DWORD NameLen
  222. );
  223. extern
  224. VOID
  225. NmsMsgfFrmNamRelReq(
  226. IN DWORD TransId,
  227. IN MSG_T pMsg,
  228. OUT PMSG_LEN_T pMsgLen,
  229. IN LPBYTE pNameToFormat,
  230. IN DWORD NameLen,
  231. IN NMSMSGF_NODE_TYP_E NodeTyp_e,
  232. IN PCOMM_ADD_T pNodeAdd
  233. );
  234. extern
  235. STATUS
  236. NmsMsgfFrmNamRegReq(
  237. IN DWORD TransId,
  238. IN MSG_T pMsg,
  239. OUT PMSG_LEN_T pMsgLen,
  240. IN LPBYTE pNameToFormat,
  241. IN DWORD NameLen,
  242. IN NMSMSGF_NODE_TYP_E NodeTyp_e,
  243. IN PCOMM_ADD_T pNodeAdd
  244. );
  245. extern
  246. VOID
  247. NmsMsgfFrmWACK(
  248. IN LPBYTE Buff,
  249. OUT LPDWORD pBuffLen,
  250. IN MSG_T pMsg,
  251. IN DWORD QuesSecNamLen,
  252. IN DWORD TTL
  253. );
  254. extern
  255. STATUS
  256. NmsMsgfUfmNamRsp(
  257. IN LPBYTE pMsg,
  258. OUT PNMSMSGF_NAM_REQ_TYP_E pOpcode_e,
  259. OUT LPDWORD pTransId,
  260. OUT LPBYTE pName,
  261. OUT LPDWORD pNameLen,
  262. OUT PNMSMSGF_CNT_ADD_T pCntAdd,
  263. OUT PNMSMSGF_ERR_CODE_E pRcode_e,
  264. OUT PBOOL fGroup
  265. );
  266. extern
  267. VOID
  268. NmsMsgfSndNamRsp(
  269. PCOMM_HDL_T pDlgHdl,
  270. LPBYTE pMsg,
  271. DWORD MsgLen,
  272. DWORD BlockOfReq
  273. );
  274. #ifdef __cplusplus
  275. }
  276. #endif
  277. #endif //_NMSMSGF_