1 /***********************************************************************\
2 *                                 nb30.d                                *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *                 Translated from MinGW Windows headers                 *
7 *                           by Stewart Gordon                           *
8 *                                                                       *
9 *                       Placed into public domain                       *
10 \***********************************************************************/
11 module windows.nb30;
12 
13 private import windows.windef;
14 nothrow:
15 const size_t
16 	NCBNAMSZ =  16,
17 	MAX_LANA = 254;
18 
19 // FIXME: are these really two sets of constants?
20 enum : UCHAR {
21 	REGISTERING     = 0,
22 	REGISTERED      = 4,
23 	DEREGISTERED,
24 	DUPLICATE,
25 	DUPLICATE_DEREG, // = 7
26 	UNIQUE_NAME     = 0,
27 	GROUP_NAME      = 0x80,
28 	NAME_FLAGS_MASK = 0x87
29 }
30 
31 enum : UCHAR {
32 	LISTEN_OUTSTANDING = 1,
33 	CALL_PENDING,
34 	SESSION_ESTABLISHED,
35 	HANGUP_PENDING,
36 	HANGUP_COMPLETE,
37 	SESSION_ABORTED // = 6
38 }
39 
40 const char[4]
41 	ALL_TRANSPORTS = "M\0\0\0",
42 	MS_NBF         = "MNBF";
43 
44 enum : UCHAR {
45 	NCBCALL        = 0x10,
46 	NCBLISTEN,
47 	NCBHANGUP,  // = 0x12
48 	NCBSEND        = 0x14,
49 	NCBRECV,
50 	NCBRECVANY,
51 	NCBCHAINSEND, // = 0x17
52 	NCBDGSEND      = 0x20,
53 	NCBDGRECV,
54 	NCBDGSENDBC,
55 	NCBDGRECVBC, // = 0x23,
56 	NCBADDNAME     = 0x30,
57 	NCBDELNAME,
58 	NCBRESET,
59 	NCBASTAT,
60 	NCBSSTAT,
61 	NCBCANCEL,
62 	NCBADDGRNAME,
63 	NCBENUM,    // = 0x37
64 	NCBUNLINK      = 0x70,
65 	NCBSENDNA,
66 	NCBCHAINSENDNA,
67 	NCBLANSTALERT, // = 0x73
68 	NCBACTION      = 0x77,
69 	NCBFINDNAME,
70 	NCBTRACE    // = 0x79
71 }
72 
73 const UCHAR ASYNCH = 0x80;
74 
75 enum : UCHAR {
76 	NRC_GOODRET     = 0x00,
77 	NRC_BUFLEN      = 0x01,
78 	NRC_ILLCMD      = 0x03,
79 	NRC_CMDTMO      = 0x05,
80 	NRC_INCOMP,
81 	NRC_BADDR,
82 	NRC_SNUMOUT,
83 	NRC_NORES,
84 	NRC_SCLOSED,
85 	NRC_CMDCAN,  // = 0x0b
86 	NRC_DUPNAME     = 0x0d,
87 	NRC_NAMTFUL,
88 	NRC_ACTSES,  // = 0x0f,
89 	NRC_LOCTFUL     = 0x11,
90 	NRC_REMTFUL,
91 	NRC_ILLNN,
92 	NRC_NOCALL,
93 	NRC_NOWILD,
94 	NRC_INUSE,
95 	NRC_NAMERR,
96 	NRC_SABORT,
97 	NRC_NAMCONF, // = 0x19
98 	NRC_IFBUSY      = 0x21,
99 	NRC_TOOMANY,
100 	NRC_BRIDGE,
101 	NRC_CANOCCR, // = 0x24
102 	NRC_CANCEL      = 0x26,
103 	NRC_DUPENV      = 0x30,
104 	NRC_ENVNOTDEF   = 0x34,
105 	NRC_OSRESNOTAV,
106 	NRC_MAXAPPS,
107 	NRC_NOSAPS,
108 	NRC_NORESOURCES,
109 	NRC_INVADDRESS, // = 0x39
110 	NRC_INVDDID     = 0x3B,
111 	NRC_LOCKFAIL    = 0x3C,
112 	NRC_OPENERR     = 0x3f,
113 	NRC_SYSTEM      = 0x40,
114 	NRC_PENDING     = 0xff
115 }
116 
117 struct ACTION_HEADER {
118 	union {
119 		/*	transport_id is defined as a ULONG, but both the above constants
120 		 *	and the documented description suggest it should be a char[4]
121 		 */
122 		ULONG   transport_id;
123 		char[4] c_transport_id;
124 	}
125 	USHORT action_code;
126 	USHORT reserved;
127 }
128 alias ACTION_HEADER* PACTION_HEADER;
129 
130 struct ADAPTER_STATUS {
131 	UCHAR[6] adapter_address;
132 	UCHAR    rev_major;
133 	UCHAR    reserved0;
134 	UCHAR    adapter_type;
135 	UCHAR    rev_minor;
136 	WORD     duration;
137 	WORD     frmr_recv;
138 	WORD     frmr_xmit;
139 	WORD     iframe_recv_err;
140 	WORD     xmit_aborts;
141 	DWORD    xmit_success;
142 	DWORD    recv_success;
143 	WORD     iframe_xmit_err;
144 	WORD     recv_buff_unavail;
145 	WORD     t1_timeouts;
146 	WORD     ti_timeouts;
147 	DWORD    reserved1;
148 	WORD     free_ncbs;
149 	WORD     max_cfg_ncbs;
150 	WORD     max_ncbs;
151 	WORD     xmit_buf_unavail;
152 	WORD     max_dgram_size;
153 	WORD     pending_sess;
154 	WORD     max_cfg_sess;
155 	WORD     max_sess;
156 	WORD     max_sess_pkt_size;
157 	WORD     name_count;
158 }
159 alias ADAPTER_STATUS* PADAPTER_STATUS;
160 
161 struct FIND_NAME_BUFFER {
162 	/*	From Win32 API docs
163 	 *
164 	 *	length
165 	 *		Specifies the length, in bytes, of the FIND_NAME_BUFFER
166 	 *		structure. Although this structure always occupies 33 bytes,
167 	 *		not all of the structure is necessarily valid.
168 	 *
169 	 *	On this basis, should length be initialised?
170 	 */
171 	UCHAR     length;
172 	UCHAR     access_control;
173 	UCHAR     frame_control;
174 	UCHAR[6]  destination_addr;
175 	UCHAR[6]  source_addr;
176 	UCHAR[18] routing_info;
177 }
178 alias FIND_NAME_BUFFER* PFIND_NAME_BUFFER;
179 
180 struct FIND_NAME_HEADER {
181 	WORD  node_count;
182 	UCHAR reserved;
183 	UCHAR unique_group;
184 }
185 alias FIND_NAME_HEADER* PFIND_NAME_HEADER;
186 
187 struct LANA_ENUM {
188 	UCHAR             length;
189 	UCHAR[MAX_LANA+1] lana;
190 }
191 alias LANA_ENUM* PLANA_ENUM;
192 
193 struct NAME_BUFFER {
194 	UCHAR[NCBNAMSZ] name;
195 	UCHAR           name_num;
196 	UCHAR           name_flags;
197 }
198 alias NAME_BUFFER* PNAME_BUFFER;
199 
200 struct NCB {
201 	UCHAR           ncb_command;
202 	UCHAR           ncb_retcode;
203 	UCHAR           ncb_lsn;
204 	UCHAR           ncb_num;
205 	PUCHAR          ncb_buffer;
206 	WORD            ncb_length;
207 	UCHAR[NCBNAMSZ] ncb_callname;
208 	UCHAR[NCBNAMSZ] ncb_name;
209 	UCHAR           ncb_rto;
210 	UCHAR           ncb_sto;
211 	extern (Windows) void function(NCB*) ncb_post;
212 	UCHAR           ncb_lana_num;
213 	UCHAR           ncb_cmd_cplt;
214 	UCHAR[10]       ncb_reserve;
215 	HANDLE          ncb_event;
216 }
217 alias NCB* PNCB;
218 
219 struct SESSION_BUFFER {
220 	UCHAR           lsn;
221 	UCHAR           state;
222 	UCHAR[NCBNAMSZ] local_name;
223 	UCHAR[NCBNAMSZ] remote_name;
224 	UCHAR           rcvs_outstanding;
225 	UCHAR           sends_outstanding;
226 }
227 alias SESSION_BUFFER* PSESSION_BUFFER;
228 
229 struct SESSION_HEADER {
230 	UCHAR sess_name;
231 	UCHAR num_sess;
232 	UCHAR rcv_dg_outstanding;
233 	UCHAR rcv_any_outstanding;
234 }
235 alias SESSION_HEADER* PSESSION_HEADER;
236 
237 extern (Windows) UCHAR Netbios(PNCB);