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.

308 lines
12 KiB

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