| 60 | | static void InitCommand ( struct cdrom_generic_command *p_cgc, |
|---|
| 61 | | void *buf, int i_len, int i_type ); |
|---|
| 62 | | static int SendCommand ( int i_fd, struct cdrom_generic_command *p_cgc ); |
|---|
| 63 | | #endif |
|---|
| 64 | | |
|---|
| 65 | | /***************************************************************************** |
|---|
| 66 | | * dvd_ReadKey: |
|---|
| 67 | | ***************************************************************************** |
|---|
| 68 | | * |
|---|
| 69 | | *****************************************************************************/ |
|---|
| 70 | | int dvd_ReadKey( css_t *p_css, u8 *p_key ) |
|---|
| 71 | | { |
|---|
| 72 | | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| 73 | | int i_ret; |
|---|
| | 65 | static void BeInitRDC ( raw_device_command *, void *, int ); |
|---|
| | 66 | #endif |
|---|
| | 67 | |
|---|
| | 68 | /***************************************************************************** |
|---|
| | 69 | * ioctl_ReadCopyright: check whether the disc is encrypted or not |
|---|
| | 70 | *****************************************************************************/ |
|---|
| | 71 | int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright ) |
|---|
| | 72 | { |
|---|
| | 73 | int i_ret; |
|---|
| | 74 | |
|---|
| | 75 | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| | 76 | dvd_struct dvd; |
|---|
| | 77 | |
|---|
| | 78 | dvd.type = DVD_STRUCT_COPYRIGHT; |
|---|
| | 79 | dvd.copyright.layer_num = i_layer; |
|---|
| | 80 | |
|---|
| | 81 | i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd ); |
|---|
| | 82 | |
|---|
| | 83 | *pi_copyright = dvd.copyright.cpst; |
|---|
| | 84 | |
|---|
| | 85 | #elif defined( SYS_BEOS ) |
|---|
| | 86 | raw_device_command rdc; |
|---|
| | 87 | u8 p_buffer[ 8 ]; |
|---|
| | 88 | |
|---|
| | 89 | BeInitRDC( &rdc, p_buffer, 8 ); |
|---|
| | 90 | |
|---|
| | 91 | rdc.flags = B_RAW_DEVICE_DATA_IN; |
|---|
| | 92 | rdc.command[ 0 ] = GPCMD_READ_DVD_STRUCTURE; |
|---|
| | 93 | rdc.command[ 6 ] = i_layer; |
|---|
| | 94 | rdc.command[ 7 ] = DVD_STRUCT_COPYRIGHT; |
|---|
| | 95 | |
|---|
| | 96 | i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); |
|---|
| | 97 | |
|---|
| | 98 | *pi_copyright = p_buffer[ 4 ]; |
|---|
| | 99 | |
|---|
| | 100 | #elif defined( SYS_DARWIN1_3 ) |
|---|
| | 101 | intf_ErrMsg( "css error: DVD ioctls not fully functional yet" ); |
|---|
| | 102 | |
|---|
| | 103 | intf_ErrMsg( "css error: assuming disc is unencrypted" ); |
|---|
| | 104 | *pi_copyright = 0; |
|---|
| | 105 | |
|---|
| | 106 | i_ret = 0; |
|---|
| | 107 | |
|---|
| | 108 | #else |
|---|
| | 109 | /* DVD ioctls unavailable - do as if the ioctl failed */ |
|---|
| | 110 | i_ret = -1; |
|---|
| | 111 | |
|---|
| | 112 | #endif |
|---|
| | 113 | return i_ret; |
|---|
| | 114 | } |
|---|
| | 115 | |
|---|
| | 116 | /***************************************************************************** |
|---|
| | 117 | * ioctl_ReadKey: get the disc key |
|---|
| | 118 | *****************************************************************************/ |
|---|
| | 119 | int ioctl_ReadKey( css_t *p_css, u8 *p_key ) |
|---|
| | 120 | { |
|---|
| | 121 | int i_ret; |
|---|
| | 122 | |
|---|
| | 123 | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| 89 | | return i_ret; |
|---|
| 90 | | |
|---|
| 91 | | #elif defined( SYS_BEOS ) |
|---|
| 92 | | int i_ret, size; |
|---|
| 93 | | u8 p_buf[ 2048 + 4]; |
|---|
| 94 | | struct cdrom_generic_command cgc; |
|---|
| 95 | | |
|---|
| 96 | | size = 2048 + 4; |
|---|
| 97 | | |
|---|
| 98 | | InitCommand( &cgc, p_buf, size, CGC_DATA_READ ); |
|---|
| 99 | | |
|---|
| 100 | | cgc.cmd[0] = GPCMD_READ_DVD_STRUCTURE; |
|---|
| 101 | | |
|---|
| 102 | | cgc.cmd[7] = DVD_STRUCT_DISCKEY; |
|---|
| 103 | | cgc.cmd[8] = size >> 8; |
|---|
| 104 | | cgc.cmd[9] = size & 0xff; |
|---|
| 105 | | cgc.cmd[10] = p_css->i_agid << 6; |
|---|
| 106 | | |
|---|
| 107 | | i_ret = SendCommand( p_css->i_fd, &cgc ); |
|---|
| | 139 | |
|---|
| | 140 | #elif defined( SYS_BEOS ) |
|---|
| | 141 | raw_device_command rdc; |
|---|
| | 142 | u8 p_buffer[ 2048 + 4 ]; |
|---|
| | 143 | |
|---|
| | 144 | BeInitRDC( &rdc, p_buffer, 2048 + 4 ); |
|---|
| | 145 | |
|---|
| | 146 | rdc.flags = B_RAW_DEVICE_DATA_IN; |
|---|
| | 147 | rdc.command[ 0 ] = GPCMD_READ_DVD_STRUCTURE; |
|---|
| | 148 | rdc.command[ 7 ] = DVD_STRUCT_DISCKEY; |
|---|
| | 149 | rdc.command[ 10 ] = p_css->i_agid << 6; |
|---|
| | 150 | |
|---|
| | 151 | i_ret = ioctl( p_css->i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); |
|---|
| 114 | | memcpy( p_key, p_buf + 4, 2048 ); |
|---|
| 115 | | return i_ret; |
|---|
| 116 | | |
|---|
| 117 | | #else |
|---|
| 118 | | return -1; |
|---|
| 119 | | |
|---|
| 120 | | #endif |
|---|
| 121 | | } |
|---|
| 122 | | |
|---|
| 123 | | /***************************************************************************** |
|---|
| 124 | | * dvd_ReadCopyright: |
|---|
| 125 | | ***************************************************************************** |
|---|
| 126 | | * |
|---|
| 127 | | *****************************************************************************/ |
|---|
| 128 | | int dvd_ReadCopyright( int i_fd, int i_layer, int *pi_copyright ) |
|---|
| 129 | | { |
|---|
| 130 | | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| 131 | | int i_ret; |
|---|
| 132 | | dvd_struct dvd; |
|---|
| 133 | | |
|---|
| 134 | | dvd.type = DVD_STRUCT_COPYRIGHT; |
|---|
| 135 | | dvd.copyright.layer_num = i_layer; |
|---|
| 136 | | |
|---|
| 137 | | i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd ); |
|---|
| 138 | | |
|---|
| 139 | | *pi_copyright = dvd.copyright.cpst; |
|---|
| 140 | | return i_ret; |
|---|
| 141 | | |
|---|
| 142 | | #elif defined( SYS_BEOS ) |
|---|
| 143 | | int i_ret; |
|---|
| 144 | | u8 p_buf[8]; |
|---|
| 145 | | struct cdrom_generic_command cgc; |
|---|
| 146 | | |
|---|
| 147 | | InitCommand( &cgc, p_buf, sizeof(p_buf), CGC_DATA_READ ); |
|---|
| 148 | | |
|---|
| 149 | | cgc.cmd[0] = GPCMD_READ_DVD_STRUCTURE; |
|---|
| 150 | | |
|---|
| 151 | | cgc.cmd[6] = i_layer; |
|---|
| 152 | | cgc.cmd[7] = DVD_STRUCT_COPYRIGHT; |
|---|
| 153 | | cgc.cmd[8] = cgc.buflen >> 8; |
|---|
| 154 | | cgc.cmd[9] = cgc.buflen & 0xff; |
|---|
| 155 | | |
|---|
| 156 | | i_ret = SendCommand( i_fd, &cgc ); |
|---|
| 157 | | |
|---|
| 158 | | *pi_copyright = p_buf[4]; |
|---|
| 159 | | return i_ret; |
|---|
| 160 | | |
|---|
| 161 | | #elif defined( SYS_DARWIN1_3 ) |
|---|
| 162 | | intf_ErrMsg( "css error: DVD ioctls not fully functional yet" ); |
|---|
| 163 | | intf_ErrMsg( "css error: assuming disc is unencrypted" ); |
|---|
| 164 | | |
|---|
| 165 | | *pi_copyright = 0; |
|---|
| 166 | | return 0; |
|---|
| 167 | | |
|---|
| 168 | | #else |
|---|
| 169 | | return -1; |
|---|
| 170 | | |
|---|
| 171 | | #endif |
|---|
| 172 | | } |
|---|
| 173 | | |
|---|
| 174 | | /***************************************************************************** |
|---|
| 175 | | * dvd_LUSendAgid: |
|---|
| 176 | | ***************************************************************************** |
|---|
| 177 | | * |
|---|
| 178 | | *****************************************************************************/ |
|---|
| 179 | | int dvd_LUSendAgid( css_t *p_css ) |
|---|
| 180 | | { |
|---|
| 181 | | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| 182 | | int i_ret; |
|---|
| | 158 | memcpy( p_key, p_buffer + 4, 2048 ); |
|---|
| | 159 | |
|---|
| | 160 | #else |
|---|
| | 161 | /* DVD ioctls unavailable - do as if the ioctl failed */ |
|---|
| | 162 | i_ret = -1; |
|---|
| | 163 | |
|---|
| | 164 | #endif |
|---|
| | 165 | return i_ret; |
|---|
| | 166 | } |
|---|
| | 167 | |
|---|
| | 168 | /***************************************************************************** |
|---|
| | 169 | * ioctl_LUSendAgid: get AGID from the drive |
|---|
| | 170 | *****************************************************************************/ |
|---|
| | 171 | int ioctl_LUSendAgid( css_t *p_css ) |
|---|
| | 172 | { |
|---|
| | 173 | int i_ret; |
|---|
| | 174 | |
|---|
| | 175 | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| 191 | | return i_ret; |
|---|
| 192 | | |
|---|
| 193 | | #elif defined( SYS_BEOS ) |
|---|
| 194 | | u8 p_buf[8]; |
|---|
| 195 | | int i_ret; |
|---|
| 196 | | struct cdrom_generic_command cgc; |
|---|
| 197 | | |
|---|
| 198 | | //memset( p_buf, 0, sizeof( p_buf ) ); |
|---|
| 199 | | |
|---|
| 200 | | InitCommand( &cgc, p_buf, 0, CGC_DATA_READ ); |
|---|
| 201 | | |
|---|
| 202 | | cgc.cmd[0] = GPCMD_REPORT_KEY; |
|---|
| 203 | | cgc.cmd[10] = 0x00 | (p_css->i_agid << 6); |
|---|
| 204 | | cgc.buflen = 8; |
|---|
| 205 | | cgc.cmd[9] = cgc.buflen; |
|---|
| 206 | | cgc.data_direction = CGC_DATA_READ; |
|---|
| 207 | | |
|---|
| 208 | | i_ret = SendCommand( p_css->i_fd, &cgc ); |
|---|
| 209 | | |
|---|
| 210 | | p_css->i_agid = p_buf[7] >> 6; |
|---|
| 211 | | return i_ret; |
|---|
| 212 | | |
|---|
| 213 | | #else |
|---|
| 214 | | return -1; |
|---|
| 215 | | |
|---|
| 216 | | #endif |
|---|
| 217 | | } |
|---|
| 218 | | |
|---|
| 219 | | /***************************************************************************** |
|---|
| 220 | | * dvd_InvalidateAgid: |
|---|
| 221 | | ***************************************************************************** |
|---|
| 222 | | * |
|---|
| 223 | | *****************************************************************************/ |
|---|
| 224 | | int dvd_InvalidateAgid( css_t *p_css ) |
|---|
| 225 | | { |
|---|
| 226 | | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| 227 | | int i_ret; |
|---|
| 228 | | dvd_authinfo auth_info; |
|---|
| 229 | | |
|---|
| 230 | | auth_info.type = DVD_INVALIDATE_AGID; |
|---|
| 231 | | auth_info.lsa.agid = p_css->i_agid; |
|---|
| | 184 | |
|---|
| | 185 | #elif defined( SYS_BEOS ) |
|---|
| | 186 | raw_device_command rdc; |
|---|
| | 187 | u8 p_buffer[ 8 ]; |
|---|
| | 188 | |
|---|
| | 189 | BeInitRDC( &rdc, p_buffer, 8 ); |
|---|
| | 190 | |
|---|
| | 191 | rdc.flags = B_RAW_DEVICE_DATA_IN; |
|---|
| | 192 | rdc.command[ 0 ] = GPCMD_REPORT_KEY; |
|---|
| | 193 | rdc.command[ 10 ] = 0x00 | (p_css->i_agid << 6); |
|---|
| | 194 | |
|---|
| | 195 | i_ret = ioctl( p_css->i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); |
|---|
| | 196 | |
|---|
| | 197 | p_css->i_agid = p_buffer[ 7 ] >> 6; |
|---|
| | 198 | |
|---|
| | 199 | #else |
|---|
| | 200 | /* DVD ioctls unavailable - do as if the ioctl failed */ |
|---|
| | 201 | i_ret = -1; |
|---|
| | 202 | |
|---|
| | 203 | #endif |
|---|
| | 204 | return i_ret; |
|---|
| | 205 | } |
|---|
| | 206 | |
|---|
| | 207 | /***************************************************************************** |
|---|
| | 208 | * ioctl_LUSendChallenge: get challenge from the drive |
|---|
| | 209 | *****************************************************************************/ |
|---|
| | 210 | int ioctl_LUSendChallenge( css_t *p_css, u8 *p_challenge ) |
|---|
| | 211 | { |
|---|
| | 212 | int i_ret; |
|---|
| | 213 | |
|---|
| | 214 | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| | 215 | dvd_authinfo auth_info; |
|---|
| | 216 | |
|---|
| | 217 | auth_info.type = DVD_LU_SEND_CHALLENGE; |
|---|
| 235 | | p_css->i_agid = auth_info.lsa.agid; |
|---|
| 236 | | return i_ret; |
|---|
| 237 | | |
|---|
| 238 | | #elif defined( SYS_BEOS ) |
|---|
| 239 | | u8 p_buf[0]; |
|---|
| 240 | | struct cdrom_generic_command cgc; |
|---|
| 241 | | |
|---|
| 242 | | //memset( p_buf, 0, sizeof( p_buf ) ); |
|---|
| 243 | | |
|---|
| 244 | | InitCommand( &cgc, p_buf, 0, CGC_DATA_READ ); |
|---|
| 245 | | |
|---|
| 246 | | cgc.cmd[0] = GPCMD_REPORT_KEY; |
|---|
| 247 | | cgc.cmd[10] = 0x3f | (p_css->i_agid << 6); |
|---|
| 248 | | cgc.cmd[9] = cgc.buflen = 0; |
|---|
| 249 | | cgc.data_direction = CGC_DATA_READ; |
|---|
| 250 | | |
|---|
| 251 | | return SendCommand( p_css->i_fd, &cgc ); |
|---|
| 252 | | |
|---|
| 253 | | #else |
|---|
| 254 | | return -1; |
|---|
| 255 | | |
|---|
| 256 | | #endif |
|---|
| 257 | | } |
|---|
| 258 | | |
|---|
| 259 | | /***************************************************************************** |
|---|
| 260 | | * dvd_HostSendChallenge: |
|---|
| 261 | | ***************************************************************************** |
|---|
| 262 | | * |
|---|
| 263 | | *****************************************************************************/ |
|---|
| 264 | | int dvd_HostSendChallenge( css_t *p_css, u8 *p_challenge ) |
|---|
| 265 | | { |
|---|
| 266 | | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| 267 | | dvd_authinfo auth_info; |
|---|
| 268 | | |
|---|
| 269 | | auth_info.type = DVD_HOST_SEND_CHALLENGE; |
|---|
| 270 | | |
|---|
| 271 | | memcpy( auth_info.hsc.chal, p_challenge, sizeof(dvd_challenge) ); |
|---|
| 272 | | |
|---|
| 273 | | return ioctl( p_css->i_fd, DVD_AUTH, &auth_info ); |
|---|
| 274 | | |
|---|
| 275 | | #elif defined( SYS_BEOS ) |
|---|
| 276 | | u8 p_buf[16]; |
|---|
| 277 | | struct cdrom_generic_command cgc; |
|---|
| 278 | | |
|---|
| 279 | | //memset( p_buf, 0, sizeof( p_buf ) ); |
|---|
| 280 | | |
|---|
| 281 | | InitCommand( &cgc, p_buf, 0, CGC_DATA_READ ); |
|---|
| 282 | | |
|---|
| 283 | | cgc.cmd[0] = GPCMD_SEND_KEY; |
|---|
| 284 | | cgc.cmd[10] = 0x01 | (p_css->i_agid << 6); |
|---|
| 285 | | cgc.buflen = 16; |
|---|
| 286 | | cgc.cmd[9] = cgc.buflen; |
|---|
| 287 | | cgc.data_direction = CGC_DATA_WRITE; |
|---|
| 288 | | |
|---|
| 289 | | p_buf[1] = 0xe; |
|---|
| 290 | | memcpy( p_buf + 4, p_challenge, sizeof(dvd_challenge) ); |
|---|
| 291 | | |
|---|
| 292 | | return SendCommand( p_css->i_fd, &cgc ); |
|---|
| 293 | | |
|---|
| 294 | | #else |
|---|
| 295 | | return -1; |
|---|
| 296 | | |
|---|
| 297 | | #endif |
|---|
| 298 | | } |
|---|
| 299 | | |
|---|
| 300 | | /***************************************************************************** |
|---|
| 301 | | * dvd_LUSendASF: |
|---|
| 302 | | ***************************************************************************** |
|---|
| 303 | | * |
|---|
| 304 | | *****************************************************************************/ |
|---|
| 305 | | int dvd_LUSendASF( css_t *p_css, int *pi_asf ) |
|---|
| 306 | | { |
|---|
| 307 | | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| 308 | | int i_ret; |
|---|
| | 221 | memcpy( p_challenge, auth_info.lsc.chal, sizeof(dvd_challenge) ); |
|---|
| | 222 | |
|---|
| | 223 | #elif defined( SYS_BEOS ) |
|---|
| | 224 | raw_device_command rdc; |
|---|
| | 225 | u8 p_buffer[ 16 ]; |
|---|
| | 226 | |
|---|
| | 227 | BeInitRDC( &rdc, p_buffer, 16 ); |
|---|
| | 228 | |
|---|
| | 229 | rdc.flags = B_RAW_DEVICE_DATA_IN; |
|---|
| | 230 | rdc.command[ 0 ] = GPCMD_REPORT_KEY; |
|---|
| | 231 | rdc.command[ 10 ] = 0x01 | (p_css->i_agid << 6); |
|---|
| | 232 | |
|---|
| | 233 | i_ret = ioctl( p_css->i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); |
|---|
| | 234 | |
|---|
| | 235 | memcpy( p_challenge, p_buffer + 4, sizeof(dvd_challenge) ); |
|---|
| | 236 | |
|---|
| | 237 | #else |
|---|
| | 238 | /* DVD ioctls unavailable - do as if the ioctl failed */ |
|---|
| | 239 | i_ret = -1; |
|---|
| | 240 | |
|---|
| | 241 | #endif |
|---|
| | 242 | return i_ret; |
|---|
| | 243 | } |
|---|
| | 244 | |
|---|
| | 245 | /***************************************************************************** |
|---|
| | 246 | * ioctl_LUSendASF: get ASF from the drive |
|---|
| | 247 | *****************************************************************************/ |
|---|
| | 248 | int ioctl_LUSendASF( css_t *p_css, int *pi_asf ) |
|---|
| | 249 | { |
|---|
| | 250 | int i_ret; |
|---|
| | 251 | |
|---|
| | 252 | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| 318 | | return i_ret; |
|---|
| 319 | | |
|---|
| 320 | | #elif defined( SYS_BEOS ) |
|---|
| 321 | | int i_ret; |
|---|
| 322 | | u8 p_buf[8]; |
|---|
| 323 | | struct cdrom_generic_command cgc; |
|---|
| 324 | | |
|---|
| 325 | | //memset( p_buf, 0, sizeof( p_buf ) ); |
|---|
| 326 | | |
|---|
| 327 | | InitCommand( &cgc, p_buf, 0, CGC_DATA_READ ); |
|---|
| 328 | | |
|---|
| 329 | | cgc.cmd[0] = GPCMD_REPORT_KEY; |
|---|
| 330 | | cgc.cmd[10] = 0x05 | (p_css->i_agid << 6); |
|---|
| 331 | | cgc.buflen = 8; |
|---|
| 332 | | cgc.cmd[9] = cgc.buflen; |
|---|
| 333 | | cgc.data_direction = CGC_DATA_READ; |
|---|
| 334 | | |
|---|
| 335 | | i_ret = SendCommand( p_css->i_fd, &cgc ); |
|---|
| 336 | | |
|---|
| 337 | | *pi_asf = p_buf[7] & 1; |
|---|
| 338 | | return i_ret; |
|---|
| 339 | | |
|---|
| 340 | | #else |
|---|
| 341 | | return -1; |
|---|
| 342 | | |
|---|
| 343 | | #endif |
|---|
| 344 | | } |
|---|
| 345 | | |
|---|
| 346 | | /***************************************************************************** |
|---|
| 347 | | * dvd_LUSendChallenge: |
|---|
| 348 | | ***************************************************************************** |
|---|
| 349 | | * |
|---|
| 350 | | *****************************************************************************/ |
|---|
| 351 | | int dvd_LUSendChallenge( css_t *p_css, u8 *p_challenge ) |
|---|
| 352 | | { |
|---|
| 353 | | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| 354 | | int i_ret; |
|---|
| 355 | | dvd_authinfo auth_info; |
|---|
| 356 | | |
|---|
| 357 | | auth_info.type = DVD_LU_SEND_CHALLENGE; |
|---|
| 358 | | |
|---|
| 359 | | i_ret = ioctl( p_css->i_fd, DVD_AUTH, &auth_info ); |
|---|
| 360 | | |
|---|
| 361 | | memcpy( p_challenge, auth_info.lsc.chal, sizeof(dvd_challenge) ); |
|---|
| 362 | | return i_ret; |
|---|
| 363 | | |
|---|
| 364 | | #elif defined( SYS_BEOS ) |
|---|
| 365 | | int i_ret; |
|---|
| 366 | | u8 p_buf[16]; |
|---|
| 367 | | struct cdrom_generic_command cgc; |
|---|
| 368 | | |
|---|
| 369 | | //memset( p_buf, 0, sizeof( p_buf ) ); |
|---|
| 370 | | |
|---|
| 371 | | InitCommand( &cgc, p_buf, 0, CGC_DATA_READ ); |
|---|
| 372 | | |
|---|
| 373 | | cgc.cmd[0] = GPCMD_REPORT_KEY; |
|---|
| 374 | | cgc.cmd[10] = 0x01 | (p_css->i_agid << 6); |
|---|
| 375 | | cgc.buflen = 16; |
|---|
| 376 | | cgc.cmd[9] = cgc.buflen; |
|---|
| 377 | | cgc.data_direction = CGC_DATA_READ; |
|---|
| 378 | | |
|---|
| 379 | | i_ret = SendCommand( p_css->i_fd, &cgc ); |
|---|
| 380 | | |
|---|
| 381 | | memcpy( p_challenge, p_buf + 4, sizeof(dvd_challenge) ); |
|---|
| 382 | | return i_ret; |
|---|
| 383 | | |
|---|
| 384 | | #else |
|---|
| 385 | | return -1; |
|---|
| 386 | | |
|---|
| 387 | | #endif |
|---|
| 388 | | } |
|---|
| 389 | | |
|---|
| 390 | | /***************************************************************************** |
|---|
| 391 | | * dvd_LUSendKey1: |
|---|
| 392 | | ***************************************************************************** |
|---|
| 393 | | * |
|---|
| 394 | | *****************************************************************************/ |
|---|
| 395 | | int dvd_LUSendKey1( css_t *p_css, u8 *p_key ) |
|---|
| 396 | | { |
|---|
| 397 | | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| 398 | | int i_ret; |
|---|
| | 262 | |
|---|
| | 263 | #elif defined( SYS_BEOS ) |
|---|
| | 264 | raw_device_command rdc; |
|---|
| | 265 | u8 p_buffer[ 8 ]; |
|---|
| | 266 | |
|---|
| | 267 | BeInitRDC( &rdc, p_buffer, 8 ); |
|---|
| | 268 | |
|---|
| | 269 | rdc.flags = B_RAW_DEVICE_DATA_IN; |
|---|
| | 270 | rdc.command[ 0 ] = GPCMD_REPORT_KEY; |
|---|
| | 271 | rdc.command[ 10 ] = 0x05 | (p_css->i_agid << 6); |
|---|
| | 272 | |
|---|
| | 273 | i_ret = ioctl( p_css->i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); |
|---|
| | 274 | |
|---|
| | 275 | *pi_asf = p_buffer[ 7 ] & 1; |
|---|
| | 276 | |
|---|
| | 277 | #elif defined( SYS_DARWIN1_3 ) |
|---|
| | 278 | dvdioctl_data_t data; |
|---|
| | 279 | u8 p_buffer[ 8 ]; |
|---|
| | 280 | |
|---|
| | 281 | data.p_buffer = p_buffer; |
|---|
| | 282 | data.i_lba = 0; |
|---|
| | 283 | data.i_agid = p_css->i_agid; |
|---|
| | 284 | data.i_keyclass = kCSS_CSS2_CPRM; |
|---|
| | 285 | data.i_keyformat = kASF; |
|---|
| | 286 | |
|---|
| | 287 | i_ret = ioctl( p_css->i_fd, IODVD_REPORT_KEY, &data ); |
|---|
| | 288 | |
|---|
| | 289 | *pi_asf = p_buffer[ 7 ] & 1; |
|---|
| | 290 | |
|---|
| | 291 | #else |
|---|
| | 292 | /* DVD ioctls unavailable - do as if the ioctl failed */ |
|---|
| | 293 | i_ret = -1; |
|---|
| | 294 | |
|---|
| | 295 | #endif |
|---|
| | 296 | return i_ret; |
|---|
| | 297 | } |
|---|
| | 298 | |
|---|
| | 299 | /***************************************************************************** |
|---|
| | 300 | * ioctl_LUSendKey1: get the first key from the drive |
|---|
| | 301 | *****************************************************************************/ |
|---|
| | 302 | int ioctl_LUSendKey1( css_t *p_css, u8 *p_key ) |
|---|
| | 303 | { |
|---|
| | 304 | int i_ret; |
|---|
| | 305 | |
|---|
| | 306 | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| 407 | | return i_ret; |
|---|
| 408 | | |
|---|
| 409 | | #elif defined( SYS_BEOS ) |
|---|
| 410 | | int i_ret; |
|---|
| 411 | | u8 p_buf[12]; |
|---|
| 412 | | struct cdrom_generic_command cgc; |
|---|
| 413 | | |
|---|
| 414 | | //memset( p_buf, 0, sizeof( p_buf ) ); |
|---|
| 415 | | |
|---|
| 416 | | InitCommand( &cgc, p_buf, 0, CGC_DATA_READ ); |
|---|
| 417 | | |
|---|
| 418 | | cgc.cmd[0] = GPCMD_REPORT_KEY; |
|---|
| 419 | | cgc.cmd[10] = 0x02 | (p_css->i_agid << 6); |
|---|
| 420 | | cgc.buflen = 12; |
|---|
| 421 | | cgc.cmd[9] = cgc.buflen; |
|---|
| 422 | | cgc.data_direction = CGC_DATA_READ; |
|---|
| 423 | | |
|---|
| 424 | | i_ret = SendCommand( p_css->i_fd, &cgc ); |
|---|
| 425 | | |
|---|
| 426 | | memcpy( p_key, p_buf + 4, sizeof(dvd_key) ); |
|---|
| 427 | | return i_ret; |
|---|
| 428 | | |
|---|
| 429 | | #else |
|---|
| | 315 | |
|---|
| | 316 | #elif defined( SYS_BEOS ) |
|---|
| | 317 | raw_device_command rdc; |
|---|
| | 318 | u8 p_buffer[ 12 ]; |
|---|
| | 319 | |
|---|
| | 320 | BeInitRDC( &rdc, p_buffer, 12 ); |
|---|
| | 321 | |
|---|
| | 322 | rdc.flags = B_RAW_DEVICE_DATA_IN; |
|---|
| | 323 | rdc.command[ 0 ] = GPCMD_REPORT_KEY; |
|---|
| | 324 | rdc.command[ 10 ] = 0x02 | (p_css->i_agid << 6); |
|---|
| | 325 | |
|---|
| | 326 | i_ret = ioctl( p_css->i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); |
|---|
| | 327 | |
|---|
| | 328 | memcpy( p_key, p_buffer + 4, sizeof(dvd_key) ); |
|---|
| | 329 | |
|---|
| | 330 | #else |
|---|
| | 331 | /* DVD ioctls unavailable - do as if the ioctl failed */ |
|---|
| | 332 | i_ret = -1; |
|---|
| | 333 | |
|---|
| | 334 | #endif |
|---|
| | 335 | return i_ret; |
|---|
| | 336 | } |
|---|
| | 337 | |
|---|
| | 338 | /***************************************************************************** |
|---|
| | 339 | * ioctl_InvalidateAgid: invalidate the current AGID |
|---|
| | 340 | *****************************************************************************/ |
|---|
| | 341 | int ioctl_InvalidateAgid( css_t *p_css ) |
|---|
| | 342 | { |
|---|
| | 343 | int i_ret; |
|---|
| | 344 | |
|---|
| | 345 | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| | 346 | dvd_authinfo auth_info; |
|---|
| | 347 | |
|---|
| | 348 | auth_info.type = DVD_INVALIDATE_AGID; |
|---|
| | 349 | auth_info.lsa.agid = p_css->i_agid; |
|---|
| | 350 | |
|---|
| | 351 | i_ret = ioctl( p_css->i_fd, DVD_AUTH, &auth_info ); |
|---|
| | 352 | |
|---|
| | 353 | p_css->i_agid = auth_info.lsa.agid; |
|---|
| | 354 | |
|---|
| | 355 | #elif defined( SYS_BEOS ) |
|---|
| | 356 | raw_device_command rdc; |
|---|
| | 357 | u8 p_buffer[ 0 ]; |
|---|
| | 358 | |
|---|
| | 359 | BeInitRDC( &rdc, p_buffer, 0 ); |
|---|
| | 360 | |
|---|
| | 361 | rdc.flags = B_RAW_DEVICE_DATA_IN; |
|---|
| | 362 | rdc.command[ 0 ] = GPCMD_REPORT_KEY; |
|---|
| | 363 | rdc.command[ 10 ] = 0x3f | (p_css->i_agid << 6); |
|---|
| | 364 | |
|---|
| | 365 | i_ret = ioctl( p_css->i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); |
|---|
| | 366 | |
|---|
| | 367 | #else |
|---|
| | 368 | /* DVD ioctls unavailable - do as if the ioctl failed */ |
|---|
| | 369 | i_ret = -1; |
|---|
| | 370 | |
|---|
| | 371 | #endif |
|---|
| | 372 | return i_ret; |
|---|
| | 373 | } |
|---|
| | 374 | |
|---|
| | 375 | /***************************************************************************** |
|---|
| | 376 | * ioctl_HostSendChallenge: send challenge to the drive |
|---|
| | 377 | *****************************************************************************/ |
|---|
| | 378 | int ioctl_HostSendChallenge( css_t *p_css, u8 *p_challenge ) |
|---|
| | 379 | { |
|---|
| | 380 | #if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) |
|---|
| | 381 | dvd_authinfo auth_info; |
|---|
| | 382 | |
|---|
| | 383 | auth_info.type = DVD_HOST_SEND_CHALLENGE; |
|---|
| | 384 | |
|---|
| | 385 | memcpy( auth_info.hsc.chal, p_challenge, sizeof(dvd_challenge) ); |
|---|
| | 386 | |
|---|
| | 387 | return ioctl( p_css->i_fd, DVD_AUTH, &auth_info ); |
|---|
| | 388 | |
|---|
| | 389 | #elif defined( SYS_BEOS ) |
|---|
| | 390 | raw_device_command rdc; |
|---|
| | 391 | u8 p_buffer[ 16 ]; |
|---|
| | 392 | |
|---|
| | 393 | BeInitRDC( &rdc, p_buffer, 16 ); |
|---|
| | 394 | |
|---|
| | 395 | rdc.command[ 0 ] = GPCMD_SEND_KEY; |
|---|
| | 396 | rdc.command[ 10 ] = 0x01 | (p_css->i_agid << 6); |
|---|
| | 397 | |
|---|
| | 398 | p_buffer[ 1 ] = 0xe; |
|---|
| | 399 | memcpy( p_buffer + 4, p_challenge, sizeof(dvd_challenge) ); |
|---|
| | 400 | |
|---|
| | 401 | return ioctl( p_css->i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); |
|---|
| | 402 | |
|---|
| | 403 | #else |
|---|
| | 404 | /* DVD ioctls unavailable - do as if the ioctl failed */ |
|---|