libexplain
1.4.D001
|
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 it 00006 * under the terms of the GNU Lesser General Public License as published by 00007 * the Free Software Foundation; either version 3 of the License, or (at your 00008 * option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, but WITHOUT 00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00013 * 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/net_tstamp.h> 00020 #include <libexplain/ac/net/if.h> 00021 00022 #include <libexplain/buffer/ifreq_data/hwtstamp_config.h> 00023 #include <libexplain/buffer/pointer.h> 00024 #include <libexplain/parse_bits.h> 00025 #include <libexplain/is_efault.h> 00026 00027 00028 void 00029 explain_buffer_ifreq_data_hwtstamp_config(explain_string_buffer_t *sb, 00030 const struct ifreq *data) 00031 { 00032 if (explain_is_efault_pointer(data, sizeof(*data))) 00033 { 00034 explain_buffer_pointer(sb, data); 00035 return; 00036 } 00037 00038 explain_string_buffer_puts(sb, "{ ifr_data = "); 00039 explain_buffer_hwtstamp_config 00040 ( 00041 sb, 00042 (const struct hwtstamp_config *)data->ifr_data 00043 ); 00044 explain_string_buffer_puts(sb, " }"); 00045 } 00046 00047 #ifdef HAVE_LINUX_NET_TSTAMP_H 00048 00049 static void 00050 explain_buffer_hwtstamp_config_flags(explain_string_buffer_t *sb, int value) 00051 { 00052 static const explain_parse_bits_table_t table[] = 00053 { 00054 { "SOF_TIMESTAMPING_TX_HARDWARE", SOF_TIMESTAMPING_TX_HARDWARE }, 00055 { "SOF_TIMESTAMPING_TX_SOFTWARE", SOF_TIMESTAMPING_TX_SOFTWARE }, 00056 { "SOF_TIMESTAMPING_RX_HARDWARE", SOF_TIMESTAMPING_RX_HARDWARE }, 00057 { "SOF_TIMESTAMPING_RX_SOFTWARE", SOF_TIMESTAMPING_RX_SOFTWARE }, 00058 { "SOF_TIMESTAMPING_SOFTWARE", SOF_TIMESTAMPING_SOFTWARE }, 00059 { "SOF_TIMESTAMPING_SYS_HARDWARE", SOF_TIMESTAMPING_SYS_HARDWARE }, 00060 { "SOF_TIMESTAMPING_RAW_HARDWARE", SOF_TIMESTAMPING_RAW_HARDWARE }, 00061 }; 00062 00063 explain_parse_bits_print(sb, value, table, SIZEOF(table)); 00064 } 00065 00066 00067 static void 00068 explain_buffer_hwtstamp_config_tx_type(explain_string_buffer_t *sb, int value) 00069 { 00070 static const explain_parse_bits_table_t table[] = 00071 { 00072 { "HWTSTAMP_TX_OFF", HWTSTAMP_TX_OFF }, 00073 { "HWTSTAMP_TX_ON", HWTSTAMP_TX_ON }, 00074 }; 00075 00076 explain_parse_bits_print_single(sb, value, table, SIZEOF(table)); 00077 } 00078 00079 00080 static void 00081 explain_buffer_hwtstamp_config_rx_filter(explain_string_buffer_t *sb, int value) 00082 { 00083 static const explain_parse_bits_table_t table[] = 00084 { 00085 { "HWTSTAMP_FILTER_NONE", HWTSTAMP_FILTER_NONE }, 00086 { "HWTSTAMP_FILTER_ALL", HWTSTAMP_FILTER_ALL }, 00087 { "HWTSTAMP_FILTER_SOME", HWTSTAMP_FILTER_SOME }, 00088 { "HWTSTAMP_FILTER_PTP_V1_L4_EVENT", HWTSTAMP_FILTER_PTP_V1_L4_EVENT }, 00089 { "HWTSTAMP_FILTER_PTP_V1_L4_SYNC", HWTSTAMP_FILTER_PTP_V1_L4_SYNC }, 00090 { "HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ", 00091 HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ }, 00092 { "HWTSTAMP_FILTER_PTP_V2_L4_EVENT", HWTSTAMP_FILTER_PTP_V2_L4_EVENT }, 00093 { "HWTSTAMP_FILTER_PTP_V2_L4_SYNC", HWTSTAMP_FILTER_PTP_V2_L4_SYNC }, 00094 { "HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ", 00095 HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ }, 00096 { "HWTSTAMP_FILTER_PTP_V2_L2_EVENT", HWTSTAMP_FILTER_PTP_V2_L2_EVENT }, 00097 { "HWTSTAMP_FILTER_PTP_V2_L2_SYNC", HWTSTAMP_FILTER_PTP_V2_L2_SYNC }, 00098 { "HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ", 00099 HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ }, 00100 { "HWTSTAMP_FILTER_PTP_V2_EVENT", HWTSTAMP_FILTER_PTP_V2_EVENT }, 00101 { "HWTSTAMP_FILTER_PTP_V2_SYNC", HWTSTAMP_FILTER_PTP_V2_SYNC }, 00102 { "HWTSTAMP_FILTER_PTP_V2_DELAY_REQ", 00103 HWTSTAMP_FILTER_PTP_V2_DELAY_REQ }, 00104 }; 00105 00106 explain_parse_bits_print_single(sb, value, table, SIZEOF(table)); 00107 } 00108 00109 00110 void 00111 explain_buffer_hwtstamp_config(explain_string_buffer_t *sb, 00112 const struct hwtstamp_config *data) 00113 { 00114 if (explain_is_efault_pointer(data, sizeof(*data))) 00115 { 00116 explain_buffer_pointer(sb, data); 00117 return; 00118 } 00119 00120 explain_string_buffer_puts(sb, "{ flags = "); 00121 explain_buffer_hwtstamp_config_flags(sb, data->flags); 00122 explain_string_buffer_puts(sb, ", tx_type = "); 00123 explain_buffer_hwtstamp_config_tx_type(sb, data->tx_type); 00124 explain_string_buffer_puts(sb, ", rx_filter = "); 00125 explain_buffer_hwtstamp_config_rx_filter(sb, data->rx_filter); 00126 explain_string_buffer_puts(sb, " }"); 00127 } 00128 00129 #else 00130 00131 void 00132 explain_buffer_hwtstamp_config(explain_string_buffer_t *sb, 00133 const struct hwtstamp_config *data) 00134 { 00135 explain_buffer_pointer(sb, data); 00136 } 00137 00138 #endif 00139 00140 00141 /* vim: set ts=8 sw=4 et : */