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 it 00006 * under the terms of the GNU Lesser General Public License as published by 00007 * the Free Software Foundation; either version 3 of the License, or (at your 00008 * option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful,but WITHOUT 00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 00013 * 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/sys/ioctl.h> 00020 #include <libexplain/ac/errno.h> 00021 #include <libexplain/ac/linux/if_eql.h> 00022 #include <libexplain/ac/net/if.h> 00023 00024 #include <libexplain/buffer/efault.h> 00025 #include <libexplain/buffer/ifreq/slave_config.h> 00026 #include <libexplain/iocontrol/generic.h> 00027 #include <libexplain/iocontrol/eql_getslavecfg.h> 00028 #include <libexplain/is_efault.h> 00029 00030 #ifdef EQL_GETSLAVECFG 00031 00032 00033 static void 00034 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb, int 00035 errnum, int fildes, int request, const void *data) 00036 { 00037 (void)p; 00038 (void)errnum; 00039 (void)fildes; 00040 (void)request; 00041 explain_buffer_ifreq_slave_config(sb, data, 0); 00042 } 00043 00044 00045 static void 00046 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, int 00047 errnum, int fildes, int request, const void *data) 00048 { 00049 /* see Linux kernel sources, drivers/net/eql.c */ 00050 switch (errnum) 00051 { 00052 case EFAULT: 00053 { 00054 const struct ifreq *i; 00055 const struct slave_config *s; 00056 00057 i = data; 00058 if (explain_is_efault_pointer(i, sizeof(*i))) 00059 { 00060 explain_buffer_efault(sb, "data"); 00061 break; 00062 } 00063 s = (const struct slave_config *)i->ifr_data; 00064 if (explain_is_efault_pointer(s, sizeof(*s))) 00065 { 00066 explain_buffer_efault(sb, "data->ifr_data"); 00067 break; 00068 } 00069 } 00070 goto generic; 00071 00072 case ENODEV: 00073 /* 00074 * FIXME: named slave device does not exist 00075 */ 00076 goto generic; 00077 00078 case EINVAL: 00079 /* 00080 * FIXME: the named device may not be a slave, the named device 00081 * may not a an if_eql slave. 00082 */ 00083 goto generic; 00084 00085 default: 00086 generic: 00087 explain_iocontrol_generic_print_explanation 00088 ( 00089 p, 00090 sb, 00091 errnum, 00092 fildes, 00093 request, 00094 data 00095 ); 00096 break; 00097 } 00098 } 00099 00100 00101 static void 00102 print_data_returned(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00103 int errnum, int fildes, int request, const void *data) 00104 { 00105 (void)p; 00106 (void)errnum; 00107 (void)fildes; 00108 (void)request; 00109 explain_buffer_ifreq_slave_config(sb, data, 1); 00110 } 00111 00112 00113 const explain_iocontrol_t explain_iocontrol_eql_getslavecfg = 00114 { 00115 "EQL_GETSLAVECFG", /* name */ 00116 EQL_GETSLAVECFG, /* value */ 00117 explain_iocontrol_disambiguate_is_if_eql, 00118 0, /* print_name */ 00119 print_data, 00120 print_explanation, 00121 print_data_returned, 00122 sizeof(struct ifreq), /* data_size */ 00123 "struct ifreq *", /* data_type */ 00124 IOCONTROL_FLAG_NON_META, /* flags */ 00125 __FILE__, 00126 __LINE__, 00127 }; 00128 00129 #else /* ndef EQL_GETSLAVECFG */ 00130 00131 const explain_iocontrol_t explain_iocontrol_eql_getslavecfg = 00132 { 00133 0, /* name */ 00134 0, /* value */ 00135 0, /* disambiguate */ 00136 0, /* print_name */ 00137 0, /* print_data */ 00138 0, /* print_explanation */ 00139 0, /* print_data_returned */ 00140 0, /* data_size */ 00141 0, /* data_type */ 00142 0, /* flags */ 00143 __FILE__, 00144 __LINE__, 00145 }; 00146 00147 #endif /* EQL_GETSLAVECFG */ 00148 00149 00150 /* vim: set ts=8 sw=4 et : */