libexplain  1.4.D001
libexplain/buffer/if_ppp_state.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  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU Lesser General Public License as
00007  * published by the Free Software Foundation; either version 3 of the
00008  * License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License 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/linux/if_ppp.h>
00020 
00021 #include <libexplain/buffer/if_ppp_state.h>
00022 #include <libexplain/buffer/pointer.h>
00023 #include <libexplain/parse_bits.h>
00024 #include <libexplain/is_efault.h>
00025 #include <libexplain/sizeof.h>
00026 
00027 
00028 #ifdef HAVE_LINUX_IF_PPP_H
00029 
00030 static explain_parse_bits_table_t table[] =
00031 {
00032     { "SC_COMP_PROT", SC_COMP_PROT },
00033     { "SC_COMP_AC", SC_COMP_AC },
00034     { "SC_COMP_TCP", SC_COMP_TCP },
00035     { "SC_NO_TCP_CCID", SC_NO_TCP_CCID },
00036     { "SC_REJ_COMP_AC", SC_REJ_COMP_AC },
00037     { "SC_REJ_COMP_TCP", SC_REJ_COMP_TCP },
00038     { "SC_CCP_OPEN", SC_CCP_OPEN },
00039     { "SC_CCP_UP", SC_CCP_UP },
00040     { "SC_ENABLE_IP", SC_ENABLE_IP },
00041     { "SC_LOOP_TRAFFIC", SC_LOOP_TRAFFIC },
00042     { "SC_MULTILINK", SC_MULTILINK },
00043     { "SC_MP_SHORTSEQ", SC_MP_SHORTSEQ },
00044     { "SC_COMP_RUN", SC_COMP_RUN },
00045     { "SC_DECOMP_RUN", SC_DECOMP_RUN },
00046     { "SC_MP_XSHORTSEQ", SC_MP_XSHORTSEQ },
00047     { "SC_DEBUG", SC_DEBUG },
00048     { "SC_LOG_INPKT", SC_LOG_INPKT },
00049     { "SC_LOG_OUTPKT", SC_LOG_OUTPKT },
00050     { "SC_LOG_RAWIN", SC_LOG_RAWIN },
00051     { "SC_LOG_FLUSH", SC_LOG_FLUSH },
00052     { "SC_SYNC", SC_SYNC },
00053     { "SC_MUST_COMP", SC_MUST_COMP },
00054     { "SC_XMIT_BUSY", SC_XMIT_BUSY },
00055     { "SC_RCV_ODDP", SC_RCV_ODDP },
00056     { "SC_RCV_EVNP", SC_RCV_EVNP },
00057     { "SC_RCV_B7_1", SC_RCV_B7_1 },
00058     { "SC_RCV_B7_0", SC_RCV_B7_0 },
00059     { "SC_DC_FERROR", SC_DC_FERROR },
00060     { "SC_DC_ERROR", SC_DC_ERROR },
00061 };
00062 
00063 
00064 void
00065 explain_buffer_if_ppp_state(explain_string_buffer_t *sb, const int *data)
00066 {
00067     if (explain_is_efault_pointer(data, sizeof(*data)))
00068     {
00069         explain_buffer_pointer(sb, data);
00070     }
00071     else
00072     {
00073         explain_string_buffer_puts(sb, "{ ");
00074         explain_parse_bits_print(sb, *data, table, SIZEOF(table));
00075         explain_string_buffer_puts(sb, " }");
00076     }
00077 }
00078 
00079 #else
00080 
00081 void
00082 explain_buffer_if_ppp_state(explain_string_buffer_t *sb, const int *data)
00083 {
00084     explain_buffer_pointer(sb, data);
00085 }
00086 
00087 #endif
00088 
00089 
00090 /* vim: set ts=8 sw=4 et : */