libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2009-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/net/if_arp.h> 00020 00021 #include <libexplain/buffer/arpreq.h> 00022 #include <libexplain/buffer/pointer.h> 00023 #include <libexplain/buffer/sockaddr.h> 00024 #include <libexplain/parse_bits.h> 00025 #include <libexplain/is_efault.h> 00026 #include <libexplain/sizeof.h> 00027 00028 00029 static void 00030 explain_buffer_arpreq_flags(explain_string_buffer_t *sb, int data) 00031 { 00032 static const explain_parse_bits_table_t table[] = 00033 { 00034 #ifdef ATF_COM 00035 { "ATF_COM", ATF_COM }, 00036 #endif 00037 #ifdef ATF_PERM 00038 { "ATF_PERM", ATF_PERM }, 00039 #endif 00040 #ifdef ATF_PUBL 00041 { "ATF_PUBL", ATF_PUBL }, 00042 #endif 00043 #ifdef ATF_USETRAILERS 00044 { "ATF_USETRAILERS", ATF_USETRAILERS }, 00045 #endif 00046 #ifdef ATF_NETMASK 00047 { "ATF_NETMASK", ATF_NETMASK }, 00048 #endif 00049 #ifdef ATF_DONTPUB 00050 { "ATF_DONTPUB", ATF_DONTPUB }, 00051 #endif 00052 #ifdef ATF_MAGIC 00053 { "ATF_MAGIC", ATF_MAGIC }, 00054 #endif 00055 }; 00056 00057 explain_parse_bits_print(sb, data, table, SIZEOF(table)); 00058 } 00059 00060 00061 void 00062 explain_buffer_arpreq(explain_string_buffer_t *sb, 00063 const struct arpreq *data) 00064 { 00065 if (explain_is_efault_pointer(data, sizeof(*data))) 00066 explain_buffer_pointer(sb, data); 00067 else 00068 { 00069 explain_string_buffer_puts(sb, "{ arp_pa = "); 00070 explain_buffer_sockaddr(sb, &data->arp_pa, sizeof(data->arp_pa)); 00071 explain_string_buffer_puts(sb, ", arp_ha = "); 00072 explain_buffer_sockaddr(sb, &data->arp_ha, sizeof(data->arp_ha)); 00073 explain_string_buffer_puts(sb, ", arp_flags = "); 00074 explain_buffer_arpreq_flags(sb, data->arp_flags); 00075 #ifdef ATF_NETMASK 00076 explain_string_buffer_puts(sb, ", arp_netmask = "); 00077 explain_buffer_sockaddr 00078 ( 00079 sb, 00080 &data->arp_netmask, 00081 sizeof(data->arp_netmask) 00082 ); 00083 #endif 00084 explain_string_buffer_puts(sb, " }"); 00085 } 00086 } 00087 00088 00089 /* vim: set ts=8 sw=4 et : */