7027
|
1 /*****************************************************************************
|
|
2 * ioctl.c: DVD ioctl replacement function
|
|
3 *****************************************************************************
|
|
4 * Copyright (C) 1999-2001 VideoLAN
|
|
5 * $Id$
|
|
6 *
|
|
7 * Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
|
|
8 * Samuel Hocevar <sam@zoy.org>
|
|
9 * Jon Lech Johansen <jon-vl@nanocrew.net>
|
|
10 * Håkan Hjort <d95hjort@dtek.chalmers.se>
|
|
11 * Eugenio Jarosiewicz <ej0@cise.ufl.edu>
|
|
12 * David Siebörger <drs-videolan@rucus.ru.ac.za>
|
|
13 * Alex Strelnikov <lelik@os2.ru>
|
|
14 *
|
|
15 * This program is free software; you can redistribute it and/or modify
|
|
16 * it under the terms of the GNU General Public License as published by
|
|
17 * the Free Software Foundation; either version 2 of the License, or
|
|
18 * (at your option) any later version.
|
|
19 *
|
|
20 * This program is distributed in the hope that it will be useful,
|
|
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
23 * GNU General Public License for more details.
|
|
24 *
|
|
25 * You should have received a copy of the GNU General Public License
|
|
26 * along with this program; if not, write to the Free Software
|
|
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
|
28 *****************************************************************************/
|
|
29
|
|
30 /*****************************************************************************
|
|
31 * Preamble
|
|
32 *****************************************************************************/
|
|
33 #include "config.h"
|
|
34
|
|
35 #include <stdio.h>
|
|
36
|
|
37 #include <string.h> /* memcpy(), memset() */
|
|
38 #include <sys/types.h>
|
|
39
|
|
40 #if defined( WIN32 )
|
|
41 # include <windows.h>
|
|
42 # include <winioctl.h>
|
|
43 #elif defined ( SYS_OS2 )
|
|
44 # define INCL_DOSFILEMGR
|
|
45 # define INCL_DOSDEVICES
|
|
46 # define INCL_DOSDEVIOCTL
|
|
47 # define INCL_DOSERRORS
|
|
48 # include <os2.h>
|
|
49 # include <sys/ioctl.h>
|
|
50 #else
|
|
51 # include <netinet/in.h>
|
|
52 # include <sys/ioctl.h>
|
|
53 #endif
|
|
54
|
|
55 #ifdef DVD_STRUCT_IN_SYS_CDIO_H
|
|
56 # include <sys/cdio.h>
|
|
57 #endif
|
|
58 #ifdef DVD_STRUCT_IN_SYS_DVDIO_H
|
|
59 # include <sys/dvdio.h>
|
|
60 #endif
|
|
61 #ifdef DVD_STRUCT_IN_LINUX_CDROM_H
|
|
62 # include <linux/cdrom.h>
|
|
63 #endif
|
|
64 #ifdef DVD_STRUCT_IN_DVD_H
|
|
65 # include <dvd.h>
|
|
66 #endif
|
|
67 #ifdef DVD_STRUCT_IN_BSDI_DVDIOCTL_DVD_H
|
|
68 # include "bsdi_dvd.h"
|
|
69 #endif
|
|
70 #ifdef SYS_BEOS
|
|
71 # include <malloc.h>
|
|
72 # include <scsi.h>
|
|
73 #endif
|
|
74 #ifdef HPUX_SCTL_IO
|
|
75 # include <sys/scsi.h>
|
|
76 #endif
|
|
77 #ifdef SOLARIS_USCSI
|
|
78 # include <unistd.h>
|
|
79 # include <stropts.h>
|
|
80 # include <sys/scsi/scsi_types.h>
|
|
81 # include <sys/scsi/impl/uscsi.h>
|
|
82 #endif
|
|
83 #ifdef DARWIN_DVD_IOCTL
|
|
84 # include <IOKit/storage/IODVDMediaBSDClient.h>
|
|
85 #endif
|
|
86 #ifdef __QNXNTO__
|
|
87 # include <sys/mman.h>
|
|
88 # include <sys/dcmd_cam.h>
|
|
89 #endif
|
|
90
|
|
91 #include "common.h"
|
|
92
|
|
93 #include "ioctl.h"
|
|
94
|
|
95 /*****************************************************************************
|
|
96 * Local prototypes, BeOS specific
|
|
97 *****************************************************************************/
|
|
98 #if defined( SYS_BEOS )
|
|
99 static void BeInitRDC ( raw_device_command *, int );
|
|
100 #endif
|
|
101
|
|
102 /*****************************************************************************
|
|
103 * Local prototypes, HP-UX specific
|
|
104 *****************************************************************************/
|
|
105 #if defined( HPUX_SCTL_IO )
|
|
106 static void HPUXInitSCTL ( struct sctl_io *sctl_io, int i_type );
|
|
107 #endif
|
|
108
|
|
109 /*****************************************************************************
|
|
110 * Local prototypes, Solaris specific
|
|
111 *****************************************************************************/
|
|
112 #if defined( SOLARIS_USCSI )
|
|
113 static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type );
|
|
114 #endif
|
|
115
|
|
116 /*****************************************************************************
|
|
117 * Local prototypes, win32 (aspi) specific
|
|
118 *****************************************************************************/
|
|
119 #if defined( WIN32 )
|
|
120 static void WinInitSSC ( struct SRB_ExecSCSICmd *, int );
|
|
121 static int WinSendSSC ( int, struct SRB_ExecSCSICmd * );
|
|
122 #endif
|
|
123
|
|
124 /*****************************************************************************
|
|
125 * Local prototypes, QNX specific
|
|
126 *****************************************************************************/
|
|
127 #if defined( __QNXNTO__ )
|
|
128 static void QNXInitCPT ( CAM_PASS_THRU *, int );
|
|
129 #endif
|
|
130
|
|
131 /*****************************************************************************
|
|
132 * Local prototypes, OS2 specific
|
|
133 *****************************************************************************/
|
|
134 #if defined( SYS_OS2 )
|
|
135 static void OS2InitSDC( struct OS2_ExecSCSICmd *, int );
|
|
136 #endif
|
|
137
|
|
138 /*****************************************************************************
|
|
139 * ioctl_ReadCopyright: check whether the disc is encrypted or not
|
|
140 *****************************************************************************/
|
|
141 int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
|
|
142 {
|
|
143 int i_ret;
|
|
144
|
|
145 #if defined( HAVE_LINUX_DVD_STRUCT )
|
|
146 dvd_struct dvd;
|
|
147
|
|
148 memset( &dvd, 0, sizeof( dvd ) );
|
|
149 dvd.type = DVD_STRUCT_COPYRIGHT;
|
|
150 dvd.copyright.layer_num = i_layer;
|
|
151
|
|
152 i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd );
|
|
153
|
|
154 *pi_copyright = dvd.copyright.cpst;
|
|
155
|
|
156 #elif defined( HAVE_BSD_DVD_STRUCT )
|
|
157 struct dvd_struct dvd;
|
|
158
|
|
159 memset( &dvd, 0, sizeof( dvd ) );
|
|
160 dvd.format = DVD_STRUCT_COPYRIGHT;
|
|
161 dvd.layer_num = i_layer;
|
|
162
|
|
163 i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd );
|
|
164
|
|
165 *pi_copyright = dvd.cpst;
|
|
166
|
|
167 #elif defined( SYS_BEOS )
|
|
168 INIT_RDC( GPCMD_READ_DVD_STRUCTURE, 8 );
|
|
169
|
|
170 rdc.command[ 6 ] = i_layer;
|
|
171 rdc.command[ 7 ] = DVD_STRUCT_COPYRIGHT;
|
|
172
|
|
173 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
|
|
174
|
|
175 *pi_copyright = p_buffer[ 4 ];
|
|
176
|
|
177 #elif defined( HPUX_SCTL_IO )
|
|
178 INIT_SCTL_IO( GPCMD_READ_DVD_STRUCTURE, 8 );
|
|
179
|
|
180 sctl_io.cdb[ 6 ] = i_layer;
|
|
181 sctl_io.cdb[ 7 ] = DVD_STRUCT_COPYRIGHT;
|
|
182
|
|
183 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
|
|
184
|
|
185 *pi_copyright = p_buffer[ 4 ];
|
|
186
|
|
187 #elif defined( SOLARIS_USCSI )
|
|
188 INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, 8 );
|
|
189
|
|
190 rs_cdb.cdb_opaque[ 6 ] = i_layer;
|
|
191 rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_COPYRIGHT;
|
|
192
|
|
193 i_ret = ioctl(i_fd, USCSICMD, &sc);
|
|
194
|
|
195 if( i_ret < 0 || sc.uscsi_status ) {
|
|
196 i_ret = -1;
|
|
197 }
|
|
198
|
|
199 *pi_copyright = p_buffer[ 4 ];
|
|
200 /* s->copyright.rmi = p_buffer[ 5 ]; */
|
|
201
|
|
202 #elif defined( DARWIN_DVD_IOCTL )
|
|
203 INIT_DVDIOCTL( dk_dvd_read_structure_t, DVDCopyrightInfo,
|
|
204 kDVDStructureFormatCopyrightInfo );
|
|
205
|
|
206 dvd.layer = i_layer;
|
|
207
|
|
208 i_ret = ioctl( i_fd, DKIOCDVDREADSTRUCTURE, &dvd );
|
|
209
|
|
210 *pi_copyright = dvdbs.copyrightProtectionSystemType;
|
|
211
|
|
212 #elif defined( WIN32 )
|
|
213 if( WIN2K ) /* NT/Win2000/Whistler */
|
|
214 {
|
|
215 DWORD tmp;
|
|
216 u8 p_buffer[ 8 ];
|
|
217 SCSI_PASS_THROUGH_DIRECT sptd;
|
|
218
|
|
219 memset( &sptd, 0, sizeof( sptd ) );
|
|
220 memset( &p_buffer, 0, sizeof( p_buffer ) );
|
|
221
|
|
222 /* When using IOCTL_DVD_READ_STRUCTURE and
|
|
223 DVD_COPYRIGHT_DESCRIPTOR, CopyrightProtectionType
|
|
224 is always 6. So we send a raw scsi command instead. */
|
|
225
|
|
226 sptd.Length = sizeof( SCSI_PASS_THROUGH_DIRECT );
|
|
227 sptd.CdbLength = 12;
|
|
228 sptd.DataIn = SCSI_IOCTL_DATA_IN;
|
|
229 sptd.DataTransferLength = 8;
|
|
230 sptd.TimeOutValue = 2;
|
|
231 sptd.DataBuffer = p_buffer;
|
|
232 sptd.Cdb[ 0 ] = GPCMD_READ_DVD_STRUCTURE;
|
|
233 sptd.Cdb[ 6 ] = i_layer;
|
|
234 sptd.Cdb[ 7 ] = DVD_STRUCT_COPYRIGHT;
|
|
235 sptd.Cdb[ 8 ] = (8 >> 8) & 0xff;
|
|
236 sptd.Cdb[ 9 ] = 8 & 0xff;
|
|
237
|
|
238 i_ret = DeviceIoControl( (HANDLE) i_fd,
|
|
239 IOCTL_SCSI_PASS_THROUGH_DIRECT,
|
|
240 &sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ),
|
|
241 &sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ),
|
|
242 &tmp, NULL ) ? 0 : -1;
|
|
243
|
|
244 *pi_copyright = p_buffer[ 4 ];
|
|
245 }
|
|
246 else
|
|
247 {
|
|
248 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 8 );
|
|
249
|
|
250 ssc.CDBByte[ 6 ] = i_layer;
|
|
251 ssc.CDBByte[ 7 ] = DVD_STRUCT_COPYRIGHT;
|
|
252
|
|
253 i_ret = WinSendSSC( i_fd, &ssc );
|
|
254
|
|
255 *pi_copyright = p_buffer[ 4 ];
|
|
256 }
|
|
257
|
|
258 #elif defined( __QNXNTO__ )
|
|
259
|
|
260 INIT_CPT( GPCMD_READ_DVD_STRUCTURE, 8 );
|
|
261
|
|
262 p_cpt->cam_cdb[ 6 ] = i_layer;
|
|
263 p_cpt->cam_cdb[ 7 ] = DVD_STRUCT_COPYRIGHT;
|
|
264
|
|
265 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
|
|
266
|
|
267 *pi_copyright = p_buffer[4];
|
|
268
|
|
269 #elif defined( SYS_OS2 )
|
|
270 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 8 );
|
|
271
|
|
272 sdc.command[ 6 ] = i_layer;
|
|
273 sdc.command[ 7 ] = DVD_STRUCT_COPYRIGHT;
|
|
274
|
|
275 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
|
|
276 &sdc, sizeof(sdc), &ulParamLen,
|
|
277 p_buffer, sizeof(p_buffer), &ulDataLen);
|
|
278
|
|
279 *pi_copyright = p_buffer[ 4 ];
|
|
280
|
|
281 #else
|
|
282 # error "DVD ioctls are unavailable on this system"
|
|
283
|
|
284 #endif
|
|
285 return i_ret;
|
|
286 }
|
|
287
|
|
288 /*****************************************************************************
|
|
289 * ioctl_ReadDiscKey: get the disc key
|
|
290 *****************************************************************************/
|
|
291 int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
|
|
292 {
|
|
293 int i_ret;
|
|
294
|
|
295 #if defined( HAVE_LINUX_DVD_STRUCT )
|
|
296 dvd_struct dvd;
|
|
297
|
|
298 memset( &dvd, 0, sizeof( dvd ) );
|
|
299 dvd.type = DVD_STRUCT_DISCKEY;
|
|
300 dvd.disckey.agid = *pi_agid;
|
|
301 memset( dvd.disckey.value, 0, DVD_DISCKEY_SIZE );
|
|
302
|
|
303 i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd );
|
|
304
|
|
305 if( i_ret < 0 )
|
|
306 {
|
|
307 return i_ret;
|
|
308 }
|
|
309
|
|
310 memcpy( p_key, dvd.disckey.value, DVD_DISCKEY_SIZE );
|
|
311
|
|
312 #elif defined( HAVE_BSD_DVD_STRUCT )
|
|
313 struct dvd_struct dvd;
|
|
314
|
|
315 memset( &dvd, 0, sizeof( dvd ) );
|
|
316 dvd.format = DVD_STRUCT_DISCKEY;
|
|
317 dvd.agid = *pi_agid;
|
|
318 memset( dvd.data, 0, DVD_DISCKEY_SIZE );
|
|
319
|
|
320 i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd );
|
|
321
|
|
322 if( i_ret < 0 )
|
|
323 {
|
|
324 return i_ret;
|
|
325 }
|
|
326
|
|
327 memcpy( p_key, dvd.data, DVD_DISCKEY_SIZE );
|
|
328
|
|
329 #elif defined( SYS_BEOS )
|
|
330 INIT_RDC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
|
|
331
|
|
332 rdc.command[ 7 ] = DVD_STRUCT_DISCKEY;
|
|
333 rdc.command[ 10 ] = *pi_agid << 6;
|
|
334
|
|
335 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
|
|
336
|
|
337 if( i_ret < 0 )
|
|
338 {
|
|
339 return i_ret;
|
|
340 }
|
|
341
|
|
342 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
|
|
343
|
|
344 #elif defined( HPUX_SCTL_IO )
|
|
345 INIT_SCTL_IO( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
|
|
346
|
|
347 sctl_io.cdb[ 7 ] = DVD_STRUCT_DISCKEY;
|
|
348 sctl_io.cdb[ 10 ] = *pi_agid << 6;
|
|
349
|
|
350 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
|
|
351
|
|
352 if( i_ret < 0 )
|
|
353 {
|
|
354 return i_ret;
|
|
355 }
|
|
356
|
|
357 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
|
|
358
|
|
359 #elif defined( SOLARIS_USCSI )
|
|
360 INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
|
|
361
|
|
362 rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_DISCKEY;
|
|
363 rs_cdb.cdb_opaque[ 10 ] = *pi_agid << 6;
|
|
364
|
|
365 i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
366
|
|
367 if( i_ret < 0 || sc.uscsi_status )
|
|
368 {
|
|
369 i_ret = -1;
|
|
370 return i_ret;
|
|
371 }
|
|
372
|
|
373 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
|
|
374
|
|
375 #elif defined( DARWIN_DVD_IOCTL )
|
|
376 INIT_DVDIOCTL( dk_dvd_read_structure_t, DVDDiscKeyInfo,
|
|
377 kDVDStructureFormatDiscKeyInfo );
|
|
378
|
|
379 dvd.grantID = *pi_agid;
|
|
380
|
|
381 i_ret = ioctl( i_fd, DKIOCDVDREADSTRUCTURE, &dvd );
|
|
382
|
|
383 memcpy( p_key, dvdbs.discKeyStructures, DVD_DISCKEY_SIZE );
|
|
384
|
|
385 #elif defined( WIN32 )
|
|
386 if( WIN2K ) /* NT/Win2000/Whistler */
|
|
387 {
|
|
388 DWORD tmp;
|
|
389 u8 buffer[DVD_DISK_KEY_LENGTH];
|
|
390 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
|
|
391
|
|
392 memset( &buffer, 0, sizeof( buffer ) );
|
|
393
|
|
394 key->KeyLength = DVD_DISK_KEY_LENGTH;
|
|
395 key->SessionId = *pi_agid;
|
|
396 key->KeyType = DvdDiskKey;
|
|
397 key->KeyFlags = 0;
|
|
398
|
|
399 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
|
|
400 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
|
|
401
|
|
402 if( i_ret < 0 )
|
|
403 {
|
|
404 return i_ret;
|
|
405 }
|
|
406
|
|
407 memcpy( p_key, key->KeyData, DVD_DISCKEY_SIZE );
|
|
408 }
|
|
409 else
|
|
410 {
|
|
411 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
|
|
412
|
|
413 ssc.CDBByte[ 7 ] = DVD_STRUCT_DISCKEY;
|
|
414 ssc.CDBByte[ 10 ] = *pi_agid << 6;
|
|
415
|
|
416 i_ret = WinSendSSC( i_fd, &ssc );
|
|
417
|
|
418 if( i_ret < 0 )
|
|
419 {
|
|
420 return i_ret;
|
|
421 }
|
|
422
|
|
423 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
|
|
424 }
|
|
425
|
|
426 #elif defined( __QNXNTO__ )
|
|
427
|
|
428 INIT_CPT( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
|
|
429
|
|
430 p_cpt->cam_cdb[ 7 ] = DVD_STRUCT_DISCKEY;
|
|
431 p_cpt->cam_cdb[ 10 ] = *pi_agid << 6;
|
|
432
|
|
433 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
|
|
434
|
|
435 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
|
|
436
|
|
437 #elif defined ( SYS_OS2 )
|
|
438 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
|
|
439
|
|
440 sdc.command[ 7 ] = DVD_STRUCT_DISCKEY;
|
|
441 sdc.command[ 10 ] = *pi_agid << 6;
|
|
442
|
|
443 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
|
|
444 &sdc, sizeof(sdc), &ulParamLen,
|
|
445 p_buffer, sizeof(p_buffer), &ulDataLen);
|
|
446
|
|
447 if( i_ret < 0 )
|
|
448 {
|
|
449 return i_ret;
|
|
450 }
|
|
451
|
|
452 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
|
|
453
|
|
454 #else
|
|
455 # error "DVD ioctls are unavailable on this system"
|
|
456
|
|
457 #endif
|
|
458 return i_ret;
|
|
459 }
|
|
460
|
|
461 /*****************************************************************************
|
|
462 * ioctl_ReadTitleKey: get the title key
|
|
463 *****************************************************************************/
|
|
464 int ioctl_ReadTitleKey( int i_fd, int *pi_agid, int i_pos, u8 *p_key )
|
|
465 {
|
|
466 int i_ret;
|
|
467
|
|
468 #if defined( HAVE_LINUX_DVD_STRUCT )
|
|
469 dvd_authinfo auth_info;
|
|
470
|
|
471 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
472 auth_info.type = DVD_LU_SEND_TITLE_KEY;
|
|
473 auth_info.lstk.agid = *pi_agid;
|
|
474 auth_info.lstk.lba = i_pos;
|
|
475
|
|
476 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
|
|
477
|
|
478 memcpy( p_key, auth_info.lstk.title_key, DVD_KEY_SIZE );
|
|
479
|
|
480 #elif defined( HAVE_BSD_DVD_STRUCT )
|
|
481 struct dvd_authinfo auth_info;
|
|
482
|
|
483 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
484 auth_info.format = DVD_REPORT_TITLE_KEY;
|
|
485 auth_info.agid = *pi_agid;
|
|
486 auth_info.lba = i_pos;
|
|
487
|
|
488 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
|
|
489
|
|
490 memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE );
|
|
491
|
|
492 #elif defined( SYS_BEOS )
|
|
493 INIT_RDC( GPCMD_REPORT_KEY, 12 );
|
|
494
|
|
495 rdc.command[ 2 ] = ( i_pos >> 24 ) & 0xff;
|
|
496 rdc.command[ 3 ] = ( i_pos >> 16 ) & 0xff;
|
|
497 rdc.command[ 4 ] = ( i_pos >> 8 ) & 0xff;
|
|
498 rdc.command[ 5 ] = ( i_pos ) & 0xff;
|
|
499 rdc.command[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
|
|
500
|
|
501 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
|
|
502
|
|
503 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
|
|
504
|
|
505 #elif defined( HPUX_SCTL_IO )
|
|
506 INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 );
|
|
507
|
|
508 sctl_io.cdb[ 2 ] = ( i_pos >> 24 ) & 0xff;
|
|
509 sctl_io.cdb[ 3 ] = ( i_pos >> 16 ) & 0xff;
|
|
510 sctl_io.cdb[ 4 ] = ( i_pos >> 8 ) & 0xff;
|
|
511 sctl_io.cdb[ 5 ] = ( i_pos ) & 0xff;
|
|
512 sctl_io.cdb[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
|
|
513
|
|
514 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
|
|
515
|
|
516 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
|
|
517
|
|
518 #elif defined( SOLARIS_USCSI )
|
|
519 INIT_USCSI( GPCMD_REPORT_KEY, 12 );
|
|
520
|
|
521 rs_cdb.cdb_opaque[ 2 ] = ( i_pos >> 24 ) & 0xff;
|
|
522 rs_cdb.cdb_opaque[ 3 ] = ( i_pos >> 16 ) & 0xff;
|
|
523 rs_cdb.cdb_opaque[ 4 ] = ( i_pos >> 8 ) & 0xff;
|
|
524 rs_cdb.cdb_opaque[ 5 ] = ( i_pos ) & 0xff;
|
|
525 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
|
|
526
|
|
527 i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
528
|
|
529 if( i_ret < 0 || sc.uscsi_status )
|
|
530 {
|
|
531 i_ret = -1;
|
|
532 }
|
|
533
|
|
534 /* Do we want to return the cp_sec flag perhaps? */
|
|
535 /* a->lstk.cpm = (buf[ 4 ] >> 7) & 1; */
|
|
536 /* a->lstk.cp_sec = (buf[ 4 ] >> 6) & 1; */
|
|
537 /* a->lstk.cgms = (buf[ 4 ] >> 4) & 3; */
|
|
538
|
|
539 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
|
|
540
|
|
541 #elif defined( DARWIN_DVD_IOCTL )
|
|
542 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDTitleKeyInfo,
|
|
543 kDVDKeyFormatTitleKey );
|
|
544
|
|
545 dvd.address = i_pos;
|
|
546 dvd.grantID = *pi_agid;
|
|
547 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM;
|
|
548
|
|
549 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
|
|
550
|
|
551 memcpy( p_key, dvdbs.titleKeyValue, DVD_KEY_SIZE );
|
|
552
|
|
553 #elif defined( WIN32 )
|
|
554 if( WIN2K ) /* NT/Win2000/Whistler */
|
|
555 {
|
|
556 DWORD tmp;
|
|
557 u8 buffer[DVD_BUS_KEY_LENGTH];
|
|
558 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
|
|
559
|
|
560 memset( &buffer, 0, sizeof( buffer ) );
|
|
561
|
|
562 key->KeyLength = DVD_TITLE_KEY_LENGTH;
|
|
563 key->SessionId = *pi_agid;
|
|
564 key->KeyType = DvdTitleKey;
|
|
565 key->KeyFlags = 0;
|
|
566 key->Parameters.TitleOffset.QuadPart = (LONGLONG) i_pos;
|
|
567
|
|
568 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
|
|
569 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
|
|
570
|
|
571 memcpy( p_key, key->KeyData, DVD_KEY_SIZE );
|
|
572 }
|
|
573 else
|
|
574 {
|
|
575 INIT_SSC( GPCMD_REPORT_KEY, 12 );
|
|
576
|
|
577 ssc.CDBByte[ 2 ] = ( i_pos >> 24 ) & 0xff;
|
|
578 ssc.CDBByte[ 3 ] = ( i_pos >> 16 ) & 0xff;
|
|
579 ssc.CDBByte[ 4 ] = ( i_pos >> 8 ) & 0xff;
|
|
580 ssc.CDBByte[ 5 ] = ( i_pos ) & 0xff;
|
|
581 ssc.CDBByte[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
|
|
582
|
|
583 i_ret = WinSendSSC( i_fd, &ssc );
|
|
584
|
|
585 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
|
|
586 }
|
|
587
|
|
588 #elif defined( __QNXNTO__ )
|
|
589
|
|
590 INIT_CPT( GPCMD_REPORT_KEY, 12 );
|
|
591
|
|
592 p_cpt->cam_cdb[ 2 ] = ( i_pos >> 24 ) & 0xff;
|
|
593 p_cpt->cam_cdb[ 3 ] = ( i_pos >> 16 ) & 0xff;
|
|
594 p_cpt->cam_cdb[ 4 ] = ( i_pos >> 8 ) & 0xff;
|
|
595 p_cpt->cam_cdb[ 5 ] = ( i_pos ) & 0xff;
|
|
596 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
|
|
597
|
|
598 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
|
|
599
|
|
600 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
|
|
601
|
|
602 #elif defined( SYS_OS2 )
|
|
603 INIT_SSC( GPCMD_REPORT_KEY, 12 );
|
|
604
|
|
605 sdc.command[ 2 ] = ( i_pos >> 24 ) & 0xff;
|
|
606 sdc.command[ 3 ] = ( i_pos >> 16 ) & 0xff;
|
|
607 sdc.command[ 4 ] = ( i_pos >> 8 ) & 0xff;
|
|
608 sdc.command[ 5 ] = ( i_pos ) & 0xff;
|
|
609 sdc.command[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
|
|
610
|
|
611 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
|
|
612 &sdc, sizeof(sdc), &ulParamLen,
|
|
613 p_buffer, sizeof(p_buffer), &ulDataLen);
|
|
614
|
|
615 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
|
|
616
|
|
617 #else
|
|
618 # error "DVD ioctls are unavailable on this system"
|
|
619
|
|
620 #endif
|
|
621
|
|
622 return i_ret;
|
|
623 }
|
|
624
|
|
625
|
|
626 /*****************************************************************************
|
|
627 * ioctl_ReportAgid: get AGID from the drive
|
|
628 *****************************************************************************/
|
|
629 int ioctl_ReportAgid( int i_fd, int *pi_agid )
|
|
630 {
|
|
631 int i_ret;
|
|
632
|
|
633 #if defined( HAVE_LINUX_DVD_STRUCT )
|
|
634 dvd_authinfo auth_info;
|
|
635
|
|
636 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
637 auth_info.type = DVD_LU_SEND_AGID;
|
|
638 auth_info.lsa.agid = *pi_agid;
|
|
639
|
|
640 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
|
|
641
|
|
642 *pi_agid = auth_info.lsa.agid;
|
|
643
|
|
644 #elif defined( HAVE_BSD_DVD_STRUCT )
|
|
645 struct dvd_authinfo auth_info;
|
|
646
|
|
647 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
648 auth_info.format = DVD_REPORT_AGID;
|
|
649 auth_info.agid = *pi_agid;
|
|
650
|
|
651 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
|
|
652
|
|
653 *pi_agid = auth_info.agid;
|
|
654
|
|
655 #elif defined( SYS_BEOS )
|
|
656 INIT_RDC( GPCMD_REPORT_KEY, 8 );
|
|
657
|
|
658 rdc.command[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
|
|
659
|
|
660 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
|
|
661
|
|
662 *pi_agid = p_buffer[ 7 ] >> 6;
|
|
663
|
|
664 #elif defined( HPUX_SCTL_IO )
|
|
665 INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 );
|
|
666
|
|
667 sctl_io.cdb[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
|
|
668
|
|
669 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
|
|
670
|
|
671 *pi_agid = p_buffer[ 7 ] >> 6;
|
|
672
|
|
673 #elif defined( SOLARIS_USCSI )
|
|
674 INIT_USCSI( GPCMD_REPORT_KEY, 8 );
|
|
675
|
|
676 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
|
|
677
|
|
678 i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
679
|
|
680 if( i_ret < 0 || sc.uscsi_status )
|
|
681 {
|
|
682 i_ret = -1;
|
|
683 }
|
|
684
|
|
685 *pi_agid = p_buffer[ 7 ] >> 6;
|
|
686
|
|
687 #elif defined( DARWIN_DVD_IOCTL )
|
|
688 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDAuthenticationGrantIDInfo,
|
|
689 kDVDKeyFormatAGID_CSS );
|
|
690
|
|
691 dvd.grantID = *pi_agid;
|
|
692 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM;
|
|
693
|
|
694 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
|
|
695
|
|
696 *pi_agid = dvdbs.grantID;
|
|
697
|
|
698 #elif defined( WIN32 )
|
|
699 if( WIN2K ) /* NT/Win2000/Whistler */
|
|
700 {
|
|
701 ULONG id;
|
|
702 DWORD tmp;
|
|
703
|
|
704 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_START_SESSION,
|
|
705 &tmp, 4, &id, sizeof( id ), &tmp, NULL ) ? 0 : -1;
|
|
706
|
|
707 *pi_agid = id;
|
|
708 }
|
|
709 else
|
|
710 {
|
|
711 INIT_SSC( GPCMD_REPORT_KEY, 8 );
|
|
712
|
|
713 ssc.CDBByte[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
|
|
714
|
|
715 i_ret = WinSendSSC( i_fd, &ssc );
|
|
716
|
|
717 *pi_agid = p_buffer[ 7 ] >> 6;
|
|
718 }
|
|
719
|
|
720 #elif defined( __QNXNTO__ )
|
|
721
|
|
722 INIT_CPT( GPCMD_REPORT_KEY, 8 );
|
|
723
|
|
724 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
|
|
725
|
|
726 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
|
|
727
|
|
728 *pi_agid = p_buffer[ 7 ] >> 6;
|
|
729
|
|
730 #elif defined( SYS_OS2 )
|
|
731 INIT_SSC( GPCMD_REPORT_KEY, 8 );
|
|
732
|
|
733 sdc.command[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
|
|
734
|
|
735 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
|
|
736 &sdc, sizeof(sdc), &ulParamLen,
|
|
737 p_buffer, sizeof(p_buffer), &ulDataLen);
|
|
738
|
|
739 *pi_agid = p_buffer[ 7 ] >> 6;
|
|
740
|
|
741 #else
|
|
742 # error "DVD ioctls are unavailable on this system"
|
|
743
|
|
744 #endif
|
|
745 return i_ret;
|
|
746 }
|
|
747
|
|
748 /*****************************************************************************
|
|
749 * ioctl_ReportChallenge: get challenge from the drive
|
|
750 *****************************************************************************/
|
|
751 int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
|
|
752 {
|
|
753 int i_ret;
|
|
754
|
|
755 #if defined( HAVE_LINUX_DVD_STRUCT )
|
|
756 dvd_authinfo auth_info;
|
|
757
|
|
758 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
759 auth_info.type = DVD_LU_SEND_CHALLENGE;
|
|
760 auth_info.lsc.agid = *pi_agid;
|
|
761
|
|
762 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
|
|
763
|
|
764 memcpy( p_challenge, auth_info.lsc.chal, DVD_CHALLENGE_SIZE );
|
|
765
|
|
766 #elif defined( HAVE_BSD_DVD_STRUCT )
|
|
767 struct dvd_authinfo auth_info;
|
|
768
|
|
769 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
770 auth_info.format = DVD_REPORT_CHALLENGE;
|
|
771 auth_info.agid = *pi_agid;
|
|
772
|
|
773 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
|
|
774
|
|
775 memcpy( p_challenge, auth_info.keychal, DVD_CHALLENGE_SIZE );
|
|
776
|
|
777 #elif defined( SYS_BEOS )
|
|
778 INIT_RDC( GPCMD_REPORT_KEY, 16 );
|
|
779
|
|
780 rdc.command[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
|
|
781
|
|
782 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
|
|
783
|
|
784 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
|
|
785
|
|
786 #elif defined( HPUX_SCTL_IO )
|
|
787 INIT_SCTL_IO( GPCMD_REPORT_KEY, 16 );
|
|
788
|
|
789 sctl_io.cdb[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
|
|
790
|
|
791 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
|
|
792
|
|
793 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
|
|
794
|
|
795 #elif defined( SOLARIS_USCSI )
|
|
796 INIT_USCSI( GPCMD_REPORT_KEY, 16 );
|
|
797
|
|
798 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
|
|
799
|
|
800 i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
801
|
|
802 if( i_ret < 0 || sc.uscsi_status )
|
|
803 {
|
|
804 i_ret = -1;
|
|
805 }
|
|
806
|
|
807 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
|
|
808
|
|
809 #elif defined( DARWIN_DVD_IOCTL )
|
|
810 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDChallengeKeyInfo,
|
|
811 kDVDKeyFormatChallengeKey );
|
|
812
|
|
813 dvd.grantID = *pi_agid;
|
|
814
|
|
815 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
|
|
816
|
|
817 memcpy( p_challenge, dvdbs.challengeKeyValue, DVD_CHALLENGE_SIZE );
|
|
818
|
|
819 #elif defined( WIN32 )
|
|
820 if( WIN2K ) /* NT/Win2000/Whistler */
|
|
821 {
|
|
822 DWORD tmp;
|
|
823 u8 buffer[DVD_CHALLENGE_KEY_LENGTH];
|
|
824 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
|
|
825
|
|
826 memset( &buffer, 0, sizeof( buffer ) );
|
|
827
|
|
828 key->KeyLength = DVD_CHALLENGE_KEY_LENGTH;
|
|
829 key->SessionId = *pi_agid;
|
|
830 key->KeyType = DvdChallengeKey;
|
|
831 key->KeyFlags = 0;
|
|
832
|
|
833 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
|
|
834 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
|
|
835
|
|
836 if( i_ret < 0 )
|
|
837 {
|
|
838 return i_ret;
|
|
839 }
|
|
840
|
|
841 memcpy( p_challenge, key->KeyData, DVD_CHALLENGE_SIZE );
|
|
842 }
|
|
843 else
|
|
844 {
|
|
845 INIT_SSC( GPCMD_REPORT_KEY, 16 );
|
|
846
|
|
847 ssc.CDBByte[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
|
|
848
|
|
849 i_ret = WinSendSSC( i_fd, &ssc );
|
|
850
|
|
851 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
|
|
852 }
|
|
853
|
|
854 #elif defined( __QNXNTO__ )
|
|
855
|
|
856 INIT_CPT( GPCMD_REPORT_KEY, 16 );
|
|
857
|
|
858 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
|
|
859
|
|
860 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
|
|
861
|
|
862 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
|
|
863
|
|
864 #elif defined( SYS_OS2 )
|
|
865 INIT_SSC( GPCMD_REPORT_KEY, 16 );
|
|
866
|
|
867 sdc.command[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
|
|
868
|
|
869 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
|
|
870 &sdc, sizeof(sdc), &ulParamLen,
|
|
871 p_buffer, sizeof(p_buffer), &ulDataLen);
|
|
872
|
|
873 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
|
|
874
|
|
875 #else
|
|
876 # error "DVD ioctls are unavailable on this system"
|
|
877
|
|
878 #endif
|
|
879 return i_ret;
|
|
880 }
|
|
881
|
|
882 /*****************************************************************************
|
|
883 * ioctl_ReportASF: get ASF from the drive
|
|
884 *****************************************************************************/
|
|
885 int ioctl_ReportASF( int i_fd, int *pi_remove_me, int *pi_asf )
|
|
886 {
|
|
887 int i_ret;
|
|
888
|
|
889 #if defined( HAVE_LINUX_DVD_STRUCT )
|
|
890 dvd_authinfo auth_info;
|
|
891
|
|
892 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
893 auth_info.type = DVD_LU_SEND_ASF;
|
|
894 auth_info.lsasf.asf = *pi_asf;
|
|
895
|
|
896 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
|
|
897
|
|
898 *pi_asf = auth_info.lsasf.asf;
|
|
899
|
|
900 #elif defined( HAVE_BSD_DVD_STRUCT )
|
|
901 struct dvd_authinfo auth_info;
|
|
902
|
|
903 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
904 auth_info.format = DVD_REPORT_ASF;
|
|
905 auth_info.asf = *pi_asf;
|
|
906
|
|
907 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
|
|
908
|
|
909 *pi_asf = auth_info.asf;
|
|
910
|
|
911 #elif defined( SYS_BEOS )
|
|
912 INIT_RDC( GPCMD_REPORT_KEY, 8 );
|
|
913
|
|
914 rdc.command[ 10 ] = DVD_REPORT_ASF;
|
|
915
|
|
916 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
|
|
917
|
|
918 *pi_asf = p_buffer[ 7 ] & 1;
|
|
919
|
|
920 #elif defined( HPUX_SCTL_IO )
|
|
921 INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 );
|
|
922
|
|
923 sctl_io.cdb[ 10 ] = DVD_REPORT_ASF;
|
|
924
|
|
925 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
|
|
926
|
|
927 *pi_asf = p_buffer[ 7 ] & 1;
|
|
928
|
|
929 #elif defined( SOLARIS_USCSI )
|
|
930 INIT_USCSI( GPCMD_REPORT_KEY, 8 );
|
|
931
|
|
932 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_ASF;
|
|
933
|
|
934 i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
935
|
|
936 if( i_ret < 0 || sc.uscsi_status )
|
|
937 {
|
|
938 i_ret = -1;
|
|
939 }
|
|
940
|
|
941 *pi_asf = p_buffer[ 7 ] & 1;
|
|
942
|
|
943 #elif defined( DARWIN_DVD_IOCTL )
|
|
944 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDAuthenticationSuccessFlagInfo,
|
|
945 kDVDKeyFormatASF );
|
|
946
|
|
947 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
|
|
948
|
|
949 *pi_asf = dvdbs.successFlag;
|
|
950
|
|
951 #elif defined( WIN32 )
|
|
952 if( WIN2K ) /* NT/Win2000/Whistler */
|
|
953 {
|
|
954 DWORD tmp;
|
|
955 u8 buffer[DVD_ASF_LENGTH];
|
|
956 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
|
|
957
|
|
958 memset( &buffer, 0, sizeof( buffer ) );
|
|
959
|
|
960 key->KeyLength = DVD_ASF_LENGTH;
|
|
961 key->KeyType = DvdAsf;
|
|
962 key->KeyFlags = 0;
|
|
963
|
|
964 ((PDVD_ASF)key->KeyData)->SuccessFlag = *pi_asf;
|
|
965
|
|
966 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
|
|
967 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
|
|
968
|
|
969 if( i_ret < 0 )
|
|
970 {
|
|
971 return i_ret;
|
|
972 }
|
|
973
|
|
974 *pi_asf = ((PDVD_ASF)key->KeyData)->SuccessFlag;
|
|
975 }
|
|
976 else
|
|
977 {
|
|
978 INIT_SSC( GPCMD_REPORT_KEY, 8 );
|
|
979
|
|
980 ssc.CDBByte[ 10 ] = DVD_REPORT_ASF;
|
|
981
|
|
982 i_ret = WinSendSSC( i_fd, &ssc );
|
|
983
|
|
984 *pi_asf = p_buffer[ 7 ] & 1;
|
|
985 }
|
|
986
|
|
987 #elif defined( __QNXNTO__ )
|
|
988
|
|
989 INIT_CPT( GPCMD_REPORT_KEY, 8 );
|
|
990
|
|
991 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_ASF;
|
|
992
|
|
993 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
|
|
994
|
|
995 *pi_asf = p_buffer[ 7 ] & 1;
|
|
996
|
|
997 #elif defined( SYS_OS2 )
|
|
998 INIT_SSC( GPCMD_REPORT_KEY, 8 );
|
|
999
|
|
1000 sdc.command[ 10 ] = DVD_REPORT_ASF;
|
|
1001
|
|
1002 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
|
|
1003 &sdc, sizeof(sdc), &ulParamLen,
|
|
1004 p_buffer, sizeof(p_buffer), &ulDataLen);
|
|
1005
|
|
1006 *pi_asf = p_buffer[ 7 ] & 1;
|
|
1007
|
|
1008 #else
|
|
1009 # error "DVD ioctls are unavailable on this system"
|
|
1010
|
|
1011 #endif
|
|
1012 return i_ret;
|
|
1013 }
|
|
1014
|
|
1015 /*****************************************************************************
|
|
1016 * ioctl_ReportKey1: get the first key from the drive
|
|
1017 *****************************************************************************/
|
|
1018 int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
|
|
1019 {
|
|
1020 int i_ret;
|
|
1021
|
|
1022 #if defined( HAVE_LINUX_DVD_STRUCT )
|
|
1023 dvd_authinfo auth_info;
|
|
1024
|
|
1025 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
1026 auth_info.type = DVD_LU_SEND_KEY1;
|
|
1027 auth_info.lsk.agid = *pi_agid;
|
|
1028
|
|
1029 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
|
|
1030
|
|
1031 memcpy( p_key, auth_info.lsk.key, DVD_KEY_SIZE );
|
|
1032
|
|
1033 #elif defined( HAVE_BSD_DVD_STRUCT )
|
|
1034 struct dvd_authinfo auth_info;
|
|
1035
|
|
1036 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
1037 auth_info.format = DVD_REPORT_KEY1;
|
|
1038 auth_info.agid = *pi_agid;
|
|
1039
|
|
1040 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
|
|
1041
|
|
1042 memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE );
|
|
1043
|
|
1044 #elif defined( SYS_BEOS )
|
|
1045 INIT_RDC( GPCMD_REPORT_KEY, 12 );
|
|
1046
|
|
1047 rdc.command[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
|
|
1048
|
|
1049 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
|
|
1050
|
|
1051 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
|
|
1052
|
|
1053 #elif defined( HPUX_SCTL_IO )
|
|
1054 INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 );
|
|
1055
|
|
1056 sctl_io.cdb[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
|
|
1057
|
|
1058 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
|
|
1059
|
|
1060 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
|
|
1061
|
|
1062 #elif defined( SOLARIS_USCSI )
|
|
1063 INIT_USCSI( GPCMD_REPORT_KEY, 12 );
|
|
1064
|
|
1065 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
|
|
1066
|
|
1067 i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
1068
|
|
1069 if( i_ret < 0 || sc.uscsi_status )
|
|
1070 {
|
|
1071 i_ret = -1;
|
|
1072 }
|
|
1073
|
|
1074 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
|
|
1075
|
|
1076 #elif defined( DARWIN_DVD_IOCTL )
|
|
1077 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDKey1Info,
|
|
1078 kDVDKeyFormatKey1 );
|
|
1079
|
|
1080 dvd.grantID = *pi_agid;
|
|
1081
|
|
1082 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
|
|
1083
|
|
1084 memcpy( p_key, dvdbs.key1Value, DVD_KEY_SIZE );
|
|
1085
|
|
1086 #elif defined( WIN32 )
|
|
1087 if( WIN2K ) /* NT/Win2000/Whistler */
|
|
1088 {
|
|
1089 DWORD tmp;
|
|
1090 u8 buffer[DVD_BUS_KEY_LENGTH];
|
|
1091 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
|
|
1092
|
|
1093 memset( &buffer, 0, sizeof( buffer ) );
|
|
1094
|
|
1095 key->KeyLength = DVD_BUS_KEY_LENGTH;
|
|
1096 key->SessionId = *pi_agid;
|
|
1097 key->KeyType = DvdBusKey1;
|
|
1098 key->KeyFlags = 0;
|
|
1099
|
|
1100 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
|
|
1101 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
|
|
1102
|
|
1103 memcpy( p_key, key->KeyData, DVD_KEY_SIZE );
|
|
1104 }
|
|
1105 else
|
|
1106 {
|
|
1107 INIT_SSC( GPCMD_REPORT_KEY, 12 );
|
|
1108
|
|
1109 ssc.CDBByte[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
|
|
1110
|
|
1111 i_ret = WinSendSSC( i_fd, &ssc );
|
|
1112
|
|
1113 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
|
|
1114 }
|
|
1115
|
|
1116 #elif defined( __QNXNTO__ )
|
|
1117
|
|
1118 INIT_CPT( GPCMD_REPORT_KEY, 12 );
|
|
1119
|
|
1120 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
|
|
1121
|
|
1122 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
|
|
1123
|
|
1124 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
|
|
1125
|
|
1126 #elif defined( SYS_OS2 )
|
|
1127 INIT_SSC( GPCMD_REPORT_KEY, 12 );
|
|
1128
|
|
1129 sdc.command[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
|
|
1130
|
|
1131 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
|
|
1132 &sdc, sizeof(sdc), &ulParamLen,
|
|
1133 p_buffer, sizeof(p_buffer), &ulDataLen);
|
|
1134
|
|
1135 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
|
|
1136
|
|
1137 #else
|
|
1138 # error "DVD ioctls are unavailable on this system"
|
|
1139
|
|
1140 #endif
|
|
1141 return i_ret;
|
|
1142 }
|
|
1143
|
|
1144 /*****************************************************************************
|
|
1145 * ioctl_InvalidateAgid: invalidate the current AGID
|
|
1146 *****************************************************************************/
|
|
1147 int ioctl_InvalidateAgid( int i_fd, int *pi_agid )
|
|
1148 {
|
|
1149 int i_ret;
|
|
1150
|
|
1151 #if defined( HAVE_LINUX_DVD_STRUCT )
|
|
1152 dvd_authinfo auth_info;
|
|
1153
|
|
1154 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
1155 auth_info.type = DVD_INVALIDATE_AGID;
|
|
1156 auth_info.lsa.agid = *pi_agid;
|
|
1157
|
|
1158 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
|
|
1159
|
|
1160 #elif defined( HAVE_BSD_DVD_STRUCT )
|
|
1161 struct dvd_authinfo auth_info;
|
|
1162
|
|
1163 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
1164 auth_info.format = DVD_INVALIDATE_AGID;
|
|
1165 auth_info.agid = *pi_agid;
|
|
1166
|
|
1167 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
|
|
1168
|
|
1169 #elif defined( SYS_BEOS )
|
|
1170 INIT_RDC( GPCMD_REPORT_KEY, 0 );
|
|
1171
|
|
1172 rdc.command[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
|
|
1173
|
|
1174 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
|
|
1175
|
|
1176 #elif defined( HPUX_SCTL_IO )
|
|
1177 INIT_SCTL_IO( GPCMD_REPORT_KEY, 0 );
|
|
1178
|
|
1179 sctl_io.cdb[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
|
|
1180
|
|
1181 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
|
|
1182
|
|
1183 #elif defined( SOLARIS_USCSI )
|
|
1184 INIT_USCSI( GPCMD_REPORT_KEY, 0 );
|
|
1185
|
|
1186 rs_cdb.cdb_opaque[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
|
|
1187
|
|
1188 i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
1189
|
|
1190 if( i_ret < 0 || sc.uscsi_status )
|
|
1191 {
|
|
1192 i_ret = -1;
|
|
1193 }
|
|
1194
|
|
1195 #elif defined( DARWIN_DVD_IOCTL )
|
|
1196 INIT_DVDIOCTL( dk_dvd_send_key_t, DVDAuthenticationGrantIDInfo,
|
|
1197 kDVDKeyFormatAGID_Invalidate );
|
|
1198
|
|
1199 dvd.grantID = *pi_agid;
|
|
1200
|
|
1201 i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
|
|
1202
|
|
1203 #elif defined( WIN32 )
|
|
1204 if( WIN2K ) /* NT/Win2000/Whistler */
|
|
1205 {
|
|
1206 DWORD tmp;
|
|
1207
|
|
1208 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_END_SESSION,
|
|
1209 pi_agid, sizeof( *pi_agid ), NULL, 0, &tmp, NULL ) ? 0 : -1;
|
|
1210 }
|
|
1211 else
|
|
1212 {
|
|
1213 #if defined( __MINGW32__ )
|
|
1214 INIT_SSC( GPCMD_REPORT_KEY, 0 );
|
|
1215 #else
|
|
1216 INIT_SSC( GPCMD_REPORT_KEY, 1 );
|
|
1217
|
|
1218 ssc.SRB_BufLen = 0;
|
|
1219 ssc.CDBByte[ 8 ] = 0;
|
|
1220 ssc.CDBByte[ 9 ] = 0;
|
|
1221 #endif
|
|
1222
|
|
1223 ssc.CDBByte[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
|
|
1224
|
|
1225 i_ret = WinSendSSC( i_fd, &ssc );
|
|
1226 }
|
|
1227
|
|
1228 #elif defined( __QNXNTO__ )
|
|
1229
|
|
1230 INIT_CPT( GPCMD_REPORT_KEY, 0 );
|
|
1231
|
|
1232 p_cpt->cam_cdb[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
|
|
1233
|
|
1234 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
|
|
1235
|
|
1236 #elif defined( SYS_OS2 )
|
|
1237 INIT_SSC( GPCMD_REPORT_KEY, 1 );
|
|
1238
|
|
1239 sdc.data_length = 0;
|
|
1240 sdc.command[ 8 ] = 0;
|
|
1241 sdc.command[ 9 ] = 0;
|
|
1242
|
|
1243 sdc.command[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
|
|
1244
|
|
1245 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
|
|
1246 &sdc, sizeof(sdc), &ulParamLen,
|
|
1247 NULL, 0, &ulDataLen);
|
|
1248 #else
|
|
1249 # error "DVD ioctls are unavailable on this system"
|
|
1250
|
|
1251 #endif
|
|
1252 return i_ret;
|
|
1253 }
|
|
1254
|
|
1255 /*****************************************************************************
|
|
1256 * ioctl_SendChallenge: send challenge to the drive
|
|
1257 *****************************************************************************/
|
|
1258 int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
|
|
1259 {
|
|
1260 int i_ret;
|
|
1261
|
|
1262 #if defined( HAVE_LINUX_DVD_STRUCT )
|
|
1263 dvd_authinfo auth_info;
|
|
1264
|
|
1265 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
1266 auth_info.type = DVD_HOST_SEND_CHALLENGE;
|
|
1267 auth_info.hsc.agid = *pi_agid;
|
|
1268
|
|
1269 memcpy( auth_info.hsc.chal, p_challenge, DVD_CHALLENGE_SIZE );
|
|
1270
|
|
1271 return ioctl( i_fd, DVD_AUTH, &auth_info );
|
|
1272
|
|
1273 #elif defined( HAVE_BSD_DVD_STRUCT )
|
|
1274 struct dvd_authinfo auth_info;
|
|
1275
|
|
1276 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
1277 auth_info.format = DVD_SEND_CHALLENGE;
|
|
1278 auth_info.agid = *pi_agid;
|
|
1279
|
|
1280 memcpy( auth_info.keychal, p_challenge, DVD_CHALLENGE_SIZE );
|
|
1281
|
|
1282 return ioctl( i_fd, DVDIOCSENDKEY, &auth_info );
|
|
1283
|
|
1284 #elif defined( SYS_BEOS )
|
|
1285 INIT_RDC( GPCMD_SEND_KEY, 16 );
|
|
1286
|
|
1287 rdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
|
|
1288
|
|
1289 p_buffer[ 1 ] = 0xe;
|
|
1290 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
|
|
1291
|
|
1292 return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
|
|
1293
|
|
1294 #elif defined( HPUX_SCTL_IO )
|
|
1295 INIT_SCTL_IO( GPCMD_SEND_KEY, 16 );
|
|
1296
|
|
1297 sctl_io.cdb[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
|
|
1298
|
|
1299 p_buffer[ 1 ] = 0xe;
|
|
1300 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
|
|
1301
|
|
1302 return ioctl( i_fd, SIOC_IO, &sctl_io );
|
|
1303
|
|
1304 #elif defined( SOLARIS_USCSI )
|
|
1305 INIT_USCSI( GPCMD_SEND_KEY, 16 );
|
|
1306
|
|
1307 rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
|
|
1308
|
|
1309 p_buffer[ 1 ] = 0xe;
|
|
1310 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
|
|
1311
|
|
1312 if( ioctl( i_fd, USCSICMD, &sc ) < 0 || sc.uscsi_status )
|
|
1313 {
|
|
1314 return -1;
|
|
1315 }
|
|
1316
|
|
1317 return 0;
|
|
1318
|
|
1319 #elif defined( DARWIN_DVD_IOCTL )
|
|
1320 INIT_DVDIOCTL( dk_dvd_send_key_t, DVDChallengeKeyInfo,
|
|
1321 kDVDKeyFormatChallengeKey );
|
|
1322
|
|
1323 dvd.grantID = *pi_agid;
|
|
1324 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM;
|
|
1325
|
|
1326 dvdbs.dataLength[ 1 ] = 0xe;
|
|
1327 memcpy( dvdbs.challengeKeyValue, p_challenge, DVD_CHALLENGE_SIZE );
|
|
1328
|
|
1329 i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
|
|
1330
|
|
1331 #elif defined( WIN32 )
|
|
1332 if( WIN2K ) /* NT/Win2000/Whistler */
|
|
1333 {
|
|
1334 DWORD tmp;
|
|
1335 u8 buffer[DVD_CHALLENGE_KEY_LENGTH];
|
|
1336 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
|
|
1337
|
|
1338 memset( &buffer, 0, sizeof( buffer ) );
|
|
1339
|
|
1340 key->KeyLength = DVD_CHALLENGE_KEY_LENGTH;
|
|
1341 key->SessionId = *pi_agid;
|
|
1342 key->KeyType = DvdChallengeKey;
|
|
1343 key->KeyFlags = 0;
|
|
1344
|
|
1345 memcpy( key->KeyData, p_challenge, DVD_CHALLENGE_SIZE );
|
|
1346
|
|
1347 return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
|
|
1348 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
|
|
1349 }
|
|
1350 else
|
|
1351 {
|
|
1352 INIT_SSC( GPCMD_SEND_KEY, 16 );
|
|
1353
|
|
1354 ssc.CDBByte[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
|
|
1355
|
|
1356 p_buffer[ 1 ] = 0xe;
|
|
1357 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
|
|
1358
|
|
1359 return WinSendSSC( i_fd, &ssc );
|
|
1360 }
|
|
1361
|
|
1362 #elif defined( __QNXNTO__ )
|
|
1363
|
|
1364 INIT_CPT( GPCMD_SEND_KEY, 16 );
|
|
1365
|
|
1366 p_cpt->cam_cdb[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
|
|
1367
|
|
1368 p_buffer[ 1 ] = 0xe;
|
|
1369 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
|
|
1370
|
|
1371 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
|
|
1372
|
|
1373 #elif defined( SYS_OS2 )
|
|
1374 INIT_SSC( GPCMD_SEND_KEY, 16 );
|
|
1375
|
|
1376 sdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
|
|
1377
|
|
1378 p_buffer[ 1 ] = 0xe;
|
|
1379 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
|
|
1380
|
|
1381 return DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
|
|
1382 &sdc, sizeof(sdc), &ulParamLen,
|
|
1383 p_buffer, sizeof(p_buffer), &ulDataLen);
|
|
1384
|
|
1385 #else
|
|
1386 # error "DVD ioctls are unavailable on this system"
|
|
1387
|
|
1388 #endif
|
|
1389 return i_ret;
|
|
1390 }
|
|
1391
|
|
1392 /*****************************************************************************
|
|
1393 * ioctl_SendKey2: send the second key to the drive
|
|
1394 *****************************************************************************/
|
|
1395 int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key )
|
|
1396 {
|
|
1397 int i_ret;
|
|
1398
|
|
1399 #if defined( HAVE_LINUX_DVD_STRUCT )
|
|
1400 dvd_authinfo auth_info;
|
|
1401
|
|
1402 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
1403 auth_info.type = DVD_HOST_SEND_KEY2;
|
|
1404 auth_info.hsk.agid = *pi_agid;
|
|
1405
|
|
1406 memcpy( auth_info.hsk.key, p_key, DVD_KEY_SIZE );
|
|
1407
|
|
1408 return ioctl( i_fd, DVD_AUTH, &auth_info );
|
|
1409
|
|
1410 #elif defined( HAVE_BSD_DVD_STRUCT )
|
|
1411 struct dvd_authinfo auth_info;
|
|
1412
|
|
1413 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
1414 auth_info.format = DVD_SEND_KEY2;
|
|
1415 auth_info.agid = *pi_agid;
|
|
1416
|
|
1417 memcpy( auth_info.keychal, p_key, DVD_KEY_SIZE );
|
|
1418
|
|
1419 return ioctl( i_fd, DVDIOCSENDKEY, &auth_info );
|
|
1420
|
|
1421 #elif defined( SYS_BEOS )
|
|
1422 INIT_RDC( GPCMD_SEND_KEY, 12 );
|
|
1423
|
|
1424 rdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
|
|
1425
|
|
1426 p_buffer[ 1 ] = 0xa;
|
|
1427 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
|
|
1428
|
|
1429 return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
|
|
1430
|
|
1431 #elif defined( HPUX_SCTL_IO )
|
|
1432 INIT_SCTL_IO( GPCMD_SEND_KEY, 12 );
|
|
1433
|
|
1434 sctl_io.cdb[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
|
|
1435
|
|
1436 p_buffer[ 1 ] = 0xa;
|
|
1437 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
|
|
1438
|
|
1439 return ioctl( i_fd, SIOC_IO, &sctl_io );
|
|
1440
|
|
1441 #elif defined( SOLARIS_USCSI )
|
|
1442 INIT_USCSI( GPCMD_SEND_KEY, 12 );
|
|
1443
|
|
1444 rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
|
|
1445
|
|
1446 p_buffer[ 1 ] = 0xa;
|
|
1447 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
|
|
1448
|
|
1449 if( ioctl( i_fd, USCSICMD, &sc ) < 0 || sc.uscsi_status )
|
|
1450 {
|
|
1451 return -1;
|
|
1452 }
|
|
1453
|
|
1454 return 0;
|
|
1455
|
|
1456 #elif defined( DARWIN_DVD_IOCTL )
|
|
1457 INIT_DVDIOCTL( dk_dvd_send_key_t, DVDKey2Info,
|
|
1458 kDVDKeyFormatKey2 );
|
|
1459
|
|
1460 dvd.grantID = *pi_agid;
|
|
1461 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM;
|
|
1462
|
|
1463 dvdbs.dataLength[ 1 ] = 0xa;
|
|
1464 memcpy( dvdbs.key2Value, p_key, DVD_KEY_SIZE );
|
|
1465
|
|
1466 i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
|
|
1467
|
|
1468 #elif defined( WIN32 )
|
|
1469 if( WIN2K ) /* NT/Win2000/Whistler */
|
|
1470 {
|
|
1471 DWORD tmp;
|
|
1472 u8 buffer[DVD_BUS_KEY_LENGTH];
|
|
1473 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
|
|
1474
|
|
1475 memset( &buffer, 0, sizeof( buffer ) );
|
|
1476
|
|
1477 key->KeyLength = DVD_BUS_KEY_LENGTH;
|
|
1478 key->SessionId = *pi_agid;
|
|
1479 key->KeyType = DvdBusKey2;
|
|
1480 key->KeyFlags = 0;
|
|
1481
|
|
1482 memcpy( key->KeyData, p_key, DVD_KEY_SIZE );
|
|
1483
|
|
1484 return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
|
|
1485 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
|
|
1486 }
|
|
1487 else
|
|
1488 {
|
|
1489 INIT_SSC( GPCMD_SEND_KEY, 12 );
|
|
1490
|
|
1491 ssc.CDBByte[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
|
|
1492
|
|
1493 p_buffer[ 1 ] = 0xa;
|
|
1494 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
|
|
1495
|
|
1496 return WinSendSSC( i_fd, &ssc );
|
|
1497 }
|
|
1498
|
|
1499 #elif defined( __QNXNTO__ )
|
|
1500
|
|
1501 INIT_CPT( GPCMD_SEND_KEY, 12 );
|
|
1502
|
|
1503 p_cpt->cam_cdb[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
|
|
1504
|
|
1505 p_buffer[ 1 ] = 0xa;
|
|
1506 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
|
|
1507
|
|
1508 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
|
|
1509
|
|
1510 #elif defined( SYS_OS2 )
|
|
1511 INIT_SSC( GPCMD_SEND_KEY, 12 );
|
|
1512
|
|
1513 sdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
|
|
1514
|
|
1515 p_buffer[ 1 ] = 0xa;
|
|
1516 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
|
|
1517
|
|
1518 return DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
|
|
1519 &sdc, sizeof(sdc), &ulParamLen,
|
|
1520 p_buffer, sizeof(p_buffer), &ulDataLen);
|
|
1521
|
|
1522 #else
|
|
1523 # error "DVD ioctls are unavailable on this system"
|
|
1524
|
|
1525 #endif
|
|
1526 return i_ret;
|
|
1527 }
|
|
1528
|
|
1529 /*****************************************************************************
|
|
1530 * ioctl_ReportRPC: get RPC status for the drive
|
|
1531 *****************************************************************************/
|
|
1532 int ioctl_ReportRPC( int i_fd, int *p_type, int *p_mask, int *p_scheme )
|
|
1533 {
|
|
1534 int i_ret;
|
|
1535
|
|
1536 #if defined( HAVE_LINUX_DVD_STRUCT ) && defined( DVD_LU_SEND_RPC_STATE )
|
|
1537 dvd_authinfo auth_info;
|
|
1538
|
|
1539 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
1540 auth_info.type = DVD_LU_SEND_RPC_STATE;
|
|
1541
|
|
1542 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
|
|
1543
|
|
1544 *p_type = auth_info.lrpcs.type;
|
|
1545 *p_mask = auth_info.lrpcs.region_mask;
|
|
1546 *p_scheme = auth_info.lrpcs.rpc_scheme;
|
|
1547
|
|
1548 #elif defined( HAVE_LINUX_DVD_STRUCT )
|
|
1549 /* FIXME: OpenBSD doesn't know this */
|
|
1550 i_ret = -1;
|
|
1551
|
|
1552 #elif defined( HAVE_BSD_DVD_STRUCT )
|
|
1553 struct dvd_authinfo auth_info;
|
|
1554
|
|
1555 memset( &auth_info, 0, sizeof( auth_info ) );
|
|
1556 auth_info.format = DVD_REPORT_RPC;
|
|
1557
|
|
1558 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
|
|
1559
|
|
1560 *p_type = auth_info.reg_type;
|
|
1561 *p_mask = auth_info.region; // ??
|
|
1562 *p_scheme = auth_info.rpc_scheme;
|
|
1563
|
|
1564 #elif defined( SYS_BEOS )
|
|
1565 INIT_RDC( GPCMD_REPORT_KEY, 8 );
|
|
1566
|
|
1567 rdc.command[ 10 ] = DVD_REPORT_RPC;
|
|
1568
|
|
1569 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
|
|
1570
|
|
1571 *p_type = p_buffer[ 4 ] >> 6;
|
|
1572 *p_mask = p_buffer[ 5 ];
|
|
1573 *p_scheme = p_buffer[ 6 ];
|
|
1574
|
|
1575 #elif defined( HPUX_SCTL_IO )
|
|
1576 INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 );
|
|
1577
|
|
1578 sctl_io.cdb[ 10 ] = DVD_REPORT_RPC;
|
|
1579
|
|
1580 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
|
|
1581
|
|
1582 *p_type = p_buffer[ 4 ] >> 6;
|
|
1583 *p_mask = p_buffer[ 5 ];
|
|
1584 *p_scheme = p_buffer[ 6 ];
|
|
1585
|
|
1586 #elif defined( SOLARIS_USCSI )
|
|
1587 INIT_USCSI( GPCMD_REPORT_KEY, 8 );
|
|
1588
|
|
1589 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_RPC;
|
|
1590
|
|
1591 i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
1592
|
|
1593 if( i_ret < 0 || sc.uscsi_status )
|
|
1594 {
|
|
1595 i_ret = -1;
|
|
1596 }
|
|
1597
|
|
1598 *p_type = p_buffer[ 4 ] >> 6;
|
|
1599 *p_mask = p_buffer[ 5 ];
|
|
1600 *p_scheme = p_buffer[ 6 ];
|
|
1601
|
|
1602 #elif defined( DARWIN_DVD_IOCTL )
|
|
1603 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDRegionPlaybackControlInfo,
|
|
1604 kDVDKeyFormatRegionState );
|
|
1605
|
|
1606 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM;
|
|
1607
|
|
1608 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
|
|
1609
|
|
1610 *p_type = dvdbs.typeCode;
|
|
1611 *p_mask = dvdbs.driveRegion;
|
|
1612 *p_scheme = dvdbs.rpcScheme;
|
|
1613
|
|
1614 #elif defined( WIN32 )
|
|
1615 if( WIN2K ) /* NT/Win2000/Whistler */
|
|
1616 {
|
|
1617 DWORD tmp;
|
|
1618 u8 buffer[ DVD_REGION_LENGTH ];
|
|
1619 PDVD_REGION region = (PDVD_REGION) &buffer;
|
|
1620
|
|
1621 memset( &buffer, 0, sizeof( buffer ) );
|
|
1622
|
|
1623 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_GET_REGION, NULL, 0,
|
|
1624 region, DVD_REGION_LENGTH, &tmp, NULL ) ? 0 : -1;
|
|
1625
|
|
1626 /* Someone who has the headers should correct all this. */
|
|
1627 /* Use the IOCTL_SCSI_PASS_THROUGH_DIRECT so we get the real
|
|
1628 * values of theses entities? */
|
|
1629 if(region->SystemRegion != 0) {
|
|
1630 *p_type = region->ResetCount > 1 ? 1 : 3 - region->ResetCount;
|
|
1631 *p_mask = 0xff ^ (1 << (region->SystemRegion - 1));
|
|
1632 *p_scheme = 1;
|
|
1633 }
|
|
1634 else
|
|
1635 {
|
|
1636 *p_type = 0; /* ?? */
|
|
1637 *p_mask = 0xff;
|
|
1638 *p_scheme = 1; /* ?? */
|
|
1639 }
|
|
1640 }
|
|
1641 else
|
|
1642 {
|
|
1643 INIT_SSC( GPCMD_REPORT_KEY, 8 );
|
|
1644
|
|
1645 ssc.CDBByte[ 10 ] = DVD_REPORT_RPC;
|
|
1646
|
|
1647 i_ret = WinSendSSC( i_fd, &ssc );
|
|
1648
|
|
1649 *p_type = p_buffer[ 4 ] >> 6;
|
|
1650 *p_mask = p_buffer[ 5 ];
|
|
1651 *p_scheme = p_buffer[ 6 ];
|
|
1652 }
|
|
1653
|
|
1654 #elif defined( __QNXNTO__ )
|
|
1655
|
|
1656 INIT_CPT( GPCMD_REPORT_KEY, 8 );
|
|
1657
|
|
1658 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_RPC;
|
|
1659
|
|
1660 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
|
|
1661
|
|
1662 *p_type = p_buffer[ 4 ] >> 6;
|
|
1663 *p_mask = p_buffer[ 5 ];
|
|
1664 *p_scheme = p_buffer[ 6 ];
|
|
1665
|
|
1666 #elif defined( SYS_OS2 )
|
|
1667 INIT_SSC( GPCMD_REPORT_KEY, 8 );
|
|
1668
|
|
1669 sdc.command[ 10 ] = DVD_REPORT_RPC;
|
|
1670
|
|
1671 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
|
|
1672 &sdc, sizeof(sdc), &ulParamLen,
|
|
1673 p_buffer, sizeof(p_buffer), &ulDataLen);
|
|
1674
|
|
1675 *p_type = p_buffer[ 4 ] >> 6;
|
|
1676 *p_mask = p_buffer[ 5 ];
|
|
1677 *p_scheme = p_buffer[ 6 ];
|
|
1678
|
|
1679 #else
|
|
1680 # error "DVD ioctls are unavailable on this system"
|
|
1681
|
|
1682 #endif
|
|
1683 return i_ret;
|
|
1684 }
|
|
1685
|
|
1686 /* Local prototypes */
|
|
1687
|
|
1688 #if defined( SYS_BEOS )
|
|
1689 /*****************************************************************************
|
|
1690 * BeInitRDC: initialize a RDC structure for the BeOS kernel
|
|
1691 *****************************************************************************
|
|
1692 * This function initializes a BeOS raw device command structure for future
|
|
1693 * use, either a read command or a write command.
|
|
1694 *****************************************************************************/
|
|
1695 static void BeInitRDC( raw_device_command *p_rdc, int i_type )
|
|
1696 {
|
|
1697 memset( p_rdc->data, 0, p_rdc->data_length );
|
|
1698
|
|
1699 switch( i_type )
|
|
1700 {
|
|
1701 case GPCMD_SEND_KEY:
|
|
1702 /* leave the flags to 0 */
|
|
1703 break;
|
|
1704
|
|
1705 case GPCMD_READ_DVD_STRUCTURE: case GPCMD_REPORT_KEY:
|
|
1706 p_rdc->flags = B_RAW_DEVICE_DATA_IN; break; }
|
|
1707
|
|
1708 p_rdc->command[ 0 ] = i_type;
|
|
1709
|
|
1710 p_rdc->command[ 8 ] = (p_rdc->data_length >> 8) & 0xff;
|
|
1711 p_rdc->command[ 9 ] = p_rdc->data_length & 0xff;
|
|
1712 p_rdc->command_length = 12;
|
|
1713
|
|
1714 p_rdc->sense_data = NULL;
|
|
1715 p_rdc->sense_data_length = 0;
|
|
1716
|
|
1717 p_rdc->timeout = 1000000;
|
|
1718 }
|
|
1719 #endif
|
|
1720
|
|
1721 #if defined( HPUX_SCTL_IO )
|
|
1722 /*****************************************************************************
|
|
1723 * HPUXInitSCTL: initialize a sctl_io structure for the HP-UX kernel
|
|
1724 *****************************************************************************
|
|
1725 * This function initializes a HP-UX command structure for future
|
|
1726 * use, either a read command or a write command.
|
|
1727 *****************************************************************************/
|
|
1728 static void HPUXInitSCTL( struct sctl_io *sctl_io, int i_type )
|
|
1729 {
|
|
1730 memset( sctl_io->data, 0, sctl_io->data_length );
|
|
1731
|
|
1732 switch( i_type )
|
|
1733 {
|
|
1734 case GPCMD_SEND_KEY:
|
|
1735 /* leave the flags to 0 */
|
|
1736 break;
|
|
1737
|
|
1738 case GPCMD_READ_DVD_STRUCTURE:
|
|
1739 case GPCMD_REPORT_KEY:
|
|
1740 sctl_io->flags = SCTL_READ;
|
|
1741 break;
|
|
1742 }
|
|
1743
|
|
1744 sctl_io->cdb[ 0 ] = i_type;
|
|
1745
|
|
1746 sctl_io->cdb[ 8 ] = (sctl_io->data_length >> 8) & 0xff;
|
|
1747 sctl_io->cdb[ 9 ] = sctl_io->data_length & 0xff;
|
|
1748 sctl_io->cdb_length = 12;
|
|
1749
|
|
1750 sctl_io->max_msecs = 1000000;
|
|
1751 }
|
|
1752 #endif
|
|
1753
|
|
1754 #if defined( SOLARIS_USCSI )
|
|
1755 /*****************************************************************************
|
|
1756 * SolarisInitUSCSI: initialize a USCSICMD structure for the Solaris kernel
|
|
1757 *****************************************************************************
|
|
1758 * This function initializes a Solaris userspace scsi command structure for
|
|
1759 * future use, either a read command or a write command.
|
|
1760 *****************************************************************************/
|
|
1761 static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type )
|
|
1762 {
|
|
1763 union scsi_cdb *rs_cdb;
|
|
1764 memset( p_sc->uscsi_cdb, 0, sizeof( union scsi_cdb ) );
|
|
1765 memset( p_sc->uscsi_bufaddr, 0, p_sc->uscsi_buflen );
|
|
1766
|
|
1767 switch( i_type )
|
|
1768 {
|
|
1769 case GPCMD_SEND_KEY:
|
|
1770 p_sc->uscsi_flags = USCSI_ISOLATE | USCSI_WRITE;
|
|
1771 break;
|
|
1772
|
|
1773 case GPCMD_READ_DVD_STRUCTURE:
|
|
1774 case GPCMD_REPORT_KEY:
|
|
1775 p_sc->uscsi_flags = USCSI_ISOLATE | USCSI_READ;
|
|
1776 break;
|
|
1777 }
|
|
1778
|
|
1779 rs_cdb = (union scsi_cdb *)p_sc->uscsi_cdb;
|
|
1780
|
|
1781 rs_cdb->scc_cmd = i_type;
|
|
1782
|
|
1783 rs_cdb->cdb_opaque[ 8 ] = (p_sc->uscsi_buflen >> 8) & 0xff;
|
|
1784 rs_cdb->cdb_opaque[ 9 ] = p_sc->uscsi_buflen & 0xff;
|
|
1785 p_sc->uscsi_cdblen = 12;
|
|
1786
|
|
1787 USCSI_TIMEOUT( p_sc, 15 );
|
|
1788 }
|
|
1789 #endif
|
|
1790
|
|
1791 #if defined( WIN32 )
|
|
1792 /*****************************************************************************
|
|
1793 * WinInitSSC: initialize a ssc structure for the win32 aspi layer
|
|
1794 *****************************************************************************
|
|
1795 * This function initializes a ssc raw device command structure for future
|
|
1796 * use, either a read command or a write command.
|
|
1797 *****************************************************************************/
|
|
1798 static void WinInitSSC( struct SRB_ExecSCSICmd *p_ssc, int i_type )
|
|
1799 {
|
|
1800 memset( p_ssc->SRB_BufPointer, 0, p_ssc->SRB_BufLen );
|
|
1801
|
|
1802 switch( i_type )
|
|
1803 {
|
|
1804 case GPCMD_SEND_KEY:
|
|
1805 p_ssc->SRB_Flags = SRB_DIR_OUT;
|
|
1806 break;
|
|
1807
|
|
1808 case GPCMD_READ_DVD_STRUCTURE:
|
|
1809 case GPCMD_REPORT_KEY:
|
|
1810 p_ssc->SRB_Flags = SRB_DIR_IN;
|
|
1811 break;
|
|
1812 }
|
|
1813
|
|
1814 p_ssc->SRB_Cmd = SC_EXEC_SCSI_CMD;
|
|
1815 p_ssc->SRB_Flags |= SRB_EVENT_NOTIFY;
|
|
1816
|
|
1817 p_ssc->CDBByte[ 0 ] = i_type;
|
|
1818
|
|
1819 p_ssc->CDBByte[ 8 ] = (u8)(p_ssc->SRB_BufLen >> 8) & 0xff;
|
|
1820 p_ssc->CDBByte[ 9 ] = (u8) p_ssc->SRB_BufLen & 0xff;
|
|
1821 p_ssc->SRB_CDBLen = 12;
|
|
1822
|
|
1823 p_ssc->SRB_SenseLen = SENSE_LEN;
|
|
1824 }
|
|
1825
|
|
1826 /*****************************************************************************
|
|
1827 * WinSendSSC: send a ssc structure to the aspi layer
|
|
1828 *****************************************************************************/
|
|
1829 static int WinSendSSC( int i_fd, struct SRB_ExecSCSICmd *p_ssc )
|
|
1830 {
|
|
1831 HANDLE hEvent = NULL;
|
|
1832 struct w32_aspidev *fd = (struct w32_aspidev *) i_fd;
|
|
1833
|
|
1834 hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
|
|
1835 if( hEvent == NULL )
|
|
1836 {
|
|
1837 return -1;
|
|
1838 }
|
|
1839
|
|
1840 p_ssc->SRB_PostProc = hEvent;
|
|
1841 p_ssc->SRB_HaId = LOBYTE( fd->i_sid );
|
|
1842 p_ssc->SRB_Target = HIBYTE( fd->i_sid );
|
|
1843
|
|
1844 ResetEvent( hEvent );
|
|
1845 if( fd->lpSendCommand( (void*) p_ssc ) == SS_PENDING )
|
|
1846 WaitForSingleObject( hEvent, INFINITE );
|
|
1847
|
|
1848 CloseHandle( hEvent );
|
|
1849
|
|
1850 return p_ssc->SRB_Status == SS_COMP ? 0 : -1;
|
|
1851 }
|
|
1852 #endif
|
|
1853
|
|
1854 #if defined( __QNXNTO__ )
|
|
1855 /*****************************************************************************
|
|
1856 * QNXInitCPT: initialize a ssc structure for the win32 aspi layer
|
|
1857 *****************************************************************************
|
|
1858 * This function initializes a ssc raw device command structure for future
|
|
1859 * use, either a read command or a write command.
|
|
1860 *****************************************************************************/
|
|
1861 static void QNXInitCPT( CAM_PASS_THRU * p_cpt, int i_type )
|
|
1862 {
|
|
1863 switch( i_type )
|
|
1864 {
|
|
1865 case GPCMD_SEND_KEY:
|
|
1866 p_cpt->cam_flags = CAM_DIR_OUT;
|
|
1867 break;
|
|
1868
|
|
1869 case GPCMD_READ_DVD_STRUCTURE:
|
|
1870 case GPCMD_REPORT_KEY:
|
|
1871 p_cpt->cam_flags = CAM_DIR_IN;
|
|
1872 break;
|
|
1873 }
|
|
1874
|
|
1875 p_cpt->cam_cdb[0] = i_type;
|
|
1876
|
|
1877 p_cpt->cam_cdb[ 8 ] = (p_cpt->cam_dxfer_len >> 8) & 0xff;
|
|
1878 p_cpt->cam_cdb[ 9 ] = p_cpt->cam_dxfer_len & 0xff;
|
|
1879 p_cpt->cam_cdb_len = 12;
|
|
1880
|
|
1881 p_cpt->cam_timeout = CAM_TIME_DEFAULT;
|
|
1882 }
|
|
1883 #endif
|
|
1884
|
|
1885 #if defined( SYS_OS2 )
|
|
1886 /*****************************************************************************
|
|
1887 * OS2InitSDC: initialize a SDC structure for the Execute SCSI-command
|
|
1888 *****************************************************************************
|
|
1889 * This function initializes a OS2 'execute SCSI command' structure for
|
|
1890 * future use, either a read command or a write command.
|
|
1891 *****************************************************************************/
|
|
1892 static void OS2InitSDC( struct OS2_ExecSCSICmd *p_sdc, int i_type )
|
|
1893 {
|
|
1894 switch( i_type )
|
|
1895 {
|
|
1896 case GPCMD_SEND_KEY:
|
|
1897 p_sdc->flags = 0;
|
|
1898 break;
|
|
1899
|
|
1900 case GPCMD_READ_DVD_STRUCTURE:
|
|
1901 case GPCMD_REPORT_KEY:
|
|
1902 p_sdc->flags = EX_DIRECTION_IN;
|
|
1903 break;
|
|
1904 }
|
|
1905
|
|
1906 p_sdc->command[ 0 ] = i_type;
|
|
1907 p_sdc->command[ 8 ] = (p_sdc->data_length >> 8) & 0xff;
|
|
1908 p_sdc->command[ 9 ] = p_sdc->data_length & 0xff;
|
|
1909 p_sdc->id_code = 0x31304443; // 'CD01'
|
|
1910 p_sdc->cmd_length = 12;
|
|
1911 }
|
|
1912 #endif
|