libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2009, 2011, 2013 Peter Miller 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU Lesser General Public License as 00007 * published by the Free Software Foundation; either version 3 of the 00008 * License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #include <libexplain/ac/linux/cdrom.h> 00020 00021 #include <libexplain/buffer/dvd_authinfo.h> 00022 #include <libexplain/buffer/hexdump.h> 00023 #include <libexplain/buffer/int.h> 00024 #include <libexplain/buffer/pointer.h> 00025 #include <libexplain/is_efault.h> 00026 #include <libexplain/parse_bits.h> 00027 #include <libexplain/sizeof.h> 00028 00029 00030 #ifdef HAVE_LINUX_CDROM_H 00031 00032 static void 00033 explain_buffer_dvd_authinfo_type(explain_string_buffer_t *sb, int value) 00034 { 00035 static const explain_parse_bits_table_t table[] = 00036 { 00037 { "DVD_LU_SEND_AGID", DVD_LU_SEND_AGID }, 00038 { "DVD_HOST_SEND_CHALLENGE", DVD_HOST_SEND_CHALLENGE }, 00039 { "DVD_LU_SEND_KEY1", DVD_LU_SEND_KEY1 }, 00040 { "DVD_LU_SEND_CHALLENGE", DVD_LU_SEND_CHALLENGE }, 00041 { "DVD_HOST_SEND_KEY2", DVD_HOST_SEND_KEY2 }, 00042 { "DVD_AUTH_ESTABLISHED", DVD_AUTH_ESTABLISHED }, 00043 { "DVD_AUTH_FAILURE", DVD_AUTH_FAILURE }, 00044 { "DVD_LU_SEND_TITLE_KEY", DVD_LU_SEND_TITLE_KEY }, 00045 { "DVD_LU_SEND_ASF", DVD_LU_SEND_ASF }, 00046 { "DVD_INVALIDATE_AGID", DVD_INVALIDATE_AGID }, 00047 { "DVD_LU_SEND_RPC_STATE", DVD_LU_SEND_RPC_STATE }, 00048 { "DVD_HOST_SEND_RPC_STATE", DVD_HOST_SEND_RPC_STATE }, 00049 }; 00050 00051 explain_parse_bits_print_single(sb, value, table, SIZEOF(table)); 00052 } 00053 00054 00055 void 00056 explain_buffer_dvd_authinfo(explain_string_buffer_t *sb, 00057 const dvd_authinfo *data) 00058 { 00059 if (explain_is_efault_pointer(data, sizeof(*data))) 00060 { 00061 explain_buffer_pointer(sb, data); 00062 return; 00063 } 00064 00065 explain_string_buffer_puts(sb, "{ type = "); 00066 explain_buffer_dvd_authinfo_type(sb, data->type); 00067 switch (data->type) 00068 { 00069 case DVD_LU_SEND_AGID: 00070 explain_string_buffer_puts(sb, ", agid = "); 00071 explain_buffer_int(sb, data->lsa.agid); 00072 break; 00073 00074 case DVD_HOST_SEND_CHALLENGE: 00075 explain_string_buffer_puts(sb, ", agid = "); 00076 explain_buffer_int(sb, data->hsc.agid); 00077 explain_string_buffer_puts(sb, ", chal = "); 00078 explain_buffer_hexdump(sb, data->hsc.chal, sizeof(data->hsc.chal)); 00079 break; 00080 00081 case DVD_LU_SEND_KEY1: 00082 explain_string_buffer_puts(sb, ", agid = "); 00083 explain_buffer_int(sb, data->lsk.agid); 00084 explain_string_buffer_puts(sb, ", chal = "); 00085 explain_buffer_hexdump(sb, data->lsk.key, sizeof(data->lsk.key)); 00086 break; 00087 00088 case DVD_LU_SEND_CHALLENGE: 00089 explain_string_buffer_puts(sb, ", agid = "); 00090 explain_buffer_int(sb, data->lsc.agid); 00091 explain_string_buffer_puts(sb, ", chal = "); 00092 explain_buffer_hexdump(sb, data->lsc.chal, sizeof(data->lsc.chal)); 00093 break; 00094 00095 case DVD_HOST_SEND_KEY2: 00096 explain_string_buffer_puts(sb, ", agid = "); 00097 explain_buffer_int(sb, data->hsk.agid); 00098 explain_string_buffer_puts(sb, ", chal = "); 00099 explain_buffer_hexdump(sb, data->hsk.key, sizeof(data->hsk.key)); 00100 break; 00101 00102 case DVD_AUTH_ESTABLISHED: 00103 break; 00104 00105 case DVD_AUTH_FAILURE: 00106 break; 00107 00108 case DVD_LU_SEND_TITLE_KEY: 00109 explain_string_buffer_puts(sb, ", agid = "); 00110 explain_buffer_int(sb, data->lstk.agid); 00111 explain_string_buffer_puts(sb, ", title_key = "); 00112 explain_buffer_hexdump 00113 ( 00114 sb, 00115 data->lstk.title_key, 00116 sizeof(data->lstk.title_key) 00117 ); 00118 explain_string_buffer_puts(sb, ", lba = "); 00119 explain_buffer_int(sb, data->lstk.lba); 00120 explain_string_buffer_puts(sb, ", cpm = "); 00121 explain_buffer_int(sb, data->lstk.cpm); 00122 explain_string_buffer_puts(sb, ", cp_sec = "); 00123 explain_buffer_int(sb, data->lstk.cp_sec); 00124 explain_string_buffer_puts(sb, ", cgms = "); 00125 explain_buffer_int(sb, data->lstk.cgms); 00126 break; 00127 00128 case DVD_LU_SEND_ASF: 00129 explain_string_buffer_puts(sb, ", agid = "); 00130 explain_buffer_int(sb, data->lsasf.agid); 00131 explain_string_buffer_puts(sb, ", asf = "); 00132 explain_buffer_int(sb, data->lsasf.asf); 00133 break; 00134 00135 case DVD_INVALIDATE_AGID: 00136 break; 00137 00138 case DVD_LU_SEND_RPC_STATE: 00139 explain_string_buffer_puts(sb, ", type = "); 00140 explain_buffer_int(sb, data->lrpcs.type); 00141 explain_string_buffer_puts(sb, ", vra = "); 00142 explain_buffer_int(sb, data->lrpcs.vra); 00143 explain_string_buffer_puts(sb, ", ucca = "); 00144 explain_buffer_int(sb, data->lrpcs.ucca); 00145 explain_string_buffer_puts(sb, ", region_mask = "); 00146 explain_buffer_int(sb, data->lrpcs.region_mask); 00147 explain_string_buffer_puts(sb, ", rpc_scheme = "); 00148 explain_buffer_int(sb, data->lrpcs.rpc_scheme); 00149 break; 00150 00151 case DVD_HOST_SEND_RPC_STATE: 00152 explain_string_buffer_puts(sb, ", type = "); 00153 explain_buffer_int(sb, data->hrpcs.type); 00154 explain_string_buffer_puts(sb, ", pdrc = "); 00155 explain_buffer_int(sb, data->hrpcs.pdrc); 00156 break; 00157 00158 default: 00159 break; 00160 } 00161 explain_string_buffer_puts(sb, " }"); 00162 } 00163 00164 #else 00165 00166 void 00167 explain_buffer_dvd_authinfo(explain_string_buffer_t *sb, const void *data) 00168 { 00169 explain_buffer_pointer(sb, data); 00170 } 00171 00172 #endif 00173 00174 00175 /* vim: set ts=8 sw=4 et : */