libexplain  1.4.D001
libexplain/iocontrol/disambiguate/if_ppp.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 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/sys/ioctl.h>
00021 #include <libexplain/ac/net/if_ppp.h>
00022 
00023 #include <libexplain/iocontrol/disambiguate/if_ppp.h>
00024 
00025 
00026 int
00027 explain_iocontrol_disambiguate_is_if_ppp(int fildes, int request,
00028     const void *data)
00029 {
00030 #ifdef SIOCGPPPSTATS
00031     int             debug;
00032 
00033     (void)data;
00034 
00035     /*
00036      * Eliminate as much as possible without any system calls at all.
00037      */
00038     switch (request)
00039     {
00040     case SIOCGPPPCSTATS:
00041     case SIOCGPPPSTATS:
00042     case SIOCGPPPVER:
00043         break;
00044 
00045     default:
00046         return DISAMBIGUATE_DO_NOT_USE;
00047     }
00048 
00049     /*
00050      * We ask the file descriptor for its PPP debug level.
00051      * If it barfs, this file descriptor isn't suitable.
00052      */
00053     debug = 0;
00054     if (ioctl(fildes, PPPIOCGDEBUG, &debug) < 0)
00055         return DISAMBIGUATE_DO_NOT_USE;
00056 
00057     /* looks ok */
00058     return DISAMBIGUATE_USE;
00059 #else
00060     (void)fildes;
00061     (void)request;
00062     (void)data;
00063     return DISAMBIGUATE_DO_NOT_USE;
00064 #endif
00065 }
00066 
00067 
00068 /* vim: set ts=8 sw=4 et : */