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."
00129 # define WP_ATTR_HELP_tmp "Use frame timestamp only."
00130 # define WP_ATTR_HELP_dst_tmp "Use dst. + timestamp."
00131 # define WP_ATTR_HELP_src_tmp "Use src. + timestamp."
00132 # define WP_ATTR_HELP_bss_tmp "Use BSSID + timestamp."
00133 # define WP_ATTR_HELP_src_bss_tmp "Use src. + BSSID + timestamp."
00134 # define WP_ATTR_HELP_seq_tmp "Use SeqCtl + timestamp."
00135 # define WP_ATTR_HELP_seq_bss_tmp "Use SeqCtl + BSSID + timestamp."
00136 # define WP_ATTR_HELP_seq_dst_bss_tmp "Use SeqCtl + dst. + BSSID + timestamp."
00137 # define WP_ATTR_HELP_seq_src_bss_tmp "Use SeqCtl + src. + BSSID + timestamp."
00138
00139
00140
00141
00142
00143
00144 # define WP_MAPPING_DEFAULT "mapping"
00145
00146 namespace tool
00147 {
00148
00149 namespace opt
00150 {
00151
00152 struct options
00153 {
00154 typedef std::vector<std::string> input_type;
00155 typedef std::vector<std::string> output_type;
00156 typedef std::set< std::pair<unsigned, unsigned> > ref_blacklist_type;
00157
00158 enum
00159 {
00160 no_input = 0,
00161 no_output = 0,
00162 arbitrary_number_of_inputs = 8,
00163 arbitrary_number_of_outputs = 8,
00164 };
00165
00166 enum comp_method
00167 {
00168 cmp_default,
00169 cmp_802,
00170 cmp_bytes,
00171 cmp_time
00172 };
00173
00174 input_type input;
00175 output_type output;
00176 std::string mapping;
00177 std::string attributes;
00178 endian::endianness endianness;
00179 ref_blacklist_type ref_blacklist;
00180 comp_method cmp;
00181 bool prism_noise_means_error;
00182 bool print_column_headers;
00183 bool print_errors;
00184 bool print_frame_indices;
00185 bool print_microseconds;
00186 bool print_summary;
00187 };
00188
00189 options parse_args(int argc, char* const* argv,
00190 const std::string& available_options,
00191 int ninputs, int noutputs);
00192
00193 template <class Fun>
00194 int
00195 dispatch_unique_id(const options& o, Fun f);
00196
00197 void
00198 unsupported_linktype(const pcapxx::descriptor<>::link_type lt);
00199
00200 }
00201
00202 }
00203
00204 # include "options.hxx"
00205
00206 #endif // TOOL_OPTIONS_HH_