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_LLC_HEADER_HH_
00024 # define WSCOUT_GUI_LLC_HEADER_HH_
00025
00026 extern "C"
00027 {
00028 # include <inttypes.h>
00029 }
00030
00031 # include <QtGui/QLabel>
00032
00033 # include "wscout_gui_header_base.hh"
00034
00035 namespace wscout
00036 {
00037
00038 namespace gui
00039 {
00040
00046 struct LLCHeader: public HeaderBase<LLCHeader, protocol::LLC>
00047 {
00049 LLCHeader(QWidget* parent = 0);
00050
00052 virtual next_header setup(const void* header,
00053 size_t caplen,
00054 const Trace& trace,
00055 const pcapxx::frame_descriptor& desc);
00056
00057 private:
00058
00059 # define WSCOUT_PACKED_STRUCT struct __attribute__((packed))
00060
00061 WSCOUT_PACKED_STRUCT dsap_addr
00062 {
00063 enum individual_group
00064 {
00065 individual = 0,
00066 group = 1
00067 };
00068
00069 bool ig: 1;
00070 unsigned addr: 7;
00071 };
00072
00073
00074 WSCOUT_PACKED_STRUCT ssap_addr
00075 {
00076 enum command_response
00077 {
00078 command = 0,
00079 response = 1
00080 };
00081
00082 command_response cr: 1;
00083 unsigned addr: 7;
00084 };
00085
00086 WSCOUT_PACKED_STRUCT i_control
00087 {
00088 bool pf() const;
00089 unsigned snd_sn() const;
00090 unsigned rcv_sn() const;
00091
00092 private:
00093 unsigned head: 1;
00094 unsigned send_seqnum: 7;
00095 bool poll_final: 1;
00096 unsigned receive_seqnum: 7;
00097 };
00098
00099 WSCOUT_PACKED_STRUCT s_control
00100 {
00101 enum supervisory_function
00102 {
00103 receive_ready = 0,
00104 reject = 1,
00105 receive_not_ready = 2,
00106 invalid = 3
00107 };
00108
00109 supervisory_function sf() const;
00110 bool pf() const;
00111 unsigned rcv_sn() const;
00112
00113 private:
00114 unsigned head: 2;
00115 unsigned superv_func: 2;
00116 unsigned reserved: 4;
00117 bool poll_final: 1;
00118 unsigned receive_seqnum: 7;
00119 };
00120
00121 WSCOUT_PACKED_STRUCT u_control
00122 {
00123 enum command
00124 {
00125 UI = 0x00,
00126 DM = 0x03,
00127 DISC = 0x20,
00128 UA = 0x30,
00129 AC0 = 0x31,
00130 FRMR = 0x41,
00131 SABME = 0x33,
00132 XID = 0x53,
00133 TEST = 0x70,
00134 AC1 = 0x71
00135 };
00136
00137 command cmd() const;
00138 bool pf() const;
00139
00140 private:
00141 unsigned head: 2;
00142 unsigned m1: 2;
00143 bool poll_final: 1;
00144 unsigned m2: 3;
00145 };
00146
00147 template <class Control>
00148 WSCOUT_PACKED_STRUCT frame
00149 {
00150 dsap_addr dsap;
00151 ssap_addr ssap;
00152 Control ctl;
00153 uint8_t info[];
00154 };
00155
00156 typedef frame<i_control> i_frame;
00157 typedef frame<s_control> s_frame;
00158 typedef frame<u_control> u_frame;
00159
00160 # undef WSCOUT_PACKED_STRUCT
00161
00162 enum frame_format
00163 {
00164 information_transfer,
00165 supervisory,
00166 unnumbered,
00167 unknown
00168 };
00169
00170 static frame_format format(const void* f, size_t caplen);
00171 static unsigned as_byte(const dsap_addr& a);
00172 static unsigned as_byte(const ssap_addr& a);
00173
00174 template <class C>
00175 void
00176 setupDsapSsap(const frame<C>* header, size_t caplen);
00177
00178 template <class C>
00179 next_header
00180 setup(const frame<C>* header,
00181 size_t caplen,
00182 std::ostream& summary,
00183 std::ostream& control);
00184
00185 QLabel summary_;
00186 QLabel dsapSsap_;
00187 QLabel control_;
00188 };
00189
00190 }
00191
00192 }
00193
00194 # include "wscout_gui_llc_header.hxx"
00195
00196 #endif // ! WSCOUT_GUI_LLC_HEADER_HH_