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