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.

316 lines
12 KiB

  1. //*++
  2. //
  3. // Copyright (c) 1991-1999 Microsoft Corporation
  4. //
  5. // Module Name:
  6. //
  7. // nb30.h
  8. //
  9. // Abstract:
  10. //
  11. // This module contains the definitions for portable NetBIOS 3.0
  12. // support.
  13. //
  14. //--*/
  15. #ifndef NCB_INCLUDED
  16. #define NCB_INCLUDED
  17. #if _MSC_VER > 1000
  18. #pragma once
  19. #endif
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /****************************************************************
  24. * *
  25. * Data structure templates *
  26. * *
  27. ****************************************************************/
  28. #define NCBNAMSZ 16 /* absolute length of a net name */
  29. #define MAX_LANA 254 /* lana's in range 0 to MAX_LANA inclusive */
  30. /*
  31. * Network Control Block
  32. */
  33. typedef struct _NCB {
  34. UCHAR ncb_command; /* command code */
  35. UCHAR ncb_retcode; /* return code */
  36. UCHAR ncb_lsn; /* local session number */
  37. UCHAR ncb_num; /* number of our network name */
  38. PUCHAR ncb_buffer; /* address of message buffer */
  39. WORD ncb_length; /* size of message buffer */
  40. UCHAR ncb_callname[NCBNAMSZ]; /* blank-padded name of remote */
  41. UCHAR ncb_name[NCBNAMSZ]; /* our blank-padded netname */
  42. UCHAR ncb_rto; /* rcv timeout/retry count */
  43. UCHAR ncb_sto; /* send timeout/sys timeout */
  44. void (CALLBACK *ncb_post)( struct _NCB * ); /* POST routine address */
  45. UCHAR ncb_lana_num; /* lana (adapter) number */
  46. UCHAR ncb_cmd_cplt; /* 0xff => commmand pending */
  47. #ifdef _WIN64
  48. UCHAR ncb_reserve[18]; /* reserved, used by BIOS */
  49. #else
  50. UCHAR ncb_reserve[10]; /* reserved, used by BIOS */
  51. #endif
  52. HANDLE ncb_event; /* HANDLE to Win32 event which */
  53. /* will be set to the signalled */
  54. /* state when an ASYNCH command */
  55. /* completes */
  56. } NCB, *PNCB;
  57. /*
  58. * Structure returned to the NCB command NCBASTAT is ADAPTER_STATUS followed
  59. * by an array of NAME_BUFFER structures.
  60. */
  61. typedef struct _ADAPTER_STATUS {
  62. UCHAR adapter_address[6];
  63. UCHAR rev_major;
  64. UCHAR reserved0;
  65. UCHAR adapter_type;
  66. UCHAR rev_minor;
  67. WORD duration;
  68. WORD frmr_recv;
  69. WORD frmr_xmit;
  70. WORD iframe_recv_err;
  71. WORD xmit_aborts;
  72. DWORD xmit_success;
  73. DWORD recv_success;
  74. WORD iframe_xmit_err;
  75. WORD recv_buff_unavail;
  76. WORD t1_timeouts;
  77. WORD ti_timeouts;
  78. DWORD reserved1;
  79. WORD free_ncbs;
  80. WORD max_cfg_ncbs;
  81. WORD max_ncbs;
  82. WORD xmit_buf_unavail;
  83. WORD max_dgram_size;
  84. WORD pending_sess;
  85. WORD max_cfg_sess;
  86. WORD max_sess;
  87. WORD max_sess_pkt_size;
  88. WORD name_count;
  89. } ADAPTER_STATUS, *PADAPTER_STATUS;
  90. typedef struct _NAME_BUFFER {
  91. UCHAR name[NCBNAMSZ];
  92. UCHAR name_num;
  93. UCHAR name_flags;
  94. } NAME_BUFFER, *PNAME_BUFFER;
  95. // values for name_flags bits.
  96. #define NAME_FLAGS_MASK 0x87
  97. #define GROUP_NAME 0x80
  98. #define UNIQUE_NAME 0x00
  99. #define REGISTERING 0x00
  100. #define REGISTERED 0x04
  101. #define DEREGISTERED 0x05
  102. #define DUPLICATE 0x06
  103. #define DUPLICATE_DEREG 0x07
  104. /*
  105. * Structure returned to the NCB command NCBSSTAT is SESSION_HEADER followed
  106. * by an array of SESSION_BUFFER structures. If the NCB_NAME starts with an
  107. * asterisk then an array of these structures is returned containing the
  108. * status for all names.
  109. */
  110. typedef struct _SESSION_HEADER {
  111. UCHAR sess_name;
  112. UCHAR num_sess;
  113. UCHAR rcv_dg_outstanding;
  114. UCHAR rcv_any_outstanding;
  115. } SESSION_HEADER, *PSESSION_HEADER;
  116. typedef struct _SESSION_BUFFER {
  117. UCHAR lsn;
  118. UCHAR state;
  119. UCHAR local_name[NCBNAMSZ];
  120. UCHAR remote_name[NCBNAMSZ];
  121. UCHAR rcvs_outstanding;
  122. UCHAR sends_outstanding;
  123. } SESSION_BUFFER, *PSESSION_BUFFER;
  124. // Values for state
  125. #define LISTEN_OUTSTANDING 0x01
  126. #define CALL_PENDING 0x02
  127. #define SESSION_ESTABLISHED 0x03
  128. #define HANGUP_PENDING 0x04
  129. #define HANGUP_COMPLETE 0x05
  130. #define SESSION_ABORTED 0x06
  131. /*
  132. * Structure returned to the NCB command NCBENUM.
  133. *
  134. * On a system containing lana's 0, 2 and 3, a structure with
  135. * length =3, lana[0]=0, lana[1]=2 and lana[2]=3 will be returned.
  136. */
  137. typedef struct _LANA_ENUM {
  138. UCHAR length; // Number of valid entries in lana[]
  139. UCHAR lana[MAX_LANA+1];
  140. } LANA_ENUM, *PLANA_ENUM;
  141. /*
  142. * Structure returned to the NCB command NCBFINDNAME is FIND_NAME_HEADER followed
  143. * by an array of FIND_NAME_BUFFER structures.
  144. */
  145. typedef struct _FIND_NAME_HEADER {
  146. WORD node_count;
  147. UCHAR reserved;
  148. UCHAR unique_group;
  149. } FIND_NAME_HEADER, *PFIND_NAME_HEADER;
  150. typedef struct _FIND_NAME_BUFFER {
  151. UCHAR length;
  152. UCHAR access_control;
  153. UCHAR frame_control;
  154. UCHAR destination_addr[6];
  155. UCHAR source_addr[6];
  156. UCHAR routing_info[18];
  157. } FIND_NAME_BUFFER, *PFIND_NAME_BUFFER;
  158. /*
  159. * Structure provided with NCBACTION. The purpose of NCBACTION is to provide
  160. * transport specific extensions to netbios.
  161. */
  162. typedef struct _ACTION_HEADER {
  163. ULONG transport_id;
  164. USHORT action_code;
  165. USHORT reserved;
  166. } ACTION_HEADER, *PACTION_HEADER;
  167. // Values for transport_id
  168. #define ALL_TRANSPORTS "M\0\0\0"
  169. #define MS_NBF "MNBF"
  170. /****************************************************************
  171. * *
  172. * Special values and constants *
  173. * *
  174. ****************************************************************/
  175. /*
  176. * NCB Command codes
  177. */
  178. #define NCBCALL 0x10 /* NCB CALL */
  179. #define NCBLISTEN 0x11 /* NCB LISTEN */
  180. #define NCBHANGUP 0x12 /* NCB HANG UP */
  181. #define NCBSEND 0x14 /* NCB SEND */
  182. #define NCBRECV 0x15 /* NCB RECEIVE */
  183. #define NCBRECVANY 0x16 /* NCB RECEIVE ANY */
  184. #define NCBCHAINSEND 0x17 /* NCB CHAIN SEND */
  185. #define NCBDGSEND 0x20 /* NCB SEND DATAGRAM */
  186. #define NCBDGRECV 0x21 /* NCB RECEIVE DATAGRAM */
  187. #define NCBDGSENDBC 0x22 /* NCB SEND BROADCAST DATAGRAM */
  188. #define NCBDGRECVBC 0x23 /* NCB RECEIVE BROADCAST DATAGRAM */
  189. #define NCBADDNAME 0x30 /* NCB ADD NAME */
  190. #define NCBDELNAME 0x31 /* NCB DELETE NAME */
  191. #define NCBRESET 0x32 /* NCB RESET */
  192. #define NCBASTAT 0x33 /* NCB ADAPTER STATUS */
  193. #define NCBSSTAT 0x34 /* NCB SESSION STATUS */
  194. #define NCBCANCEL 0x35 /* NCB CANCEL */
  195. #define NCBADDGRNAME 0x36 /* NCB ADD GROUP NAME */
  196. #define NCBENUM 0x37 /* NCB ENUMERATE LANA NUMBERS */
  197. #define NCBUNLINK 0x70 /* NCB UNLINK */
  198. #define NCBSENDNA 0x71 /* NCB SEND NO ACK */
  199. #define NCBCHAINSENDNA 0x72 /* NCB CHAIN SEND NO ACK */
  200. #define NCBLANSTALERT 0x73 /* NCB LAN STATUS ALERT */
  201. #define NCBACTION 0x77 /* NCB ACTION */
  202. #define NCBFINDNAME 0x78 /* NCB FIND NAME */
  203. #define NCBTRACE 0x79 /* NCB TRACE */
  204. #define ASYNCH 0x80 /* high bit set == asynchronous */
  205. /*
  206. * NCB Return codes
  207. */
  208. #define NRC_GOODRET 0x00 /* good return */
  209. /* also returned when ASYNCH request accepted */
  210. #define NRC_BUFLEN 0x01 /* illegal buffer length */
  211. #define NRC_ILLCMD 0x03 /* illegal command */
  212. #define NRC_CMDTMO 0x05 /* command timed out */
  213. #define NRC_INCOMP 0x06 /* message incomplete, issue another command */
  214. #define NRC_BADDR 0x07 /* illegal buffer address */
  215. #define NRC_SNUMOUT 0x08 /* session number out of range */
  216. #define NRC_NORES 0x09 /* no resource available */
  217. #define NRC_SCLOSED 0x0a /* session closed */
  218. #define NRC_CMDCAN 0x0b /* command cancelled */
  219. #define NRC_DUPNAME 0x0d /* duplicate name */
  220. #define NRC_NAMTFUL 0x0e /* name table full */
  221. #define NRC_ACTSES 0x0f /* no deletions, name has active sessions */
  222. #define NRC_LOCTFUL 0x11 /* local session table full */
  223. #define NRC_REMTFUL 0x12 /* remote session table full */
  224. #define NRC_ILLNN 0x13 /* illegal name number */
  225. #define NRC_NOCALL 0x14 /* no callname */
  226. #define NRC_NOWILD 0x15 /* cannot put * in NCB_NAME */
  227. #define NRC_INUSE 0x16 /* name in use on remote adapter */
  228. #define NRC_NAMERR 0x17 /* name deleted */
  229. #define NRC_SABORT 0x18 /* session ended abnormally */
  230. #define NRC_NAMCONF 0x19 /* name conflict detected */
  231. #define NRC_IFBUSY 0x21 /* interface busy, IRET before retrying */
  232. #define NRC_TOOMANY 0x22 /* too many commands outstanding, retry later */
  233. #define NRC_BRIDGE 0x23 /* ncb_lana_num field invalid */
  234. #define NRC_CANOCCR 0x24 /* command completed while cancel occurring */
  235. #define NRC_CANCEL 0x26 /* command not valid to cancel */
  236. #define NRC_DUPENV 0x30 /* name defined by anther local process */
  237. #define NRC_ENVNOTDEF 0x34 /* environment undefined. RESET required */
  238. #define NRC_OSRESNOTAV 0x35 /* required OS resources exhausted */
  239. #define NRC_MAXAPPS 0x36 /* max number of applications exceeded */
  240. #define NRC_NOSAPS 0x37 /* no saps available for netbios */
  241. #define NRC_NORESOURCES 0x38 /* requested resources are not available */
  242. #define NRC_INVADDRESS 0x39 /* invalid ncb address or length > segment */
  243. #define NRC_INVDDID 0x3B /* invalid NCB DDID */
  244. #define NRC_LOCKFAIL 0x3C /* lock of user area failed */
  245. #define NRC_OPENERR 0x3f /* NETBIOS not loaded */
  246. #define NRC_SYSTEM 0x40 /* system error */
  247. #define NRC_PENDING 0xff /* asynchronous command is not yet finished */
  248. /****************************************************************
  249. * *
  250. * main user entry point for NetBIOS 3.0 *
  251. * *
  252. * Usage: result = Netbios( pncb ); *
  253. ****************************************************************/
  254. UCHAR
  255. APIENTRY
  256. Netbios(
  257. PNCB pncb
  258. );
  259. /****************************************************************
  260. * *
  261. * Prefix for callback routines *
  262. * *
  263. * Usage in a declaration: NCB_POST MyPostRoutine( PNCB pncb ); *
  264. ****************************************************************/
  265. #define NCB_POST void CALLBACK
  266. #ifdef __cplusplus
  267. }
  268. #endif
  269. #endif /* NCB_INCLUDED */