00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TOOL_OPTIONS_HH_
00023 # define TOOL_OPTIONS_HH_
00024
00025 # include <vector>
00026 # include <string>
00027 # include <set>
00028 # include <utility>
00029
00030 # include <wipal/tool/endianness.hh>
00031 # include <wipal/pcap/descriptor.hh>
00032
00033
00034
00035
00036
00037
00038 # define WP_OPT_NONE ""
00039 # define WP_OPT_802CMP "8"
00040 # define WP_OPT_ATTR "a:"
00041 # define WP_OPT_BYTESCMP "b"
00042 # define WP_OPT_COLHEADS "cC"
00043 # define WP_OPT_DEFAULTCMP "d"
00044 # define WP_OPT_ERRS "eE"
00045 # define WP_OPT_HELP "h"
00046 # define WP_OPT_FRM_IDX "iI"
00047 # define WP_OPT_MAPPING "m:"
00048 # define WP_OPT_ENDIANNESS "nN"
00049 # define WP_OPT_PRISM_NOISE "pP"
00050 # define WP_OPT_QUIET "q"
00051 # define WP_OPT_IGNORE_REF "r:"
00052 # define WP_OPT_TIMECMP "t"
00053 # define WP_OPT_USEC "uU"
00054
00055
00056 # define WP_OPT_VERSION_ "v"
00057
00058 # define WP_OPT_LIST (802CMP)(ATTR)(BYTESCMP)(COLHEADS)(DEFAULTCMP) \
00059 (ERRS)(HELP)(FRM_IDX)(MAPPING)(ENDIANNESS) \
00060 (PRISM_NOISE)(QUIET)(IGNORE_REF)(TIMECMP)(USEC) \
00061 (VERSION_)
00062
00063 # define WP_HELP_STRING(L, M) " -" #L " " M "\n"
00064
00065 # define WP_HELP_802CMP \
00066 WP_HELP_STRING(8, "Only compare 802.11 frames (no PHY header, no PCAP).")
00067
00068 # define WP_HELP_ATTR \
00069 WP_HELP_STRING(a, "Attributes for unique frames identification " \
00070 "(default: " BOOST_PP_STRINGIZE(WP_DEFAULT_ATTRIBUTE) ").")
00071
00072 # define WP_HELP_BYTESCMP \
00073 WP_HELP_STRING(b, "Only compare frame bytes (no PCAP header).")
00074
00075 # define WP_HELP_COLHEADS \
00076 WP_HELP_STRING(c, "Do not print column headers " \
00077 "(default if output is not a tty).") \
00078 WP_HELP_STRING(C, "Print column headers (default if output is a tty).")
00079
00080 # define WP_HELP_DEFAULTCMP \
00081 WP_HELP_STRING(d, "Compare everything: PCAP data and bytes (default).")
00082
00083 # define WP_HELP_ERRS \
00084 WP_HELP_STRING(e, "Do not print error values (default).") \
00085 WP_HELP_STRING(E, "Print error values.")
00086
00087 # define WP_HELP_HELP \
00088 WP_HELP_STRING(h, "Print this help.")
00089
00090 # define WP_HELP_FRM_IDX \
00091 WP_HELP_STRING(i, "Do not print frame indices.") \
00092 WP_HELP_STRING(I, "Print frame indices (default).")
00093
00094 # define WP_HELP_MAPPING \
00095 WP_HELP_STRING(m, "MAC addresses mapping file " \
00096 "(default: " WP_MAPPING_DEFAULT ").")
00097
00098 # define WP_HELP_ENDIANNESS \
00099 WP_HELP_STRING(n, "Force little endian for PHY headers.") \
00100 WP_HELP_STRING(N, "Force big endian for PHY headers.")
00101
00102 # define WP_HELP_PRISM_NOISE \
00103 WP_HELP_STRING(p, "Prism noise fields have no special meaning (default).") \
00104 WP_HELP_STRING(P, "Consider a non-zero Prism noise field as a PHY error.")
00105
00106 # define WP_HELP_QUIET \
00107 WP_HELP_STRING(q, "Quiet ; produce minimal output (no column headers, etc.).")
00108
00109 # define WP_HELP_IGNORE_REF \
00110 WP_HELP_STRING(r, "Ignore reference. Blacklist a given x-y reference frame.")
00111
00112 # define WP_HELP_TIMECMP \
00113 WP_HELP_STRING(t, "Compare 802.11 frames and time of arrival. " \
00114 "Use a precision of 106us.")
00115
00116 # define WP_HELP_USEC \
00117 WP_HELP_STRING(u, "Do not print microseconds (default).") \
00118 WP_HELP_STRING(U, "Print microseconds.")
00119
00120 # define WP_HELP_VERSION_ \
00121 WP_HELP_STRING(v, "Print version information.")
00122
00123
00124
00125
00126
00127
00128 # define WP_ATTR_HELP_hsh "Hash frame using MD5 (16 bytes)."
00129 # define WP_ATTR_HELP_tmp "Use frame timestamp only (8 bytes)."
00130 # define WP_ATTR_HELP_dst_tmp "Use dst. + timestamp (12 bytes)."
00131 # define WP_ATTR_HELP_src_tmp "Use src. + timestamp (12 bytes)."
00132 # define WP_ATTR_HELP_bss_tmp "Use BSS + timestamp (12 bytes)."
00133 # define WP_ATTR_HELP_src_bss_tmp "Use src. + BSS + tmp. (16 bytes)."
00134 # define WP_ATTR_HELP_seq_tmp "Use SeqCtl + timestamp (10 bytes)."
00135 # define WP_ATTR_HELP_seq_bss_tmp "Use SC. + BSS + tmp. (14 bytes)."
00136 # define WP_ATTR_HELP_seq_dst_bss_tmp "Use SC. + dst. + BSS + tmp. " \
00137 "(18 bytes)."
00138 # define WP_ATTR_HELP_seq_src_bss_tmp "Use SC. + src. + BSS + tmp. " \
00139 "(18 bytes)."
00140
00141
00142
00143
00144
00145
00146 # define WP_MAPPING_DEFAULT "mapping"
00147
00148 namespace tool
00149 {
00150
00151 namespace opt
00152 {
00153
00154 struct options
00155 {
00156 typedef std::vector<std::string> input_type;
00157 typedef std::vector<std::string> output_type;
00158 typedef std::set< std::pair<unsigned, unsigned> > ref_blacklist_type;
00159
00160 enum
00161 {
00162 no_input = 0,
00163 no_output = 0,
00164 arbitrary_number_of_inputs = 8,
00165 arbitrary_number_of_outputs = 8,
00166 };
00167
00168 enum comp_method
00169 {
00170 cmp_default,
00171 cmp_802,
00172 cmp_bytes,
00173 cmp_time
00174 };
00175
00176 input_type input;
00177 output_type output;
00178 std::string mapping;
00179 std::string attributes;
00180 endian::endianness endianness;
00181 ref_blacklist_type ref_blacklist;
00182 comp_method cmp;
00183 bool prism_noise_means_error;
00184 bool print_column_headers;
00185 bool print_errors;
00186 bool print_frame_indices;
00187 bool print_microseconds;
00188 bool print_summary;
00189 };
00190
00191 options parse_args(int argc, char* const* argv,
00192 const std::string& available_options,
00193 int ninputs, int noutputs);
00194
00195 template <class Fun>
00196 int
00197 dispatch_unique_id(const options& o, Fun f);
00198
00199 void
00200 unsupported_linktype(const pcapxx::descriptor<>::link_type lt);
00201
00202 }
00203
00204 }
00205
00206 # include "options.hxx"
00207
00208 #endif // TOOL_OPTIONS_HH_