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/net/if_ppp.h> 00022 #include <libexplain/ac/sys/ioctl.h> 00023 00024 #include <libexplain/buffer/efault.h> 00025 #include <libexplain/buffer/ifreq_data/ppp_stats.h> 00026 #include <libexplain/iocontrol/disambiguate/if_ppp.h> 00027 #include <libexplain/iocontrol/generic.h> 00028 #include <libexplain/iocontrol/siocgpppstats.h> 00029 #include <libexplain/is_efault.h> 00030 00031 #ifdef SIOCGPPPSTATS 00032 00033 00034 static void 00035 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00036 int errnum, int fildes, int request, const void *data) 00037 { 00038 (void)p; 00039 (void)errnum; 00040 (void)fildes; 00041 (void)request; 00042 explain_buffer_ifreq_data_ppp_stats(sb, data, 0); 00043 } 00044 00045 00046 static void 00047 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00048 int errnum, int fildes, int request, const void *data) 00049 { 00050 switch (errnum) 00051 { 00052 case EFAULT: 00053 { 00054 const struct ifreq *rq; 00055 00056 rq = data; 00057 if (explain_is_efault_pointer(rq, sizeof(*rq))) 00058 explain_buffer_efault(sb, "data"); 00059 else 00060 explain_buffer_efault(sb, "data->ifr_data"); 00061 } 00062 break; 00063 00064 default: 00065 explain_iocontrol_generic_print_explanation 00066 ( 00067 p, 00068 sb, 00069 errnum, 00070 fildes, 00071 request, 00072 data 00073 ); 00074 break; 00075 } 00076 } 00077 00078 00079 static void 00080 print_data_returned(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00081 int errnum, int fildes, int request, const void *data) 00082 { 00083 (void)p; 00084 (void)errnum; 00085 (void)fildes; 00086 (void)request; 00087 explain_buffer_ifreq_data_ppp_stats(sb, data, 1); 00088 } 00089 00090 00091 const explain_iocontrol_t explain_iocontrol_siocgpppstats = 00092 { 00093 "SIOCGPPPSTATS", /* name */ 00094 SIOCGPPPSTATS, /* value */ 00095 explain_iocontrol_disambiguate_is_if_ppp, 00096 0, /* print_name */ 00097 print_data, 00098 print_explanation, 00099 print_data_returned, 00100 sizeof(struct ifreq), /* data_size */ 00101 "struct ifreq *", /* data_type */ 00102 IOCONTROL_FLAG_NON_META, /* flags */ 00103 __FILE__, 00104 __LINE__, 00105 }; 00106 00107 #else /* ndef SIOCGPPPSTATS */ 00108 00109 const explain_iocontrol_t explain_iocontrol_siocgpppstats = 00110 { 00111 0, /* name */ 00112 0, /* value */ 00113 0, /* disambiguate */ 00114 0, /* print_name */ 00115 0, /* print_data */ 00116 0, /* print_explanation */ 00117 0, /* print_data_returned */ 00118 0, /* data_size */ 00119 0, /* data_type */ 00120 0, /* flags */ 00121 __FILE__, 00122 __LINE__, 00123 }; 00124 00125 #endif /* SIOCGPPPSTATS */ 00126 00127 00128 /* vim: set ts=8 sw=4 et : */