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