libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2010, 2011, 2013 Peter Miller 00004 * Written by Peter Miller <pmiller@opensource.org.au> 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 3 of the License, or (at your 00009 * option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but WITHOUT 00012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00014 * License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #include <libexplain/ac/errno.h> 00021 #include <libexplain/ac/linux/filter.h> 00022 #include <libexplain/ac/linux/if_ppp.h> 00023 #include <libexplain/ac/sys/ioctl.h> 00024 00025 #include <libexplain/buffer/efault.h> 00026 #include <libexplain/buffer/einval.h> 00027 #include <libexplain/buffer/enomem.h> 00028 #include <libexplain/buffer/sock_fprog.h> 00029 #include <libexplain/iocontrol/generic.h> 00030 #include <libexplain/iocontrol/pppiocspass.h> 00031 #include <libexplain/is_efault.h> 00032 00033 #ifdef PPPIOCSPASS 00034 00035 00036 static void 00037 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00038 int errnum, int fildes, int request, const void *data) 00039 { 00040 (void)p; 00041 (void)errnum; 00042 (void)fildes; 00043 (void)request; 00044 explain_buffer_sock_fprog(sb, data); 00045 } 00046 00047 00048 static void 00049 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00050 int errnum, int fildes, int request, const void *data) 00051 { 00052 switch (errnum) 00053 { 00054 case EFAULT: 00055 { 00056 const struct sock_fprog *prog; 00057 00058 prog = data; 00059 if (explain_is_efault_pointer(prog, sizeof(*prog))) 00060 explain_buffer_efault(sb, "data"); 00061 else 00062 explain_buffer_efault(sb, "data->filter"); 00063 } 00064 break; 00065 00066 case ENOMEM: 00067 explain_buffer_enomem_kernel(sb); 00068 break; 00069 00070 case EINVAL: 00071 /* 00072 * from Linux kernel net/core/filter.c 00073 * 00074 * "Check the user's filter code. If we let some ugly 00075 * filter code slip through kaboom! The filter must contain 00076 * no references or jumps that are out of range, no illegal 00077 * instructions, and must end with a RET instruction." 00078 */ 00079 explain_buffer_einval_sock_fprog(sb, data); 00080 break; 00081 00082 default: 00083 explain_iocontrol_generic_print_explanation 00084 ( 00085 p, 00086 sb, 00087 errnum, 00088 fildes, 00089 request, 00090 data 00091 ); 00092 break; 00093 } 00094 } 00095 00096 00097 const explain_iocontrol_t explain_iocontrol_pppiocspass = 00098 { 00099 "PPPIOCSPASS", /* name */ 00100 PPPIOCSPASS, /* value */ 00101 0, /* disambiguate */ 00102 0, /* print_name */ 00103 print_data, 00104 print_explanation, 00105 0, /* print_data_returned */ 00106 sizeof(struct sock_fprog), /* data_size */ 00107 "struct sock_fprog *", /* data_type */ 00108 0, /* flags */ 00109 __FILE__, 00110 __LINE__, 00111 }; 00112 00113 #else /* ndef PPPIOCSPASS */ 00114 00115 const explain_iocontrol_t explain_iocontrol_pppiocspass = 00116 { 00117 0, /* name */ 00118 0, /* value */ 00119 0, /* disambiguate */ 00120 0, /* print_name */ 00121 0, /* print_data */ 00122 0, /* print_explanation */ 00123 0, /* print_data_returned */ 00124 0, /* data_size */ 00125 0, /* data_type */ 00126 0, /* flags */ 00127 __FILE__, 00128 __LINE__, 00129 }; 00130 00131 #endif /* PPPIOCSPASS */ 00132 00133 00134 /* vim: set ts=8 sw=4 et : */