libexplain  1.4.D001
libexplain/iocontrol/siocsccskiss.c
Go to the documentation of this file.
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
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 3 of the License, or (at
00009  * your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License along
00017  * with this program. If not, see <http://www.gnu.org/licenses/>.
00018  */
00019 
00020 #include <libexplain/ac/errno.h>
00021 #include <libexplain/ac/linux/scc.h>
00022 
00023 #include <libexplain/buffer/dac.h>
00024 #include <libexplain/buffer/efault.h>
00025 #include <libexplain/buffer/scc_kiss_cmd.h>
00026 #include <libexplain/iocontrol/generic.h>
00027 #include <libexplain/iocontrol/siocsccskiss.h>
00028 #include <libexplain/is_efault.h>
00029 
00030 #ifdef HAVE_LINUX_SCC_H
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_scc_kiss_cmd(sb, data, 1);
00042 }
00043 
00044 
00045 static void
00046 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb,
00047     int errnum, int fildes, int request, const void *data)
00048 {
00049     switch (errnum)
00050     {
00051     case EPERM:
00052         explain_buffer_dac_net_admin(sb);
00053         break;
00054 
00055     case EFAULT:
00056         efault:
00057         explain_buffer_efault(sb, "data");
00058         break;
00059 
00060     case EINVAL:
00061         if (explain_is_efault_pointer(data, sizeof(struct scc_kiss_cmd)))
00062             goto efault;
00063         /* Fall through... */
00064 
00065     default:
00066         explain_iocontrol_generic_print_explanation
00067         (
00068             p,
00069             sb,
00070             errnum,
00071             fildes,
00072             request,
00073             data
00074         );
00075         break;
00076     }
00077 }
00078 
00079 
00080 const explain_iocontrol_t explain_iocontrol_siocsccskiss =
00081 {
00082     "SIOCSCCSKISS", /* name */
00083     SIOCSCCSKISS, /* value */
00084     explain_iocontrol_disambiguate_scc,
00085     0, /* print_name */
00086     print_data,
00087     print_explanation,
00088     0, /* print_data_returned */
00089     sizeof(struct scc_kiss_cmd), /* data_size */
00090     "struct scc_kiss_cmd *", /* data_type */
00091     IOCONTROL_FLAG_SIZE_DOES_NOT_AGREE, /* flags */
00092     __FILE__,
00093     __LINE__,
00094 };
00095 
00096 #else /* ndef SIOCSCCSKISS */
00097 
00098 const explain_iocontrol_t explain_iocontrol_siocsccskiss =
00099 {
00100     0, /* name */
00101     0, /* value */
00102     0, /* disambiguate */
00103     0, /* print_name */
00104     0, /* print_data */
00105     0, /* print_explanation */
00106     0, /* print_data_returned */
00107     0, /* data_size */
00108     0, /* data_type */
00109     0, /* flags */
00110     __FILE__,
00111     __LINE__,
00112 };
00113 
00114 #endif /* SIOCSCCSKISS */
00115 
00116 
00117 /* vim: set ts=8 sw=4 et : */