Commit 22899aa9 authored by Sam Hocevar's avatar Sam Hocevar

libdvdcss changes:

  * Support for REPORT_TITLE_KEY and RPC commands by H�kan Hjort
    <d95hjort@dtek.chalmers.se>.

vlc changes:
  * Minor coding style fixes (please avoid tabs).
parent 14047fa1
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
HEAD HEAD
* Support for REPORT_TITLE_KEY and RPC commands by Håkan Hjort
<d95hjort@dtek.chalmers.se>.
* HP-UX port courtesy of David Siebörger <drs-videolan@rucus.ru.ac.za>. * HP-UX port courtesy of David Siebörger <drs-videolan@rucus.ru.ac.za>.
1.0.1 1.0.1
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ioctl.c: DVD ioctl replacement function * ioctl.c: DVD ioctl replacement function
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: ioctl.c,v 1.16 2001/12/11 14:43:38 sam Exp $ * $Id: ioctl.c,v 1.17 2001/12/16 18:00:18 sam Exp $
* *
* Authors: Markus Kuespert <ltlBeBoy@beosmail.com> * Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -122,6 +122,7 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright ) ...@@ -122,6 +122,7 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
#if defined( HAVE_LINUX_DVD_STRUCT ) #if defined( HAVE_LINUX_DVD_STRUCT )
dvd_struct dvd; dvd_struct dvd;
memset( &dvd, 0, sizeof( dvd ) );
dvd.type = DVD_STRUCT_COPYRIGHT; dvd.type = DVD_STRUCT_COPYRIGHT;
dvd.copyright.layer_num = i_layer; dvd.copyright.layer_num = i_layer;
...@@ -132,6 +133,7 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright ) ...@@ -132,6 +133,7 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
#elif defined( HAVE_BSD_DVD_STRUCT ) #elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_struct dvd; struct dvd_struct dvd;
memset( &dvd, 0, sizeof( dvd ) );
dvd.format = DVD_STRUCT_COPYRIGHT; dvd.format = DVD_STRUCT_COPYRIGHT;
dvd.layer_num = i_layer; dvd.layer_num = i_layer;
...@@ -225,7 +227,7 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright ) ...@@ -225,7 +227,7 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
&sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ), &sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ),
&tmp, NULL ) ? 0 : -1; &tmp, NULL ) ? 0 : -1;
*pi_copyright = p_buffer[4]; *pi_copyright = p_buffer[ 4 ];
} }
else else
{ {
...@@ -267,9 +269,10 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -267,9 +269,10 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
#if defined( HAVE_LINUX_DVD_STRUCT ) #if defined( HAVE_LINUX_DVD_STRUCT )
dvd_struct dvd; dvd_struct dvd;
memset( &dvd, 0, sizeof( dvd ) );
dvd.type = DVD_STRUCT_DISCKEY; dvd.type = DVD_STRUCT_DISCKEY;
dvd.disckey.agid = *pi_agid; dvd.disckey.agid = *pi_agid;
memset( dvd.disckey.value, 0, 2048 ); memset( dvd.disckey.value, 0, DVD_DISCKEY_SIZE );
i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd ); i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd );
...@@ -278,14 +281,15 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -278,14 +281,15 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
return i_ret; return i_ret;
} }
memcpy( p_key, dvd.disckey.value, 2048 ); memcpy( p_key, dvd.disckey.value, DVD_DISCKEY_SIZE );
#elif defined( HAVE_BSD_DVD_STRUCT ) #elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_struct dvd; struct dvd_struct dvd;
memset( &dvd, 0, sizeof( dvd ) );
dvd.format = DVD_STRUCT_DISCKEY; dvd.format = DVD_STRUCT_DISCKEY;
dvd.agid = *pi_agid; dvd.agid = *pi_agid;
memset( dvd.data, 0, 2048 ); memset( dvd.data, 0, DVD_DISCKEY_SIZE );
i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd ); i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd );
...@@ -294,10 +298,10 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -294,10 +298,10 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
return i_ret; return i_ret;
} }
memcpy( p_key, dvd.data, 2048 ); memcpy( p_key, dvd.data, DVD_DISCKEY_SIZE );
#elif defined( SYS_BEOS ) #elif defined( SYS_BEOS )
INIT_RDC( GPCMD_READ_DVD_STRUCTURE, 2048 + 4 ); INIT_RDC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
rdc.command[ 7 ] = DVD_STRUCT_DISCKEY; rdc.command[ 7 ] = DVD_STRUCT_DISCKEY;
rdc.command[ 10 ] = *pi_agid << 6; rdc.command[ 10 ] = *pi_agid << 6;
...@@ -309,10 +313,10 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -309,10 +313,10 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
return i_ret; return i_ret;
} }
memcpy( p_key, p_buffer + 4, 2048 ); memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
#elif defined( HPUX_SCTL_IO ) #elif defined( HPUX_SCTL_IO )
INIT_SCTL_IO( GPCMD_READ_DVD_STRUCTURE, 2048 + 4 ); INIT_SCTL_IO( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
sctl_io.cdb[ 7 ] = DVD_STRUCT_DISCKEY; sctl_io.cdb[ 7 ] = DVD_STRUCT_DISCKEY;
sctl_io.cdb[ 10 ] = *pi_agid << 6; sctl_io.cdb[ 10 ] = *pi_agid << 6;
...@@ -324,10 +328,10 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -324,10 +328,10 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
return i_ret; return i_ret;
} }
memcpy( p_key, p_buffer + 4, 2048 ); memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
#elif defined( SOLARIS_USCSI ) #elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, 2048 + 4 ); INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_DISCKEY; rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_DISCKEY;
rs_cdb.cdb_opaque[ 10 ] = *pi_agid << 6; rs_cdb.cdb_opaque[ 10 ] = *pi_agid << 6;
...@@ -340,7 +344,7 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -340,7 +344,7 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
return i_ret; return i_ret;
} }
memcpy( p_key, p_buffer + 4, 2048 ); memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
#elif defined( SYS_DARWIN ) #elif defined( SYS_DARWIN )
dk_dvd_read_structure_t dvd; dk_dvd_read_structure_t dvd;
...@@ -355,12 +359,12 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -355,12 +359,12 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
dvd.grantID = *pi_agid; dvd.grantID = *pi_agid;
/* 2048+2 ; maybe we should do bit shifts to value of (sizeof(dvddki)-2) */ /* 2048+2 ; maybe we should do bit shifts to value of (sizeof(dvddki)-2) */
dvddki.dataLength[0] = 0x04; dvddki.dataLength[ 0 ] = 0x04;
dvddki.dataLength[1] = 0x02; dvddki.dataLength[ 1 ] = 0x02;
i_ret = ioctl( i_fd, DKIOCDVDREADSTRUCTURE, &dvd ); i_ret = ioctl( i_fd, DKIOCDVDREADSTRUCTURE, &dvd );
memcpy( p_key, dvddki.discKeyStructures, sizeof(dvddki.discKeyStructures) ); memcpy( p_key, dvddki.discKeyStructures, DVD_DISCKEY_SIZE );
#elif defined( WIN32 ) #elif defined( WIN32 )
if( WIN2K ) /* NT/Win2000/Whistler */ if( WIN2K ) /* NT/Win2000/Whistler */
...@@ -384,11 +388,11 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -384,11 +388,11 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
return i_ret; return i_ret;
} }
memcpy( p_key, key->KeyData, 2048 ); memcpy( p_key, key->KeyData, DVD_DISCKEY_SIZE );
} }
else else
{ {
INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 2048 + 4 ); INIT_SSC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
ssc.CDBByte[ 7 ] = DVD_STRUCT_DISCKEY; ssc.CDBByte[ 7 ] = DVD_STRUCT_DISCKEY;
ssc.CDBByte[ 10 ] = *pi_agid << 6; ssc.CDBByte[ 10 ] = *pi_agid << 6;
...@@ -400,7 +404,7 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -400,7 +404,7 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
return i_ret; return i_ret;
} }
memcpy( p_key, p_buffer + 4, 2048 ); memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
} }
#else #else
...@@ -419,33 +423,77 @@ int ioctl_ReadTitleKey( int i_fd, int *pi_agid, int i_pos, u8 *p_key ) ...@@ -419,33 +423,77 @@ int ioctl_ReadTitleKey( int i_fd, int *pi_agid, int i_pos, u8 *p_key )
int i_ret; int i_ret;
#if defined( HAVE_LINUX_DVD_STRUCT ) #if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo dvd_ai; dvd_authinfo auth_info;
memset( &dvd_ai, 0, sizeof(dvd_ai) );
dvd_ai.type = DVD_LU_SEND_TITLE_KEY;
dvd_ai.lstk.agid = *pi_agid;
dvd_ai.lstk.lba = i_pos;
i_ret = ioctl( i_fd, DVD_AUTH, &dvd_ai ); memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_LU_SEND_TITLE_KEY;
auth_info.lstk.agid = *pi_agid;
auth_info.lstk.lba = i_pos;
if( i_ret < 0 ) i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
{
return i_ret;
}
memcpy( p_key, dvd_ai.lstk.title_key, 5 ); memcpy( p_key, auth_info.lstk.title_key, DVD_KEY_SIZE );
#elif defined( HAVE_BSD_DVD_STRUCT ) #elif defined( HAVE_BSD_DVD_STRUCT )
i_ret = -1; struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_REPORT_TITLE_KEY;
auth_info.agid = *pi_agid;
auth_info.lba = i_pos;
i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE );
#elif defined( SYS_BEOS ) #elif defined( SYS_BEOS )
i_ret = -1; INIT_RDC( GPCMD_REPORT_KEY, 12 );
rdc.command[ 2 ] = ( i_pos >> 24 ) & 0xff;
rdc.command[ 3 ] = ( i_pos >> 16 ) & 0xff;
rdc.command[ 4 ] = ( i_pos >> 8 ) & 0xff;
rdc.command[ 5 ] = ( i_pos ) & 0xff;
rdc.command[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
#elif defined( HPUX_SCTL_IO ) #elif defined( HPUX_SCTL_IO )
i_ret = -1; INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 );
sctl_io.cdb[ 2 ] = ( i_pos >> 24 ) & 0xff;
sctl_io.cdb[ 3 ] = ( i_pos >> 16 ) & 0xff;
sctl_io.cdb[ 4 ] = ( i_pos >> 8 ) & 0xff;
sctl_io.cdb[ 5 ] = ( i_pos ) & 0xff;
sctl_io.cdb[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
#elif defined( SOLARIS_USCSI ) #elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 12 );
rs_cdb.cdb_opaque[ 2 ] = ( i_pos >> 24 ) & 0xff;
rs_cdb.cdb_opaque[ 3 ] = ( i_pos >> 16 ) & 0xff;
rs_cdb.cdb_opaque[ 4 ] = ( i_pos >> 8 ) & 0xff;
rs_cdb.cdb_opaque[ 5 ] = ( i_pos ) & 0xff;
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
i_ret = ioctl( i_fd, USCSICMD, &sc );
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1; i_ret = -1;
}
/* Do we want to return the cp_sec flag perhaps? */
/* a->lstk.cpm = (buf[ 4 ] >> 7) & 1; */
/* a->lstk.cp_sec = (buf[ 4 ] >> 6) & 1; */
/* a->lstk.cgms = (buf[ 4 ] >> 4) & 3; */
memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
#elif defined( SYS_DARWIN ) #elif defined( SYS_DARWIN )
dk_dvd_report_key_t dvd; dk_dvd_report_key_t dvd;
...@@ -461,19 +509,54 @@ int ioctl_ReadTitleKey( int i_fd, int *pi_agid, int i_pos, u8 *p_key ) ...@@ -461,19 +509,54 @@ int ioctl_ReadTitleKey( int i_fd, int *pi_agid, int i_pos, u8 *p_key )
dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; /* or this - this is memset 0x00 anyways */ dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; /* or this - this is memset 0x00 anyways */
/* dvdtki.dataLength[0] = 0x00; */ /* dataLength[0] is already memset to 0 */ /* dvdtki.dataLength[0] = 0x00; */ /* dataLength[0] is already memset to 0 */
dvdtki.dataLength[1] = 0x0a; dvdtki.dataLength[ 1 ] = 0x0a;
/* What are DVDTitleKeyInfo.{CP_MOD,CGMS,CP_SEC,CPM} and do they need to be set? */ /* What are DVDTitleKeyInfo.{CP_MOD,CGMS,CP_SEC,CPM} and do they need to be set? */
#warning "Correct title key reading for MacOSX / Darwin!"
/* hh: No that should be part of the result I belive.
* You do need to set the sector/lba/position somehow though! */
i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
memcpy( p_key, dvdtki.titleKeyValue, sizeof(dvdtki.titleKeyValue) ); memcpy( p_key, dvdtki.titleKeyValue, DVD_KEY_SIZE );
#elif defined( WIN32 ) #elif defined( WIN32 )
i_ret = -1; if( WIN2K ) /* NT/Win2000/Whistler */
{
DWORD tmp;
u8 buffer[DVD_BUS_KEY_LENGTH];
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
#else memset( &buffer, 0, sizeof( buffer ) );
key->KeyLength = DVD_BUS_KEY_LENGTH;
key->SessionId = *pi_agid;
key->KeyType = DvdTitleKey;
key->KeyFlags = 0;
key->Parameters.TitleOffset = i_pos; // is this ok?
i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
memcpy( p_key, key->KeyData, DVD_KEY_SIZE );
}
else
{
INIT_SSC( GPCMD_REPORT_KEY, 12 );
ssc.CDBByte[ 2 ] = ( i_pos >> 24 ) & 0xff;
ssc.CDBByte[ 3 ] = ( i_pos >> 16 ) & 0xff;
ssc.CDBByte[ 4 ] = ( i_pos >> 8 ) & 0xff;
ssc.CDBByte[ 5 ] = ( i_pos ) & 0xff;
ssc.CDBByte[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
i_ret = WinSendSSC( i_fd, &ssc );
memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
}
#else
/* DVD ioctls unavailable - do as if the ioctl failed */
i_ret = -1; i_ret = -1;
#endif #endif
...@@ -492,6 +575,7 @@ int ioctl_ReportAgid( int i_fd, int *pi_agid ) ...@@ -492,6 +575,7 @@ int ioctl_ReportAgid( int i_fd, int *pi_agid )
#if defined( HAVE_LINUX_DVD_STRUCT ) #if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo auth_info; dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_LU_SEND_AGID; auth_info.type = DVD_LU_SEND_AGID;
auth_info.lsa.agid = *pi_agid; auth_info.lsa.agid = *pi_agid;
...@@ -502,6 +586,7 @@ int ioctl_ReportAgid( int i_fd, int *pi_agid ) ...@@ -502,6 +586,7 @@ int ioctl_ReportAgid( int i_fd, int *pi_agid )
#elif defined( HAVE_BSD_DVD_STRUCT ) #elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_authinfo auth_info; struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_REPORT_AGID; auth_info.format = DVD_REPORT_AGID;
auth_info.agid = *pi_agid; auth_info.agid = *pi_agid;
...@@ -602,22 +687,24 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -602,22 +687,24 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
#if defined( HAVE_LINUX_DVD_STRUCT ) #if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo auth_info; dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_LU_SEND_CHALLENGE; auth_info.type = DVD_LU_SEND_CHALLENGE;
auth_info.lsc.agid = *pi_agid; auth_info.lsc.agid = *pi_agid;
i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
memcpy( p_challenge, auth_info.lsc.chal, sizeof(dvd_challenge) ); memcpy( p_challenge, auth_info.lsc.chal, DVD_CHALLENGE_SIZE );
#elif defined( HAVE_BSD_DVD_STRUCT ) #elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_authinfo auth_info; struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_REPORT_CHALLENGE; auth_info.format = DVD_REPORT_CHALLENGE;
auth_info.agid = *pi_agid; auth_info.agid = *pi_agid;
i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
memcpy( p_challenge, auth_info.keychal, 10 ); memcpy( p_challenge, auth_info.keychal, DVD_CHALLENGE_SIZE );
#elif defined( SYS_BEOS ) #elif defined( SYS_BEOS )
INIT_RDC( GPCMD_REPORT_KEY, 16 ); INIT_RDC( GPCMD_REPORT_KEY, 16 );
...@@ -626,7 +713,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -626,7 +713,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
memcpy( p_challenge, p_buffer + 4, 12 ); memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
#elif defined( HPUX_SCTL_IO ) #elif defined( HPUX_SCTL_IO )
INIT_SCTL_IO( GPCMD_REPORT_KEY, 16 ); INIT_SCTL_IO( GPCMD_REPORT_KEY, 16 );
...@@ -635,7 +722,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -635,7 +722,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
memcpy( p_challenge, p_buffer + 4, 12 ); memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
#elif defined( SOLARIS_USCSI ) #elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 16 ); INIT_USCSI( GPCMD_REPORT_KEY, 16 );
...@@ -649,7 +736,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -649,7 +736,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
i_ret = -1; i_ret = -1;
} }
memcpy( p_challenge, p_buffer + 4, 12 ); memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
#elif defined( SYS_DARWIN ) #elif defined( SYS_DARWIN )
dk_dvd_report_key_t dvd; dk_dvd_report_key_t dvd;
...@@ -664,11 +751,11 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -664,11 +751,11 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
dvd.grantID = *pi_agid; dvd.grantID = *pi_agid;
/* dvdcki.dataLength[0] = 0x00; */ /* dataLength[0] is already memset to 0 */ /* dvdcki.dataLength[0] = 0x00; */ /* dataLength[0] is already memset to 0 */
dvdcki.dataLength[1] = 0x0e; dvdcki.dataLength[ 1 ] = 0x0e;
i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
memcpy( p_challenge, dvdcki.challengeKeyValue, sizeof(dvdcki.challengeKeyValue) ); memcpy( p_challenge, dvdcki.challengeKeyValue, DVD_CHALLENGE_SIZE );
#elif defined( WIN32 ) #elif defined( WIN32 )
if( WIN2K ) /* NT/Win2000/Whistler */ if( WIN2K ) /* NT/Win2000/Whistler */
...@@ -692,7 +779,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -692,7 +779,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
return i_ret; return i_ret;
} }
memcpy( p_challenge, key->KeyData, 10 ); memcpy( p_challenge, key->KeyData, DVD_CHALLENGE_SIZE );
} }
else else
{ {
...@@ -702,7 +789,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -702,7 +789,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
i_ret = WinSendSSC( i_fd, &ssc ); i_ret = WinSendSSC( i_fd, &ssc );
memcpy( p_challenge, p_buffer + 4, 12 ); memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
} }
#else #else
...@@ -716,15 +803,15 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -716,15 +803,15 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
/***************************************************************************** /*****************************************************************************
* ioctl_ReportASF: get ASF from the drive * ioctl_ReportASF: get ASF from the drive
*****************************************************************************/ *****************************************************************************/
int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf ) int ioctl_ReportASF( int i_fd, int *pi_remove_me, int *pi_asf )
{ {
int i_ret; int i_ret;
#if defined( HAVE_LINUX_DVD_STRUCT ) #if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo auth_info; dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_LU_SEND_ASF; auth_info.type = DVD_LU_SEND_ASF;
auth_info.lsasf.agid = *pi_agid;
auth_info.lsasf.asf = *pi_asf; auth_info.lsasf.asf = *pi_asf;
i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
...@@ -734,8 +821,8 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf ) ...@@ -734,8 +821,8 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
#elif defined( HAVE_BSD_DVD_STRUCT ) #elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_authinfo auth_info; struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_REPORT_ASF; auth_info.format = DVD_REPORT_ASF;
auth_info.agid = *pi_agid;
auth_info.asf = *pi_asf; auth_info.asf = *pi_asf;
i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
...@@ -745,7 +832,7 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf ) ...@@ -745,7 +832,7 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
#elif defined( SYS_BEOS ) #elif defined( SYS_BEOS )
INIT_RDC( GPCMD_REPORT_KEY, 8 ); INIT_RDC( GPCMD_REPORT_KEY, 8 );
rdc.command[ 10 ] = DVD_REPORT_ASF | (*pi_agid << 6); rdc.command[ 10 ] = DVD_REPORT_ASF;
i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
...@@ -754,7 +841,7 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf ) ...@@ -754,7 +841,7 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
#elif defined( HPUX_SCTL_IO ) #elif defined( HPUX_SCTL_IO )
INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 ); INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 );
sctl_io.cdb[ 10 ] = DVD_REPORT_ASF | (*pi_agid << 6); sctl_io.cdb[ 10 ] = DVD_REPORT_ASF;
i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
...@@ -763,7 +850,7 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf ) ...@@ -763,7 +850,7 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
#elif defined( SOLARIS_USCSI ) #elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 8 ); INIT_USCSI( GPCMD_REPORT_KEY, 8 );
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_ASF | (*pi_agid << 6); rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_ASF;
i_ret = ioctl( i_fd, USCSICMD, &sc ); i_ret = ioctl( i_fd, USCSICMD, &sc );
...@@ -784,11 +871,10 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf ) ...@@ -784,11 +871,10 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
dvd.buffer = &dvdasfi; dvd.buffer = &dvdasfi;
dvd.bufferLength = sizeof(dvdasfi); dvd.bufferLength = sizeof(dvdasfi);
dvd.format = kDVDKeyFormatASF; dvd.format = kDVDKeyFormatASF;
dvd.grantID = *pi_agid;
dvdasfi.successFlag = *pi_asf; dvdasfi.successFlag = *pi_asf;
/* dvdasfi.dataLength[0] = 0x00; */ /* dataLength[0] is already memset to 0 */ /* dvdasfi.dataLength[0] = 0x00; */ /* dataLength[0] is already memset to 0 */
dvdasfi.dataLength[1] = 0x06; dvdasfi.dataLength[ 1 ] = 0x06;
i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
...@@ -804,7 +890,6 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf ) ...@@ -804,7 +890,6 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
memset( &buffer, 0, sizeof( buffer ) ); memset( &buffer, 0, sizeof( buffer ) );
key->KeyLength = DVD_ASF_LENGTH; key->KeyLength = DVD_ASF_LENGTH;
key->SessionId = *pi_agid;
key->KeyType = DvdAsf; key->KeyType = DvdAsf;
key->KeyFlags = 0; key->KeyFlags = 0;
...@@ -824,7 +909,7 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf ) ...@@ -824,7 +909,7 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
{ {
INIT_SSC( GPCMD_REPORT_KEY, 8 ); INIT_SSC( GPCMD_REPORT_KEY, 8 );
ssc.CDBByte[ 10 ] = DVD_REPORT_ASF | (*pi_agid << 6); ssc.CDBByte[ 10 ] = DVD_REPORT_ASF;
i_ret = WinSendSSC( i_fd, &ssc ); i_ret = WinSendSSC( i_fd, &ssc );
...@@ -849,22 +934,24 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -849,22 +934,24 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
#if defined( HAVE_LINUX_DVD_STRUCT ) #if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo auth_info; dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_LU_SEND_KEY1; auth_info.type = DVD_LU_SEND_KEY1;
auth_info.lsk.agid = *pi_agid; auth_info.lsk.agid = *pi_agid;
i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
memcpy( p_key, auth_info.lsk.key, sizeof(dvd_key) ); memcpy( p_key, auth_info.lsk.key, DVD_KEY_SIZE );
#elif defined( HAVE_BSD_DVD_STRUCT ) #elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_authinfo auth_info; struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_REPORT_KEY1; auth_info.format = DVD_REPORT_KEY1;
auth_info.agid = *pi_agid; auth_info.agid = *pi_agid;
i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
memcpy( p_key, auth_info.keychal, 8 ); memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE );
#elif defined( SYS_BEOS ) #elif defined( SYS_BEOS )
INIT_RDC( GPCMD_REPORT_KEY, 12 ); INIT_RDC( GPCMD_REPORT_KEY, 12 );
...@@ -873,7 +960,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -873,7 +960,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
memcpy( p_key, p_buffer + 4, 8 ); memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
#elif defined( HPUX_SCTL_IO ) #elif defined( HPUX_SCTL_IO )
INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 ); INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 );
...@@ -882,7 +969,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -882,7 +969,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
memcpy( p_key, p_buffer + 4, 8 ); memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
#elif defined( SOLARIS_USCSI ) #elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 12 ); INIT_USCSI( GPCMD_REPORT_KEY, 12 );
...@@ -896,7 +983,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -896,7 +983,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
i_ret = -1; i_ret = -1;
} }
memcpy( p_key, p_buffer + 4, 8 );; memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
#elif defined( SYS_DARWIN ) #elif defined( SYS_DARWIN )
dk_dvd_report_key_t dvd; dk_dvd_report_key_t dvd;
...@@ -911,11 +998,11 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -911,11 +998,11 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
dvd.grantID = *pi_agid; dvd.grantID = *pi_agid;
/* dvdk1i.dataLength[0] = 0x00; */ /* dataLength[0] is already memset to 0 */ /* dvdk1i.dataLength[0] = 0x00; */ /* dataLength[0] is already memset to 0 */
dvdk1i.dataLength[1] = 0x0a; dvdk1i.dataLength[ 1 ] = 0x0a;
i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
memcpy( p_key, dvdk1i.key1Value, sizeof(dvdk1i.key1Value) ); memcpy( p_key, dvdk1i.key1Value, DVD_KEY_SIZE );
#elif defined( WIN32 ) #elif defined( WIN32 )
if( WIN2K ) /* NT/Win2000/Whistler */ if( WIN2K ) /* NT/Win2000/Whistler */
...@@ -934,7 +1021,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -934,7 +1021,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
memcpy( p_key, key->KeyData, 8 ); memcpy( p_key, key->KeyData, DVD_KEY_SIZE );
} }
else else
{ {
...@@ -944,7 +1031,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -944,7 +1031,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
i_ret = WinSendSSC( i_fd, &ssc ); i_ret = WinSendSSC( i_fd, &ssc );
memcpy( p_key, p_buffer + 4, 8 ); memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
} }
#else #else
...@@ -965,23 +1052,21 @@ int ioctl_InvalidateAgid( int i_fd, int *pi_agid ) ...@@ -965,23 +1052,21 @@ int ioctl_InvalidateAgid( int i_fd, int *pi_agid )
#if defined( HAVE_LINUX_DVD_STRUCT ) #if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo auth_info; dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_INVALIDATE_AGID; auth_info.type = DVD_INVALIDATE_AGID;
auth_info.lsa.agid = *pi_agid; auth_info.lsa.agid = *pi_agid;
i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
*pi_agid = auth_info.lsa.agid;
#elif defined( HAVE_BSD_DVD_STRUCT ) #elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_authinfo auth_info; struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_INVALIDATE_AGID; auth_info.format = DVD_INVALIDATE_AGID;
auth_info.agid = *pi_agid; auth_info.agid = *pi_agid;
i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
*pi_agid = auth_info.agid;
#elif defined( SYS_BEOS ) #elif defined( SYS_BEOS )
INIT_RDC( GPCMD_REPORT_KEY, 0 ); INIT_RDC( GPCMD_REPORT_KEY, 0 );
...@@ -1026,8 +1111,6 @@ int ioctl_InvalidateAgid( int i_fd, int *pi_agid ) ...@@ -1026,8 +1111,6 @@ int ioctl_InvalidateAgid( int i_fd, int *pi_agid )
i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd ); i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
*pi_agid = dvdagid.grantID;
#elif defined( WIN32 ) #elif defined( WIN32 )
if( WIN2K ) /* NT/Win2000/Whistler */ if( WIN2K ) /* NT/Win2000/Whistler */
{ {
...@@ -1071,20 +1154,22 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -1071,20 +1154,22 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
#if defined( HAVE_LINUX_DVD_STRUCT ) #if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo auth_info; dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_HOST_SEND_CHALLENGE; auth_info.type = DVD_HOST_SEND_CHALLENGE;
auth_info.hsc.agid = *pi_agid; auth_info.hsc.agid = *pi_agid;
memcpy( auth_info.hsc.chal, p_challenge, sizeof(dvd_challenge) ); memcpy( auth_info.hsc.chal, p_challenge, DVD_CHALLENGE_SIZE );
return ioctl( i_fd, DVD_AUTH, &auth_info ); return ioctl( i_fd, DVD_AUTH, &auth_info );
#elif defined( HAVE_BSD_DVD_STRUCT ) #elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_authinfo auth_info; struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_SEND_CHALLENGE; auth_info.format = DVD_SEND_CHALLENGE;
auth_info.agid = *pi_agid; auth_info.agid = *pi_agid;
memcpy( auth_info.keychal, p_challenge, 12 ); memcpy( auth_info.keychal, p_challenge, DVD_CHALLENGE_SIZE );
return ioctl( i_fd, DVDIOCSENDKEY, &auth_info ); return ioctl( i_fd, DVDIOCSENDKEY, &auth_info );
...@@ -1094,7 +1179,7 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -1094,7 +1179,7 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
rdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); rdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
p_buffer[ 1 ] = 0xe; p_buffer[ 1 ] = 0xe;
memcpy( p_buffer + 4, p_challenge, 12 ); memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
...@@ -1104,7 +1189,7 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -1104,7 +1189,7 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
sctl_io.cdb[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); sctl_io.cdb[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
p_buffer[ 1 ] = 0xe; p_buffer[ 1 ] = 0xe;
memcpy( p_buffer + 4, p_challenge, 12 ); memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
return ioctl( i_fd, SIOC_IO, &sctl_io ); return ioctl( i_fd, SIOC_IO, &sctl_io );
...@@ -1114,7 +1199,7 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -1114,7 +1199,7 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
p_buffer[ 1 ] = 0xe; p_buffer[ 1 ] = 0xe;
memcpy( p_buffer + 4, p_challenge, 12 ); memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
if( ioctl( i_fd, USCSICMD, &sc ) < 0 || sc.uscsi_status ) if( ioctl( i_fd, USCSICMD, &sc ) < 0 || sc.uscsi_status )
{ {
...@@ -1136,9 +1221,9 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -1136,9 +1221,9 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
dvd.grantID = *pi_agid; dvd.grantID = *pi_agid;
/* dvdcki.dataLength[0] = 0x00; */ /* dataLength[0] is already memset to 0 */ /* dvdcki.dataLength[0] = 0x00; */ /* dataLength[0] is already memset to 0 */
dvdcki.dataLength[1] = 0x0e; dvdcki.dataLength[ 1 ] = 0x0e;
memcpy( dvdcki.challengeKeyValue, p_challenge, sizeof(dvdcki.challengeKeyValue) ); memcpy( dvdcki.challengeKeyValue, p_challenge, DVD_CHALLENGE_SIZE );
i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd ); i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
...@@ -1156,7 +1241,7 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -1156,7 +1241,7 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
key->KeyType = DvdChallengeKey; key->KeyType = DvdChallengeKey;
key->KeyFlags = 0; key->KeyFlags = 0;
memcpy( key->KeyData, p_challenge, 10 ); memcpy( key->KeyData, p_challenge, DVD_CHALLENGE_SIZE );
return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key, return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
...@@ -1168,7 +1253,7 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -1168,7 +1253,7 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
ssc.CDBByte[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); ssc.CDBByte[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
p_buffer[ 1 ] = 0xe; p_buffer[ 1 ] = 0xe;
memcpy( p_buffer + 4, p_challenge, 12 ); memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
return WinSendSSC( i_fd, &ssc ); return WinSendSSC( i_fd, &ssc );
} }
...@@ -1191,20 +1276,22 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -1191,20 +1276,22 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key )
#if defined( HAVE_LINUX_DVD_STRUCT ) #if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo auth_info; dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_HOST_SEND_KEY2; auth_info.type = DVD_HOST_SEND_KEY2;
auth_info.hsk.agid = *pi_agid; auth_info.hsk.agid = *pi_agid;
memcpy( auth_info.hsk.key, p_key, sizeof(dvd_key) ); memcpy( auth_info.hsk.key, p_key, DVD_KEY_SIZE );
return ioctl( i_fd, DVD_AUTH, &auth_info ); return ioctl( i_fd, DVD_AUTH, &auth_info );
#elif defined( HAVE_BSD_DVD_STRUCT ) #elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_authinfo auth_info; struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_SEND_KEY2; auth_info.format = DVD_SEND_KEY2;
auth_info.agid = *pi_agid; auth_info.agid = *pi_agid;
memcpy( auth_info.keychal, p_key, 8 ); memcpy( auth_info.keychal, p_key, DVD_KEY_SIZE );
return ioctl( i_fd, DVDIOCSENDKEY, &auth_info ); return ioctl( i_fd, DVDIOCSENDKEY, &auth_info );
...@@ -1214,7 +1301,7 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -1214,7 +1301,7 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key )
rdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); rdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
p_buffer[ 1 ] = 0xa; p_buffer[ 1 ] = 0xa;
memcpy( p_buffer + 4, p_key, 8 ); memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
...@@ -1224,7 +1311,7 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -1224,7 +1311,7 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key )
sctl_io.cdb[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); sctl_io.cdb[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
p_buffer[ 1 ] = 0xa; p_buffer[ 1 ] = 0xa;
memcpy( p_buffer + 4, p_key, 8 ); memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
return ioctl( i_fd, SIOC_IO, &sctl_io ); return ioctl( i_fd, SIOC_IO, &sctl_io );
...@@ -1234,7 +1321,7 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -1234,7 +1321,7 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key )
rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
p_buffer[ 1 ] = 0xa; p_buffer[ 1 ] = 0xa;
memcpy( p_buffer + 4, p_key, 8 ); memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
if( ioctl( i_fd, USCSICMD, &sc ) < 0 || sc.uscsi_status ) if( ioctl( i_fd, USCSICMD, &sc ) < 0 || sc.uscsi_status )
{ {
...@@ -1256,9 +1343,9 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -1256,9 +1343,9 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key )
dvd.grantID = *pi_agid; dvd.grantID = *pi_agid;
/* dvdk2i.dataLength[0] = 0x00; */ /*dataLength[0] is already memset to 0 */ /* dvdk2i.dataLength[0] = 0x00; */ /*dataLength[0] is already memset to 0 */
dvdk2i.dataLength[1] = 0x0a; dvdk2i.dataLength[ 1 ] = 0x0a;
memcpy( dvdk2i.key2Value, p_key, sizeof(dvdk2i.key2Value) ); memcpy( dvdk2i.key2Value, p_key, DVD_KEY_SIZE );
i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd ); i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
...@@ -1276,7 +1363,7 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -1276,7 +1363,7 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key )
key->KeyType = DvdBusKey2; key->KeyType = DvdBusKey2;
key->KeyFlags = 0; key->KeyFlags = 0;
memcpy( key->KeyData, p_key, 8 ); memcpy( key->KeyData, p_key, DVD_KEY_SIZE );
return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key, return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
...@@ -1288,14 +1375,124 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -1288,14 +1375,124 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key )
ssc.CDBByte[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); ssc.CDBByte[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
p_buffer[ 1 ] = 0xa; p_buffer[ 1 ] = 0xa;
memcpy( p_buffer + 4, p_key, 8 ); memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
return WinSendSSC( i_fd, &ssc ); return WinSendSSC( i_fd, &ssc );
} }
#else #else
/* DVD ioctls unavailable - do as if the ioctl failed */ /* DVD ioctls unavailable - do as if the ioctl failed */
return -1; i_ret = -1;
#endif
return i_ret;
}
/*****************************************************************************
* ioctl_ReportRPC: get RPC status for the drive
*****************************************************************************/
int ioctl_ReportRPC( int i_fd, int *p_type, int *p_mask, int *p_scheme )
{
int i_ret;
#if defined( HAVE_LINUX_DVD_STRUCT ) && !defined(__OpenBSD__)
dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_LU_SEND_RPC_STATE;
i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
*p_type = auth_info.lrpcs.type;
*p_mask = auth_info.lrpcs.region_mask;
*p_scheme = auth_info.lrpcs.rpc_scheme;
#elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_REPORT_RPC;
i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
*p_type = auth_info.reg_type;
*p_mask = auth_info.region; // ??
*p_scheme = auth_info.rpc_scheme;
#elif defined( SYS_BEOS )
INIT_RDC( GPCMD_REPORT_KEY, 8 );
rdc.command[ 10 ] = DVD_REPORT_RPC;
i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
*p_type = p_buffer[ 4 ] >> 6;
*p_mask = p_buffer[ 5 ];
*p_scheme = p_buffer[ 6 ];
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 8 );
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_RPC;
i_ret = ioctl( i_fd, USCSICMD, &sc );
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
}
*p_type = p_buffer[ 4 ] >> 6;
*p_mask = p_buffer[ 5 ];
*p_scheme = p_buffer[ 6 ];
#elif defined( SYS_DARWIN )
/* The headers for Darwin / MacOSX are unavaialbe. */
/* Someone who has them should have no problem implementing this. */
i_ret = -1;
#elif defined( WIN32 )
if( WIN2K ) /* NT/Win2000/Whistler */
{
DWORD tmp;
u8 buffer[ DVD_ASF_LENGTH ]; /* correct this */
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
memset( &buffer, 0, sizeof( buffer ) );
key->KeyLength = DVD_ASF_LENGTH; /* correct this */
key->SessionId = *pi_agid;
key->KeyType = DvdGetRpcKey;
key->KeyFlags = 0;
#warning "Fix ReportRPC for WIN32!"
/* The IOCTL_DVD_READ_KEY might be the right IOCTL */
i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
/* Someone who has the headers should correct all this. */
*p_type = 0;
*p_mask = 0;
*p_scheme = 0;
i_ret = -1; /* Remove this line when implemented. */
}
else
{
INIT_SSC( GPCMD_REPORT_KEY, 8 );
ssc.CDBByte[ 10 ] = DVD_REPORT_RPC;
i_ret = WinSendSSC( i_fd, &ssc );
*p_type = p_buffer[ 4 ] >> 6;
*p_mask = p_buffer[ 5 ];
*p_scheme = p_buffer[ 6 ];
}
#else
/* DVD ioctls unavailable - do as if the ioctl failed */
i_ret = -1;
#endif #endif
return i_ret; return i_ret;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ioctl.h: DVD ioctl replacement function * ioctl.h: DVD ioctl replacement function
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: ioctl.h,v 1.10 2001/12/11 14:43:38 sam Exp $ * $Id: ioctl.h,v 1.11 2001/12/16 18:00:18 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -32,6 +32,10 @@ int ioctl_InvalidateAgid ( int, int * ); ...@@ -32,6 +32,10 @@ int ioctl_InvalidateAgid ( int, int * );
int ioctl_SendChallenge ( int, int *, u8 * ); int ioctl_SendChallenge ( int, int *, u8 * );
int ioctl_SendKey2 ( int, int *, u8 * ); int ioctl_SendKey2 ( int, int *, u8 * );
#define DVD_KEY_SIZE 5
#define DVD_CHALLENGE_SIZE 10
#define DVD_DISCKEY_SIZE 2048
/***************************************************************************** /*****************************************************************************
* Common macro, BeOS specific * Common macro, BeOS specific
*****************************************************************************/ *****************************************************************************/
...@@ -102,9 +106,16 @@ int ioctl_SendKey2 ( int, int *, u8 * ); ...@@ -102,9 +106,16 @@ int ioctl_SendKey2 ( int, int *, u8 * );
#endif #endif
/***************************************************************************** /*****************************************************************************
* Various DVD I/O tables * Additional types, OpenBSD specific
*****************************************************************************/ *****************************************************************************/
#if defined( HAVE_OPENBSD_DVD_STRUCT )
typedef union dvd_struct dvd_struct;
typedef union dvd_authinfo dvd_authinfo;
#endif
/*****************************************************************************
* Various DVD I/O tables
*****************************************************************************/
#if defined( SYS_BEOS ) || defined( WIN32 ) || defined ( SOLARIS_USCSI ) || defined ( HPUX_SCTL_IO ) #if defined( SYS_BEOS ) || defined( WIN32 ) || defined ( SOLARIS_USCSI ) || defined ( HPUX_SCTL_IO )
/* The generic packet command opcodes for CD/DVD Logical Units, /* The generic packet command opcodes for CD/DVD Logical Units,
* From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
...@@ -123,31 +134,21 @@ int ioctl_SendKey2 ( int, int *, u8 * ); ...@@ -123,31 +134,21 @@ int ioctl_SendKey2 ( int, int *, u8 * );
# define DVD_SEND_CHALLENGE 0x01 # define DVD_SEND_CHALLENGE 0x01
# define DVD_REPORT_KEY1 0x02 # define DVD_REPORT_KEY1 0x02
# define DVD_SEND_KEY2 0x03 # define DVD_SEND_KEY2 0x03
# define DVD_REPORT_TITLE_KEY 0x04
# define DVD_REPORT_ASF 0x05 # define DVD_REPORT_ASF 0x05
# define DVD_SEND_RPC 0x06
# define DVD_REPORT_RPC 0x08
# define DVD_INVALIDATE_AGID 0x3f # define DVD_INVALIDATE_AGID 0x3f
#endif #endif
#if defined( HAVE_OPENBSD_DVD_STRUCT )
/***************************************************************************** /*****************************************************************************
* OpenBSD ioctl specific * win32 ioctl specific
*****************************************************************************/ *****************************************************************************/
typedef union dvd_struct dvd_struct;
typedef union dvd_authinfo dvd_authinfo;
typedef u_int8_t dvd_key[5];
typedef u_int8_t dvd_challenge[10];
#endif
#if defined( WIN32 ) #if defined( WIN32 )
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
/*****************************************************************************
* win32 ioctl specific
*****************************************************************************/
#define IOCTL_DVD_START_SESSION CTL_CODE(FILE_DEVICE_DVD, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS) #define IOCTL_DVD_START_SESSION CTL_CODE(FILE_DEVICE_DVD, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_DVD_READ_KEY CTL_CODE(FILE_DEVICE_DVD, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS) #define IOCTL_DVD_READ_KEY CTL_CODE(FILE_DEVICE_DVD, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_DVD_SEND_KEY CTL_CODE(FILE_DEVICE_DVD, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS) #define IOCTL_DVD_SEND_KEY CTL_CODE(FILE_DEVICE_DVD, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* bob.c : BOB deinterlacer plugin for vlc * bob.c : BOB deinterlacer plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: bob.c,v 1.1 2001/12/16 16:18:36 sam Exp $ * $Id: bob.c,v 1.2 2001/12/16 18:00:18 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -352,19 +352,24 @@ static int BobNewPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -352,19 +352,24 @@ static int BobNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
i_chroma_bytes = p_pic->i_chroma_size * sizeof(pixel_data_t); i_chroma_bytes = p_pic->i_chroma_size * sizeof(pixel_data_t);
/* Y buffer */ /* Y buffer */
p_pic->planes[ Y_PLANE ].p_data = malloc( i_luma_bytes + 2 * i_chroma_bytes ); p_pic->planes[ Y_PLANE ].p_data = malloc( i_luma_bytes
+ 2 * i_chroma_bytes );
p_pic->planes[ Y_PLANE ].i_bytes = i_luma_bytes; p_pic->planes[ Y_PLANE ].i_bytes = i_luma_bytes;
p_pic->planes[ Y_PLANE ].i_line_bytes = i_width * sizeof(pixel_data_t); p_pic->planes[ Y_PLANE ].i_line_bytes = i_width * sizeof(pixel_data_t);
/* U buffer */ /* U buffer */
p_pic->planes[ U_PLANE ].p_data = p_pic->planes[ Y_PLANE ].p_data + i_height * i_width; p_pic->planes[ U_PLANE ].p_data = p_pic->planes[ Y_PLANE ].p_data
+ i_height * i_width;
p_pic->planes[ U_PLANE ].i_bytes = i_chroma_bytes / 2; p_pic->planes[ U_PLANE ].i_bytes = i_chroma_bytes / 2;
p_pic->planes[ U_PLANE ].i_line_bytes = p_pic->i_chroma_width * sizeof(pixel_data_t); p_pic->planes[ U_PLANE ].i_line_bytes = p_pic->i_chroma_width
* sizeof(pixel_data_t);
/* V buffer */ /* V buffer */
p_pic->planes[ V_PLANE ].p_data = p_pic->planes[ U_PLANE ].p_data + i_height * p_pic->i_chroma_width; p_pic->planes[ V_PLANE ].p_data = p_pic->planes[ U_PLANE ].p_data
+ i_height * p_pic->i_chroma_width;
p_pic->planes[ V_PLANE ].i_bytes = i_chroma_bytes / 2; p_pic->planes[ V_PLANE ].i_bytes = i_chroma_bytes / 2;
p_pic->planes[ V_PLANE ].i_line_bytes = p_pic->i_chroma_width * sizeof(pixel_data_t); p_pic->planes[ V_PLANE ].i_line_bytes = p_pic->i_chroma_width
* sizeof(pixel_data_t);
/* We allocated 3 planes */ /* We allocated 3 planes */
p_pic->i_planes = 3; p_pic->i_planes = 3;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment