libexplain  1.4.D001
libexplain/buffer/siocgifbr.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - Explain errno values returned by libc functions
00003  * Copyright (C) 2009, 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_bridge.h>
00020 
00021 #include <libexplain/buffer/siocgifbr.h>
00022 #include <libexplain/parse_bits.h>
00023 #include <libexplain/sizeof.h>
00024 
00025 
00026 #ifdef HAVE_LINUX_IF_BRIDGE_H
00027 
00028 static void
00029 explain_buffer_brctl(explain_string_buffer_t *sb, int data)
00030 {
00031     static const explain_parse_bits_table_t table[] =
00032     {
00033         { "BRCTL_GET_VERSION", BRCTL_GET_VERSION },
00034         { "BRCTL_GET_BRIDGES", BRCTL_GET_BRIDGES },
00035         { "BRCTL_ADD_BRIDGE", BRCTL_ADD_BRIDGE },
00036         { "BRCTL_DEL_BRIDGE", BRCTL_DEL_BRIDGE },
00037         { "BRCTL_ADD_IF", BRCTL_ADD_IF },
00038         { "BRCTL_DEL_IF", BRCTL_DEL_IF },
00039         { "BRCTL_GET_BRIDGE_INFO", BRCTL_GET_BRIDGE_INFO },
00040         { "BRCTL_GET_PORT_LIST", BRCTL_GET_PORT_LIST },
00041         { "BRCTL_SET_BRIDGE_FORWARD_DELAY", BRCTL_SET_BRIDGE_FORWARD_DELAY },
00042         { "BRCTL_SET_BRIDGE_HELLO_TIME", BRCTL_SET_BRIDGE_HELLO_TIME },
00043         { "BRCTL_SET_BRIDGE_MAX_AGE", BRCTL_SET_BRIDGE_MAX_AGE },
00044         { "BRCTL_SET_AGEING_TIME", BRCTL_SET_AGEING_TIME },
00045         { "BRCTL_SET_GC_INTERVAL", BRCTL_SET_GC_INTERVAL },
00046         { "BRCTL_GET_PORT_INFO", BRCTL_GET_PORT_INFO },
00047         { "BRCTL_SET_BRIDGE_STP_STATE", BRCTL_SET_BRIDGE_STP_STATE },
00048         { "BRCTL_SET_BRIDGE_PRIORITY", BRCTL_SET_BRIDGE_PRIORITY },
00049         { "BRCTL_SET_PORT_PRIORITY", BRCTL_SET_PORT_PRIORITY },
00050         { "BRCTL_SET_PATH_COST", BRCTL_SET_PATH_COST },
00051         { "BRCTL_GET_FDB_ENTRIES", BRCTL_GET_FDB_ENTRIES },
00052     };
00053 
00054     explain_parse_bits_print_single(sb, data, table, SIZEOF(table));
00055 }
00056 
00057 
00058 void
00059 explain_buffer_siocgifbr(explain_string_buffer_t *sb,
00060     const unsigned long data[3])
00061 {
00062     explain_string_buffer_puts(sb, "{ ");
00063     explain_buffer_brctl(sb, data[0]);
00064     explain_string_buffer_printf(sb, ", %lu, %lu }", data[1], data[2]);
00065 }
00066 
00067 #else
00068 
00069 void
00070 explain_buffer_siocgifbr(explain_string_buffer_t *sb,
00071     const unsigned long data[3])
00072 {
00073     explain_string_buffer_printf
00074     (
00075         sb,
00076         "{ %lu, %lu, %lu }",
00077         data[0],
00078         data[1],
00079         data[2]
00080     );
00081 }
00082 
00083 #endif
00084 
00085 
00086 /* vim: set ts=8 sw=4 et : */