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.

314 lines
12 KiB

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