libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2008, 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/sys/socket.h> 00020 00021 #include <libexplain/buffer/address_family.h> 00022 #include <libexplain/parse_bits.h> 00023 #include <libexplain/sizeof.h> 00024 00025 00026 static const explain_parse_bits_table_t table[] = 00027 { 00028 #ifdef PF_UNSPEC 00029 { "PF_UNSPEC", PF_UNSPEC }, 00030 #endif 00031 #ifdef PF_UNIX 00032 { "PF_UNIX", PF_UNIX }, 00033 #endif 00034 #ifdef PF_LOCAL 00035 { "PF_LOCAL", PF_LOCAL }, 00036 #endif 00037 #ifdef PF_FILE 00038 { "PF_FILE", PF_FILE }, 00039 #endif 00040 #ifdef PF_INET 00041 { "PF_INET", PF_INET }, 00042 #endif 00043 #ifdef PF_AX25 00044 { "PF_AX25", PF_AX25 }, 00045 #endif 00046 #ifdef PF_IPX 00047 { "PF_IPX", PF_IPX }, 00048 #endif 00049 #ifdef PF_APPLETALK 00050 { "PF_APPLETALK", PF_APPLETALK }, 00051 #endif 00052 #ifdef PF_NETROM 00053 { "PF_NETROM", PF_NETROM }, 00054 #endif 00055 #ifdef PF_BRIDGE 00056 { "PF_BRIDGE", PF_BRIDGE }, 00057 #endif 00058 #ifdef PF_ATMPVC 00059 { "PF_ATMPVC", PF_ATMPVC }, 00060 #endif 00061 #ifdef PF_X25 00062 { "PF_X25", PF_X25 }, 00063 #endif 00064 #ifdef PF_INET6 00065 { "PF_INET6", PF_INET6 }, 00066 #endif 00067 #ifdef PF_ROSE 00068 { "PF_ROSE", PF_ROSE }, 00069 #endif 00070 #ifdef PF_DECnet 00071 { "PF_DECnet", PF_DECnet }, 00072 #endif 00073 #ifdef PF_NETBEUI 00074 { "PF_NETBEUI", PF_NETBEUI }, 00075 #endif 00076 #ifdef PF_SECURITY 00077 { "PF_SECURITY", PF_SECURITY }, 00078 #endif 00079 #ifdef PF_KEY 00080 { "PF_KEY", PF_KEY }, 00081 #endif 00082 #ifdef PF_NETLINK 00083 { "PF_NETLINK", PF_NETLINK }, 00084 #endif 00085 #ifdef PF_ROUTE 00086 { "PF_ROUTE", PF_ROUTE }, 00087 #endif 00088 #ifdef PF_PACKET 00089 { "PF_PACKET", PF_PACKET }, 00090 #endif 00091 #ifdef PF_ASH 00092 { "PF_ASH", PF_ASH }, 00093 #endif 00094 #ifdef PF_ECONET 00095 { "PF_ECONET", PF_ECONET }, 00096 #endif 00097 #ifdef PF_ATMSVC 00098 { "PF_ATMSVC", PF_ATMSVC }, 00099 #endif 00100 #ifdef PF_SNA 00101 { "PF_SNA", PF_SNA }, 00102 #endif 00103 #ifdef PF_IRDA 00104 { "PF_IRDA", PF_IRDA }, 00105 #endif 00106 #ifdef PF_PPPOX 00107 { "PF_PPPOX", PF_PPPOX }, 00108 #endif 00109 #ifdef PF_WANPIPE 00110 { "PF_WANPIPE", PF_WANPIPE }, 00111 #endif 00112 #ifdef PF_BLUETOOTH 00113 { "PF_BLUETOOTH", PF_BLUETOOTH }, 00114 #endif 00115 #ifdef PF_IUCV 00116 { "PF_IUCV", PF_IUCV }, 00117 #endif 00118 #ifdef PF_RXRPC 00119 { "PF_RXRPC", PF_RXRPC }, 00120 #endif 00121 #ifdef AF_UNSPEC 00122 { "AF_UNSPEC", AF_UNSPEC }, 00123 #endif 00124 #ifdef AF_LOCAL 00125 { "AF_LOCAL", AF_LOCAL }, 00126 #endif 00127 #ifdef AF_UNIX 00128 { "AF_UNIX", AF_UNIX }, 00129 #endif 00130 #ifdef AF_FILE 00131 { "AF_FILE", AF_FILE }, 00132 #endif 00133 #ifdef AF_INET 00134 { "AF_INET", AF_INET }, 00135 #endif 00136 #ifdef AF_AX25 00137 { "AF_AX25", AF_AX25 }, 00138 #endif 00139 #ifdef AF_IPX 00140 { "AF_IPX", AF_IPX }, 00141 #endif 00142 #ifdef AF_APPLETALK 00143 { "AF_APPLETALK", AF_APPLETALK }, 00144 #endif 00145 #ifdef AF_NETROM 00146 { "AF_NETROM", AF_NETROM }, 00147 #endif 00148 #ifdef AF_BRIDGE 00149 { "AF_BRIDGE", AF_BRIDGE }, 00150 #endif 00151 #ifdef AF_ATMPVC 00152 { "AF_ATMPVC", AF_ATMPVC }, 00153 #endif 00154 #ifdef AF_X25 00155 { "AF_X25", AF_X25 }, 00156 #endif 00157 #ifdef AF_INET6 00158 { "AF_INET6", AF_INET6 }, 00159 #endif 00160 #ifdef AF_ROSE 00161 { "AF_ROSE", AF_ROSE }, 00162 #endif 00163 #ifdef AF_DECnet 00164 { "AF_DECnet", AF_DECnet }, 00165 #endif 00166 #ifdef AF_NETBEUI 00167 { "AF_NETBEUI", AF_NETBEUI }, 00168 #endif 00169 #ifdef AF_SECURITY 00170 { "AF_SECURITY", AF_SECURITY }, 00171 #endif 00172 #ifdef AF_KEY 00173 { "AF_KEY", AF_KEY }, 00174 #endif 00175 #ifdef AF_NETLINK 00176 { "AF_NETLINK", AF_NETLINK }, 00177 #endif 00178 #ifdef AF_ROUTE 00179 { "AF_ROUTE", AF_ROUTE }, 00180 #endif 00181 #ifdef AF_PACKET 00182 { "AF_PACKET", AF_PACKET }, 00183 #endif 00184 #ifdef AF_ASH 00185 { "AF_ASH", AF_ASH }, 00186 #endif 00187 #ifdef AF_ECONET 00188 { "AF_ECONET", AF_ECONET }, 00189 #endif 00190 #ifdef AF_ATMSVC 00191 { "AF_ATMSVC", AF_ATMSVC }, 00192 #endif 00193 #ifdef AF_SNA 00194 { "AF_SNA", AF_SNA }, 00195 #endif 00196 #ifdef AF_IRDA 00197 { "AF_IRDA", AF_IRDA }, 00198 #endif 00199 #ifdef AF_PPPOX 00200 { "AF_PPPOX", AF_PPPOX }, 00201 #endif 00202 #ifdef AF_WANPIPE 00203 { "AF_WANPIPE", AF_WANPIPE }, 00204 #endif 00205 #ifdef AF_BLUETOOTH 00206 { "AF_BLUETOOTH", AF_BLUETOOTH }, 00207 #endif 00208 #ifdef AF_IUCV 00209 { "AF_IUCV", AF_IUCV }, 00210 #endif 00211 #ifdef AF_RXRPC 00212 { "AF_RXRPC", AF_RXRPC }, 00213 #endif 00214 }; 00215 00216 00217 void 00218 explain_buffer_address_family(explain_string_buffer_t *sb, int domain) 00219 { 00220 const explain_parse_bits_table_t *tp; 00221 00222 tp = explain_parse_bits_find_by_value(domain, table, SIZEOF(table)); 00223 if (tp) 00224 explain_string_buffer_puts(sb, tp->name); 00225 else 00226 explain_string_buffer_printf(sb, "%d", domain); 00227 } 00228 00229 00230 int 00231 explain_parse_address_family_or_die(const char *text, const char *caption) 00232 { 00233 return explain_parse_bits_or_die(text, table, SIZEOF(table), caption); 00234 } 00235 00236 00237 /* vim: set ts=8 sw=4 et : */