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