00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef WSCOUT_GUI_IEEE802_11_HEADER_HXX_
00024 # define WSCOUT_GUI_IEEE802_11_HEADER_HXX_
00025
00026 # include <QtGui/QLabel>
00027 # include <boost/foreach.hpp>
00028
00029 # include <wipal/wifi/frame.hh>
00030
00031 # include "wscout_gui_ieee802_11_header.hh"
00032
00033 namespace wscout
00034 {
00035
00036 namespace gui
00037 {
00038
00039 inline
00040 void
00041 IEEE80211Header::setColor(const QColor fore, const QColor back)
00042 {
00043 QPalette p;
00044
00045 p.setColor(QPalette::WindowText, fore);
00046 p.setColor(QPalette::Window, back);
00047 setPalette(p);
00048 }
00049
00050 inline
00051 IEEE80211Header::ieee80211_hooks::ieee80211_hooks(IEEE80211Header& h):
00052 h_ (h)
00053 {
00054 }
00055
00056 inline
00057 void
00058 IEEE80211Header::ieee80211_hooks::frame_hook(const void*, size_t)
00059 {
00060 h_.duration.hide();
00061 h_.flags.hide();
00062 h_.seq_ctl.hide();
00063 BOOST_FOREACH(QLabel& l, h_.addr) l.hide();
00064 BOOST_FOREACH(QFrame& f, h_.addr_sep) f.hide();
00065 }
00066
00067 inline
00068 void
00069 IEEE80211Header::ieee80211_hooks::addr_hook(const void*, size_t,
00070 unsigned i,
00071 const wpl::wifi::addr& a)
00072 {
00073 h_.addr[i - 1].setText(make_string(a).c_str());
00074 h_.addr[i - 1].show();
00075 if (i - 1)
00076 h_.addr_sep[i - 2].show();
00077 }
00078
00079 inline
00080 void
00081 IEEE80211Header::ieee80211_hooks::seq_ctl_hook(const void*, size_t,
00082 unsigned fragnum,
00083 unsigned seqnum)
00084 {
00085 h_.seq_ctl.setText(tr("%1-%2").arg(fragnum).arg(seqnum));
00086 h_.seq_ctl.show();
00087 }
00088
00089 inline
00090 void
00091 IEEE80211Header::ieee80211_hooks::
00092 end_of_frame_headers_hook(const void*, size_t, const void* next_header)
00093 {
00094 h_.next.second = next_header;
00095 }
00096
00097 inline
00098 void
00099 IEEE80211Header::
00100 ieee80211_hooks::management_hook(const wpl::wifi::mgt::header* h, size_t)
00101 {
00102 using namespace protocol;
00103
00104 static const attributes subtypes[16] = {
00105 { "Assoc. request (MGT)", black, lightblue, IEEE802_11_ASS_REQ },
00106 { "Assoc. response (MGT)", black, lightblue, IEEE802_11_ASS_RESP },
00107 { "Reassoc. request (MGT)", black, lightblue, IEEE802_11_REASS_REQ },
00108 { "Reassoc. response (MGT)", black, lightblue, IEEE802_11_REASS_RESP },
00109 { "Probe request (MGT)", black, lightblue, IEEE802_11_PROBE_REQ },
00110 { "Probe response (MGT)", black, lightblue, IEEE802_11_PROBE_RESP },
00111 { "Invalid (MGT:6)", lightblue, red, UNKNOWN },
00112 { "Invalid (MGT:7)", lightblue, red, UNKNOWN },
00113 { "Beacon (MGT)", black, lightblue, IEEE802_11_BEACON },
00114 { "Ann. traffic indic. mess. (MGT)", black, lightblue, NONE },
00115 { "Disassoc. (MGT)", black, lightblue, IEEE802_11_DISASSOC },
00116 { "Auth. (MGT)", black, lightblue, IEEE802_11_AUTH },
00117 { "Deauth. (MGT)", black, lightblue, IEEE802_11_DEAUTH },
00118 { "Action (MGT)", black, lightblue, IEEE802_11_ACTION },
00119 { "Invalid (MGT:14)", lightblue, red, UNKNOWN },
00120 { "Invalid (MGT:15)", lightblue, red, UNKNOWN },
00121 };
00122
00123 const unsigned s = wpl::wifi::subtype_of(h);
00124 const bool p = wpl::wifi::control_flag(6, h);
00125 const protocol::id i = subtypes[s].next;
00126
00127 h_.next.first = i == UNKNOWN or i == NONE or not p ? i : ENCRYPTED;
00128 setDesc(subtypes[s]);
00129 setControl(h);
00130 }
00131
00132 inline
00133 void
00134 IEEE80211Header::ieee80211_hooks::control_hook(const void* h, size_t)
00135 {
00136 static const attributes subtypes[16] =
00137 {
00138 { "Invalid (CTL:0)", yellow, red, protocol::NONE },
00139 { "Invalid (CTL:1)", yellow, red, protocol::NONE },
00140 { "Invalid (CTL:2)", yellow, red, protocol::NONE },
00141 { "Invalid (CTL:3)", yellow, red, protocol::NONE},
00142 { "Invalid (CTL:4)", yellow, red, protocol::NONE },
00143 { "Invalid (CTL:5)", yellow, red, protocol::NONE },
00144 { "Invalid (CTL:6)", yellow, red, protocol::NONE },
00145 { "Invalid (CTL:7)", yellow, red, protocol::NONE },
00146 { "Block Ack. Req. (CTL)", black, yellow, protocol::NONE },
00147 { "Block Ack. (CTL)", black, yellow, protocol::NONE },
00148 { "PS-Poll (CTL)", black, yellow, protocol::NONE },
00149 { "RTS (CTL)", black, yellow, protocol::NONE },
00150 { "CTS (CTL)", black, yellow, protocol::NONE },
00151 { "Ack. (CTL)", black, yellow, protocol::NONE },
00152 { "CF-End (CTL)", black, yellow, protocol::NONE },
00153 { "CF-Ack (CTL)", black, yellow, protocol::NONE },
00154 };
00155
00156 const unsigned s = wpl::wifi::subtype_of(h);
00157
00158 h_.next.first = subtypes[s].next;
00159 setDesc(subtypes[s]);
00160 setControl(h);
00161 }
00162
00163 inline
00164 void
00165 IEEE80211Header::ieee80211_hooks::data_hook(const void* h, size_t)
00166 {
00167 using namespace protocol;
00168
00169 static const attributes subtypes[16] =
00170 {
00171 { "Data", black, lightgreen, LLC },
00172 { "Data + CF-Ack", black, lightgreen, LLC },
00173 { "Data + CF-Poll", black, lightgreen, LLC },
00174 { "Data + CF-Ack + CF-Poll", black, lightgreen, LLC },
00175 { "Null (no data)", black, lightgreen, NONE },
00176 { "CF-Ack (no data)", black, lightgreen, NONE },
00177 { "CF-Poll (no data)", black, lightgreen, NONE },
00178 { "CF-Ack + CF-Poll (no data)", black, lightgreen, NONE },
00179 { "QoS Data", black, lightgreen, LLC },
00180 { "QoS Data + CF-Ack", black, lightgreen, LLC },
00181 { "QoS Data + CF-Poll", black, lightgreen, LLC },
00182 { "QoS Data + CF-Ack + CF-Poll", black, lightgreen, LLC },
00183 { "QoS Null (no data)", black, lightgreen, NONE },
00184 { "Invalid (DATA:13)", lightgreen, red, UNKNOWN },
00185 { "QoS CF-Poll (no data)", black, lightgreen, NONE },
00186 { "QoS CF-Ack + CF-Poll (no data)", black, lightgreen, NONE },
00187 };
00188
00189 const unsigned s = wpl::wifi::subtype_of(h);
00190 const bool p = wpl::wifi::control_flag(6, h);
00191 const protocol::id i = subtypes[s].next;
00192
00193 h_.next.first = i == UNKNOWN or i == NONE or not p ? i : ENCRYPTED;
00194 setDesc(subtypes[s]);
00195 setControl(h);
00196 }
00197
00198 inline
00199 void
00200 IEEE80211Header::ieee80211_hooks::invalid_type_hook(const void* h, size_t)
00201 {
00202 const unsigned type = wpl::wifi::type_of(h);
00203 const unsigned subtype = wpl::wifi::subtype_of(h);
00204
00205 h_.setColor(white, red);
00206 h_.desc.setText(tr("Invalid frame type (%1:%2)").arg(type).arg(subtype));
00207 }
00208
00209 inline
00210 void
00211 IEEE80211Header::ieee80211_hooks::
00212 truncated_frame_hook(const void*, size_t,
00213 wpl::wifi::dissector_status::status s)
00214 {
00215 static const attributes truncated =
00216 { "Truncated frame", white, red, protocol::NONE };
00217
00218 if (s == wpl::wifi::dissector_status::invalid)
00219 setDesc(truncated);
00220 }
00221
00222 inline
00223 void
00224 IEEE80211Header::ieee80211_hooks::setDesc(const attributes& attr)
00225 {
00226 h_.setColor(attr.fore, attr.back);
00227 h_.desc.setText(tr(attr.desc.c_str()));
00228 }
00229
00230 inline
00231 void
00232 IEEE80211Header::ieee80211_hooks::setControl(const void* f)
00233 {
00234
00235 h_.duration.setText(tr("duration: %1").arg(wpl::wifi::duration_of(f)));
00236 h_.duration.show();
00237
00238
00239 {
00240 static const char set[] = "TFGRPDWO";
00241 char res[sizeof (set)];
00242
00243 for (size_t i = 0; i < sizeof (set) - 1; ++i)
00244 res[i] = wpl::wifi::control_flag(i, f) ? set[i] : '-';
00245 res[sizeof (set) - 1] = '\0';
00246 h_.flags.setText(res);
00247 h_.flags.show();
00248 }
00249 }
00250
00251 }
00252
00253 }
00254
00255 #endif // ! WSCOUT_GUI_IEEE802_11_HEADER_HXX_