nb30.pp 13 KB

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