libexplain  1.4.D001
libexplain/buffer/sockopt_level.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/bluetooth/bluetooth.h>
00020 #include <libexplain/ac/netinet/in.h>
00021 #include <libexplain/ac/sys/socket.h>
00022 
00023 /* This one doesn't play nice with others on 64-bit machines?!? */
00024 #include <libexplain/ac/linux/irda.h>
00025 
00026 #include <libexplain/buffer/sockopt_level.h>
00027 #include <libexplain/parse_bits.h>
00028 #include <libexplain/sizeof.h>
00029 
00030 
00031 static const explain_parse_bits_table_t table[] =
00032 {
00033     /* <sys/socket.h> */
00034 #ifdef SOL_RAW
00035     { "SOL_RAW", SOL_RAW },
00036 #endif
00037 #ifdef SOL_DECNET
00038     { "SOL_DECNET", SOL_DECNET },
00039 #endif
00040 #ifdef SOL_X25
00041     { "SOL_X25", SOL_X25 },
00042 #endif
00043 #ifdef SOL_PACKET
00044     { "SOL_PACKET", SOL_PACKET },
00045 #endif
00046 #ifdef SOL_ATM
00047     { "SOL_ATM", SOL_ATM },
00048 #endif
00049 #ifdef SOL_AAL
00050     { "SOL_AAL", SOL_AAL },
00051 #endif
00052 #ifdef SOL_IRDA
00053     { "SOL_IRDA", SOL_IRDA },
00054 #endif
00055 #ifdef SOL_IP
00056     { "SOL_IP", SOL_IP },
00057 #endif
00058 #ifdef SOL_TCP
00059     { "SOL_TCP", SOL_TCP },
00060 #endif
00061 #ifdef SOL_UDP
00062     { "SOL_UDP", SOL_UDP },
00063 #endif
00064 #ifdef SOL_IPV6
00065     { "SOL_IPV6", SOL_IPV6 },
00066 #endif
00067 #ifdef SOL_ICMPV6
00068     { "SOL_ICMPV6", SOL_ICMPV6 },
00069 #endif
00070 #ifdef SOL_SCTP
00071     { "SOL_SCTP", SOL_SCTP },
00072 #endif
00073 #ifdef SOL_UDPLITE
00074     { "SOL_UDPLITE", SOL_UDPLITE },
00075 #endif
00076 #ifdef SOL_RAW
00077     { "SOL_RAW", SOL_RAW },
00078 #endif
00079 #ifdef SOL_IPX
00080     { "SOL_IPX", SOL_IPX },
00081 #endif
00082 #ifdef SOL_AX25
00083     { "SOL_AX25", SOL_AX25 },
00084 #endif
00085 #ifdef SOL_ATALK
00086     { "SOL_ATALK", SOL_ATALK },
00087 #endif
00088 #ifdef SOL_NETROM
00089     { "SOL_NETROM", SOL_NETROM },
00090 #endif
00091 #ifdef SOL_ROSE
00092     { "SOL_ROSE", SOL_ROSE },
00093 #endif
00094 #ifdef SOL_DECNET
00095     { "SOL_DECNET", SOL_DECNET },
00096 #endif
00097 #ifdef SOL_X25
00098     { "SOL_X25", SOL_X25 },
00099 #endif
00100 #ifdef SOL_PACKET
00101     { "SOL_PACKET", SOL_PACKET },
00102 #endif
00103 #ifdef SOL_ATM
00104     { "SOL_ATM", SOL_ATM },
00105 #endif
00106 #ifdef SOL_AAL
00107     { "SOL_AAL", SOL_AAL },
00108 #endif
00109 #ifdef SOL_IRDA
00110     { "SOL_IRDA", SOL_IRDA },
00111 #endif
00112 #ifdef SOL_NETBEUI
00113     { "SOL_NETBEUI", SOL_NETBEUI },
00114 #endif
00115 #ifdef SOL_LLC
00116     { "SOL_LLC", SOL_LLC },
00117 #endif
00118 #ifdef SOL_DCCP
00119     { "SOL_DCCP", SOL_DCCP },
00120 #endif
00121 #ifdef SOL_NETLINK
00122     { "SOL_NETLINK", SOL_NETLINK },
00123 #endif
00124 #ifdef SOL_TIPC
00125     { "SOL_TIPC", SOL_TIPC },
00126 #endif
00127 #ifdef SOL_RXRPC
00128     { "SOL_RXRPC", SOL_RXRPC },
00129 #endif
00130 #ifdef SOL_PPPOL2TP
00131     { "SOL_PPPOL2TP", SOL_PPPOL2TP },
00132 #endif
00133 #ifdef SOL_BLUETOOTH
00134     { "SOL_BLUETOOTH", SOL_BLUETOOTH },
00135 #endif
00136 #ifdef SOL_SOCKET
00137     { "SOL_SOCKET", SOL_SOCKET },
00138 #endif
00139 
00140     /* <linux/irda.h> */
00141 #ifdef SOL_IRLMP
00142     { "SOL_IRLMP", SOL_IRLMP },
00143 #endif
00144 #ifdef SOL_IRTTP
00145     { "SOL_IRTTP", SOL_IRTTP },
00146 #endif
00147 
00148     /* <bluetooth/bluetooth.h> */
00149 #ifdef SOL_HCI
00150     { "SOL_HCI", SOL_HCI },
00151 #endif
00152 #ifdef SOL_L2CAP
00153     { "SOL_L2CAP", SOL_L2CAP },
00154 #endif
00155 #ifdef SOL_SCO
00156     { "SOL_SCO", SOL_SCO },
00157 #endif
00158 #ifdef SOL_RFCOMM
00159     { "SOL_RFCOMM", SOL_RFCOMM },
00160 #endif
00161 };
00162 
00163 
00164 void
00165 explain_buffer_sockopt_level(explain_string_buffer_t *sb, int data)
00166 {
00167     explain_parse_bits_print_single(sb, data, table, SIZEOF(table));
00168 }
00169 
00170 
00171 int
00172 explain_parse_sockopt_level_or_die(const char *text, const char *caption)
00173 {
00174     return explain_parse_bits_or_die(text, table, SIZEOF(table), caption);
00175 }
00176 
00177 
00178 /* vim: set ts=8 sw=4 et : */