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