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