1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 //! This module contains the definitions for portable NetBIOS 3.0 support.
7 use shared::minwindef::{DWORD, PUCHAR, UCHAR, ULONG, USHORT, WORD};
8 use um::winnt::HANDLE;
9 pub const NCBNAMSZ: usize = 16;
10 pub const MAX_LANA: usize = 254;
11 FN!{stdcall PFPOST(
12     *mut NCB,
13 ) -> ()}
14 #[cfg(target_pointer_width = "64")]
15 STRUCT!{struct NCB {
16     ncb_command: UCHAR,
17     ncb_retcode: UCHAR,
18     ncb_lsn: UCHAR,
19     ncb_num: UCHAR,
20     ncb_buffer: PUCHAR,
21     ncb_length: WORD,
22     ncb_callname: [UCHAR; NCBNAMSZ],
23     ncb_name: [UCHAR; NCBNAMSZ],
24     ncb_rto: UCHAR,
25     ncb_sto: UCHAR,
26     ncb_post: PFPOST,
27     ncb_lana_num: UCHAR,
28     ncb_cmd_cplt: UCHAR,
29     ncb_reserve: [UCHAR; 18],
30     ncb_event: HANDLE,
31 }}
32 #[cfg(target_pointer_width = "32")]
33 STRUCT!{struct NCB {
34     ncb_command: UCHAR,
35     ncb_retcode: UCHAR,
36     ncb_lsn: UCHAR,
37     ncb_num: UCHAR,
38     ncb_buffer: PUCHAR,
39     ncb_length: WORD,
40     ncb_callname: [UCHAR; NCBNAMSZ],
41     ncb_name: [UCHAR; NCBNAMSZ],
42     ncb_rto: UCHAR,
43     ncb_sto: UCHAR,
44     ncb_post: PFPOST,
45     ncb_lana_num: UCHAR,
46     ncb_cmd_cplt: UCHAR,
47     ncb_reserve: [UCHAR; 10],
48     ncb_event: HANDLE,
49 }}
50 pub type PNCB = *mut NCB;
51 STRUCT!{struct ADAPTER_STATUS {
52     adapter_address: [UCHAR; 6],
53     rev_major: UCHAR,
54     reserved0: UCHAR,
55     adapter_type: UCHAR,
56     rev_minor: UCHAR,
57     duration: WORD,
58     frmr_recv: WORD,
59     frmr_xmit: WORD,
60     iframe_recv_err: WORD,
61     xmit_aborts: WORD,
62     xmit_success: DWORD,
63     recv_success: DWORD,
64     iframe_xmit_err: WORD,
65     recv_buff_unavail: WORD,
66     t1_timeouts: WORD,
67     ti_timeouts: WORD,
68     reserved1: DWORD,
69     free_ncbs: WORD,
70     max_cfg_ncbs: WORD,
71     max_ncbs: WORD,
72     xmit_buf_unavail: WORD,
73     max_dgram_size: WORD,
74     pending_sess: WORD,
75     max_cfg_sess: WORD,
76     max_sess: WORD,
77     max_sess_pkt_size: WORD,
78     name_count: WORD,
79 }}
80 pub type PADAPTER_STATUS = *mut ADAPTER_STATUS;
81 STRUCT!{struct NAME_BUFFER {
82     name: [UCHAR; NCBNAMSZ],
83     name_num: UCHAR,
84     name_flags: UCHAR,
85 }}
86 pub type PNAME_BUFFER = *mut NAME_BUFFER;
87 pub const NAME_FLAGS_MASK: UCHAR = 0x87;
88 pub const GROUP_NAME: UCHAR = 0x80;
89 pub const UNIQUE_NAME: UCHAR = 0x00;
90 pub const REGISTERING: UCHAR = 0x00;
91 pub const REGISTERED: UCHAR = 0x04;
92 pub const DEREGISTERED: UCHAR = 0x05;
93 pub const DUPLICATE: UCHAR = 0x06;
94 pub const DUPLICATE_DEREG: UCHAR = 0x07;
95 STRUCT!{struct SESSION_HEADER {
96     sess_name: UCHAR,
97     num_sess: UCHAR,
98     rcv_dg_outstanding: UCHAR,
99     rcv_any_outstanding: UCHAR,
100 }}
101 pub type PSESSION_HEADER = *mut SESSION_HEADER;
102 STRUCT!{struct SESSION_BUFFER {
103     lsn: UCHAR,
104     state: UCHAR,
105     local_name: [UCHAR; NCBNAMSZ],
106     remote_name: [UCHAR; NCBNAMSZ],
107     rcvs_outstanding: UCHAR,
108     sends_outstanding: UCHAR,
109 }}
110 pub type PSESSION_BUFFER = *mut SESSION_BUFFER;
111 pub const LISTEN_OUTSTANDING: UCHAR = 0x01;
112 pub const CALL_PENDING: UCHAR = 0x02;
113 pub const SESSION_ESTABLISHED: UCHAR = 0x03;
114 pub const HANGUP_PENDING: UCHAR = 0x04;
115 pub const HANGUP_COMPLETE: UCHAR = 0x05;
116 pub const SESSION_ABORTED: UCHAR = 0x06;
117 STRUCT!{struct LANA_ENUM {
118     length: UCHAR,
119     lana: [UCHAR; MAX_LANA + 1],
120 }}
121 pub type PLANA_ENUM = *mut LANA_ENUM;
122 STRUCT!{struct FIND_NAME_HEADER {
123     node_count: WORD,
124     reserved: UCHAR,
125     unique_group: UCHAR,
126 }}
127 pub type PFIND_NAME_HEADER = *mut FIND_NAME_HEADER;
128 STRUCT!{struct FIND_NAME_BUFFER {
129     length: UCHAR,
130     access_control: UCHAR,
131     frame_control: UCHAR,
132     destination_addr: [UCHAR; 6],
133     source_addr: [UCHAR; 6],
134     routing_info: [UCHAR; 18],
135 }}
136 pub type PFIND_NAME_BUFFER = *mut FIND_NAME_BUFFER;
137 STRUCT!{struct ACTION_HEADER {
138     transport_id: ULONG,
139     action_code: USHORT,
140     reserved: USHORT,
141 }}
142 pub type PACTION_HEADER = *mut ACTION_HEADER;
143 pub const ALL_TRANSPORTS: ULONG = 0x0000004d;
144 pub const MS_NBF: ULONG = 0x46424e4d;
145 pub const NCBCALL: UCHAR = 0x10;
146 pub const NCBLISTEN: UCHAR = 0x11;
147 pub const NCBHANGUP: UCHAR = 0x12;
148 pub const NCBSEND: UCHAR = 0x14;
149 pub const NCBRECV: UCHAR = 0x15;
150 pub const NCBRECVANY: UCHAR = 0x16;
151 pub const NCBCHAINSEND: UCHAR = 0x17;
152 pub const NCBDGSEND: UCHAR = 0x20;
153 pub const NCBDGRECV: UCHAR = 0x21;
154 pub const NCBDGSENDBC: UCHAR = 0x22;
155 pub const NCBADDNAME: UCHAR = 0x30;
156 pub const NCBDELNAME: UCHAR = 0x31;
157 pub const NCBRESET: UCHAR = 0x32;
158 pub const NCBASTAT: UCHAR = 0x33;
159 pub const NCBSSTAT: UCHAR = 0x34;
160 pub const NCBCANCEL: UCHAR = 0x35;
161 pub const NCBADDGRNAME: UCHAR = 0x36;
162 pub const NCBENUM: UCHAR = 0x37;
163 pub const NCBUNLINK: UCHAR = 0x70;
164 pub const NCBSENDNA: UCHAR = 0x71;
165 pub const NCBCHAINSENDNA: UCHAR = 0x72;
166 pub const NCBLANSTALERT: UCHAR = 0x73;
167 pub const NCBACTION: UCHAR = 0x77;
168 pub const NCBFINDNAME: UCHAR = 0x78;
169 pub const NCBTRACE: UCHAR = 0x79;
170 pub const ASYNCH: UCHAR = 0x80;
171 pub const NRC_GOODRET: UCHAR = 0x00;
172 pub const NRC_BUFLEN: UCHAR = 0x01;
173 pub const NRC_ILLCMD: UCHAR = 0x03;
174 pub const NRC_CMDTMO: UCHAR = 0x05;
175 pub const NRC_INCOMP: UCHAR = 0x06;
176 pub const NRC_BADDR: UCHAR = 0x07;
177 pub const NRC_SNUMOUT: UCHAR = 0x08;
178 pub const NRC_NORES: UCHAR = 0x09;
179 pub const NRC_SCLOSED: UCHAR = 0x0a;
180 pub const NRC_CMDCAN: UCHAR = 0x0b;
181 pub const NRC_DUPNAME: UCHAR = 0x0d;
182 pub const NRC_NAMTFUL: UCHAR = 0x0e;
183 pub const NRC_ACTSES: UCHAR = 0x0f;
184 pub const NRC_LOCTFUL: UCHAR = 0x11;
185 pub const NRC_REMTFUL: UCHAR = 0x12;
186 pub const NRC_ILLNN: UCHAR = 0x13;
187 pub const NRC_NOCALL: UCHAR = 0x14;
188 pub const NRC_NOWILD: UCHAR = 0x15;
189 pub const NRC_INUSE: UCHAR = 0x16;
190 pub const NRC_NAMERR: UCHAR = 0x17;
191 pub const NRC_SABORT: UCHAR = 0x18;
192 pub const NRC_NAMCONF: UCHAR = 0x19;
193 pub const NRC_IFBUSY: UCHAR = 0x21;
194 pub const NRC_TOOMANY: UCHAR = 0x22;
195 pub const NRC_BRIDGE: UCHAR = 0x23;
196 pub const NRC_CANOCCR: UCHAR = 0x24;
197 pub const NRC_CANCEL: UCHAR = 0x26;
198 pub const NRC_DUPENV: UCHAR = 0x30;
199 pub const NRC_ENVNOTDEF: UCHAR = 0x34;
200 pub const NRC_OSRESNOTAV: UCHAR = 0x35;
201 pub const NRC_MAXAPPS: UCHAR = 0x36;
202 pub const NRC_NOSAPS: UCHAR = 0x37;
203 pub const NRC_NORESOURCES: UCHAR = 0x38;
204 pub const NRC_INVADDRESS: UCHAR = 0x39;
205 pub const NRC_INVDDID: UCHAR = 0x3B;
206 pub const NRC_LOCKFAIL: UCHAR = 0x3C;
207 pub const NRC_OPENERR: UCHAR = 0x3f;
208 pub const NRC_SYSTEM: UCHAR = 0x40;
209 pub const NRC_PENDING: UCHAR = 0xff;
210 extern "system" {
Netbios( pncb: PNCB, ) -> UCHAR211     pub fn Netbios(
212         pncb: PNCB,
213     ) -> UCHAR;
214 }
215