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/master_config.h> 00026 #include <libexplain/iocontrol/generic.h> 00027 #include <libexplain/iocontrol/eql_getmastrcfg.h> 00028 #include <libexplain/is_efault.h> 00029 00030 #ifdef EQL_GETMASTRCFG 00031 00032 00033 static void 00034 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00035 int 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_master_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 master_config *m; 00056 00057 i = data; 00058 if (explain_is_efault_pointer(i, sizeof(*i))) 00059 { 00060 explain_buffer_efault(sb, "data"); 00061 break; 00062 } 00063 m = (const struct master_config *)i->ifr_data; 00064 if (explain_is_efault_pointer(m, sizeof(*m))) 00065 { 00066 explain_buffer_efault(sb, "data->ifr_data"); 00067 break; 00068 } 00069 } 00070 goto generic; 00071 00072 case EINVAL: 00073 /* 00074 * FIXME: it may not be a master 00075 */ 00076 goto generic; 00077 00078 default: 00079 generic: 00080 explain_iocontrol_generic_print_explanation 00081 ( 00082 p, 00083 sb, 00084 errnum, 00085 fildes, 00086 request, 00087 data 00088 ); 00089 break; 00090 } 00091 } 00092 00093 00094 static void 00095 print_data_returned(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00096 int errnum, int fildes, int request, const void *data) 00097 { 00098 (void)p; 00099 (void)errnum; 00100 (void)fildes; 00101 (void)request; 00102 explain_buffer_ifreq_master_config(sb, data, 1); 00103 } 00104 00105 00106 const explain_iocontrol_t explain_iocontrol_eql_getmastrcfg = 00107 { 00108 "EQL_GETMASTRCFG", /* name */ 00109 EQL_GETMASTRCFG, /* value */ 00110 explain_iocontrol_disambiguate_is_if_eql, 00111 0, /* print_name */ 00112 print_data, 00113 print_explanation, 00114 print_data_returned, 00115 sizeof(struct ifreq), /* data_size */ 00116 "struct ifreq *", /* data_type */ 00117 IOCONTROL_FLAG_NON_META, /* flags */ 00118 __FILE__, 00119 __LINE__, 00120 }; 00121 00122 #else /* ndef EQL_GETMASTRCFG */ 00123 00124 const explain_iocontrol_t explain_iocontrol_eql_getmastrcfg = 00125 { 00126 0, /* name */ 00127 0, /* value */ 00128 0, /* disambiguate */ 00129 0, /* print_name */ 00130 0, /* print_data */ 00131 0, /* print_explanation */ 00132 0, /* print_data_returned */ 00133 0, /* data_size */ 00134 0, /* data_type */ 00135 0, /* flags */ 00136 __FILE__, 00137 __LINE__, 00138 }; 00139 00140 #endif /* EQL_GETMASTRCFG */ 00141 00142 00143 /* vim: set ts=8 sw=4 et : */