summaryrefslogtreecommitdiff
path: root/libopie2/opienet
authorzecke <zecke>2004-03-13 19:51:45 (UTC)
committer zecke <zecke>2004-03-13 19:51:45 (UTC)
commit6d08277737e22b7a1527124623f3571969073ddf (patch) (unidiff)
tree4129e674e21df767b31299e873dd44e33a308e1b /libopie2/opienet
parent8e28911f7199f4450ac5eef09482069f9b9caea2 (diff)
downloadopie-6d08277737e22b7a1527124623f3571969073ddf.zip
opie-6d08277737e22b7a1527124623f3571969073ddf.tar.gz
opie-6d08277737e22b7a1527124623f3571969073ddf.tar.bz2
Move XML class to internal PIM
Add namespaces!!! Opie::Core and Opie::Core::Private Opie::Net and Opie::Net::Private Opie::Ui and Opie::Ui::Private Opie::MM and Opie::MM::Private Opie::DB and Opie::DB::Private PIM classes are not yet converted because we will do other work on it as well
Diffstat (limited to 'libopie2/opienet') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/802_11_user.h1
-rw-r--r--libopie2/opienet/dhcp.h2
-rw-r--r--libopie2/opienet/odebugmapper.cpp10
-rw-r--r--libopie2/opienet/odebugmapper.h10
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp7
-rw-r--r--libopie2/opienet/omanufacturerdb.h8
-rw-r--r--libopie2/opienet/onetutils.cpp9
-rw-r--r--libopie2/opienet/onetutils.h15
-rw-r--r--libopie2/opienet/onetwork.cpp9
-rw-r--r--libopie2/opienet/onetwork.h31
-rw-r--r--libopie2/opienet/opcap.cpp8
-rw-r--r--libopie2/opienet/opcap.h52
-rw-r--r--libopie2/opienet/ostation.cpp8
-rw-r--r--libopie2/opienet/ostation.h9
14 files changed, 176 insertions, 3 deletions
diff --git a/libopie2/opienet/802_11_user.h b/libopie2/opienet/802_11_user.h
index 7ae27c5..1a9a7a0 100644
--- a/libopie2/opienet/802_11_user.h
+++ b/libopie2/opienet/802_11_user.h
@@ -74,385 +74,386 @@ struct ieee_802_11_802_2_header {
74#define ETH_ALEN 6 74#define ETH_ALEN 6
75 75
76struct myarphdr 76struct myarphdr
77{ 77{
78 unsigned short int ar_hrd; /* Format of hardware address. */ 78 unsigned short int ar_hrd; /* Format of hardware address. */
79 unsigned short int ar_pro; /* Format of protocol address. */ 79 unsigned short int ar_pro; /* Format of protocol address. */
80 unsigned char ar_hln; /* Length of hardware address. */ 80 unsigned char ar_hln; /* Length of hardware address. */
81 unsigned char ar_pln; /* Length of protocol address. */ 81 unsigned char ar_pln; /* Length of protocol address. */
82 unsigned short int ar_op; /* ARP opcode (command). */ 82 unsigned short int ar_op; /* ARP opcode (command). */
83 /* Ethernet looks like this : This bit is variable sized 83 /* Ethernet looks like this : This bit is variable sized
84 however... */ 84 however... */
85 unsigned char ar_sha[ETH_ALEN]; /* Sender hardware address. */ 85 unsigned char ar_sha[ETH_ALEN]; /* Sender hardware address. */
86 unsigned char ar_sip[4]; /* Sender IP address. */ 86 unsigned char ar_sip[4]; /* Sender IP address. */
87 unsigned char ar_tha[ETH_ALEN]; /* Target hardware address. */ 87 unsigned char ar_tha[ETH_ALEN]; /* Target hardware address. */
88 unsigned char ar_tip[4]; /* Target IP address. */ 88 unsigned char ar_tip[4]; /* Target IP address. */
89}; 89};
90 90
91 91
92// following is incoplete and may be incorrect and need reorganization 92// following is incoplete and may be incorrect and need reorganization
93 93
94 #define ieee_802_11_frame_type_Management0x00 94 #define ieee_802_11_frame_type_Management0x00
95 #define ieee_802_11_frame_type_Control 0x01 95 #define ieee_802_11_frame_type_Control 0x01
96 #define ieee_802_11_frame_type_Data 0x10 96 #define ieee_802_11_frame_type_Data 0x10
97 #define ieee_802_11_frame_type_Reserved 0x11 97 #define ieee_802_11_frame_type_Reserved 0x11
98 98
99 #define ieee_802_11_frame_subtype_Association_Req0x0 // Association Request 99 #define ieee_802_11_frame_subtype_Association_Req0x0 // Association Request
100 #define ieee_802_11_frame_subtype_Association_Resp0x1 // Association Response 100 #define ieee_802_11_frame_subtype_Association_Resp0x1 // Association Response
101 #define ieee_802_11_frame_subtype_Reassociation_Req0x2 // Reassociation Request 101 #define ieee_802_11_frame_subtype_Reassociation_Req0x2 // Reassociation Request
102 #define ieee_802_11_frame_subtype_Reassociation_Resp0x3 // Reassociation Response 102 #define ieee_802_11_frame_subtype_Reassociation_Resp0x3 // Reassociation Response
103 #define ieee_802_11_frame_subtype_Probe_Req 0x4 // Probe Request 103 #define ieee_802_11_frame_subtype_Probe_Req 0x4 // Probe Request
104 #define ieee_802_11_frame_subtype_Probe_Resp 0x5 // Probe Response 104 #define ieee_802_11_frame_subtype_Probe_Resp 0x5 // Probe Response
105 #define ieee_802_11_frame_subtype_Beacon 0x8 // Beacon 105 #define ieee_802_11_frame_subtype_Beacon 0x8 // Beacon
106 #define ieee_802_11_frame_subtype_ATIM 0x9 // ATIM 106 #define ieee_802_11_frame_subtype_ATIM 0x9 // ATIM
107 #define ieee_802_11_frame_subtype_Disassociation 0xA // Disassociation 107 #define ieee_802_11_frame_subtype_Disassociation 0xA // Disassociation
108 #define ieee_802_11_frame_subtype_Authentication 0xB // Authentication 108 #define ieee_802_11_frame_subtype_Authentication 0xB // Authentication
109 #define ieee_802_11_frame_subtype_Deauthentication 0xC // Deauthentication 109 #define ieee_802_11_frame_subtype_Deauthentication 0xC // Deauthentication
110 #define ieee_802_11_frame_subtype_PS_Poll 0xA // PS-Poll 110 #define ieee_802_11_frame_subtype_PS_Poll 0xA // PS-Poll
111 #define ieee_802_11_frame_subtype_RTS 0xB // RTS 111 #define ieee_802_11_frame_subtype_RTS 0xB // RTS
112 #define ieee_802_11_frame_subtype_CTS 0xC // CTS 112 #define ieee_802_11_frame_subtype_CTS 0xC // CTS
113 #define ieee_802_11_frame_subtype_ACK 0xD // ACK 113 #define ieee_802_11_frame_subtype_ACK 0xD // ACK
114 #define ieee_802_11_frame_subtype_CFEnd 0xE // CF-End 114 #define ieee_802_11_frame_subtype_CFEnd 0xE // CF-End
115 #define ieee_802_11_frame_subtype_CFEnd_CFAck 0xF // CF-End + CF-Ack 115 #define ieee_802_11_frame_subtype_CFEnd_CFAck 0xF // CF-End + CF-Ack
116 #define ieee_802_11_frame_subtype_Data 0x0 // Data 116 #define ieee_802_11_frame_subtype_Data 0x0 // Data
117 #define ieee_802_11_frame_subtype_Data_CFAck 0x1 // Data + CF-Ack 117 #define ieee_802_11_frame_subtype_Data_CFAck 0x1 // Data + CF-Ack
118 #define ieee_802_11_frame_subtype_Data_CF_Poll 0x2 // Data + CF-Poll 118 #define ieee_802_11_frame_subtype_Data_CF_Poll 0x2 // Data + CF-Poll
119 #define ieee_802_11_frame_subtype_Data_CF_AckCF_Poll 0x3 // Data + CF-Ack + CF-Poll 119 #define ieee_802_11_frame_subtype_Data_CF_AckCF_Poll 0x3 // Data + CF-Ack + CF-Poll
120 #define ieee_802_11_frame_subtype_NullFunction 0x4 // Null Function (no data) 120 #define ieee_802_11_frame_subtype_NullFunction 0x4 // Null Function (no data)
121 #define ieee_802_11_frame_subtype_CF_Ack 0x5 // CF-Ack (no data) 121 #define ieee_802_11_frame_subtype_CF_Ack 0x5 // CF-Ack (no data)
122 #define ieee_802_11_frame_subtype_CF_Poll 0x6 // CF-Poll (no data) 122 #define ieee_802_11_frame_subtype_CF_Poll 0x6 // CF-Poll (no data)
123 #define ieee_802_11_frame_subtype_CF_AckCF_Poll 0x7 // CF-Ack + CF-Poll (no data) 123 #define ieee_802_11_frame_subtype_CF_AckCF_Poll 0x7 // CF-Ack + CF-Poll (no data)
124 124
125 125
126#define ieee_802_11_frame_subtype_strings {\ 126#define ieee_802_11_frame_subtype_strings {\
127 { ieee_802_11_frame_subtype_Association_Req,0xF,"f Association Request"},\ 127 { ieee_802_11_frame_subtype_Association_Req,0xF,"f Association Request"},\
128 { ieee_802_11_frame_subtype_Association_Resp,0xF,"1 Association Response"},\ 128 { ieee_802_11_frame_subtype_Association_Resp,0xF,"1 Association Response"},\
129 { ieee_802_11_frame_subtype_Reassociation_Req,0xF,"2 Reassociation Request"},\ 129 { ieee_802_11_frame_subtype_Reassociation_Req,0xF,"2 Reassociation Request"},\
130 { ieee_802_11_frame_subtype_Reassociation_Resp,0xF,"3 Reassociation Response"},\ 130 { ieee_802_11_frame_subtype_Reassociation_Resp,0xF,"3 Reassociation Response"},\
131 { ieee_802_11_frame_subtype_Probe_Req ,0xF,"4 Probe Request"},\ 131 { ieee_802_11_frame_subtype_Probe_Req ,0xF,"4 Probe Request"},\
132 { ieee_802_11_frame_subtype_Probe_Resp ,0xF,"5 Probe Response"},\ 132 { ieee_802_11_frame_subtype_Probe_Resp ,0xF,"5 Probe Response"},\
133 { ieee_802_11_frame_subtype_Beacon ,0xF,"8 Beacon"},\ 133 { ieee_802_11_frame_subtype_Beacon ,0xF,"8 Beacon"},\
134 { ieee_802_11_frame_subtype_ATIM ,0xF,"9 ATIM"},\ 134 { ieee_802_11_frame_subtype_ATIM ,0xF,"9 ATIM"},\
135 { ieee_802_11_frame_subtype_Disassociation,0xF,"A Disassociation"},\ 135 { ieee_802_11_frame_subtype_Disassociation,0xF,"A Disassociation"},\
136 { ieee_802_11_frame_subtype_Authentication,0xF,"B Authentication"},\ 136 { ieee_802_11_frame_subtype_Authentication,0xF,"B Authentication"},\
137 { ieee_802_11_frame_subtype_Deauthentication,0xF,"C Deauthentication"},\ 137 { ieee_802_11_frame_subtype_Deauthentication,0xF,"C Deauthentication"},\
138 { ieee_802_11_frame_subtype_PS_Poll ,0xF,"A PS-Poll"},\ 138 { ieee_802_11_frame_subtype_PS_Poll ,0xF,"A PS-Poll"},\
139 { ieee_802_11_frame_subtype_RTS ,0xF,"B RTS"},\ 139 { ieee_802_11_frame_subtype_RTS ,0xF,"B RTS"},\
140 { ieee_802_11_frame_subtype_CTS ,0xF,"C CTS"},\ 140 { ieee_802_11_frame_subtype_CTS ,0xF,"C CTS"},\
141 { ieee_802_11_frame_subtype_ACK ,0xF,"D ACK"},\ 141 { ieee_802_11_frame_subtype_ACK ,0xF,"D ACK"},\
142 { ieee_802_11_frame_subtype_CFEnd ,0xF,"E CF-End"},\ 142 { ieee_802_11_frame_subtype_CFEnd ,0xF,"E CF-End"},\
143 { ieee_802_11_frame_subtype_CFEnd_CFAck ,0xF,"F CF-End + CF-Ack"},\ 143 { ieee_802_11_frame_subtype_CFEnd_CFAck ,0xF,"F CF-End + CF-Ack"},\
144 { ieee_802_11_frame_subtype_Data ,0xF,"0 Data"},\ 144 { ieee_802_11_frame_subtype_Data ,0xF,"0 Data"},\
145 { ieee_802_11_frame_subtype_Data_CFAck ,0xF,"1 Data + CF-Ack"},\ 145 { ieee_802_11_frame_subtype_Data_CFAck ,0xF,"1 Data + CF-Ack"},\
146 { ieee_802_11_frame_subtype_Data_CFPoll ,0xF,"2 Data + CF-Poll"},\ 146 { ieee_802_11_frame_subtype_Data_CFPoll ,0xF,"2 Data + CF-Poll"},\
147 { ieee_802_11_frame_subtype_Data_CFAck_CFPoll,0xF,"3 Data + CF-Ack + CF-Poll"},\ 147 { ieee_802_11_frame_subtype_Data_CFAck_CFPoll,0xF,"3 Data + CF-Ack + CF-Poll"},\
148 { ieee_802_11_frame_subtype_Null_Function ,0xF,"4 Null Function (no data)"},\ 148 { ieee_802_11_frame_subtype_Null_Function ,0xF,"4 Null Function (no data)"},\
149 { ieee_802_11_frame_subtype_CFAck , 0xF,"5 CF-Ack (no data)"},\ 149 { ieee_802_11_frame_subtype_CFAck , 0xF,"5 CF-Ack (no data)"},\
150 { ieee_802_11_frame_subtype_CFPoll , 0xF,"6 CF-Poll (no data)"},\ 150 { ieee_802_11_frame_subtype_CFPoll , 0xF,"6 CF-Poll (no data)"},\
151 { ieee_802_11_frame_subtype_CFAck_CFPoll,0xF,"y7 CF-Ack + CF-Poll (no data)"},\ 151 { ieee_802_11_frame_subtype_CFAck_CFPoll,0xF,"y7 CF-Ack + CF-Poll (no data)"},\
152 { 0,0,NULL}\ 152 { 0,0,NULL}\
153} 153}
154struct ieee_802_11_frame_subtype_class { 154struct ieee_802_11_frame_subtype_class {
155 u_int8_tsubtype; 155 u_int8_tsubtype;
156 u_int8_tmask; 156 u_int8_tmask;
157 u_int8_tklass; 157 u_int8_tklass;
158 u_int8_ttype; 158 u_int8_ttype;
159}; 159};
160#define ieee_802_11_frame_subtype_classes {\ 160#define ieee_802_11_frame_subtype_classes {\
161 { ieee_802_11_frame_subtype_Association_Req,0xF,2,ieee_802_11_frame_type_Management},\ 161 { ieee_802_11_frame_subtype_Association_Req,0xF,2,ieee_802_11_frame_type_Management},\
162 { ieee_802_11_frame_subtype_Association_Resp,0xF,2,ieee_802_11_frame_type_Management},\ 162 { ieee_802_11_frame_subtype_Association_Resp,0xF,2,ieee_802_11_frame_type_Management},\
163 { ieee_802_11_frame_subtype_Reassociation_Req,0xF,2,ieee_802_11_frame_type_Management},\ 163 { ieee_802_11_frame_subtype_Reassociation_Req,0xF,2,ieee_802_11_frame_type_Management},\
164 { ieee_802_11_frame_subtype_Reassociation_Resp,0xF,2,ieee_802_11_frame_type_Management},\ 164 { ieee_802_11_frame_subtype_Reassociation_Resp,0xF,2,ieee_802_11_frame_type_Management},\
165 { ieee_802_11_frame_subtype_Probe_Req ,0xF,1,ieee_802_11_frame_type_Management},\ 165 { ieee_802_11_frame_subtype_Probe_Req ,0xF,1,ieee_802_11_frame_type_Management},\
166 { ieee_802_11_frame_subtype_Probe_Resp ,0xF,1,ieee_802_11_frame_type_Management},\ 166 { ieee_802_11_frame_subtype_Probe_Resp ,0xF,1,ieee_802_11_frame_type_Management},\
167 { ieee_802_11_frame_subtype_Beacon ,0xF,1,ieee_802_11_frame_type_Management},\ 167 { ieee_802_11_frame_subtype_Beacon ,0xF,1,ieee_802_11_frame_type_Management},\
168 { ieee_802_11_frame_subtype_ATIM ,0xF,1,ieee_802_11_frame_type_Management},\ 168 { ieee_802_11_frame_subtype_ATIM ,0xF,1,ieee_802_11_frame_type_Management},\
169 { ieee_802_11_frame_subtype_Disassociation,0xF,2,ieee_802_11_frame_type_Management},\ 169 { ieee_802_11_frame_subtype_Disassociation,0xF,2,ieee_802_11_frame_type_Management},\
170 { ieee_802_11_frame_subtype_Authentication,0xF,1,ieee_802_11_frame_type_Management},\ 170 { ieee_802_11_frame_subtype_Authentication,0xF,1,ieee_802_11_frame_type_Management},\
171 { ieee_802_11_frame_subtype_Deauthentication,0xF,3,ieee_802_11_frame_type_Management},\ 171 { ieee_802_11_frame_subtype_Deauthentication,0xF,3,ieee_802_11_frame_type_Management},\
172 { ieee_802_11_frame_subtype_PS-Poll ,0xF,3,ieee_802_11_frame_type_Control},\ 172 { ieee_802_11_frame_subtype_PS-Poll ,0xF,3,ieee_802_11_frame_type_Control},\
173 { ieee_802_11_frame_subtype_RTS ,0xF,1,ieee_802_11_frame_type_Control},\ 173 { ieee_802_11_frame_subtype_RTS ,0xF,1,ieee_802_11_frame_type_Control},\
174 { ieee_802_11_frame_subtype_CTS ,0xF,1,ieee_802_11_frame_type_Control},\ 174 { ieee_802_11_frame_subtype_CTS ,0xF,1,ieee_802_11_frame_type_Control},\
175 { ieee_802_11_frame_subtype_ACK ,0xF,1,ieee_802_11_frame_type_Control},\ 175 { ieee_802_11_frame_subtype_ACK ,0xF,1,ieee_802_11_frame_type_Control},\
176 { ieee_802_11_frame_subtype_CFEnd ,0xF,1,ieee_802_11_frame_type_Control},\ 176 { ieee_802_11_frame_subtype_CFEnd ,0xF,1,ieee_802_11_frame_type_Control},\
177 { ieee_802_11_frame_subtype_CFEnd_CFAck ,0xF,1,ieee_802_11_frame_type_Control},\ 177 { ieee_802_11_frame_subtype_CFEnd_CFAck ,0xF,1,ieee_802_11_frame_type_Control},\
178 { ieee_802_11_frame_subtype_Data ,0xF,3,ieee_802_11_frame_type_Data},\ 178 { ieee_802_11_frame_subtype_Data ,0xF,3,ieee_802_11_frame_type_Data},\
179 { ieee_802_11_frame_subtype_Data_CFAck ,0xF,3,ieee_802_11_frame_type_Data},\ 179 { ieee_802_11_frame_subtype_Data_CFAck ,0xF,3,ieee_802_11_frame_type_Data},\
180 { ieee_802_11_frame_subtype_Data_CF_Poll 0xF,3,ieee_802_11_frame_type_Data},\ 180 { ieee_802_11_frame_subtype_Data_CF_Poll 0xF,3,ieee_802_11_frame_type_Data},\
181 { ieee_802_11_frame_subtype_Data_CF_AckCF_Poll,0xF,3,ieee_802_11_frame_type_Data},\ 181 { ieee_802_11_frame_subtype_Data_CF_AckCF_Poll,0xF,3,ieee_802_11_frame_type_Data},\
182 { ieee_802_11_frame_subtype_NullFunction 0xF,1,ieee_802_11_frame_type_Data},\ 182 { ieee_802_11_frame_subtype_NullFunction 0xF,1,ieee_802_11_frame_type_Data},\
183 { ieee_802_11_frame_subtype_CF_Ack , 0xF,1,ieee_802_11_frame_type_Data},\ 183 { ieee_802_11_frame_subtype_CF_Ack , 0xF,1,ieee_802_11_frame_type_Data},\
184 { ieee_802_11_frame_subtype_CF_Poll , 0xF,1,ieee_802_11_frame_type_Data},\ 184 { ieee_802_11_frame_subtype_CF_Poll , 0xF,1,ieee_802_11_frame_type_Data},\
185 { ieee_802_11_frame_subtype_CF_AckCF_Poll,0xF,1,ieee_802_11_frame_type_Data},\ 185 { ieee_802_11_frame_subtype_CF_AckCF_Poll,0xF,1,ieee_802_11_frame_type_Data},\
186 { 0,0,NULL}\ 186 { 0,0,NULL}\
187} 187}
188 188
189 #define IEEE802_11_FC_LEN2 189 #define IEEE802_11_FC_LEN2
190 190
191#define T_MGMT 0x0 /* management */ 191#define T_MGMT 0x0 /* management */
192#define T_CTRL 0x1 /* control */ 192#define T_CTRL 0x1 /* control */
193#define T_DATA 0x2 /* data */ 193#define T_DATA 0x2 /* data */
194#define T_RESV 0x3 /* reserved */ 194#define T_RESV 0x3 /* reserved */
195 195
196 #define ST_ASSOC_REQUEST 0x0 196 #define ST_ASSOC_REQUEST 0x0
197 #define ST_ASSOC_RESPONSE 0x1 197 #define ST_ASSOC_RESPONSE 0x1
198 #define ST_REASSOC_REQUEST 0x2 198 #define ST_REASSOC_REQUEST 0x2
199 #define ST_REASSOC_RESPONSE 0x3 199 #define ST_REASSOC_RESPONSE 0x3
200 #define ST_PROBE_REQUEST 0x4 200 #define ST_PROBE_REQUEST 0x4
201 #define ST_PROBE_RESPONSE 0x5 201 #define ST_PROBE_RESPONSE 0x5
202 /* RESERVED 0x6 */ 202 /* RESERVED 0x6 */
203 /* RESERVED 0x7 */ 203 /* RESERVED 0x7 */
204 #define ST_BEACON 0x8 204 #define ST_BEACON 0x8
205 #define ST_ATIM 0x9 205 #define ST_ATIM 0x9
206 #define ST_DISASSOC 0xA 206 #define ST_DISASSOC 0xA
207 #define ST_AUTH 0xB 207 #define ST_AUTH 0xB
208 #define ST_DEAUTH 0xC 208 #define ST_DEAUTH 0xC
209 /* RESERVED 0xD */ 209 /* RESERVED 0xD */
210 /* RESERVED 0xE */ 210 /* RESERVED 0xE */
211 /* RESERVED 0xF */ 211 /* RESERVED 0xF */
212 212
213 213
214 #define CTRL_PS_POLL0xA 214 #define CTRL_PS_POLL0xA
215 #define CTRL_RTS0xB 215 #define CTRL_RTS0xB
216 #define CTRL_CTS0xC 216 #define CTRL_CTS0xC
217 #define CTRL_ACK0xD 217 #define CTRL_ACK0xD
218 #define CTRL_CF_END0xE 218 #define CTRL_CF_END0xE
219 #define CTRL_END_ACK0xF 219 #define CTRL_END_ACK0xF
220 220
221/* 221/*
222 * Bits in the frame control field. 222 * Bits in the frame control field.
223 */ 223 */
224 #define FC_VERSION(fc) ((fc) & 0x3) 224 #define FC_VERSION(fc) ((fc) & 0x3)
225 #define FC_TYPE(fc) (((fc) >> 2) & 0x3) 225 #define FC_TYPE(fc) (((fc) >> 2) & 0x3)
226 #define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF) 226 #define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF)
227 #define FC_TO_DS(fc) ((fc) & 0x0100) 227 #define FC_TO_DS(fc) ((fc) & 0x0100)
228 #define FC_FROM_DS(fc) ((fc) & 0x0200) 228 #define FC_FROM_DS(fc) ((fc) & 0x0200)
229 #define FC_MORE_FLAG(fc)((fc) & 0x0400) 229 #define FC_MORE_FLAG(fc)((fc) & 0x0400)
230 #define FC_RETRY(fc) ((fc) & 0x0800) 230 #define FC_RETRY(fc) ((fc) & 0x0800)
231 #define FC_POWER_MGMT(fc)((fc) & 0x1000) 231 #define FC_POWER_MGMT(fc)((fc) & 0x1000)
232 #define FC_MORE_DATA(fc)((fc) & 0x2000) 232 #define FC_MORE_DATA(fc)((fc) & 0x2000)
233 #define FC_WEP(fc) ((fc) & 0x4000) 233 #define FC_WEP(fc) ((fc) & 0x4000)
234 #define FC_ORDER(fc) ((fc) & 0x8000) 234 #define FC_ORDER(fc) ((fc) & 0x8000)
235 235
236 236
237struct ieee_802_11_mgmt_header { 237struct ieee_802_11_mgmt_header {
238 u_int16_t fc; 238 u_int16_t fc;
239 u_int16_t duration; 239 u_int16_t duration;
240 u_int8_t da[6]; 240 u_int8_t da[6];
241 u_int8_t sa[6]; 241 u_int8_t sa[6];
242 u_int8_t bssid[6]; 242 u_int8_t bssid[6];
243 u_int16_t seq_ctrl; 243 u_int16_t seq_ctrl;
244}; 244};
245 245
246 246
247struct ieee_802_11_data_header { 247struct ieee_802_11_data_header {
248 u_int16_tfc; 248 u_int16_tfc;
249 u_int16_tduration; 249 u_int16_tduration;
250 u_int8_tmac1[6]; 250 u_int8_tmac1[6];
251 u_int8_tmac2[6]; 251 u_int8_tmac2[6];
252 u_int8_tmac3[6]; 252 u_int8_tmac3[6];
253 u_int16_tSeqCtl; 253 u_int16_tSeqCtl;
254 u_int8_tmac4[6]; 254 u_int8_tmac4[6];
255 // u_int16_tgapLen; 255 // u_int16_tgapLen;
256 // u_int8_tgap[8]; 256 // u_int8_tgap[8];
257}; 257};
258 258
259struct ieee_802_11_control_header { 259struct ieee_802_11_control_header {
260 u_int16_tfc; 260 u_int16_tfc;
261 u_int16_tduration; 261 u_int16_tduration;
262 u_int8_tmac1[6]; 262 u_int8_tmac1[6];
263 u_int8_tmac2[6]; 263 u_int8_tmac2[6];
264 u_int8_tmac3[6]; 264 u_int8_tmac3[6];
265 u_int16_tSeqCtl; 265 u_int16_tSeqCtl;
266 u_int8_tmac4[6]; 266 u_int8_tmac4[6];
267 // u_int16_tgapLen; 267 // u_int16_tgapLen;
268 // u_int8_tgap[8]; 268 // u_int8_tgap[8];
269}; 269};
270 270
271#define CAPABILITY_ESS(cap) ((cap) & 0x0001) 271#define CAPABILITY_ESS(cap) ((cap) & 0x0001)
272#define CAPABILITY_IBSS(cap) ((cap) & 0x0002) 272#define CAPABILITY_IBSS(cap) ((cap) & 0x0002)
273#define CAPABILITY_CFP(cap) ((cap) & 0x0004) 273#define CAPABILITY_CFP(cap) ((cap) & 0x0004)
274#define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008) 274#define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
275#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010) 275#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
276 276
277struct ssid_t { 277struct ssid_t {
278 u_int8_telement_id; 278 u_int8_telement_id;
279 u_int8_tlength; 279 u_int8_tlength;
280 u_char ssid[33]; /* 32 + 1 for null */ 280 u_char ssid[33]; /* 32 + 1 for null */
281}; 281};
282 282
283 283
284struct rates_t { 284struct rates_t {
285 u_int8_telement_id; 285 u_int8_telement_id;
286 u_int8_tlength; 286 u_int8_tlength;
287 u_int8_trate[8]; 287 u_int8_trate[8];
288}; 288};
289 289
290 290
291struct challenge_t { 291struct challenge_t {
292 u_int8_telement_id; 292 u_int8_telement_id;
293 u_int8_tlength; 293 u_int8_tlength;
294 u_int8_ttext[254]; /* 1-253 + 1 for null */ 294 u_int8_ttext[254]; /* 1-253 + 1 for null */
295}; 295};
296 296
297 297
298struct fh_t { 298struct fh_t {
299 u_int8_telement_id; 299 u_int8_telement_id;
300 u_int8_tlength; 300 u_int8_tlength;
301 u_int16_tdwell_time; 301 u_int16_tdwell_time;
302 u_int8_thop_set; 302 u_int8_thop_set;
303 u_int8_t hop_pattern; 303 u_int8_t hop_pattern;
304 u_int8_thop_index; 304 u_int8_thop_index;
305}; 305};
306 306
307 307
308struct ds_t { 308struct ds_t {
309 u_int8_telement_id; 309 u_int8_telement_id;
310 u_int8_tlength; 310 u_int8_tlength;
311 u_int8_tchannel; 311 u_int8_tchannel;
312}; 312};
313 313
314 314
315struct cf_t { 315struct cf_t {
316 u_int8_telement_id; 316 u_int8_telement_id;
317 u_int8_tlength; 317 u_int8_tlength;
318 u_int8_tcount; 318 u_int8_tcount;
319 u_int8_tperiod; 319 u_int8_tperiod;
320 u_int16_tmax_duration; 320 u_int16_tmax_duration;
321 u_int16_tdur_remaing; 321 u_int16_tdur_remaing;
322}; 322};
323 323
324 324
325struct tim_t { 325struct tim_t {
326 u_int8_telement_id; 326 u_int8_telement_id;
327 u_int8_tlength; 327 u_int8_tlength;
328 u_int8_tcount; 328 u_int8_tcount;
329 u_int8_tperiod; 329 u_int8_tperiod;
330 u_int8_tbitmap_control; 330 u_int8_tbitmap_control;
331 u_int8_tbitmap[251]; 331 u_int8_tbitmap[251];
332}; 332};
333 333
334 334
335struct ibss_t { 335struct ibss_t {
336 u_int8_telement_id; 336 u_int8_telement_id;
337 u_int8_tlength; 337 u_int8_tlength;
338 u_int16_tatim_window; 338 u_int16_tatim_window;
339}; 339};
340 340
341 341
342#define E_SSID 0 342#define E_SSID 0
343#define E_RATES 1 343#define E_RATES 1
344#define E_FH 2 344#define E_FH 2
345#define E_DS 3 345#define E_DS 3
346#define E_CF 4 346#define E_CF 4
347#define E_TIM 5 347#define E_TIM 5
348#define E_IBSS 6 348#define E_IBSS 6
349#define E_CHALLENGE 16 349#define E_CHALLENGE 16
350#define E_CISCO 133 350#define E_CISCO 133
351 351
352 352
353struct ieee_802_11_mgmt_body { 353struct ieee_802_11_mgmt_body {
354 u_int8_t timestamp[8]; 354 u_int8_t timestamp[8];
355 u_int16_t beacon_interval; 355 u_int16_t beacon_interval;
356 // u_int16_t listen_interval; 356 // u_int16_t listen_interval;
357 // u_int16_t status_code; 357 // u_int16_t status_code;
358 // u_int16_t aid; 358 // u_int16_t aid;
359 // u_char ap[6]; 359 // u_char ap[6];
360 // u_int16_treason_code; 360 // u_int16_treason_code;
361 // u_int16_tauth_alg; 361 // u_int16_tauth_alg;
362 // u_int16_tauth_trans_seq_num; 362 // u_int16_tauth_trans_seq_num;
363// struct challenge_t challenge; 363// struct challenge_t challenge;
364 u_int16_t capability_info; 364 u_int16_t capability_info;
365 // struct ssid_tssid; 365 // struct ssid_tssid;
366 // struct rates_t rates; 366 // struct rates_t rates;
367 // struct ds_tds; 367 // struct ds_tds;
368 // struct cf_tcf; 368 // struct cf_tcf;
369 // struct fh_tfh; 369 // struct fh_tfh;
370 // struct tim_ttim; 370 // struct tim_ttim;
371}; 371};
372 372
373/* a 802.11 value */ 373/* a 802.11 value */
374struct val_80211 { 374struct val_80211 {
375 unsigned int did; 375 unsigned int did;
376 unsigned short status, len; 376 unsigned short status, len;
377 unsigned int data; 377 unsigned int data;
378}; 378};
379 379
380/* header attached during prism monitor mode */ 380/* header attached during prism monitor mode */
381struct prism_hdr { 381struct prism_hdr {
382 unsigned int msgcode, msglen; 382 unsigned int msgcode, msglen;
383 char devname[16]; 383 char devname[16];
384 struct val_80211 hosttime, mactime, channel, rssi, sq, signal, 384 struct val_80211 hosttime, mactime, channel, rssi, sq, signal,
385 noise, rate, istx, frmlen; 385 noise, rate, istx, frmlen;
386}; 386};
387 387
388struct ieee_802_11_data_body { 388struct ieee_802_11_data_body {
389//FIXME 389//FIXME
390}; 390};
391 391
392struct ieee_802_11_control_body { 392struct ieee_802_11_control_body {
393//FIXME 393//FIXME
394}; 394};
395 395
396struct ctrl_rts_t { 396struct ctrl_rts_t {
397 u_int16_tfc; 397 u_int16_tfc;
398 u_int16_tduration; 398 u_int16_tduration;
399 u_int8_tra[6]; 399 u_int8_tra[6];
400 u_int8_tta[6]; 400 u_int8_tta[6];
401 u_int8_tfcs[4]; 401 u_int8_tfcs[4];
402}; 402};
403 403
404 #define CTRL_RTS_LEN(2+2+6+6+4) 404 #define CTRL_RTS_LEN(2+2+6+6+4)
405 405
406struct ctrl_cts_t { 406struct ctrl_cts_t {
407 u_int16_tfc; 407 u_int16_tfc;
408 u_int16_tduration; 408 u_int16_tduration;
409 u_int8_tra[6]; 409 u_int8_tra[6];
410 u_int8_tfcs[4]; 410 u_int8_tfcs[4];
411}; 411};
412 412
413 #define CTRL_CTS_LEN(2+2+6+4) 413 #define CTRL_CTS_LEN(2+2+6+4)
414 414
415struct ctrl_ack_t { 415struct ctrl_ack_t {
416 u_int16_tfc; 416 u_int16_tfc;
417 u_int16_tduration; 417 u_int16_tduration;
418 u_int8_tra[6]; 418 u_int8_tra[6];
419 u_int8_tfcs[4]; 419 u_int8_tfcs[4];
420}; 420};
421 421
422 #define CTRL_ACK_LEN(2+2+6+4) 422 #define CTRL_ACK_LEN(2+2+6+4)
423 423
424struct ctrl_ps_poll_t { 424struct ctrl_ps_poll_t {
425 u_int16_tfc; 425 u_int16_tfc;
426 u_int16_taid; 426 u_int16_taid;
427 u_int8_tbssid[6]; 427 u_int8_tbssid[6];
428 u_int8_tta[6]; 428 u_int8_tta[6];
429 u_int8_tfcs[4]; 429 u_int8_tfcs[4];
430}; 430};
431 431
432 #define CTRL_PS_POLL_LEN(2+2+6+6+4) 432 #define CTRL_PS_POLL_LEN(2+2+6+6+4)
433 433
434struct ctrl_end_t { 434struct ctrl_end_t {
435 u_int16_tfc; 435 u_int16_tfc;
436 u_int16_tduration; 436 u_int16_tduration;
437 u_int8_tra[6]; 437 u_int8_tra[6];
438 u_int8_tbssid[6]; 438 u_int8_tbssid[6];
439 u_int8_tfcs[4]; 439 u_int8_tfcs[4];
440}; 440};
441 441
442 #define CTRL_END_LEN(2+2+6+6+4) 442 #define CTRL_END_LEN(2+2+6+6+4)
443 443
444struct ctrl_end_ack_t { 444struct ctrl_end_ack_t {
445 u_int16_tfc; 445 u_int16_tfc;
446 u_int16_tduration; 446 u_int16_tduration;
447 u_int8_tra[6]; 447 u_int8_tra[6];
448 u_int8_tbssid[6]; 448 u_int8_tbssid[6];
449 u_int8_tfcs[4]; 449 u_int8_tfcs[4];
450}; 450};
451 451
452 #define CTRL_END_ACK_LEN(2+2+6+6+4) 452 #define CTRL_END_ACK_LEN(2+2+6+6+4)
453 453
454 #define IV_IV(iv)((iv) & 0xFFFFFF) 454 #define IV_IV(iv)((iv) & 0xFFFFFF)
455 #define IV_PAD(iv)(((iv) >> 24) & 0x3F) 455 #define IV_PAD(iv)(((iv) >> 24) & 0x3F)
456 #define IV_KEYID(iv)(((iv) >> 30) & 0x03) 456 #define IV_KEYID(iv)(((iv) >> 30) & 0x03)
457 457
458
458#endif 459#endif
diff --git a/libopie2/opienet/dhcp.h b/libopie2/opienet/dhcp.h
index 368e375..6ba4c53 100644
--- a/libopie2/opienet/dhcp.h
+++ b/libopie2/opienet/dhcp.h
@@ -1,201 +1,203 @@
1/* dhcp.h 1/* dhcp.h
2 2
3 Protocol structures... */ 3 Protocol structures... */
4 4
5/* 5/*
6 * Copyright (c) 1995-2001 The Internet Software Consortium. 6 * Copyright (c) 1995-2001 The Internet Software Consortium.
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 12 *
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of The Internet Software Consortium nor the names 18 * 3. Neither the name of The Internet Software Consortium nor the names
19 * of its contributors may be used to endorse or promote products derived 19 * of its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission. 20 * from this software without specific prior written permission.
21 * 21 *
22 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND 22 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
23 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 23 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR 26 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * This software has been written for the Internet Software Consortium 36 * This software has been written for the Internet Software Consortium
37 * by Ted Lemon in cooperation with Vixie Enterprises. To learn more 37 * by Ted Lemon in cooperation with Vixie Enterprises. To learn more
38 * about the Internet Software Consortium, see ``http://www.isc.org''. 38 * about the Internet Software Consortium, see ``http://www.isc.org''.
39 * To learn more about Vixie Enterprises, see ``http://www.vix.com''. 39 * To learn more about Vixie Enterprises, see ``http://www.vix.com''.
40 */ 40 */
41 41
42#ifndef DHCP_H 42#ifndef DHCP_H
43#define DHCP_H 43#define DHCP_H
44 44
45
45 #define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \ 46 #define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \
46 20 + /* IP header */ \ 47 20 + /* IP header */ \
47 8) /* UDP header */ 48 8) /* UDP header */
48 #define DHCP_SNAME_LEN 64 49 #define DHCP_SNAME_LEN 64
49 #define DHCP_FILE_LEN 128 50 #define DHCP_FILE_LEN 128
50 #define DHCP_FIXED_NON_UDP236 51 #define DHCP_FIXED_NON_UDP236
51 #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD) 52 #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD)
52 /* Everything but options. */ 53 /* Everything but options. */
53 #define DHCP_MTU_MAX 1500 54 #define DHCP_MTU_MAX 1500
54 #define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN) 55 #define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN)
55 56
56 #define BOOTP_MIN_LEN 300 57 #define BOOTP_MIN_LEN 300
57#define DHCP_MIN_LEN 548 58#define DHCP_MIN_LEN 548
58 59
59struct dhcp_packet { 60struct dhcp_packet {
60 u_int8_t op; /* 0: Message opcode/type */ 61 u_int8_t op; /* 0: Message opcode/type */
61 u_int8_t htype;/* 1: Hardware addr type (net/if_types.h) */ 62 u_int8_t htype;/* 1: Hardware addr type (net/if_types.h) */
62 u_int8_t hlen; /* 2: Hardware addr length */ 63 u_int8_t hlen; /* 2: Hardware addr length */
63 u_int8_t hops; /* 3: Number of relay agent hops from client */ 64 u_int8_t hops; /* 3: Number of relay agent hops from client */
64 u_int32_t xid; /* 4: Transaction ID */ 65 u_int32_t xid; /* 4: Transaction ID */
65 u_int16_t secs; /* 8: Seconds since client started looking */ 66 u_int16_t secs; /* 8: Seconds since client started looking */
66 u_int16_t flags;/* 10: Flag bits */ 67 u_int16_t flags;/* 10: Flag bits */
67 struct in_addr ciaddr;/* 12: Client IP address (if already in use) */ 68 struct in_addr ciaddr;/* 12: Client IP address (if already in use) */
68 struct in_addr yiaddr;/* 16: Client IP address */ 69 struct in_addr yiaddr;/* 16: Client IP address */
69 struct in_addr siaddr;/* 18: IP address of next server to talk to */ 70 struct in_addr siaddr;/* 18: IP address of next server to talk to */
70 struct in_addr giaddr;/* 20: DHCP relay agent IP address */ 71 struct in_addr giaddr;/* 20: DHCP relay agent IP address */
71 unsigned char chaddr [16];/* 24: Client hardware address */ 72 unsigned char chaddr [16];/* 24: Client hardware address */
72 char sname [DHCP_SNAME_LEN];/* 40: Server name */ 73 char sname [DHCP_SNAME_LEN];/* 40: Server name */
73 char file [DHCP_FILE_LEN];/* 104: Boot filename */ 74 char file [DHCP_FILE_LEN];/* 104: Boot filename */
74 unsigned char options [DHCP_OPTION_LEN]; 75 unsigned char options [DHCP_OPTION_LEN];
75 /* 212: Optional parameters 76 /* 212: Optional parameters
76 (actual length dependent on MTU). */ 77 (actual length dependent on MTU). */
77}; 78};
78 79
79/* BOOTP (rfc951) message types */ 80/* BOOTP (rfc951) message types */
80 #define BOOTREQUEST1 81 #define BOOTREQUEST1
81 #define BOOTREPLY2 82 #define BOOTREPLY2
82 83
83/* Possible values for flags field... */ 84/* Possible values for flags field... */
84#define BOOTP_BROADCAST 32768L 85#define BOOTP_BROADCAST 32768L
85 86
86/* Possible values for hardware type (htype) field... */ 87/* Possible values for hardware type (htype) field... */
87 #define HTYPE_ETHER1 /* Ethernet 10Mbps */ 88 #define HTYPE_ETHER1 /* Ethernet 10Mbps */
88 #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring...*/ 89 #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring...*/
89 #define HTYPE_FDDI 8 /* FDDI... */ 90 #define HTYPE_FDDI 8 /* FDDI... */
90 91
91/* Magic cookie validating dhcp options field (and bootp vendor 92/* Magic cookie validating dhcp options field (and bootp vendor
92 extensions field). */ 93 extensions field). */
93 #define DHCP_OPTIONS_COOKIE"\143\202\123\143" 94 #define DHCP_OPTIONS_COOKIE"\143\202\123\143"
94 95
95/* DHCP Option codes: */ 96/* DHCP Option codes: */
96 97
97 #define DHO_PAD 0 98 #define DHO_PAD 0
98 #define DHO_SUBNET_MASK 1 99 #define DHO_SUBNET_MASK 1
99 #define DHO_TIME_OFFSET 2 100 #define DHO_TIME_OFFSET 2
100 #define DHO_ROUTERS 3 101 #define DHO_ROUTERS 3
101 #define DHO_TIME_SERVERS 4 102 #define DHO_TIME_SERVERS 4
102 #define DHO_NAME_SERVERS 5 103 #define DHO_NAME_SERVERS 5
103 #define DHO_DOMAIN_NAME_SERVERS 6 104 #define DHO_DOMAIN_NAME_SERVERS 6
104 #define DHO_LOG_SERVERS 7 105 #define DHO_LOG_SERVERS 7
105 #define DHO_COOKIE_SERVERS 8 106 #define DHO_COOKIE_SERVERS 8
106 #define DHO_LPR_SERVERS 9 107 #define DHO_LPR_SERVERS 9
107 #define DHO_IMPRESS_SERVERS 10 108 #define DHO_IMPRESS_SERVERS 10
108 #define DHO_RESOURCE_LOCATION_SERVERS11 109 #define DHO_RESOURCE_LOCATION_SERVERS11
109 #define DHO_HOST_NAME 12 110 #define DHO_HOST_NAME 12
110 #define DHO_BOOT_SIZE 13 111 #define DHO_BOOT_SIZE 13
111 #define DHO_MERIT_DUMP 14 112 #define DHO_MERIT_DUMP 14
112 #define DHO_DOMAIN_NAME 15 113 #define DHO_DOMAIN_NAME 15
113 #define DHO_SWAP_SERVER 16 114 #define DHO_SWAP_SERVER 16
114 #define DHO_ROOT_PATH 17 115 #define DHO_ROOT_PATH 17
115 #define DHO_EXTENSIONS_PATH 18 116 #define DHO_EXTENSIONS_PATH 18
116 #define DHO_IP_FORWARDING 19 117 #define DHO_IP_FORWARDING 19
117 #define DHO_NON_LOCAL_SOURCE_ROUTING20 118 #define DHO_NON_LOCAL_SOURCE_ROUTING20
118 #define DHO_POLICY_FILTER 21 119 #define DHO_POLICY_FILTER 21
119 #define DHO_MAX_DGRAM_REASSEMBLY22 120 #define DHO_MAX_DGRAM_REASSEMBLY22
120 #define DHO_DEFAULT_IP_TTL 23 121 #define DHO_DEFAULT_IP_TTL 23
121 #define DHO_PATH_MTU_AGING_TIMEOUT24 122 #define DHO_PATH_MTU_AGING_TIMEOUT24
122 #define DHO_PATH_MTU_PLATEAU_TABLE25 123 #define DHO_PATH_MTU_PLATEAU_TABLE25
123 #define DHO_INTERFACE_MTU 26 124 #define DHO_INTERFACE_MTU 26
124 #define DHO_ALL_SUBNETS_LOCAL 27 125 #define DHO_ALL_SUBNETS_LOCAL 27
125 #define DHO_BROADCAST_ADDRESS 28 126 #define DHO_BROADCAST_ADDRESS 28
126 #define DHO_PERFORM_MASK_DISCOVERY29 127 #define DHO_PERFORM_MASK_DISCOVERY29
127 #define DHO_MASK_SUPPLIER 30 128 #define DHO_MASK_SUPPLIER 30
128 #define DHO_ROUTER_DISCOVERY 31 129 #define DHO_ROUTER_DISCOVERY 31
129 #define DHO_ROUTER_SOLICITATION_ADDRESS32 130 #define DHO_ROUTER_SOLICITATION_ADDRESS32
130 #define DHO_STATIC_ROUTES 33 131 #define DHO_STATIC_ROUTES 33
131 #define DHO_TRAILER_ENCAPSULATION34 132 #define DHO_TRAILER_ENCAPSULATION34
132 #define DHO_ARP_CACHE_TIMEOUT 35 133 #define DHO_ARP_CACHE_TIMEOUT 35
133 #define DHO_IEEE802_3_ENCAPSULATION36 134 #define DHO_IEEE802_3_ENCAPSULATION36
134 #define DHO_DEFAULT_TCP_TTL 37 135 #define DHO_DEFAULT_TCP_TTL 37
135 #define DHO_TCP_KEEPALIVE_INTERVAL38 136 #define DHO_TCP_KEEPALIVE_INTERVAL38
136 #define DHO_TCP_KEEPALIVE_GARBAGE39 137 #define DHO_TCP_KEEPALIVE_GARBAGE39
137 #define DHO_NIS_DOMAIN 40 138 #define DHO_NIS_DOMAIN 40
138 #define DHO_NIS_SERVERS 41 139 #define DHO_NIS_SERVERS 41
139 #define DHO_NTP_SERVERS 42 140 #define DHO_NTP_SERVERS 42
140 #define DHO_VENDOR_ENCAPSULATED_OPTIONS43 141 #define DHO_VENDOR_ENCAPSULATED_OPTIONS43
141 #define DHO_NETBIOS_NAME_SERVERS44 142 #define DHO_NETBIOS_NAME_SERVERS44
142 #define DHO_NETBIOS_DD_SERVER 45 143 #define DHO_NETBIOS_DD_SERVER 45
143 #define DHO_NETBIOS_NODE_TYPE 46 144 #define DHO_NETBIOS_NODE_TYPE 46
144 #define DHO_NETBIOS_SCOPE 47 145 #define DHO_NETBIOS_SCOPE 47
145 #define DHO_FONT_SERVERS 48 146 #define DHO_FONT_SERVERS 48
146 #define DHO_X_DISPLAY_MANAGER 49 147 #define DHO_X_DISPLAY_MANAGER 49
147 #define DHO_DHCP_REQUESTED_ADDRESS50 148 #define DHO_DHCP_REQUESTED_ADDRESS50
148 #define DHO_DHCP_LEASE_TIME 51 149 #define DHO_DHCP_LEASE_TIME 51
149 #define DHO_DHCP_OPTION_OVERLOAD52 150 #define DHO_DHCP_OPTION_OVERLOAD52
150 #define DHO_DHCP_MESSAGE_TYPE 53 151 #define DHO_DHCP_MESSAGE_TYPE 53
151 #define DHO_DHCP_SERVER_IDENTIFIER54 152 #define DHO_DHCP_SERVER_IDENTIFIER54
152 #define DHO_DHCP_PARAMETER_REQUEST_LIST55 153 #define DHO_DHCP_PARAMETER_REQUEST_LIST55
153 #define DHO_DHCP_MESSAGE 56 154 #define DHO_DHCP_MESSAGE 56
154 #define DHO_DHCP_MAX_MESSAGE_SIZE57 155 #define DHO_DHCP_MAX_MESSAGE_SIZE57
155 #define DHO_DHCP_RENEWAL_TIME 58 156 #define DHO_DHCP_RENEWAL_TIME 58
156 #define DHO_DHCP_REBINDING_TIME 59 157 #define DHO_DHCP_REBINDING_TIME 59
157 #define DHO_VENDOR_CLASS_IDENTIFIER60 158 #define DHO_VENDOR_CLASS_IDENTIFIER60
158 #define DHO_DHCP_CLIENT_IDENTIFIER61 159 #define DHO_DHCP_CLIENT_IDENTIFIER61
159 #define DHO_NWIP_DOMAIN_NAME 62 160 #define DHO_NWIP_DOMAIN_NAME 62
160 #define DHO_NWIP_SUBOPTIONS 63 161 #define DHO_NWIP_SUBOPTIONS 63
161 #define DHO_USER_CLASS 77 162 #define DHO_USER_CLASS 77
162 #define DHO_FQDN 81 163 #define DHO_FQDN 81
163 #define DHO_DHCP_AGENT_OPTIONS 82 164 #define DHO_DHCP_AGENT_OPTIONS 82
164 #define DHO_SUBNET_SELECTION 118 /* RFC3011! */ 165 #define DHO_SUBNET_SELECTION 118 /* RFC3011! */
165/* The DHO_AUTHENTICATE option is not a standard yet, so I've 166/* The DHO_AUTHENTICATE option is not a standard yet, so I've
166 allocated an option out of the "local" option space for it on a 167 allocated an option out of the "local" option space for it on a
167 temporary basis. Once an option code number is assigned, I will 168 temporary basis. Once an option code number is assigned, I will
168 immediately and shamelessly break this, so don't count on it 169 immediately and shamelessly break this, so don't count on it
169 continuing to work. */ 170 continuing to work. */
170 #define DHO_AUTHENTICATE 210 171 #define DHO_AUTHENTICATE 210
171 172
172 #define DHO_END 255 173 #define DHO_END 255
173 174
174/* DHCP message types. */ 175/* DHCP message types. */
175 #define DHCPDISCOVER1 176 #define DHCPDISCOVER1
176 #define DHCPOFFER2 177 #define DHCPOFFER2
177 #define DHCPREQUEST3 178 #define DHCPREQUEST3
178 #define DHCPDECLINE4 179 #define DHCPDECLINE4
179 #define DHCPACK 5 180 #define DHCPACK 5
180 #define DHCPNAK 6 181 #define DHCPNAK 6
181 #define DHCPRELEASE7 182 #define DHCPRELEASE7
182 #define DHCPINFORM8 183 #define DHCPINFORM8
183 184
184/* Relay Agent Information option subtypes: */ 185/* Relay Agent Information option subtypes: */
185 #define RAI_CIRCUIT_ID1 186 #define RAI_CIRCUIT_ID1
186 #define RAI_REMOTE_ID2 187 #define RAI_REMOTE_ID2
187 #define RAI_AGENT_ID3 188 #define RAI_AGENT_ID3
188 189
189/* FQDN suboptions: */ 190/* FQDN suboptions: */
190 #define FQDN_NO_CLIENT_UPDATE 1 191 #define FQDN_NO_CLIENT_UPDATE 1
191 #define FQDN_SERVER_UPDATE 2 192 #define FQDN_SERVER_UPDATE 2
192 #define FQDN_ENCODED 3 193 #define FQDN_ENCODED 3
193 #define FQDN_RCODE1 4 194 #define FQDN_RCODE1 4
194 #define FQDN_RCODE2 5 195 #define FQDN_RCODE2 5
195 #define FQDN_HOSTNAME 6 196 #define FQDN_HOSTNAME 6
196 #define FQDN_DOMAINNAME 7 197 #define FQDN_DOMAINNAME 7
197 #define FQDN_FQDN 8 198 #define FQDN_FQDN 8
198 #define FQDN_SUBOPTION_COUNT 8 199 #define FQDN_SUBOPTION_COUNT 8
199 200
201
200#endif 202#endif
201 203
diff --git a/libopie2/opienet/odebugmapper.cpp b/libopie2/opienet/odebugmapper.cpp
index 7e4ab2b..f679afb 100644
--- a/libopie2/opienet/odebugmapper.cpp
+++ b/libopie2/opienet/odebugmapper.cpp
@@ -1,215 +1,223 @@
1 1
2/* 2/*
3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
4 */ 4 */
5 5
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7 7
8#include "odebugmapper.h" 8#include "odebugmapper.h"
9 9
10using namespace Opie::Core;
11
12namespace Opie {
13namespace Net {
14namespace Private {
15
10DebugMapper::DebugMapper() 16DebugMapper::DebugMapper()
11{ 17{
12 odebug << "DebugMapper::DebugMapper()" << oendl; 18 odebug << "DebugMapper::DebugMapper()" << oendl;
13 19
14 20
15 _map.insert( 0x8902, new QString("SIOCSPGRP") ); 21 _map.insert( 0x8902, new QString("SIOCSPGRP") );
16 _map.insert( 0x8904, new QString("SIOCGPGRP") ); 22 _map.insert( 0x8904, new QString("SIOCGPGRP") );
17 _map.insert( 0x8905, new QString("SIOCATMARK") ); 23 _map.insert( 0x8905, new QString("SIOCATMARK") );
18 _map.insert( 0x8906, new QString("SIOCGSTAMP") ); 24 _map.insert( 0x8906, new QString("SIOCGSTAMP") );
19 _map.insert( 0x890B, new QString("SIOCADDRT") ); 25 _map.insert( 0x890B, new QString("SIOCADDRT") );
20 _map.insert( 0x890C, new QString("SIOCDELRT") ); 26 _map.insert( 0x890C, new QString("SIOCDELRT") );
21 _map.insert( 0x890D, new QString("SIOCRTMSG") ); 27 _map.insert( 0x890D, new QString("SIOCRTMSG") );
22 _map.insert( 0x8910, new QString("SIOCGIFNAME") ); 28 _map.insert( 0x8910, new QString("SIOCGIFNAME") );
23 _map.insert( 0x8911, new QString("SIOCSIFLINK") ); 29 _map.insert( 0x8911, new QString("SIOCSIFLINK") );
24 _map.insert( 0x8912, new QString("SIOCGIFCONF") ); 30 _map.insert( 0x8912, new QString("SIOCGIFCONF") );
25 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") ); 31 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") );
26 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") ); 32 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") );
27 _map.insert( 0x8915, new QString("SIOCGIFADDR") ); 33 _map.insert( 0x8915, new QString("SIOCGIFADDR") );
28 _map.insert( 0x8916, new QString("SIOCSIFADDR") ); 34 _map.insert( 0x8916, new QString("SIOCSIFADDR") );
29 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") ); 35 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") );
30 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") ); 36 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") );
31 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") ); 37 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") );
32 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") ); 38 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") );
33 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") ); 39 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") );
34 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") ); 40 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") );
35 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") ); 41 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") );
36 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") ); 42 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") );
37 _map.insert( 0x891f, new QString("SIOCGIFMEM") ); 43 _map.insert( 0x891f, new QString("SIOCGIFMEM") );
38 _map.insert( 0x8920, new QString("SIOCSIFMEM") ); 44 _map.insert( 0x8920, new QString("SIOCSIFMEM") );
39 _map.insert( 0x8921, new QString("SIOCGIFMTU") ); 45 _map.insert( 0x8921, new QString("SIOCGIFMTU") );
40 _map.insert( 0x8922, new QString("SIOCSIFMTU") ); 46 _map.insert( 0x8922, new QString("SIOCSIFMTU") );
41 _map.insert( 0x8923, new QString("SIOCSIFNAME") ); 47 _map.insert( 0x8923, new QString("SIOCSIFNAME") );
42 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") ); 48 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") );
43 _map.insert( 0x8925, new QString("SIOCGIFENCAP") ); 49 _map.insert( 0x8925, new QString("SIOCGIFENCAP") );
44 _map.insert( 0x8926, new QString("SIOCSIFENCAP") ); 50 _map.insert( 0x8926, new QString("SIOCSIFENCAP") );
45 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") ); 51 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") );
46 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") ); 52 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") );
47 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") ); 53 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") );
48 _map.insert( 0x8931, new QString("SIOCADDMULTI") ); 54 _map.insert( 0x8931, new QString("SIOCADDMULTI") );
49 _map.insert( 0x8932, new QString("SIOCDELMULTI") ); 55 _map.insert( 0x8932, new QString("SIOCDELMULTI") );
50 _map.insert( 0x8933, new QString("SIOCGIFINDEX") ); 56 _map.insert( 0x8933, new QString("SIOCGIFINDEX") );
51 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") ); 57 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") );
52 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") ); 58 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") );
53 _map.insert( 0x8936, new QString("SIOCDIFADDR") ); 59 _map.insert( 0x8936, new QString("SIOCDIFADDR") );
54 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") ); 60 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
55 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") ); 61 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") );
56 _map.insert( 0x8940, new QString("SIOCGIFBR") ); 62 _map.insert( 0x8940, new QString("SIOCGIFBR") );
57 _map.insert( 0x8941, new QString("SIOCSIFBR") ); 63 _map.insert( 0x8941, new QString("SIOCSIFBR") );
58 _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") ); 64 _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") );
59 _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") ); 65 _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") );
60 _map.insert( 0x8953, new QString("SIOCDARP") ); 66 _map.insert( 0x8953, new QString("SIOCDARP") );
61 _map.insert( 0x8954, new QString("SIOCGARP") ); 67 _map.insert( 0x8954, new QString("SIOCGARP") );
62 _map.insert( 0x8955, new QString("SIOCSARP") ); 68 _map.insert( 0x8955, new QString("SIOCSARP") );
63 _map.insert( 0x8960, new QString("SIOCDRARP") ); 69 _map.insert( 0x8960, new QString("SIOCDRARP") );
64 _map.insert( 0x8961, new QString("SIOCGRARP") ); 70 _map.insert( 0x8961, new QString("SIOCGRARP") );
65 _map.insert( 0x8962, new QString("SIOCSRARP") ); 71 _map.insert( 0x8962, new QString("SIOCSRARP") );
66 _map.insert( 0x8970, new QString("SIOCGIFMAP") ); 72 _map.insert( 0x8970, new QString("SIOCGIFMAP") );
67 _map.insert( 0x8971, new QString("SIOCSIFMAP") ); 73 _map.insert( 0x8971, new QString("SIOCSIFMAP") );
68 _map.insert( 0x8980, new QString("SIOCADDDLCI") ); 74 _map.insert( 0x8980, new QString("SIOCADDDLCI") );
69 _map.insert( 0x8981, new QString("SIOCDELDLCI") ); 75 _map.insert( 0x8981, new QString("SIOCDELDLCI") );
70 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") ); 76 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
71 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") ); 77 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
72 _map.insert( 0x1fff, new QString("SIOCPARM_MASK") ); 78 _map.insert( 0x1fff, new QString("SIOCPARM_MASK") );
73 _map.insert( 0x00000000, new QString("SIOC_VOID") ); 79 _map.insert( 0x00000000, new QString("SIOC_VOID") );
74 _map.insert( 0x20000000, new QString("SIOC_OUT") ); 80 _map.insert( 0x20000000, new QString("SIOC_OUT") );
75 _map.insert( 0x40000000, new QString("SIOC_IN") ); 81 _map.insert( 0x40000000, new QString("SIOC_IN") );
76 _map.insert( 0x8B00, new QString("SIOCSIWCOMMIT") ); 82 _map.insert( 0x8B00, new QString("SIOCSIWCOMMIT") );
77 _map.insert( 0x8B01, new QString("SIOCGIWNAME") ); 83 _map.insert( 0x8B01, new QString("SIOCGIWNAME") );
78 _map.insert( 0x8B02, new QString("SIOCSIWNWID") ); 84 _map.insert( 0x8B02, new QString("SIOCSIWNWID") );
79 _map.insert( 0x8B03, new QString("SIOCGIWNWID") ); 85 _map.insert( 0x8B03, new QString("SIOCGIWNWID") );
80 _map.insert( 0x8B04, new QString("SIOCSIWFREQ") ); 86 _map.insert( 0x8B04, new QString("SIOCSIWFREQ") );
81 _map.insert( 0x8B05, new QString("SIOCGIWFREQ") ); 87 _map.insert( 0x8B05, new QString("SIOCGIWFREQ") );
82 _map.insert( 0x8B06, new QString("SIOCSIWMODE") ); 88 _map.insert( 0x8B06, new QString("SIOCSIWMODE") );
83 _map.insert( 0x8B07, new QString("SIOCGIWMODE") ); 89 _map.insert( 0x8B07, new QString("SIOCGIWMODE") );
84 _map.insert( 0x8B08, new QString("SIOCSIWSENS") ); 90 _map.insert( 0x8B08, new QString("SIOCSIWSENS") );
85 _map.insert( 0x8B09, new QString("SIOCGIWSENS") ); 91 _map.insert( 0x8B09, new QString("SIOCGIWSENS") );
86 _map.insert( 0x8B0A, new QString("SIOCSIWRANGE") ); 92 _map.insert( 0x8B0A, new QString("SIOCSIWRANGE") );
87 _map.insert( 0x8B0B, new QString("SIOCGIWRANGE") ); 93 _map.insert( 0x8B0B, new QString("SIOCGIWRANGE") );
88 _map.insert( 0x8B0C, new QString("SIOCSIWPRIV") ); 94 _map.insert( 0x8B0C, new QString("SIOCSIWPRIV") );
89 _map.insert( 0x8B0D, new QString("SIOCGIWPRIV") ); 95 _map.insert( 0x8B0D, new QString("SIOCGIWPRIV") );
90 _map.insert( 0x8B0E, new QString("SIOCSIWSTATS") ); 96 _map.insert( 0x8B0E, new QString("SIOCSIWSTATS") );
91 _map.insert( 0x8B0F, new QString("SIOCGIWSTATS") ); 97 _map.insert( 0x8B0F, new QString("SIOCGIWSTATS") );
92 _map.insert( 0x8B10, new QString("SIOCSIWSPY") ); 98 _map.insert( 0x8B10, new QString("SIOCSIWSPY") );
93 _map.insert( 0x8B11, new QString("SIOCGIWSPY") ); 99 _map.insert( 0x8B11, new QString("SIOCGIWSPY") );
94 _map.insert( 0x8B14, new QString("SIOCSIWAP") ); 100 _map.insert( 0x8B14, new QString("SIOCSIWAP") );
95 _map.insert( 0x8B15, new QString("SIOCGIWAP") ); 101 _map.insert( 0x8B15, new QString("SIOCGIWAP") );
96 _map.insert( 0x8B17, new QString("SIOCGIWAPLIST") ); 102 _map.insert( 0x8B17, new QString("SIOCGIWAPLIST") );
97 _map.insert( 0x8B18, new QString("SIOCSIWSCAN") ); 103 _map.insert( 0x8B18, new QString("SIOCSIWSCAN") );
98 _map.insert( 0x8B19, new QString("SIOCGIWSCAN") ); 104 _map.insert( 0x8B19, new QString("SIOCGIWSCAN") );
99 _map.insert( 0x8B1A, new QString("SIOCSIWESSID") ); 105 _map.insert( 0x8B1A, new QString("SIOCSIWESSID") );
100 _map.insert( 0x8B1B, new QString("SIOCGIWESSID") ); 106 _map.insert( 0x8B1B, new QString("SIOCGIWESSID") );
101 _map.insert( 0x8B1C, new QString("SIOCSIWNICKN") ); 107 _map.insert( 0x8B1C, new QString("SIOCSIWNICKN") );
102 _map.insert( 0x8B1D, new QString("SIOCGIWNICKN") ); 108 _map.insert( 0x8B1D, new QString("SIOCGIWNICKN") );
103 _map.insert( 0x8B20, new QString("SIOCSIWRATE") ); 109 _map.insert( 0x8B20, new QString("SIOCSIWRATE") );
104 _map.insert( 0x8B21, new QString("SIOCGIWRATE") ); 110 _map.insert( 0x8B21, new QString("SIOCGIWRATE") );
105 _map.insert( 0x8B22, new QString("SIOCSIWRTS") ); 111 _map.insert( 0x8B22, new QString("SIOCSIWRTS") );
106 _map.insert( 0x8B23, new QString("SIOCGIWRTS") ); 112 _map.insert( 0x8B23, new QString("SIOCGIWRTS") );
107 _map.insert( 0x8B24, new QString("SIOCSIWFRAG") ); 113 _map.insert( 0x8B24, new QString("SIOCSIWFRAG") );
108 _map.insert( 0x8B25, new QString("SIOCGIWFRAG") ); 114 _map.insert( 0x8B25, new QString("SIOCGIWFRAG") );
109 _map.insert( 0x8B26, new QString("SIOCSIWTXPOW") ); 115 _map.insert( 0x8B26, new QString("SIOCSIWTXPOW") );
110 _map.insert( 0x8B27, new QString("SIOCGIWTXPOW") ); 116 _map.insert( 0x8B27, new QString("SIOCGIWTXPOW") );
111 _map.insert( 0x8B28, new QString("SIOCSIWRETRY") ); 117 _map.insert( 0x8B28, new QString("SIOCSIWRETRY") );
112 _map.insert( 0x8B29, new QString("SIOCGIWRETRY") ); 118 _map.insert( 0x8B29, new QString("SIOCGIWRETRY") );
113 _map.insert( 0x8B2A, new QString("SIOCSIWENCODE") ); 119 _map.insert( 0x8B2A, new QString("SIOCSIWENCODE") );
114 _map.insert( 0x8B2B, new QString("SIOCGIWENCODE") ); 120 _map.insert( 0x8B2B, new QString("SIOCGIWENCODE") );
115 _map.insert( 0x8B2C, new QString("SIOCSIWPOWER") ); 121 _map.insert( 0x8B2C, new QString("SIOCSIWPOWER") );
116 _map.insert( 0x8B2D, new QString("SIOCGIWPOWER") ); 122 _map.insert( 0x8B2D, new QString("SIOCGIWPOWER") );
117 _map.insert( 0x8BE0, new QString("SIOCIWFIRSTPRIV") ); 123 _map.insert( 0x8BE0, new QString("SIOCIWFIRSTPRIV") );
118 _map.insert( 0x8BFF, new QString("SIOCIWLASTPRIV") ); 124 _map.insert( 0x8BFF, new QString("SIOCIWLASTPRIV") );
119 _map.insert( 0x8B00, new QString("SIOCIWFIRST") ); 125 _map.insert( 0x8B00, new QString("SIOCIWFIRST") );
120 _map.insert( 0x5000, new QString("SIOCGBPQETHPARAM") ); 126 _map.insert( 0x5000, new QString("SIOCGBPQETHPARAM") );
121 _map.insert( 0x5001, new QString("SIOCSBPQETHPARAM") ); 127 _map.insert( 0x5001, new QString("SIOCSBPQETHPARAM") );
122 _map.insert( 0x890B, new QString("SIOCADDRT") ); 128 _map.insert( 0x890B, new QString("SIOCADDRT") );
123 _map.insert( 0x890C, new QString("SIOCDELRT") ); 129 _map.insert( 0x890C, new QString("SIOCDELRT") );
124 _map.insert( 0x890D, new QString("SIOCRTMSG") ); 130 _map.insert( 0x890D, new QString("SIOCRTMSG") );
125 _map.insert( 0x8910, new QString("SIOCGIFNAME") ); 131 _map.insert( 0x8910, new QString("SIOCGIFNAME") );
126 _map.insert( 0x8911, new QString("SIOCSIFLINK") ); 132 _map.insert( 0x8911, new QString("SIOCSIFLINK") );
127 _map.insert( 0x8912, new QString("SIOCGIFCONF") ); 133 _map.insert( 0x8912, new QString("SIOCGIFCONF") );
128 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") ); 134 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") );
129 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") ); 135 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") );
130 _map.insert( 0x8915, new QString("SIOCGIFADDR") ); 136 _map.insert( 0x8915, new QString("SIOCGIFADDR") );
131 _map.insert( 0x8916, new QString("SIOCSIFADDR") ); 137 _map.insert( 0x8916, new QString("SIOCSIFADDR") );
132 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") ); 138 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") );
133 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") ); 139 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") );
134 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") ); 140 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") );
135 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") ); 141 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") );
136 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") ); 142 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") );
137 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") ); 143 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") );
138 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") ); 144 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") );
139 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") ); 145 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") );
140 _map.insert( 0x891f, new QString("SIOCGIFMEM") ); 146 _map.insert( 0x891f, new QString("SIOCGIFMEM") );
141 _map.insert( 0x8920, new QString("SIOCSIFMEM") ); 147 _map.insert( 0x8920, new QString("SIOCSIFMEM") );
142 _map.insert( 0x8921, new QString("SIOCGIFMTU") ); 148 _map.insert( 0x8921, new QString("SIOCGIFMTU") );
143 _map.insert( 0x8922, new QString("SIOCSIFMTU") ); 149 _map.insert( 0x8922, new QString("SIOCSIFMTU") );
144 _map.insert( 0x8923, new QString("SIOCSIFNAME") ); 150 _map.insert( 0x8923, new QString("SIOCSIFNAME") );
145 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") ); 151 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") );
146 _map.insert( 0x8925, new QString("SIOCGIFENCAP") ); 152 _map.insert( 0x8925, new QString("SIOCGIFENCAP") );
147 _map.insert( 0x8926, new QString("SIOCSIFENCAP") ); 153 _map.insert( 0x8926, new QString("SIOCSIFENCAP") );
148 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") ); 154 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") );
149 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") ); 155 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") );
150 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") ); 156 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") );
151 _map.insert( 0x8931, new QString("SIOCADDMULTI") ); 157 _map.insert( 0x8931, new QString("SIOCADDMULTI") );
152 _map.insert( 0x8932, new QString("SIOCDELMULTI") ); 158 _map.insert( 0x8932, new QString("SIOCDELMULTI") );
153 _map.insert( 0x8933, new QString("SIOCGIFINDEX") ); 159 _map.insert( 0x8933, new QString("SIOCGIFINDEX") );
154 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") ); 160 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") );
155 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") ); 161 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") );
156 _map.insert( 0x8936, new QString("SIOCDIFADDR") ); 162 _map.insert( 0x8936, new QString("SIOCDIFADDR") );
157 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") ); 163 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
158 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") ); 164 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") );
159 _map.insert( 0x8940, new QString("SIOCGIFBR") ); 165 _map.insert( 0x8940, new QString("SIOCGIFBR") );
160 _map.insert( 0x8941, new QString("SIOCSIFBR") ); 166 _map.insert( 0x8941, new QString("SIOCSIFBR") );
161 _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") ); 167 _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") );
162 _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") ); 168 _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") );
163 _map.insert( 0x8944, new QString("SIOCGIFDIVERT") ); 169 _map.insert( 0x8944, new QString("SIOCGIFDIVERT") );
164 _map.insert( 0x8945, new QString("SIOCSIFDIVERT") ); 170 _map.insert( 0x8945, new QString("SIOCSIFDIVERT") );
165 _map.insert( 0x8946, new QString("SIOCETHTOOL") ); 171 _map.insert( 0x8946, new QString("SIOCETHTOOL") );
166 _map.insert( 0x8947, new QString("SIOCGMIIPHY") ); 172 _map.insert( 0x8947, new QString("SIOCGMIIPHY") );
167 _map.insert( 0x8948, new QString("SIOCGMIIREG") ); 173 _map.insert( 0x8948, new QString("SIOCGMIIREG") );
168 _map.insert( 0x8949, new QString("SIOCSMIIREG") ); 174 _map.insert( 0x8949, new QString("SIOCSMIIREG") );
169 _map.insert( 0x894A, new QString("SIOCWANDEV") ); 175 _map.insert( 0x894A, new QString("SIOCWANDEV") );
170 _map.insert( 0x8953, new QString("SIOCDARP") ); 176 _map.insert( 0x8953, new QString("SIOCDARP") );
171 _map.insert( 0x8954, new QString("SIOCGARP") ); 177 _map.insert( 0x8954, new QString("SIOCGARP") );
172 _map.insert( 0x8955, new QString("SIOCSARP") ); 178 _map.insert( 0x8955, new QString("SIOCSARP") );
173 _map.insert( 0x8960, new QString("SIOCDRARP") ); 179 _map.insert( 0x8960, new QString("SIOCDRARP") );
174 _map.insert( 0x8961, new QString("SIOCGRARP") ); 180 _map.insert( 0x8961, new QString("SIOCGRARP") );
175 _map.insert( 0x8962, new QString("SIOCSRARP") ); 181 _map.insert( 0x8962, new QString("SIOCSRARP") );
176 _map.insert( 0x8970, new QString("SIOCGIFMAP") ); 182 _map.insert( 0x8970, new QString("SIOCGIFMAP") );
177 _map.insert( 0x8971, new QString("SIOCSIFMAP") ); 183 _map.insert( 0x8971, new QString("SIOCSIFMAP") );
178 _map.insert( 0x8980, new QString("SIOCADDDLCI") ); 184 _map.insert( 0x8980, new QString("SIOCADDDLCI") );
179 _map.insert( 0x8981, new QString("SIOCDELDLCI") ); 185 _map.insert( 0x8981, new QString("SIOCDELDLCI") );
180 _map.insert( 0x8982, new QString("SIOCGIFVLAN") ); 186 _map.insert( 0x8982, new QString("SIOCGIFVLAN") );
181 _map.insert( 0x8983, new QString("SIOCSIFVLAN") ); 187 _map.insert( 0x8983, new QString("SIOCSIFVLAN") );
182 _map.insert( 0x8990, new QString("SIOCBONDENSLAVE") ); 188 _map.insert( 0x8990, new QString("SIOCBONDENSLAVE") );
183 _map.insert( 0x8991, new QString("SIOCBONDRELEASE") ); 189 _map.insert( 0x8991, new QString("SIOCBONDRELEASE") );
184 _map.insert( 0x8992, new QString("SIOCBONDSETHWADDR") ); 190 _map.insert( 0x8992, new QString("SIOCBONDSETHWADDR") );
185 _map.insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") ); 191 _map.insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") );
186 _map.insert( 0x8994, new QString("SIOCBONDINFOQUERY") ); 192 _map.insert( 0x8994, new QString("SIOCBONDINFOQUERY") );
187 _map.insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") ); 193 _map.insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") );
188 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") ); 194 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
189 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") ); 195 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
190 196
191}; 197};
192 198
193 199
194DebugMapper::~DebugMapper() 200DebugMapper::~DebugMapper()
195{ 201{
196 odebug << "DebugMapper::~DebugMapper()" << oendl; 202 odebug << "DebugMapper::~DebugMapper()" << oendl;
197} 203}
198 204
199 205
200const QString& DebugMapper::map( int value ) const 206const QString& DebugMapper::map( int value ) const
201{ 207{
202 QString* result = _map[ value ]; 208 QString* result = _map[ value ];
203 209
204 if ( !result ) 210 if ( !result )
205 { 211 {
206 owarn << "DebugMapper::map() - value " << value << " is not found." << oendl; 212 owarn << "DebugMapper::map() - value " << value << " is not found." << oendl;
207 return QString::null; 213 return QString::null;
208 } 214 }
209 else 215 else
210 { 216 {
211 return *result; 217 return *result;
212 } 218 }
213} 219}
214 220
215 221}
222}
223}
diff --git a/libopie2/opienet/odebugmapper.h b/libopie2/opienet/odebugmapper.h
index 66b331d..f47db47 100644
--- a/libopie2/opienet/odebugmapper.h
+++ b/libopie2/opienet/odebugmapper.h
@@ -1,26 +1,36 @@
1 1
2/* 2/*
3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
4 */ 4 */
5 5
6#ifndef DEBUGMAPPER_H 6#ifndef DEBUGMAPPER_H
7#define DEBUGMAPPER_H 7#define DEBUGMAPPER_H
8 8
9#include <qstring.h> 9#include <qstring.h>
10#include <qintdict.h> 10#include <qintdict.h>
11 11
12namespace Opie {
13namespace Net {
14namespace Private {
15
12typedef QIntDict<QString> IntStringMap; 16typedef QIntDict<QString> IntStringMap;
13 17
14class DebugMapper 18class DebugMapper
15{ 19{
16 public: 20 public:
17 DebugMapper(); 21 DebugMapper();
18 ~DebugMapper(); 22 ~DebugMapper();
19 23
20 const QString& map( int value ) const; 24 const QString& map( int value ) const;
21 private: 25 private:
22 IntStringMap _map; 26 IntStringMap _map;
27 class Private;
28 Private *d;
23}; 29};
24 30
31}
32}
33}
34
25#endif 35#endif
26 36
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index b93b752..209ec94 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -1,135 +1,142 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#include "omanufacturerdb.h" 31#include "omanufacturerdb.h"
32 32
33#define OPIE_IMPROVE_GUI_LATENCY 1 33#define OPIE_IMPROVE_GUI_LATENCY 1
34 34
35/* OPIE */ 35/* OPIE */
36#include <opie2/odebug.h> 36#include <opie2/odebug.h>
37#ifdef OPIE_IMPROVE_GUI_LATENCY 37#ifdef OPIE_IMPROVE_GUI_LATENCY
38#include <qpe/global.h> 38#include <qpe/global.h>
39#endif 39#endif
40 40
41/* QT */ 41/* QT */
42#include <qapplication.h> 42#include <qapplication.h>
43#include <qfile.h> 43#include <qfile.h>
44#include <qtextstream.h> 44#include <qtextstream.h>
45 45
46using namespace Opie::Core;
47namespace Opie {
48namespace Net {
49
46OManufacturerDB* OManufacturerDB::_instance = 0; 50OManufacturerDB* OManufacturerDB::_instance = 0;
47 51
48OManufacturerDB* OManufacturerDB::instance() 52OManufacturerDB* OManufacturerDB::instance()
49{ 53{
50 if ( !OManufacturerDB::_instance ) 54 if ( !OManufacturerDB::_instance )
51 { 55 {
52 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; 56 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl;
53 _instance = new OManufacturerDB(); 57 _instance = new OManufacturerDB();
54 } 58 }
55 return _instance; 59 return _instance;
56} 60}
57 61
58 62
59OManufacturerDB::OManufacturerDB() 63OManufacturerDB::OManufacturerDB()
60{ 64{
61 #ifdef OPIE_IMPROVE_GUI_LATENCY 65 #ifdef OPIE_IMPROVE_GUI_LATENCY
62 Global::statusMessage( "Reading Manufacturers..." ); 66 Global::statusMessage( "Reading Manufacturers..." );
63 #endif 67 #endif
64 QString filename( "/etc/manufacturers" ); 68 QString filename( "/etc/manufacturers" );
65 odebug << "OManufacturerDB: trying to read " << filename << oendl; 69 odebug << "OManufacturerDB: trying to read " << filename << oendl;
66 if ( !QFile::exists( filename ) ) 70 if ( !QFile::exists( filename ) )
67 { 71 {
68 filename = "/opt/QtPalmtop/etc/manufacturers"; 72 filename = "/opt/QtPalmtop/etc/manufacturers";
69 odebug << "OManufacturerDB: trying to read " << filename << oendl; 73 odebug << "OManufacturerDB: trying to read " << filename << oendl;
70 if ( !QFile::exists( filename ) ) 74 if ( !QFile::exists( filename ) )
71 { 75 {
72 filename = "/usr/share/wellenreiter/manufacturers"; 76 filename = "/usr/share/wellenreiter/manufacturers";
73 odebug << "OManufacturerDB: trying to read " << filename << oendl; 77 odebug << "OManufacturerDB: trying to read " << filename << oendl;
74 } 78 }
75 } 79 }
76 80
77 QFile file( filename ); 81 QFile file( filename );
78 bool hasFile = file.open( IO_ReadOnly ); 82 bool hasFile = file.open( IO_ReadOnly );
79 if (!hasFile) 83 if (!hasFile)
80 { 84 {
81 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; 85 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl;
82 } 86 }
83 else 87 else
84 { 88 {
85 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; 89 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl;
86 QTextStream s( &file ); 90 QTextStream s( &file );
87 QString addr; 91 QString addr;
88 QString manu; 92 QString manu;
89 QString extManu; 93 QString extManu;
90 #ifdef OPIE_IMPROVE_GUI_LATENCY 94 #ifdef OPIE_IMPROVE_GUI_LATENCY
91 int counter = 0; 95 int counter = 0;
92 #endif 96 #endif
93 while (!s.atEnd()) 97 while (!s.atEnd())
94 { 98 {
95 s >> addr; 99 s >> addr;
96 s >> manu; 100 s >> manu;
97 s >> extManu; 101 s >> extManu;
98 102
99 manufacturers.insert( addr, manu ); 103 manufacturers.insert( addr, manu );
100 manufacturersExt.insert( addr, extManu ); 104 manufacturersExt.insert( addr, extManu );
101 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; 105 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl;
102 #ifdef OPIE_IMPROVE_GUI_LATENCY 106 #ifdef OPIE_IMPROVE_GUI_LATENCY
103 counter++; 107 counter++;
104 if ( counter == 50 ) 108 if ( counter == 50 )
105 { 109 {
106 qApp->processEvents(); 110 qApp->processEvents();
107 counter = 0; 111 counter = 0;
108 } 112 }
109 #endif 113 #endif
110 } 114 }
111 odebug << "OManufacturerDB: manufacturer list completed." << oendl; 115 odebug << "OManufacturerDB: manufacturer list completed." << oendl;
112 #ifdef OPIE_IMPROVE_GUI_LATENCY 116 #ifdef OPIE_IMPROVE_GUI_LATENCY
113 Global::statusMessage( "Manufacturers Complete..." ); 117 Global::statusMessage( "Manufacturers Complete..." );
114 #endif 118 #endif
115 } 119 }
116} 120}
117 121
118 122
119OManufacturerDB::~OManufacturerDB() 123OManufacturerDB::~OManufacturerDB()
120{ 124{
121} 125}
122 126
123 127
124const QString& OManufacturerDB::lookup( const QString& macaddr ) const 128const QString& OManufacturerDB::lookup( const QString& macaddr ) const
125{ 129{
126 return manufacturers[macaddr.upper().left(8)]; 130 return manufacturers[macaddr.upper().left(8)];
127} 131}
128 132
129 133
130const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const 134const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
131{ 135{
132 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); 136 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
133 return it == manufacturersExt.end() ? lookup( macaddr ) : *it; 137 return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
134} 138}
135 139
140}
141}
142
diff --git a/libopie2/opienet/omanufacturerdb.h b/libopie2/opienet/omanufacturerdb.h
index c2712e5..5c1940e 100644
--- a/libopie2/opienet/omanufacturerdb.h
+++ b/libopie2/opienet/omanufacturerdb.h
@@ -1,69 +1,77 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef OMANUFACTURERDB_H 31#ifndef OMANUFACTURERDB_H
32#define OMANUFACTURERDB_H 32#define OMANUFACTURERDB_H
33 33
34#include <qmap.h> 34#include <qmap.h>
35 35
36namespace Opie {
37namespace Net {
38
36/** 39/**
37 * @brief A Ethernet card vendor database. 40 * @brief A Ethernet card vendor database.
38 * 41 *
39 * This class encapsulates the lookup of Ethernet vendor given a 42 * This class encapsulates the lookup of Ethernet vendor given a
40 * certain Mac Address. Only the first three bytes define the vendor. 43 * certain Mac Address. Only the first three bytes define the vendor.
41 */ 44 */
42class OManufacturerDB 45class OManufacturerDB
43{ 46{
44 public: 47 public:
45 /** 48 /**
46 * @returns the one-and-only @ref OManufacturerDB instance. 49 * @returns the one-and-only @ref OManufacturerDB instance.
47 */ 50 */
48 static OManufacturerDB* instance(); 51 static OManufacturerDB* instance();
49 /** 52 /**
50 * @returns the short manufacturer string given a @a macaddr. 53 * @returns the short manufacturer string given a @a macaddr.
51 */ 54 */
52 const QString& lookup( const QString& macaddr ) const; 55 const QString& lookup( const QString& macaddr ) const;
53 /** 56 /**
54 * @returns the enhanced manufacturer string given a @a macaddr. 57 * @returns the enhanced manufacturer string given a @a macaddr.
55 */ 58 */
56 const QString& lookupExt( const QString& macaddr ) const; 59 const QString& lookupExt( const QString& macaddr ) const;
57 60
58 protected: 61 protected:
59 OManufacturerDB(); 62 OManufacturerDB();
60 virtual ~OManufacturerDB(); 63 virtual ~OManufacturerDB();
61 64
62 private: 65 private:
63 QMap<QString, QString> manufacturers; 66 QMap<QString, QString> manufacturers;
64 QMap<QString, QString> manufacturersExt; 67 QMap<QString, QString> manufacturersExt;
65 static OManufacturerDB* _instance; 68 static OManufacturerDB* _instance;
69 class Private;
70 Private *d;
66}; 71};
67 72
73}
74}
75
68#endif 76#endif
69 77
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index 48cfa43..7794334 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -1,232 +1,241 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 4              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include <opie2/onetutils.h> 32#include <opie2/onetutils.h>
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/omanufacturerdb.h> 34#include <opie2/omanufacturerdb.h>
35 35
36#include <net/if.h> 36#include <net/if.h>
37#include <assert.h> 37#include <assert.h>
38#include <stdio.h> 38#include <stdio.h>
39 39
40namespace Opie {
41namespace Net {
42
40/*====================================================================================== 43/*======================================================================================
41 * OMacAddress 44 * OMacAddress
42 *======================================================================================*/ 45 *======================================================================================*/
43 46
44// static initializer for broadcast and unknown MAC Adresses 47// static initializer for broadcast and unknown MAC Adresses
45const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 48const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
46const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); 49const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast );
47const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; 50const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 };
48const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); 51const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown );
49 52
50//TODO: Incorporate Ethernet Manufacturer database here! (inline or so) 53//TODO: Incorporate Ethernet Manufacturer database here! (inline or so)
51 54
52OMacAddress::OMacAddress() 55OMacAddress::OMacAddress()
53{ 56{
54 memcpy( _bytes, __unknown, 6 ); 57 memcpy( _bytes, __unknown, 6 );
55} 58}
56 59
57 60
58OMacAddress::OMacAddress( unsigned char* p ) 61OMacAddress::OMacAddress( unsigned char* p )
59{ 62{
60 memcpy( _bytes, p, 6 ); 63 memcpy( _bytes, p, 6 );
61} 64}
62 65
63 66
64OMacAddress::OMacAddress( const unsigned char* p ) 67OMacAddress::OMacAddress( const unsigned char* p )
65{ 68{
66 memcpy( _bytes, p, 6 ); 69 memcpy( _bytes, p, 6 );
67} 70}
68 71
69 72
70OMacAddress::OMacAddress( struct ifreq& ifr ) 73OMacAddress::OMacAddress( struct ifreq& ifr )
71{ 74{
72 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); 75 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 );
73} 76}
74 77
75 78
76OMacAddress::~OMacAddress() 79OMacAddress::~OMacAddress()
77{ 80{
78} 81}
79 82
80 83
81//#ifdef QT_NO_DEBUG 84//#ifdef QT_NO_DEBUG
82//inline 85//inline
83//#endif 86//#endif
84const unsigned char* OMacAddress::native() const 87const unsigned char* OMacAddress::native() const
85{ 88{
86 return (const unsigned char*) &_bytes; 89 return (const unsigned char*) &_bytes;
87} 90}
88 91
89 92
90OMacAddress OMacAddress::fromString( const QString& str ) 93OMacAddress OMacAddress::fromString( const QString& str )
91{ 94{
92 QString addr( str ); 95 QString addr( str );
93 unsigned char buf[6]; 96 unsigned char buf[6];
94 bool ok = true; 97 bool ok = true;
95 int index = 14; 98 int index = 14;
96 for ( int i = 5; i >= 0; --i ) 99 for ( int i = 5; i >= 0; --i )
97 { 100 {
98 buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); 101 buf[i] = addr.right( 2 ).toUShort( &ok, 16 );
99 if ( !ok ) return OMacAddress::unknown; 102 if ( !ok ) return OMacAddress::unknown;
100 addr.truncate( index ); 103 addr.truncate( index );
101 index -= 3; 104 index -= 3;
102 } 105 }
103 return (const unsigned char*) &buf; 106 return (const unsigned char*) &buf;
104} 107}
105 108
106 109
107QString OMacAddress::toString( bool substitute ) const 110QString OMacAddress::toString( bool substitute ) const
108{ 111{
109 QString manu; 112 QString manu;
110 manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); 113 manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff );
111 QString serial; 114 QString serial;
112 serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); 115 serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff );
113 if ( !substitute ) return manu+serial; 116 if ( !substitute ) return manu+serial;
114 // fallback - if no vendor is found, just use the number 117 // fallback - if no vendor is found, just use the number
115 QString textmanu = OManufacturerDB::instance()->lookup( manu ); 118 QString textmanu = OManufacturerDB::instance()->lookup( manu );
116 return textmanu.isNull() ? manu+serial : textmanu+serial; 119 return textmanu.isNull() ? manu+serial : textmanu+serial;
117} 120}
118 121
119 122
120QString OMacAddress::manufacturer() const 123QString OMacAddress::manufacturer() const
121{ 124{
122 return OManufacturerDB::instance()->lookupExt( toString() ); 125 return OManufacturerDB::instance()->lookupExt( toString() );
123} 126}
124 127
125 128
126bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) 129bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
127{ 130{
128 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; 131 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0;
129} 132}
130 133
131 134
132/*====================================================================================== 135/*======================================================================================
133 * OHostAddress 136 * OHostAddress
134 *======================================================================================*/ 137 *======================================================================================*/
135 138
136 139
137/*====================================================================================== 140/*======================================================================================
138 * OPrivateIOCTL 141 * OPrivateIOCTL
139 *======================================================================================*/ 142 *======================================================================================*/
140 143
141OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) 144OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs )
142 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) 145 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs )
143{ 146{
144} 147}
145 148
146 149
147OPrivateIOCTL::~OPrivateIOCTL() 150OPrivateIOCTL::~OPrivateIOCTL()
148{ 151{
149} 152}
150 153
151 154
152int OPrivateIOCTL::numberGetArgs() const 155int OPrivateIOCTL::numberGetArgs() const
153{ 156{
154 return _getargs & IW_PRIV_SIZE_MASK; 157 return _getargs & IW_PRIV_SIZE_MASK;
155} 158}
156 159
157 160
158int OPrivateIOCTL::typeGetArgs() const 161int OPrivateIOCTL::typeGetArgs() const
159{ 162{
160 return _getargs & IW_PRIV_TYPE_MASK >> 12; 163 return _getargs & IW_PRIV_TYPE_MASK >> 12;
161} 164}
162 165
163 166
164int OPrivateIOCTL::numberSetArgs() const 167int OPrivateIOCTL::numberSetArgs() const
165{ 168{
166 return _setargs & IW_PRIV_SIZE_MASK; 169 return _setargs & IW_PRIV_SIZE_MASK;
167} 170}
168 171
169 172
170int OPrivateIOCTL::typeSetArgs() const 173int OPrivateIOCTL::typeSetArgs() const
171{ 174{
172 return _setargs & IW_PRIV_TYPE_MASK >> 12; 175 return _setargs & IW_PRIV_TYPE_MASK >> 12;
173} 176}
174 177
175 178
176void OPrivateIOCTL::invoke() const 179void OPrivateIOCTL::invoke() const
177{ 180{
178 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); 181 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl );
179} 182}
180 183
181 184
182void OPrivateIOCTL::setParameter( int num, u_int32_t value ) 185void OPrivateIOCTL::setParameter( int num, u_int32_t value )
183{ 186{
184 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; 187 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name;
185 arglist[num] = value; 188 arglist[num] = value;
186} 189}
187 190
191
192
193namespace Private {
188/*====================================================================================== 194/*======================================================================================
189 * assorted functions 195 * assorted functions
190 *======================================================================================*/ 196 *======================================================================================*/
191 197
192void dumpBytes( const unsigned char* data, int num ) 198void dumpBytes( const unsigned char* data, int num )
193{ 199{
194 printf( "Dumping %d bytes @ %0x", num, data ); 200 printf( "Dumping %d bytes @ %0x", num, data );
195 printf( "-------------------------------------------\n" ); 201 printf( "-------------------------------------------\n" );
196 202
197 for ( int i = 0; i < num; ++i ) 203 for ( int i = 0; i < num; ++i )
198 { 204 {
199 printf( "%02x ", data[i] ); 205 printf( "%02x ", data[i] );
200 if ( !((i+1) % 32) ) printf( "\n" ); 206 if ( !((i+1) % 32) ) printf( "\n" );
201 } 207 }
202 printf( "\n\n" ); 208 printf( "\n\n" );
203} 209}
204 210
205 211
206int stringToMode( const QString& mode ) 212int stringToMode( const QString& mode )
207{ 213{
208 if ( mode == "auto" ) return IW_MODE_AUTO; 214 if ( mode == "auto" ) return IW_MODE_AUTO;
209 else if ( mode == "adhoc" ) return IW_MODE_ADHOC; 215 else if ( mode == "adhoc" ) return IW_MODE_ADHOC;
210 else if ( mode == "managed" ) return IW_MODE_INFRA; 216 else if ( mode == "managed" ) return IW_MODE_INFRA;
211 else if ( mode == "master" ) return IW_MODE_MASTER; 217 else if ( mode == "master" ) return IW_MODE_MASTER;
212 else if ( mode == "repeater" ) return IW_MODE_REPEAT; 218 else if ( mode == "repeater" ) return IW_MODE_REPEAT;
213 else if ( mode == "secondary" ) return IW_MODE_SECOND; 219 else if ( mode == "secondary" ) return IW_MODE_SECOND;
214 else if ( mode == "monitor" ) return IW_MODE_MONITOR; 220 else if ( mode == "monitor" ) return IW_MODE_MONITOR;
215 else assert( 0 ); 221 else assert( 0 );
216} 222}
217 223
218 224
219QString modeToString( int mode ) 225QString modeToString( int mode )
220{ 226{
221 switch ( mode ) 227 switch ( mode )
222 { 228 {
223 case IW_MODE_AUTO: return "auto"; 229 case IW_MODE_AUTO: return "auto";
224 case IW_MODE_ADHOC: return "adhoc"; 230 case IW_MODE_ADHOC: return "adhoc";
225 case IW_MODE_INFRA: return "managed"; 231 case IW_MODE_INFRA: return "managed";
226 case IW_MODE_MASTER: return "master"; 232 case IW_MODE_MASTER: return "master";
227 case IW_MODE_REPEAT: return "repeater"; 233 case IW_MODE_REPEAT: return "repeater";
228 case IW_MODE_SECOND: return "second"; 234 case IW_MODE_SECOND: return "second";
229 case IW_MODE_MONITOR: return "monitor"; 235 case IW_MODE_MONITOR: return "monitor";
230 default: assert( 0 ); 236 default: assert( 0 );
231 } 237 }
232} 238}
239}
240}
241}
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h
index bddfab9..ca6815d 100644
--- a/libopie2/opienet/onetutils.h
+++ b/libopie2/opienet/onetutils.h
@@ -1,181 +1,196 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef ONETUTILS_H 32#ifndef ONETUTILS_H
33#define ONETUTILS_H 33#define ONETUTILS_H
34 34
35#include <qdict.h> 35#include <qdict.h>
36#include <qmap.h> 36#include <qmap.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qhostaddress.h> 38#include <qhostaddress.h>
39#include <qobject.h> 39#include <qobject.h>
40 40
41#include <sys/types.h> 41#include <sys/types.h>
42 42
43struct ifreq; 43struct ifreq;
44
45namespace Opie {
46namespace Net {
47
44class OWirelessNetworkInterface; 48class OWirelessNetworkInterface;
45 49
46/*====================================================================================== 50/*======================================================================================
47 * OMacAddress 51 * OMacAddress
48 *======================================================================================*/ 52 *======================================================================================*/
49 53
50class OMacAddress 54class OMacAddress
51{ 55{
52 public: 56 public:
53 // QString c'tor? -zecke 57 // QString c'tor? -zecke
54 OMacAddress(); 58 OMacAddress();
55 OMacAddress( unsigned char* ); 59 OMacAddress( unsigned char* );
56 OMacAddress( const unsigned char* ); 60 OMacAddress( const unsigned char* );
57 OMacAddress( struct ifreq& ); 61 OMacAddress( struct ifreq& );
58 ~OMacAddress(); 62 ~OMacAddress();
59 63
60 QString manufacturer() const; 64 QString manufacturer() const;
61 QString toString( bool substitute = false ) const; 65 QString toString( bool substitute = false ) const;
62 const unsigned char* native() const; 66 const unsigned char* native() const;
63 67
64 // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem? 68 // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem?
65 static OMacAddress fromString( const QString& ); 69 static OMacAddress fromString( const QString& );
66 70
67 public: 71 public:
68 static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff 72 static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff
69 static const OMacAddress& unknown; // 44:44:44:44:44:44 73 static const OMacAddress& unknown; // 44:44:44:44:44:44
70 74
71 private: 75 private:
72 unsigned char _bytes[6]; 76 unsigned char _bytes[6];
73 77
74 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); 78 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
79 class Private;
80 Private *d;
75 81
76}; 82};
77 83
78bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); 84bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
79 85
80 86
81/*====================================================================================== 87/*======================================================================================
82 * OHostAddress 88 * OHostAddress
83 *======================================================================================*/ 89 *======================================================================================*/
84 90
85class OHostAddress : public QHostAddress 91class OHostAddress : public QHostAddress
86{ 92{
87 /*public: 93 /*public:
88 OHostAddress(); 94 OHostAddress();
89 ~OHostAddress(); 95 ~OHostAddress();
90 */ 96 */
97 private:
98 class Private;
99 Private *d;
91}; 100};
92 101
93 102
94/*====================================================================================== 103/*======================================================================================
95 * OPrivateIOCTL 104 * OPrivateIOCTL
96 *======================================================================================*/ 105 *======================================================================================*/
97 106
98class OPrivateIOCTL : public QObject 107class OPrivateIOCTL : public QObject
99{ 108{
100 public: 109 public:
101 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); 110 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs );
102 ~OPrivateIOCTL(); 111 ~OPrivateIOCTL();
103 112
104 int numberGetArgs() const; 113 int numberGetArgs() const;
105 int typeGetArgs() const; 114 int typeGetArgs() const;
106 int numberSetArgs() const; 115 int numberSetArgs() const;
107 int typeSetArgs() const; 116 int typeSetArgs() const;
108 117
109 // FIXME return int? as ::ioctl does? -zecke 118 // FIXME return int? as ::ioctl does? -zecke
110 void invoke() const; 119 void invoke() const;
111 void setParameter( int, u_int32_t ); 120 void setParameter( int, u_int32_t );
112 121
113 private: 122 private:
114 u_int32_t _ioctl; 123 u_int32_t _ioctl;
115 u_int16_t _getargs; 124 u_int16_t _getargs;
116 u_int16_t _setargs; 125 u_int16_t _setargs;
117 126
127 class Private;
128 Private *d;
118}; 129};
119 130
120 /*====================================================================================== 131 /*======================================================================================
121 * Miscellaneous 132 * Miscellaneous
122 *======================================================================================*/ 133 *======================================================================================*/
123 134
135namespace Private {
124void dumpBytes( const unsigned char* data, int num ); 136void dumpBytes( const unsigned char* data, int num );
125QString modeToString( int ); 137QString modeToString( int );
126int stringToMode( const QString& ); 138int stringToMode( const QString& );
139}
140}
141}
127 142
128#define IW_PRIV_TYPE_MASK 0x7000 143#define IW_PRIV_TYPE_MASK 0x7000
129#define IW_PRIV_TYPE_NONE 0x0000 144#define IW_PRIV_TYPE_NONE 0x0000
130#define IW_PRIV_TYPE_BYTE 0x1000 145#define IW_PRIV_TYPE_BYTE 0x1000
131#define IW_PRIV_TYPE_CHAR 0x2000 146#define IW_PRIV_TYPE_CHAR 0x2000
132#define IW_PRIV_TYPE_INT 0x4000 147#define IW_PRIV_TYPE_INT 0x4000
133#define IW_PRIV_TYPE_FLOAT 0x5000 148#define IW_PRIV_TYPE_FLOAT 0x5000
134#define IW_PRIV_TYPE_ADDR 0x6000 149#define IW_PRIV_TYPE_ADDR 0x6000
135#define IW_PRIV_SIZE_FIXED 0x0800 150#define IW_PRIV_SIZE_FIXED 0x0800
136#define IW_PRIV_SIZE_MASK 0x07FF 151#define IW_PRIV_SIZE_MASK 0x07FF
137 152
138#ifndef ARPHRD_IEEE80211 153#ifndef ARPHRD_IEEE80211
139#define ARPHRD_IEEE80211 801 154#define ARPHRD_IEEE80211 801
140#endif 155#endif
141#ifndef ARPHRD_IEEE80211_PRISM 156#ifndef ARPHRD_IEEE80211_PRISM
142#define ARPHRD_IEEE80211_PRISM 802 157#define ARPHRD_IEEE80211_PRISM 802
143#endif 158#endif
144 159
145 160
146/* Network to host order macros */ 161/* Network to host order macros */
147 162
148#ifdef LBL_ALIGN 163#ifdef LBL_ALIGN
149#define EXTRACT_16BITS(p) \ 164#define EXTRACT_16BITS(p) \
150 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ 165 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
151 (u_int16_t)*((const u_int8_t *)(p) + 1))) 166 (u_int16_t)*((const u_int8_t *)(p) + 1)))
152#define EXTRACT_32BITS(p) \ 167#define EXTRACT_32BITS(p) \
153 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ 168 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
154 (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ 169 (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
155 (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ 170 (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
156 (u_int32_t)*((const u_int8_t *)(p) + 3))) 171 (u_int32_t)*((const u_int8_t *)(p) + 3)))
157#else 172#else
158#define EXTRACT_16BITS(p) \ 173#define EXTRACT_16BITS(p) \
159 ((u_int16_t)ntohs(*(const u_int16_t *)(p))) 174 ((u_int16_t)ntohs(*(const u_int16_t *)(p)))
160#define EXTRACT_32BITS(p) \ 175#define EXTRACT_32BITS(p) \
161 ((u_int32_t)ntohl(*(const u_int32_t *)(p))) 176 ((u_int32_t)ntohl(*(const u_int32_t *)(p)))
162#endif 177#endif
163 178
164#define EXTRACT_24BITS(p) \ 179#define EXTRACT_24BITS(p) \
165 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ 180 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
166 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ 181 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
167 (u_int32_t)*((const u_int8_t *)(p) + 2))) 182 (u_int32_t)*((const u_int8_t *)(p) + 2)))
168 183
169/* Little endian protocol host order macros */ 184/* Little endian protocol host order macros */
170#define EXTRACT_LE_8BITS(p) (*(p)) 185#define EXTRACT_LE_8BITS(p) (*(p))
171#define EXTRACT_LE_16BITS(p) \ 186#define EXTRACT_LE_16BITS(p) \
172 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ 187 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
173 (u_int16_t)*((const u_int8_t *)(p) + 0))) 188 (u_int16_t)*((const u_int8_t *)(p) + 0)))
174#define EXTRACT_LE_32BITS(p) \ 189#define EXTRACT_LE_32BITS(p) \
175 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ 190 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \
176 (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ 191 (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
177 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ 192 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
178 (u_int32_t)*((const u_int8_t *)(p) + 0))) 193 (u_int32_t)*((const u_int8_t *)(p) + 0)))
179 194
180#endif // ONETUTILS_H 195#endif // ONETUTILS_H
181 196
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index e5b091f..ab3e77f 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -1,450 +1,456 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003-2004 by Michael 'Mickey' Lauer 3              Copyright (C) 2003-2004 by Michael 'Mickey' Lauer
4 =. <mickey@Vanille.de> 4 =. <mickey@Vanille.de>
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31/* OPIE */ 31/* OPIE */
32 32
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/ostation.h> 34#include <opie2/ostation.h>
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36 36
37/* QT */ 37/* QT */
38 38
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41 41
42/* UNIX */ 42/* UNIX */
43 43
44#include <assert.h> 44#include <assert.h>
45#include <arpa/inet.h> 45#include <arpa/inet.h>
46#include <errno.h> 46#include <errno.h>
47#include <string.h> 47#include <string.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <math.h> 49#include <math.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/socket.h> 51#include <sys/socket.h>
52#include <sys/types.h> 52#include <sys/types.h>
53#include <unistd.h> 53#include <unistd.h>
54#include <linux/sockios.h> 54#include <linux/sockios.h>
55#include <net/if_arp.h> 55#include <net/if_arp.h>
56#include <stdarg.h> 56#include <stdarg.h>
57 57
58#ifndef NODEBUG 58#ifndef NODEBUG
59#include <opie2/odebugmapper.h> 59#include <opie2/odebugmapper.h>
60
61
62using namespace Opie::Core;
63using namespace Opie::Net::Private;
60DebugMapper* debugmapper = new DebugMapper(); 64DebugMapper* debugmapper = new DebugMapper();
61#endif 65#endif
62 66
63/*====================================================================================== 67/*======================================================================================
64 * ONetwork 68 * ONetwork
65 *======================================================================================*/ 69 *======================================================================================*/
66 70
71namespace Opie {
72namespace Net {
67ONetwork* ONetwork::_instance = 0; 73ONetwork* ONetwork::_instance = 0;
68 74
69ONetwork::ONetwork() 75ONetwork::ONetwork()
70{ 76{
71 odebug << "ONetwork::ONetwork()" << oendl; 77 odebug << "ONetwork::ONetwork()" << oendl;
72 odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; 78 odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl;
73 synchronize(); 79 synchronize();
74} 80}
75 81
76void ONetwork::synchronize() 82void ONetwork::synchronize()
77{ 83{
78 // gather available interfaces by inspecting /proc/net/dev 84 // gather available interfaces by inspecting /proc/net/dev
79 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 85 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
80 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices 86 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
81 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev 87 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev
82 88
83 _interfaces.clear(); 89 _interfaces.clear();
84 QString str; 90 QString str;
85 QFile f( "/proc/net/dev" ); 91 QFile f( "/proc/net/dev" );
86 bool hasFile = f.open( IO_ReadOnly ); 92 bool hasFile = f.open( IO_ReadOnly );
87 if ( !hasFile ) 93 if ( !hasFile )
88 { 94 {
89 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; 95 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl;
90 return; 96 return;
91 } 97 }
92 QTextStream s( &f ); 98 QTextStream s( &f );
93 s.readLine(); 99 s.readLine();
94 s.readLine(); 100 s.readLine();
95 while ( !s.atEnd() ) 101 while ( !s.atEnd() )
96 { 102 {
97 s >> str; 103 s >> str;
98 str.truncate( str.find( ':' ) ); 104 str.truncate( str.find( ':' ) );
99 odebug << "ONetwork: found interface '" << str << "'" << oendl; 105 odebug << "ONetwork: found interface '" << str << "'" << oendl;
100 ONetworkInterface* iface; 106 ONetworkInterface* iface;
101 if ( isWirelessInterface( str ) ) 107 if ( isWirelessInterface( str ) )
102 { 108 {
103 iface = new OWirelessNetworkInterface( this, (const char*) str ); 109 iface = new OWirelessNetworkInterface( this, (const char*) str );
104 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; 110 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl;
105 } 111 }
106 else 112 else
107 { 113 {
108 iface = new ONetworkInterface( this, (const char*) str ); 114 iface = new ONetworkInterface( this, (const char*) str );
109 } 115 }
110 _interfaces.insert( str, iface ); 116 _interfaces.insert( str, iface );
111 s.readLine(); 117 s.readLine();
112 } 118 }
113} 119}
114 120
115 121
116short ONetwork::wirelessExtensionVersion() 122short ONetwork::wirelessExtensionVersion()
117{ 123{
118 return WIRELESS_EXT; 124 return WIRELESS_EXT;
119} 125}
120 126
121 127
122int ONetwork::count() const 128int ONetwork::count() const
123{ 129{
124 return _interfaces.count(); 130 return _interfaces.count();
125} 131}
126 132
127 133
128ONetworkInterface* ONetwork::interface( const QString& iface ) const 134ONetworkInterface* ONetwork::interface( const QString& iface ) const
129{ 135{
130 return _interfaces[iface]; 136 return _interfaces[iface];
131} 137}
132 138
133 139
134ONetwork* ONetwork::instance() 140ONetwork* ONetwork::instance()
135{ 141{
136 if ( !_instance ) _instance = new ONetwork(); 142 if ( !_instance ) _instance = new ONetwork();
137 return _instance; 143 return _instance;
138} 144}
139 145
140 146
141ONetwork::InterfaceIterator ONetwork::iterator() const 147ONetwork::InterfaceIterator ONetwork::iterator() const
142{ 148{
143 return ONetwork::InterfaceIterator( _interfaces ); 149 return ONetwork::InterfaceIterator( _interfaces );
144} 150}
145 151
146 152
147bool ONetwork::isPresent( const char* name ) const 153bool ONetwork::isPresent( const char* name ) const
148{ 154{
149 int sfd = socket( AF_INET, SOCK_STREAM, 0 ); 155 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
150 struct ifreq ifr; 156 struct ifreq ifr;
151 memset( &ifr, 0, sizeof( struct ifreq ) ); 157 memset( &ifr, 0, sizeof( struct ifreq ) );
152 strcpy( (char*) &ifr.ifr_name, name ); 158 strcpy( (char*) &ifr.ifr_name, name );
153 int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr ); 159 int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr );
154 return result != -1; 160 return result != -1;
155} 161}
156 162
157 163
158bool ONetwork::isWirelessInterface( const char* name ) const 164bool ONetwork::isWirelessInterface( const char* name ) const
159{ 165{
160 int sfd = socket( AF_INET, SOCK_STREAM, 0 ); 166 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
161 struct iwreq iwr; 167 struct iwreq iwr;
162 memset( &iwr, 0, sizeof( struct iwreq ) ); 168 memset( &iwr, 0, sizeof( struct iwreq ) );
163 strcpy( (char*) &iwr.ifr_name, name ); 169 strcpy( (char*) &iwr.ifr_name, name );
164 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); 170 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr );
165 return result != -1; 171 return result != -1;
166} 172}
167 173
168/*====================================================================================== 174/*======================================================================================
169 * ONetworkInterface 175 * ONetworkInterface
170 *======================================================================================*/ 176 *======================================================================================*/
171 177
172ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) 178ONetworkInterface::ONetworkInterface( QObject* parent, const char* name )
173 :QObject( parent, name ), 179 :QObject( parent, name ),
174 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) 180 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 )
175{ 181{
176 odebug << "ONetworkInterface::ONetworkInterface()" << oendl; 182 odebug << "ONetworkInterface::ONetworkInterface()" << oendl;
177 init(); 183 init();
178} 184}
179 185
180 186
181struct ifreq& ONetworkInterface::ifr() const 187struct ifreq& ONetworkInterface::ifr() const
182{ 188{
183 return _ifr; 189 return _ifr;
184} 190}
185 191
186 192
187void ONetworkInterface::init() 193void ONetworkInterface::init()
188{ 194{
189 odebug << "ONetworkInterface::init()" << oendl; 195 odebug << "ONetworkInterface::init()" << oendl;
190 196
191 memset( &_ifr, 0, sizeof( struct ifreq ) ); 197 memset( &_ifr, 0, sizeof( struct ifreq ) );
192 198
193 if ( _sfd == -1 ) 199 if ( _sfd == -1 )
194 { 200 {
195 odebug << "ONetworkInterface::init(): Warning - can't get socket for device '" << name() << "'" << oendl; 201 odebug << "ONetworkInterface::init(): Warning - can't get socket for device '" << name() << "'" << oendl;
196 return; 202 return;
197 } 203 }
198} 204}
199 205
200 206
201bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const 207bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const
202{ 208{
203 #ifndef NODEBUG 209 #ifndef NODEBUG
204 int result = ::ioctl( _sfd, call, &ifreq ); 210 int result = ::ioctl( _sfd, call, &ifreq );
205 if ( result == -1 ) 211 if ( result == -1 )
206 odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) 212 odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call )
207 << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; 213 << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl;
208 else 214 else
209 odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) 215 odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call )
210 << "' - Status: Ok." << oendl; 216 << "' - Status: Ok." << oendl;
211 return ( result != -1 ); 217 return ( result != -1 );
212 #else 218 #else
213 return ::ioctl( _sfd, call, &ifreq ) != -1; 219 return ::ioctl( _sfd, call, &ifreq ) != -1;
214 #endif 220 #endif
215} 221}
216 222
217 223
218bool ONetworkInterface::ioctl( int call ) const 224bool ONetworkInterface::ioctl( int call ) const
219{ 225{
220 strcpy( _ifr.ifr_name, name() ); 226 strcpy( _ifr.ifr_name, name() );
221 return ioctl( call, _ifr ); 227 return ioctl( call, _ifr );
222} 228}
223 229
224 230
225bool ONetworkInterface::isLoopback() const 231bool ONetworkInterface::isLoopback() const
226{ 232{
227 ioctl( SIOCGIFFLAGS ); 233 ioctl( SIOCGIFFLAGS );
228 return _ifr.ifr_flags & IFF_LOOPBACK; 234 return _ifr.ifr_flags & IFF_LOOPBACK;
229} 235}
230 236
231 237
232bool ONetworkInterface::setUp( bool b ) 238bool ONetworkInterface::setUp( bool b )
233{ 239{
234 ioctl( SIOCGIFFLAGS ); 240 ioctl( SIOCGIFFLAGS );
235 if ( b ) _ifr.ifr_flags |= IFF_UP; 241 if ( b ) _ifr.ifr_flags |= IFF_UP;
236 else _ifr.ifr_flags &= (~IFF_UP); 242 else _ifr.ifr_flags &= (~IFF_UP);
237 return ioctl( SIOCSIFFLAGS ); 243 return ioctl( SIOCSIFFLAGS );
238} 244}
239 245
240 246
241bool ONetworkInterface::isUp() const 247bool ONetworkInterface::isUp() const
242{ 248{
243 ioctl( SIOCGIFFLAGS ); 249 ioctl( SIOCGIFFLAGS );
244 return _ifr.ifr_flags & IFF_UP; 250 return _ifr.ifr_flags & IFF_UP;
245} 251}
246 252
247 253
248void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) 254void ONetworkInterface::setIPV4Address( const QHostAddress& addr )
249{ 255{
250 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; 256 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr;
251 sa->sin_family = AF_INET; 257 sa->sin_family = AF_INET;
252 sa->sin_port = 0; 258 sa->sin_port = 0;
253 sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); 259 sa->sin_addr.s_addr = htonl( addr.ip4Addr() );
254 ioctl( SIOCSIFADDR ); 260 ioctl( SIOCSIFADDR );
255} 261}
256 262
257 263
258QString ONetworkInterface::ipV4Address() const 264QString ONetworkInterface::ipV4Address() const
259{ 265{
260 if ( ioctl( SIOCGIFADDR ) ) 266 if ( ioctl( SIOCGIFADDR ) )
261 { 267 {
262 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; 268 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr;
263 //FIXME: Use QHostAddress here 269 //FIXME: Use QHostAddress here
264 return QString( inet_ntoa( sa->sin_addr ) ); 270 return QString( inet_ntoa( sa->sin_addr ) );
265 } 271 }
266 else 272 else
267 return "<unknown>"; 273 return "<unknown>";
268 274
269} 275}
270 276
271 277
272void ONetworkInterface::setMacAddress( const OMacAddress& addr ) 278void ONetworkInterface::setMacAddress( const OMacAddress& addr )
273{ 279{
274 _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; 280 _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
275 memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); 281 memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 );
276 ioctl( SIOCSIFHWADDR ); 282 ioctl( SIOCSIFHWADDR );
277} 283}
278 284
279 285
280OMacAddress ONetworkInterface::macAddress() const 286OMacAddress ONetworkInterface::macAddress() const
281{ 287{
282 if ( ioctl( SIOCGIFHWADDR ) ) 288 if ( ioctl( SIOCGIFHWADDR ) )
283 { 289 {
284 return OMacAddress( _ifr ); 290 return OMacAddress( _ifr );
285 } 291 }
286 else 292 else
287 { 293 {
288 return OMacAddress::unknown; 294 return OMacAddress::unknown;
289 } 295 }
290} 296}
291 297
292 298
293void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) 299void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr )
294{ 300{
295 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; 301 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr;
296 sa->sin_family = AF_INET; 302 sa->sin_family = AF_INET;
297 sa->sin_port = 0; 303 sa->sin_port = 0;
298 sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); 304 sa->sin_addr.s_addr = htonl( addr.ip4Addr() );
299 ioctl( SIOCSIFNETMASK ); 305 ioctl( SIOCSIFNETMASK );
300} 306}
301 307
302 308
303QString ONetworkInterface::ipV4Netmask() const 309QString ONetworkInterface::ipV4Netmask() const
304{ 310{
305 if ( ioctl( SIOCGIFNETMASK ) ) 311 if ( ioctl( SIOCGIFNETMASK ) )
306 { 312 {
307 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; 313 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr;
308 //FIXME: Use QHostAddress here 314 //FIXME: Use QHostAddress here
309 return QString( inet_ntoa( sa->sin_addr ) ); 315 return QString( inet_ntoa( sa->sin_addr ) );
310 } 316 }
311 else 317 else
312 return "<unknown>"; 318 return "<unknown>";
313} 319}
314 320
315 321
316int ONetworkInterface::dataLinkType() const 322int ONetworkInterface::dataLinkType() const
317{ 323{
318 if ( ioctl( SIOCGIFHWADDR ) ) 324 if ( ioctl( SIOCGIFHWADDR ) )
319 { 325 {
320 return _ifr.ifr_hwaddr.sa_family; 326 return _ifr.ifr_hwaddr.sa_family;
321 } 327 }
322 else 328 else
323 { 329 {
324 return -1; 330 return -1;
325 } 331 }
326} 332}
327 333
328 334
329void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) 335void ONetworkInterface::setMonitoring( OMonitoringInterface* m )
330{ 336{
331 _mon = m; 337 _mon = m;
332 odebug << "ONetwork::setMonitoring(): Installed monitoring driver '" << m->name() << "' on interface '" << name() << "'" << oendl; 338 odebug << "ONetwork::setMonitoring(): Installed monitoring driver '" << m->name() << "' on interface '" << name() << "'" << oendl;
333} 339}
334 340
335 341
336OMonitoringInterface* ONetworkInterface::monitoring() const 342OMonitoringInterface* ONetworkInterface::monitoring() const
337{ 343{
338 return _mon; 344 return _mon;
339} 345}
340 346
341 347
342ONetworkInterface::~ONetworkInterface() 348ONetworkInterface::~ONetworkInterface()
343{ 349{
344 odebug << "ONetworkInterface::~ONetworkInterface()" << oendl; 350 odebug << "ONetworkInterface::~ONetworkInterface()" << oendl;
345 if ( _sfd != -1 ) ::close( _sfd ); 351 if ( _sfd != -1 ) ::close( _sfd );
346} 352}
347 353
348 354
349bool ONetworkInterface::setPromiscuousMode( bool b ) 355bool ONetworkInterface::setPromiscuousMode( bool b )
350{ 356{
351 ioctl( SIOCGIFFLAGS ); 357 ioctl( SIOCGIFFLAGS );
352 if ( b ) _ifr.ifr_flags |= IFF_PROMISC; 358 if ( b ) _ifr.ifr_flags |= IFF_PROMISC;
353 else _ifr.ifr_flags &= (~IFF_PROMISC); 359 else _ifr.ifr_flags &= (~IFF_PROMISC);
354 return ioctl( SIOCSIFFLAGS ); 360 return ioctl( SIOCSIFFLAGS );
355} 361}
356 362
357 363
358bool ONetworkInterface::promiscuousMode() const 364bool ONetworkInterface::promiscuousMode() const
359{ 365{
360 ioctl( SIOCGIFFLAGS ); 366 ioctl( SIOCGIFFLAGS );
361 return _ifr.ifr_flags & IFF_PROMISC; 367 return _ifr.ifr_flags & IFF_PROMISC;
362} 368}
363 369
364 370
365bool ONetworkInterface::isWireless() const 371bool ONetworkInterface::isWireless() const
366{ 372{
367 return ioctl( SIOCGIWNAME ); 373 return ioctl( SIOCGIWNAME );
368} 374}
369 375
370 376
371/*====================================================================================== 377/*======================================================================================
372 * OChannelHopper 378 * OChannelHopper
373 *======================================================================================*/ 379 *======================================================================================*/
374 380
375OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) 381OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface )
376 :QObject( 0, "Mickey's funky hopper" ), 382 :QObject( 0, "Mickey's funky hopper" ),
377 _iface( iface ), _interval( 0 ), _tid( 0 ) 383 _iface( iface ), _interval( 0 ), _tid( 0 )
378{ 384{
379 int _maxChannel = iface->channels()+1; 385 int _maxChannel = iface->channels()+1;
380 // generate fancy hopping sequence honoring the device capabilities 386 // generate fancy hopping sequence honoring the device capabilities
381 if ( _maxChannel >= 1 ) _channels.append( 1 ); 387 if ( _maxChannel >= 1 ) _channels.append( 1 );
382 if ( _maxChannel >= 7 ) _channels.append( 7 ); 388 if ( _maxChannel >= 7 ) _channels.append( 7 );
383 if ( _maxChannel >= 13 ) _channels.append( 13 ); 389 if ( _maxChannel >= 13 ) _channels.append( 13 );
384 if ( _maxChannel >= 2 ) _channels.append( 2 ); 390 if ( _maxChannel >= 2 ) _channels.append( 2 );
385 if ( _maxChannel >= 8 ) _channels.append( 8 ); 391 if ( _maxChannel >= 8 ) _channels.append( 8 );
386 if ( _maxChannel >= 3 ) _channels.append( 3 ); 392 if ( _maxChannel >= 3 ) _channels.append( 3 );
387 if ( _maxChannel >= 14 ) _channels.append( 14 ); 393 if ( _maxChannel >= 14 ) _channels.append( 14 );
388 if ( _maxChannel >= 9 ) _channels.append( 9 ); 394 if ( _maxChannel >= 9 ) _channels.append( 9 );
389 if ( _maxChannel >= 4 ) _channels.append( 4 ); 395 if ( _maxChannel >= 4 ) _channels.append( 4 );
390 if ( _maxChannel >= 10 ) _channels.append( 10 ); 396 if ( _maxChannel >= 10 ) _channels.append( 10 );
391 if ( _maxChannel >= 5 ) _channels.append( 5 ); 397 if ( _maxChannel >= 5 ) _channels.append( 5 );
392 if ( _maxChannel >= 11 ) _channels.append( 11 ); 398 if ( _maxChannel >= 11 ) _channels.append( 11 );
393 if ( _maxChannel >= 6 ) _channels.append( 6 ); 399 if ( _maxChannel >= 6 ) _channels.append( 6 );
394 if ( _maxChannel >= 12 ) _channels.append( 12 ); 400 if ( _maxChannel >= 12 ) _channels.append( 12 );
395 _channel = _channels.begin(); 401 _channel = _channels.begin();
396 402
397} 403}
398 404
399 405
400OChannelHopper::~OChannelHopper() 406OChannelHopper::~OChannelHopper()
401{ 407{
402} 408}
403 409
404 410
405bool OChannelHopper::isActive() const 411bool OChannelHopper::isActive() const
406{ 412{
407 return _tid; 413 return _tid;
408} 414}
409 415
410 416
411int OChannelHopper::channel() const 417int OChannelHopper::channel() const
412{ 418{
413 return *_channel; 419 return *_channel;
414} 420}
415 421
416 422
417void OChannelHopper::timerEvent( QTimerEvent* ) 423void OChannelHopper::timerEvent( QTimerEvent* )
418{ 424{
419 _iface->setChannel( *_channel ); 425 _iface->setChannel( *_channel );
420 emit( hopped( *_channel ) ); 426 emit( hopped( *_channel ) );
421 odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl; 427 odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl;
422 if ( ++_channel == _channels.end() ) _channel = _channels.begin(); 428 if ( ++_channel == _channels.end() ) _channel = _channels.begin();
423} 429}
424 430
425 431
426void OChannelHopper::setInterval( int interval ) 432void OChannelHopper::setInterval( int interval )
427{ 433{
428 if ( interval == _interval ) 434 if ( interval == _interval )
429 return; 435 return;
430 436
431 if ( _interval ) 437 if ( _interval )
432 killTimer( _tid ); 438 killTimer( _tid );
433 439
434 _tid = 0; 440 _tid = 0;
435 _interval = interval; 441 _interval = interval;
436 442
437 if ( _interval ) 443 if ( _interval )
438 { 444 {
439 _tid = startTimer( interval ); 445 _tid = startTimer( interval );
440 } 446 }
441} 447}
442 448
443 449
444int OChannelHopper::interval() const 450int OChannelHopper::interval() const
445{ 451{
446 return _interval; 452 return _interval;
447} 453}
448 454
449 455
450/*====================================================================================== 456/*======================================================================================
@@ -856,384 +862,387 @@ void OWirelessNetworkInterface::setSSID( const QString& ssid )
856 862
857 863
858OStationList* OWirelessNetworkInterface::scanNetwork() 864OStationList* OWirelessNetworkInterface::scanNetwork()
859{ 865{
860 _iwr.u.param.flags = IW_SCAN_DEFAULT; 866 _iwr.u.param.flags = IW_SCAN_DEFAULT;
861 _iwr.u.param.value = 0; 867 _iwr.u.param.value = 0;
862 if ( !wioctl( SIOCSIWSCAN ) ) 868 if ( !wioctl( SIOCSIWSCAN ) )
863 { 869 {
864 return 0; 870 return 0;
865 } 871 }
866 872
867 OStationList* stations = new OStationList(); 873 OStationList* stations = new OStationList();
868 874
869 int timeout = 1000000; 875 int timeout = 1000000;
870 876
871 odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; 877 odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl;
872 878
873 bool results = false; 879 bool results = false;
874 struct timeval tv; 880 struct timeval tv;
875 tv.tv_sec = 0; 881 tv.tv_sec = 0;
876 tv.tv_usec = 250000; // initial timeout ~ 250ms 882 tv.tv_usec = 250000; // initial timeout ~ 250ms
877 char buffer[IW_SCAN_MAX_DATA]; 883 char buffer[IW_SCAN_MAX_DATA];
878 884
879 while ( !results && timeout > 0 ) 885 while ( !results && timeout > 0 )
880 { 886 {
881 timeout -= tv.tv_usec; 887 timeout -= tv.tv_usec;
882 select( 0, 0, 0, 0, &tv ); 888 select( 0, 0, 0, 0, &tv );
883 889
884 _iwr.u.data.pointer = &buffer[0]; 890 _iwr.u.data.pointer = &buffer[0];
885 _iwr.u.data.flags = 0; 891 _iwr.u.data.flags = 0;
886 _iwr.u.data.length = sizeof buffer; 892 _iwr.u.data.length = sizeof buffer;
887 if ( wioctl( SIOCGIWSCAN ) ) 893 if ( wioctl( SIOCGIWSCAN ) )
888 { 894 {
889 results = true; 895 results = true;
890 continue; 896 continue;
891 } 897 }
892 else if ( errno == EAGAIN) 898 else if ( errno == EAGAIN)
893 { 899 {
894 odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl; 900 odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl;
895 #if 0 901 #if 0
896 if ( qApp ) 902 if ( qApp )
897 { 903 {
898 qApp->processEvents( 100 ); 904 qApp->processEvents( 100 );
899 continue; 905 continue;
900 } 906 }
901 #endif 907 #endif
902 tv.tv_sec = 0; 908 tv.tv_sec = 0;
903 tv.tv_usec = 100000; 909 tv.tv_usec = 100000;
904 continue; 910 continue;
905 } 911 }
906 } 912 }
907 913
908 odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl; 914 odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl;
909 915
910 if ( results ) 916 if ( results )
911 { 917 {
912 odebug << " - result length = " << _iwr.u.data.length << oendl; 918 odebug << " - result length = " << _iwr.u.data.length << oendl;
913 if ( !_iwr.u.data.length ) 919 if ( !_iwr.u.data.length )
914 { 920 {
915 odebug << " - no results (empty neighbourhood)" << oendl; 921 odebug << " - no results (empty neighbourhood)" << oendl;
916 return stations; 922 return stations;
917 } 923 }
918 924
919 odebug << " - results are in!" << oendl; 925 odebug << " - results are in!" << oendl;
920 dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); 926 dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length );
921 927
922 // parse results 928 // parse results
923 929
924 int offset = 0; 930 int offset = 0;
925 struct iw_event* we = (struct iw_event*) &buffer[0]; 931 struct iw_event* we = (struct iw_event*) &buffer[0];
926 932
927 while ( offset < _iwr.u.data.length ) 933 while ( offset < _iwr.u.data.length )
928 { 934 {
929 //const char* cmd = *(*_ioctlmap)[we->cmd]; 935 //const char* cmd = *(*_ioctlmap)[we->cmd];
930 //if ( !cmd ) cmd = "<unknown>"; 936 //if ( !cmd ) cmd = "<unknown>";
931 odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl; 937 odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl;
932 switch (we->cmd) 938 switch (we->cmd)
933 { 939 {
934 case SIOCGIWAP: 940 case SIOCGIWAP:
935 { 941 {
936 odebug << "SIOCGIWAP" << oendl; 942 odebug << "SIOCGIWAP" << oendl;
937 stations->append( new OStation() ); 943 stations->append( new OStation() );
938 stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; 944 stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0];
939 break; 945 break;
940 } 946 }
941 case SIOCGIWMODE: 947 case SIOCGIWMODE:
942 { 948 {
943 odebug << "SIOCGIWMODE" << oendl; 949 odebug << "SIOCGIWMODE" << oendl;
944 stations->last()->type = modeToString( we->u.mode ); 950 stations->last()->type = modeToString( we->u.mode );
945 break; 951 break;
946 } 952 }
947 case SIOCGIWFREQ: 953 case SIOCGIWFREQ:
948 { 954 {
949 odebug << "SIOCGIWFREQ" << oendl; 955 odebug << "SIOCGIWFREQ" << oendl;
950 stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; 956 stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ];
951 break; 957 break;
952 } 958 }
953 case SIOCGIWESSID: 959 case SIOCGIWESSID:
954 { 960 {
955 odebug << "SIOCGIWESSID" << oendl; 961 odebug << "SIOCGIWESSID" << oendl;
956 stations->last()->ssid = we->u.essid.pointer; 962 stations->last()->ssid = we->u.essid.pointer;
957 break; 963 break;
958 } 964 }
959 case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; 965 case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break;
960 case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break; 966 case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break;
961 case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ 967 case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */
962 case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */ 968 case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */
963 case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ 969 case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */
964 case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ 970 case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */
965 case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ 971 case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */
966 default: odebug << "unhandled event" << oendl; 972 default: odebug << "unhandled event" << oendl;
967 } 973 }
968 974
969 offset += we->len; 975 offset += we->len;
970 we = (struct iw_event*) &buffer[offset]; 976 we = (struct iw_event*) &buffer[offset];
971 } 977 }
972 return stations; 978 return stations;
973 979
974 return stations; 980 return stations;
975 981
976 } 982 }
977 else 983 else
978 { 984 {
979 odebug << " - no results (timeout) :(" << oendl; 985 odebug << " - no results (timeout) :(" << oendl;
980 return stations; 986 return stations;
981 } 987 }
982} 988}
983 989
984 990
985int OWirelessNetworkInterface::signalStrength() const 991int OWirelessNetworkInterface::signalStrength() const
986{ 992{
987 iw_statistics stat; 993 iw_statistics stat;
988 ::memset( &stat, 0, sizeof stat ); 994 ::memset( &stat, 0, sizeof stat );
989 _iwr.u.data.pointer = (char*) &stat; 995 _iwr.u.data.pointer = (char*) &stat;
990 _iwr.u.data.flags = 0; 996 _iwr.u.data.flags = 0;
991 _iwr.u.data.length = sizeof stat; 997 _iwr.u.data.length = sizeof stat;
992 998
993 if ( !wioctl( SIOCGIWSTATS ) ) 999 if ( !wioctl( SIOCGIWSTATS ) )
994 { 1000 {
995 return -1; 1001 return -1;
996 } 1002 }
997 1003
998 int max = _range.max_qual.qual; 1004 int max = _range.max_qual.qual;
999 int cur = stat.qual.qual; 1005 int cur = stat.qual.qual;
1000 int lev = stat.qual.level; //FIXME: Do something with them? 1006 int lev = stat.qual.level; //FIXME: Do something with them?
1001 int noi = stat.qual.noise; //FIXME: Do something with them? 1007 int noi = stat.qual.noise; //FIXME: Do something with them?
1002 1008
1003 return cur*100/max; 1009 return cur*100/max;
1004} 1010}
1005 1011
1006 1012
1007bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const 1013bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
1008{ 1014{
1009 #ifndef NODEBUG 1015 #ifndef NODEBUG
1010 int result = ::ioctl( _sfd, call, &iwreq ); 1016 int result = ::ioctl( _sfd, call, &iwreq );
1011 1017
1012 if ( result == -1 ) 1018 if ( result == -1 )
1013 odebug << "ONetworkInterface::wioctl (" << name() << ") call '" 1019 odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
1014 << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; 1020 << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl;
1015 else 1021 else
1016 odebug << "ONetworkInterface::wioctl (" << name() << ") call '" 1022 odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
1017 << debugmapper->map( call ) << "' - Status: Ok." << oendl; 1023 << debugmapper->map( call ) << "' - Status: Ok." << oendl;
1018 1024
1019 return ( result != -1 ); 1025 return ( result != -1 );
1020 #else 1026 #else
1021 return ::ioctl( _sfd, call, &iwreq ) != -1; 1027 return ::ioctl( _sfd, call, &iwreq ) != -1;
1022 #endif 1028 #endif
1023} 1029}
1024 1030
1025 1031
1026bool OWirelessNetworkInterface::wioctl( int call ) const 1032bool OWirelessNetworkInterface::wioctl( int call ) const
1027{ 1033{
1028 strcpy( _iwr.ifr_name, name() ); 1034 strcpy( _iwr.ifr_name, name() );
1029 return wioctl( call, _iwr ); 1035 return wioctl( call, _iwr );
1030} 1036}
1031 1037
1032 1038
1033/*====================================================================================== 1039/*======================================================================================
1034 * OMonitoringInterface 1040 * OMonitoringInterface
1035 *======================================================================================*/ 1041 *======================================================================================*/
1036 1042
1037OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1043OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1038 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) 1044 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader )
1039{ 1045{
1040} 1046}
1041 1047
1042 1048
1043OMonitoringInterface::~OMonitoringInterface() 1049OMonitoringInterface::~OMonitoringInterface()
1044{ 1050{
1045} 1051}
1046 1052
1047 1053
1048void OMonitoringInterface::setChannel( int c ) 1054void OMonitoringInterface::setChannel( int c )
1049{ 1055{
1050 // use standard WE channel switching protocol 1056 // use standard WE channel switching protocol
1051 memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); 1057 memset( &_if->_iwr, 0, sizeof( struct iwreq ) );
1052 _if->_iwr.u.freq.m = c; 1058 _if->_iwr.u.freq.m = c;
1053 _if->_iwr.u.freq.e = 0; 1059 _if->_iwr.u.freq.e = 0;
1054 _if->wioctl( SIOCSIWFREQ ); 1060 _if->wioctl( SIOCSIWFREQ );
1055} 1061}
1056 1062
1057 1063
1058void OMonitoringInterface::setEnabled( bool b ) 1064void OMonitoringInterface::setEnabled( bool b )
1059{ 1065{
1060} 1066}
1061 1067
1062 1068
1063/*====================================================================================== 1069/*======================================================================================
1064 * OCiscoMonitoringInterface 1070 * OCiscoMonitoringInterface
1065 *======================================================================================*/ 1071 *======================================================================================*/
1066 1072
1067OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1073OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1068 :OMonitoringInterface( iface, prismHeader ) 1074 :OMonitoringInterface( iface, prismHeader )
1069{ 1075{
1070 iface->setMonitoring( this ); 1076 iface->setMonitoring( this );
1071} 1077}
1072 1078
1073 1079
1074OCiscoMonitoringInterface::~OCiscoMonitoringInterface() 1080OCiscoMonitoringInterface::~OCiscoMonitoringInterface()
1075{ 1081{
1076} 1082}
1077 1083
1078 1084
1079void OCiscoMonitoringInterface::setEnabled( bool b ) 1085void OCiscoMonitoringInterface::setEnabled( bool b )
1080{ 1086{
1081 QString fname; 1087 QString fname;
1082 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); 1088 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() );
1083 QFile f( fname ); 1089 QFile f( fname );
1084 if ( !f.exists() ) return; 1090 if ( !f.exists() ) return;
1085 1091
1086 if ( f.open( IO_WriteOnly ) ) 1092 if ( f.open( IO_WriteOnly ) )
1087 { 1093 {
1088 QTextStream s( &f ); 1094 QTextStream s( &f );
1089 s << "Mode: r"; 1095 s << "Mode: r";
1090 s << "Mode: y"; 1096 s << "Mode: y";
1091 s << "XmitPower: 1"; 1097 s << "XmitPower: 1";
1092 } 1098 }
1093 1099
1094 // flushing and closing will be done automatically when f goes out of scope 1100 // flushing and closing will be done automatically when f goes out of scope
1095} 1101}
1096 1102
1097 1103
1098QString OCiscoMonitoringInterface::name() const 1104QString OCiscoMonitoringInterface::name() const
1099{ 1105{
1100 return "cisco"; 1106 return "cisco";
1101} 1107}
1102 1108
1103 1109
1104void OCiscoMonitoringInterface::setChannel( int ) 1110void OCiscoMonitoringInterface::setChannel( int )
1105{ 1111{
1106 // cisco devices automatically switch channels when in monitor mode 1112 // cisco devices automatically switch channels when in monitor mode
1107} 1113}
1108 1114
1109 1115
1110/*====================================================================================== 1116/*======================================================================================
1111 * OWlanNGMonitoringInterface 1117 * OWlanNGMonitoringInterface
1112 *======================================================================================*/ 1118 *======================================================================================*/
1113 1119
1114 1120
1115OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1121OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1116 :OMonitoringInterface( iface, prismHeader ) 1122 :OMonitoringInterface( iface, prismHeader )
1117{ 1123{
1118 iface->setMonitoring( this ); 1124 iface->setMonitoring( this );
1119} 1125}
1120 1126
1121 1127
1122OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() 1128OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface()
1123{ 1129{
1124} 1130}
1125 1131
1126 1132
1127void OWlanNGMonitoringInterface::setEnabled( bool b ) 1133void OWlanNGMonitoringInterface::setEnabled( bool b )
1128{ 1134{
1129 //FIXME: do nothing if its already in the same mode 1135 //FIXME: do nothing if its already in the same mode
1130 1136
1131 QString enable = b ? "true" : "false"; 1137 QString enable = b ? "true" : "false";
1132 QString prism = _prismHeader ? "true" : "false"; 1138 QString prism = _prismHeader ? "true" : "false";
1133 QString cmd; 1139 QString cmd;
1134 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", 1140 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s",
1135 (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); 1141 (const char*) _if->name(), 1, (const char*) enable, (const char*) prism );
1136 system( cmd ); 1142 system( cmd );
1137} 1143}
1138 1144
1139 1145
1140QString OWlanNGMonitoringInterface::name() const 1146QString OWlanNGMonitoringInterface::name() const
1141{ 1147{
1142 return "wlan-ng"; 1148 return "wlan-ng";
1143} 1149}
1144 1150
1145 1151
1146void OWlanNGMonitoringInterface::setChannel( int c ) 1152void OWlanNGMonitoringInterface::setChannel( int c )
1147{ 1153{
1148 //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. 1154 //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't.
1149 1155
1150 QString enable = "true"; //_if->monitorMode() ? "true" : "false"; 1156 QString enable = "true"; //_if->monitorMode() ? "true" : "false";
1151 QString prism = _prismHeader ? "true" : "false"; 1157 QString prism = _prismHeader ? "true" : "false";
1152 QString cmd; 1158 QString cmd;
1153 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", 1159 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s",
1154 (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); 1160 (const char*) _if->name(), c, (const char*) enable, (const char*) prism );
1155 system( cmd ); 1161 system( cmd );
1156} 1162}
1157 1163
1158 1164
1159/*====================================================================================== 1165/*======================================================================================
1160 * OHostAPMonitoringInterface 1166 * OHostAPMonitoringInterface
1161 *======================================================================================*/ 1167 *======================================================================================*/
1162 1168
1163OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1169OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1164 :OMonitoringInterface( iface, prismHeader ) 1170 :OMonitoringInterface( iface, prismHeader )
1165{ 1171{
1166 iface->setMonitoring( this ); 1172 iface->setMonitoring( this );
1167} 1173}
1168 1174
1169OHostAPMonitoringInterface::~OHostAPMonitoringInterface() 1175OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
1170{ 1176{
1171} 1177}
1172 1178
1173void OHostAPMonitoringInterface::setEnabled( bool b ) 1179void OHostAPMonitoringInterface::setEnabled( bool b )
1174{ 1180{
1175 int monitorCode = _prismHeader ? 1 : 2; 1181 int monitorCode = _prismHeader ? 1 : 2;
1176 if ( b ) 1182 if ( b )
1177 { 1183 {
1178 _if->setPrivate( "monitor", 1, monitorCode ); 1184 _if->setPrivate( "monitor", 1, monitorCode );
1179 } 1185 }
1180 else 1186 else
1181 { 1187 {
1182 _if->setPrivate( "monitor", 1, 0 ); 1188 _if->setPrivate( "monitor", 1, 0 );
1183 } 1189 }
1184} 1190}
1185 1191
1186 1192
1187QString OHostAPMonitoringInterface::name() const 1193QString OHostAPMonitoringInterface::name() const
1188{ 1194{
1189 return "hostap"; 1195 return "hostap";
1190} 1196}
1191 1197
1192 1198
1193/*====================================================================================== 1199/*======================================================================================
1194 * OOrinocoNetworkInterface 1200 * OOrinocoNetworkInterface
1195 *======================================================================================*/ 1201 *======================================================================================*/
1196 1202
1197OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1203OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1198 :OMonitoringInterface( iface, prismHeader ) 1204 :OMonitoringInterface( iface, prismHeader )
1199{ 1205{
1200 iface->setMonitoring( this ); 1206 iface->setMonitoring( this );
1201} 1207}
1202 1208
1203 1209
1204OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() 1210OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
1205{ 1211{
1206} 1212}
1207 1213
1208 1214
1209void OOrinocoMonitoringInterface::setChannel( int c ) 1215void OOrinocoMonitoringInterface::setChannel( int c )
1210{ 1216{
1211 if ( !_if->hasPrivate( "monitor" ) ) 1217 if ( !_if->hasPrivate( "monitor" ) )
1212 { 1218 {
1213 this->OMonitoringInterface::setChannel( c ); 1219 this->OMonitoringInterface::setChannel( c );
1214 } 1220 }
1215 else 1221 else
1216 { 1222 {
1217 int monitorCode = _prismHeader ? 1 : 2; 1223 int monitorCode = _prismHeader ? 1 : 2;
1218 _if->setPrivate( "monitor", 2, monitorCode, c ); 1224 _if->setPrivate( "monitor", 2, monitorCode, c );
1219 } 1225 }
1220} 1226}
1221 1227
1222 1228
1223void OOrinocoMonitoringInterface::setEnabled( bool b ) 1229void OOrinocoMonitoringInterface::setEnabled( bool b )
1224{ 1230{
1225 if ( b ) 1231 if ( b )
1226 { 1232 {
1227 setChannel( 1 ); 1233 setChannel( 1 );
1228 } 1234 }
1229 else 1235 else
1230 { 1236 {
1231 _if->setPrivate( "monitor", 2, 0, 0 ); 1237 _if->setPrivate( "monitor", 2, 0, 0 );
1232 } 1238 }
1233} 1239}
1234 1240
1235 1241
1236QString OOrinocoMonitoringInterface::name() const 1242QString OOrinocoMonitoringInterface::name() const
1237{ 1243{
1238 return "orinoco"; 1244 return "orinoco";
1239} 1245}
1246
1247}
1248}
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index 93b129f..a953296 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -1,559 +1,590 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003-2004 by Michael 'Mickey' Lauer 3              Copyright (C) 2003-2004 by Michael 'Mickey' Lauer
4 =. <mickey@Vanille.de> 4 =. <mickey@Vanille.de>
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef ONETWORK_H 31#ifndef ONETWORK_H
32#define ONETWORK_H 32#define ONETWORK_H
33 33
34#if !defined( OPIE_WE_VERSION ) 34#if !defined( OPIE_WE_VERSION )
35#error Need to define a wireless extension version to build against! 35#error Need to define a wireless extension version to build against!
36#endif 36#endif
37 37
38#if OPIE_WE_VERSION == 15 38#if OPIE_WE_VERSION == 15
39#include "wireless.15.h" 39#include "wireless.15.h"
40#endif 40#endif
41 41
42#if OPIE_WE_VERSION == 16 42#if OPIE_WE_VERSION == 16
43#include "wireless.16.h" 43#include "wireless.16.h"
44#endif 44#endif
45 45
46/* OPIE */ 46/* OPIE */
47 47
48#include <opie2/onetutils.h> 48#include <opie2/onetutils.h>
49#include <opie2/ostation.h> 49#include <opie2/ostation.h>
50 50
51/* QT */ 51/* QT */
52 52
53#include <qvaluelist.h> 53#include <qvaluelist.h>
54#include <qdict.h> 54#include <qdict.h>
55#include <qmap.h> 55#include <qmap.h>
56#include <qobject.h> 56#include <qobject.h>
57#include <qhostaddress.h> 57#include <qhostaddress.h>
58 58
59namespace Opie {
60namespace Net {
61
59class ONetworkInterface; 62class ONetworkInterface;
60class OWirelessNetworkInterface; 63class OWirelessNetworkInterface;
61class OChannelHopper; 64class OChannelHopper;
62class OMonitoringInterface; 65class OMonitoringInterface;
63 66
64/*====================================================================================== 67/*======================================================================================
65 * ONetwork 68 * ONetwork
66 *======================================================================================*/ 69 *======================================================================================*/
67 70
68/** 71/**
69 * @brief A container class for all network interfaces 72 * @brief A container class for all network interfaces
70 * 73 *
71 * This class provides access to all available network interfaces of your computer. 74 * This class provides access to all available network interfaces of your computer.
72 * 75 *
73 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 76 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
74 */ 77 */
75class ONetwork : public QObject 78class ONetwork : public QObject
76{ 79{
77 Q_OBJECT 80 Q_OBJECT
78 81
79 public: 82 public:
80 typedef QDict<ONetworkInterface> InterfaceMap; 83 typedef QDict<ONetworkInterface> InterfaceMap;
81 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 84 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
82 85
83 public: 86 public:
84 /** 87 /**
85 * @returns the number of available interfaces 88 * @returns the number of available interfaces
86 */ 89 */
87 int count() const; 90 int count() const;
88 /** 91 /**
89 * @returns a pointer to the (one and only) @ref ONetwork instance. 92 * @returns a pointer to the (one and only) @ref ONetwork instance.
90 */ 93 */
91 static ONetwork* instance(); 94 static ONetwork* instance();
92 /** 95 /**
93 * @returns an iterator usable for iterating through all network interfaces. 96 * @returns an iterator usable for iterating through all network interfaces.
94 */ 97 */
95 InterfaceIterator iterator() const; 98 InterfaceIterator iterator() const;
96 /** 99 /**
97 * @returns true, if the @a interface is present. 100 * @returns true, if the @a interface is present.
98 */ 101 */
99 bool isPresent( const char* interface ) const; 102 bool isPresent( const char* interface ) const;
100 /** 103 /**
101 * @returns true, if the @a interface supports the wireless extension protocol. 104 * @returns true, if the @a interface supports the wireless extension protocol.
102 */ 105 */
103 bool isWirelessInterface( const char* interface ) const; 106 bool isWirelessInterface( const char* interface ) const;
104 /** 107 /**
105 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. 108 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found.
106 * @see ONetworkInterface 109 * @see ONetworkInterface
107 */ 110 */
108 ONetworkInterface* interface( const QString& interface ) const; 111 ONetworkInterface* interface( const QString& interface ) const;
109 /** 112 /**
110 * @internal Rebuild the internal interface database 113 * @internal Rebuild the internal interface database
111 * @note Sometimes it might be useful to call this from client code, 114 * @note Sometimes it might be useful to call this from client code,
112 * e.g. after issuing a cardctl insert 115 * e.g. after issuing a cardctl insert
113 */ 116 */
114 void synchronize(); 117 void synchronize();
115 /** 118 /**
116 * @returns the wireless extension version used at compile time. 119 * @returns the wireless extension version used at compile time.
117 **/ 120 **/
118 static short wirelessExtensionVersion(); 121 static short wirelessExtensionVersion();
119 122
120 protected: 123 protected:
121 ONetwork(); 124 ONetwork();
122 125
123 private: 126 private:
124 static ONetwork* _instance; 127 static ONetwork* _instance;
125 InterfaceMap _interfaces; 128 InterfaceMap _interfaces;
129 class Private;
130 Private *d;
126}; 131};
127 132
128 133
129/*====================================================================================== 134/*======================================================================================
130 * ONetworkInterface 135 * ONetworkInterface
131 *======================================================================================*/ 136 *======================================================================================*/
132 137
133/** 138/**
134 * @brief A network interface wrapper. 139 * @brief A network interface wrapper.
135 * 140 *
136 * This class provides a wrapper for a network interface. All the cumbersume details of 141 * This class provides a wrapper for a network interface. All the cumbersume details of
137 * Linux ioctls are hidden under a convenient high-level interface. 142 * Linux ioctls are hidden under a convenient high-level interface.
138 * @warning Most of the setting methods contained in this class require the appropriate 143 * @warning Most of the setting methods contained in this class require the appropriate
139 * process permissions to work. 144 * process permissions to work.
140 * 145 *
141 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 146 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
142 */ 147 */
143class ONetworkInterface : public QObject 148class ONetworkInterface : public QObject
144{ 149{
145 friend class OMonitoringInterface; 150 friend class OMonitoringInterface;
146 friend class OCiscoMonitoringInterface; 151 friend class OCiscoMonitoringInterface;
147 friend class OWlanNGMonitoringInterface; 152 friend class OWlanNGMonitoringInterface;
148 friend class OHostAPMonitoringInterface; 153 friend class OHostAPMonitoringInterface;
149 friend class OOrinocoMonitoringInterface; 154 friend class OOrinocoMonitoringInterface;
150 155
151 public: 156 public:
152 /** 157 /**
153 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, 158 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself,
154 * but access them via @ref ONetwork::interface(). 159 * but access them via @ref ONetwork::interface().
155 */ 160 */
156 ONetworkInterface( QObject* parent, const char* name ); 161 ONetworkInterface( QObject* parent, const char* name );
157 /** 162 /**
158 * Destructor. 163 * Destructor.
159 */ 164 */
160 virtual ~ONetworkInterface(); 165 virtual ~ONetworkInterface();
161 /** 166 /**
162 * Associates a @a monitoring interface with this network interface. 167 * Associates a @a monitoring interface with this network interface.
163 * @note This is currently only useful with @ref OWirelessNetworkInterface objects. 168 * @note This is currently only useful with @ref OWirelessNetworkInterface objects.
164 */ 169 */
165 void setMonitoring( OMonitoringInterface* monitoring ); 170 void setMonitoring( OMonitoringInterface* monitoring );
166 /** 171 /**
167 * @returns the currently associated monitoring interface or 0, if no monitoring is associated. 172 * @returns the currently associated monitoring interface or 0, if no monitoring is associated.
168 */ 173 */
169 OMonitoringInterface* monitoring() const; 174 OMonitoringInterface* monitoring() const;
170 /** 175 /**
171 * Setting an interface to promiscuous mode enables the device to receive 176 * Setting an interface to promiscuous mode enables the device to receive
172 * all packets on the shared medium - as opposed to packets which are addressed to this interface. 177 * all packets on the shared medium - as opposed to packets which are addressed to this interface.
173 */ 178 */
174 bool setPromiscuousMode( bool ); 179 bool setPromiscuousMode( bool );
175 /** 180 /**
176 * @returns true if the interface is set to promiscuous mode. 181 * @returns true if the interface is set to promiscuous mode.
177 */ 182 */
178 bool promiscuousMode() const; 183 bool promiscuousMode() const;
179 /** 184 /**
180 * Setting an interface to up enables it to receive packets. 185 * Setting an interface to up enables it to receive packets.
181 */ 186 */
182 bool setUp( bool ); 187 bool setUp( bool );
183 /** 188 /**
184 * @returns true if the interface is up. 189 * @returns true if the interface is up.
185 */ 190 */
186 bool isUp() const; 191 bool isUp() const;
187 /** 192 /**
188 * @returns true if the interface is a loopback interface. 193 * @returns true if the interface is a loopback interface.
189 */ 194 */
190 bool isLoopback() const; 195 bool isLoopback() const;
191 /** 196 /**
192 * @returns true if the interface is featuring supports the wireless extension protocol. 197 * @returns true if the interface is featuring supports the wireless extension protocol.
193 */ 198 */
194 bool isWireless() const; 199 bool isWireless() const;
195 /** 200 /**
196 * Associate the IP address @ addr with the interface. 201 * Associate the IP address @ addr with the interface.
197 */ 202 */
198 void setIPV4Address( const QHostAddress& addr ); 203 void setIPV4Address( const QHostAddress& addr );
199 /** 204 /**
200 * @returns the IPv4 address associated with the interface. 205 * @returns the IPv4 address associated with the interface.
201 */ 206 */
202 QString ipV4Address() const; //TODO: make this return an OHostAddress 207 QString ipV4Address() const; //TODO: make this return an OHostAddress
203 /** 208 /**
204 * Associate the MAC address @a addr with the interface. 209 * Associate the MAC address @a addr with the interface.
205 * @note It can be necessary to shut down the interface prior to calling this method. 210 * @note It can be necessary to shut down the interface prior to calling this method.
206 * @warning This is not supported by all drivers. 211 * @warning This is not supported by all drivers.
207 */ 212 */
208 void setMacAddress( const OMacAddress& addr ); 213 void setMacAddress( const OMacAddress& addr );
209 /** 214 /**
210 * @returns the MAC address associated with the interface. 215 * @returns the MAC address associated with the interface.
211 */ 216 */
212 OMacAddress macAddress() const; 217 OMacAddress macAddress() const;
213 /** 218 /**
214 * Associate the IPv4 @a netmask with the interface. 219 * Associate the IPv4 @a netmask with the interface.
215 */ 220 */
216 void setIPV4Netmask( const QHostAddress& netmask ); 221 void setIPV4Netmask( const QHostAddress& netmask );
217 /** 222 /**
218 * @returns the IPv4 netmask associated with the interface. 223 * @returns the IPv4 netmask associated with the interface.
219 */ 224 */
220 QString ipV4Netmask() const; //TODO: make this return an OHostAddress 225 QString ipV4Netmask() const; //TODO: make this return an OHostAddress
221 /** 226 /**
222 * @returns the data link type currently associated with the interface. 227 * @returns the data link type currently associated with the interface.
223 * @see #include <net/if_arp.h> for possible values. 228 * @see #include <net/if_arp.h> for possible values.
224 */ 229 */
225 int dataLinkType() const; 230 int dataLinkType() const;
226 231
227 protected: 232 protected:
228 const int _sfd; 233 const int _sfd;
229 mutable ifreq _ifr; 234 mutable ifreq _ifr;
230 OMonitoringInterface* _mon; 235 OMonitoringInterface* _mon;
231 236
232 protected: 237 protected:
233 struct ifreq& ifr() const; 238 struct ifreq& ifr() const;
234 virtual void init(); 239 virtual void init();
235 bool ioctl( int call ) const; 240 bool ioctl( int call ) const;
236 bool ioctl( int call, struct ifreq& ) const; 241 bool ioctl( int call, struct ifreq& ) const;
242 private:
243 class Private;
244 Private *d;
237}; 245};
238 246
239/*====================================================================================== 247/*======================================================================================
240 * OChannelHopper 248 * OChannelHopper
241 *======================================================================================*/ 249 *======================================================================================*/
242 250
243/** 251/**
244 * @brief A radio frequency channel hopper. 252 * @brief A radio frequency channel hopper.
245 * 253 *
246 * This class provides a channel hopper for radio frequencies. A channel hopper frequently 254 * This class provides a channel hopper for radio frequencies. A channel hopper frequently
247 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. 255 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface.
248 * This is necessary when in monitoring mode and scanning for other devices, because 256 * This is necessary when in monitoring mode and scanning for other devices, because
249 * the radio frequency hardware can only detect packets sent on the same frequency. 257 * the radio frequency hardware can only detect packets sent on the same frequency.
250 * 258 *
251 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 259 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
252 */ 260 */
253class OChannelHopper : public QObject 261class OChannelHopper : public QObject
254{ 262{
255 Q_OBJECT 263 Q_OBJECT
256 264
257 public: 265 public:
258 /** 266 /**
259 * Constructor. 267 * Constructor.
260 */ 268 */
261 OChannelHopper( OWirelessNetworkInterface* ); 269 OChannelHopper( OWirelessNetworkInterface* );
262 /** 270 /**
263 * Destructor. 271 * Destructor.
264 */ 272 */
265 virtual ~OChannelHopper(); 273 virtual ~OChannelHopper();
266 /** 274 /**
267 * @returns true, if the channel hopper is hopping channels 275 * @returns true, if the channel hopper is hopping channels
268 */ 276 */
269 bool isActive() const; 277 bool isActive() const;
270 /** 278 /**
271 * @returns the last hopped channel 279 * @returns the last hopped channel
272 */ 280 */
273 int channel() const; 281 int channel() const;
274 /** 282 /**
275 * Set the channel hopping @a interval. 283 * Set the channel hopping @a interval.
276 * An interval of 0 deactivates the channel hopper. 284 * An interval of 0 deactivates the channel hopper.
277 */ 285 */
278 void setInterval( int interval ); 286 void setInterval( int interval );
279 /** 287 /**
280 * @returns the channel hopping interval 288 * @returns the channel hopping interval
281 */ 289 */
282 int interval() const; 290 int interval() const;
283 291
284 signals: 292 signals:
285 /** 293 /**
286 * This signal is emitted right after the channel hopper performed a hop 294 * This signal is emitted right after the channel hopper performed a hop
287 */ 295 */
288 void hopped( int ); 296 void hopped( int );
289 297
290 protected: 298 protected:
291 virtual void timerEvent( QTimerEvent* ); 299 virtual void timerEvent( QTimerEvent* );
292 300
293 private: 301 private:
294 OWirelessNetworkInterface* _iface; 302 OWirelessNetworkInterface* _iface;
295 int _interval; 303 int _interval;
296 int _tid; 304 int _tid;
297 QValueList<int> _channels; 305 QValueList<int> _channels;
298 QValueList<int>::Iterator _channel; 306 QValueList<int>::Iterator _channel;
307 class Private;
308 Private *d;
299}; 309};
300 310
301 311
302/*====================================================================================== 312/*======================================================================================
303 * OWirelessNetworkInterface 313 * OWirelessNetworkInterface
304 *======================================================================================*/ 314 *======================================================================================*/
305 315
306/** 316/**
307 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. 317 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol.
308 * 318 *
309 * This class provides a high-level encapsulation of the Linux wireless extension API. 319 * This class provides a high-level encapsulation of the Linux wireless extension API.
310 * 320 *
311 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 321 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
312 */ 322 */
313class OWirelessNetworkInterface : public ONetworkInterface 323class OWirelessNetworkInterface : public ONetworkInterface
314{ 324{
315 friend class OMonitoringInterface; 325 friend class OMonitoringInterface;
316 friend class OCiscoMonitoringInterface; 326 friend class OCiscoMonitoringInterface;
317 friend class OWlanNGMonitoringInterface; 327 friend class OWlanNGMonitoringInterface;
318 friend class OHostAPMonitoringInterface; 328 friend class OHostAPMonitoringInterface;
319 friend class OOrinocoMonitoringInterface; 329 friend class OOrinocoMonitoringInterface;
320 330
321 friend class OPrivateIOCTL; 331 friend class OPrivateIOCTL;
322 332
323 public: 333 public:
324 /** 334 /**
325 * Constructor. 335 * Constructor.
326 */ 336 */
327 OWirelessNetworkInterface( QObject* parent, const char* name ); 337 OWirelessNetworkInterface( QObject* parent, const char* name );
328 /** 338 /**
329 * Destructor. 339 * Destructor.
330 */ 340 */
331 virtual ~OWirelessNetworkInterface(); 341 virtual ~OWirelessNetworkInterface();
332 /** 342 /**
333 * Setting the @a channel of the interface changes the radio frequency (RF) 343 * Setting the @a channel of the interface changes the radio frequency (RF)
334 * of the corresponding wireless network device. 344 * of the corresponding wireless network device.
335 * @note Common channel range is within [1-14]. A value of 0 is not allowed. 345 * @note Common channel range is within [1-14]. A value of 0 is not allowed.
336 * @see channels() 346 * @see channels()
337 */ 347 */
338 virtual void setChannel( int channel ) const; 348 virtual void setChannel( int channel ) const;
339 /** 349 /**
340 * @returns the channel index of the current radio frequency. 350 * @returns the channel index of the current radio frequency.
341 */ 351 */
342 virtual int channel() const; 352 virtual int channel() const;
343 /** 353 /**
344 * @returns the current radio frequency (in MHz). 354 * @returns the current radio frequency (in MHz).
345 */ 355 */
346 virtual double frequency() const; 356 virtual double frequency() const;
347 /** 357 /**
348 * @returns the number of radio frequency channels for the 358 * @returns the number of radio frequency channels for the
349 * corresponding wireless network device. 359 * corresponding wireless network device.
350 * @note European devices usually have 14 channels, while American typically feature 11 channels. 360 * @note European devices usually have 14 channels, while American typically feature 11 channels.
351 */ 361 */
352 virtual int channels() const; 362 virtual int channels() const;
353 /** 363 /**
354 * Set the IEEE 802.11 operation @a mode. 364 * Set the IEEE 802.11 operation @a mode.
355 * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master 365 * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master
356 * @warning Not all drivers support the all modes. 366 * @warning Not all drivers support the all modes.
357 * @note You might have to change the SSID to get the operation mode change into effect. 367 * @note You might have to change the SSID to get the operation mode change into effect.
358 */ 368 */
359 virtual void setMode( const QString& mode ); 369 virtual void setMode( const QString& mode );
360 /** 370 /**
361 * @returns the current IEEE 802.11 operation mode. 371 * @returns the current IEEE 802.11 operation mode.
362 * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown 372 * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown
363 * 373 *
364 * @note: Important note concerning the 'monitor' mode: 374 * @note: Important note concerning the 'monitor' mode:
365 * Setting the monitor mode on a wireless network interface enables 375 * Setting the monitor mode on a wireless network interface enables
366 * listening to IEEE 802.11 data and management frames which normally 376 * listening to IEEE 802.11 data and management frames which normally
367 * are handled by the device firmware. This can be used to detect 377 * are handled by the device firmware. This can be used to detect
368 * other wireless network devices, e.g. Access Points or Ad-hoc stations. 378 * other wireless network devices, e.g. Access Points or Ad-hoc stations.
369 * @warning Standard wireless network drives don't support the monitor mode. 379 * @warning Standard wireless network drives don't support the monitor mode.
370 * @warning You need a patched driver for this to work. 380 * @warning You need a patched driver for this to work.
371 * @note Enabling the monitor mode is highly driver dependent and requires 381 * @note Enabling the monitor mode is highly driver dependent and requires
372 * the proper @ref OMonitoringInterface to be associated with the interface. 382 * the proper @ref OMonitoringInterface to be associated with the interface.
373 * @see OMonitoringInterface 383 * @see OMonitoringInterface
374 */ 384 */
375 virtual QString mode() const; 385 virtual QString mode() const;
376 /** 386 /**
377 * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. 387 * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping.
378 * @see OChannelHopper 388 * @see OChannelHopper
379 */ 389 */
380 virtual void setChannelHopping( int interval = 0 ); 390 virtual void setChannelHopping( int interval = 0 );
381 /** 391 /**
382 * @returns the channel hopping interval or 0, if channel hopping is disabled. 392 * @returns the channel hopping interval or 0, if channel hopping is disabled.
383 */ 393 */
384 virtual int channelHopping() const; 394 virtual int channelHopping() const;
385 /** 395 /**
386 * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before 396 * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before
387 */ 397 */
388 virtual OChannelHopper* channelHopper() const; 398 virtual OChannelHopper* channelHopper() const;
389 /** 399 /**
390 * Set the station @a nickname. 400 * Set the station @a nickname.
391 */ 401 */
392 virtual void setNickName( const QString& nickname ); 402 virtual void setNickName( const QString& nickname );
393 /** 403 /**
394 * @returns the current station nickname. 404 * @returns the current station nickname.
395 */ 405 */
396 virtual QString nickName() const; 406 virtual QString nickName() const;
397 /** 407 /**
398 * Invoke the private IOCTL @a command with a @number of parameters on the network interface. 408 * Invoke the private IOCTL @a command with a @number of parameters on the network interface.
399 * @see OPrivateIOCTL 409 * @see OPrivateIOCTL
400 */ 410 */
401 virtual void setPrivate( const QString& command, int number, ... ); 411 virtual void setPrivate( const QString& command, int number, ... );
402 /** 412 /**
403 * @returns true if the interface is featuring the private IOCTL @command. 413 * @returns true if the interface is featuring the private IOCTL @command.
404 */ 414 */
405 virtual bool hasPrivate( const QString& command ); 415 virtual bool hasPrivate( const QString& command );
406 virtual void getPrivate( const QString& command ); //FIXME: Implement and document this 416 virtual void getPrivate( const QString& command ); //FIXME: Implement and document this
407 /** 417 /**
408 * @returns true if the interface is associated to an access point 418 * @returns true if the interface is associated to an access point
409 * @note: This information is only valid if the interface is in managed mode. 419 * @note: This information is only valid if the interface is in managed mode.
410 */ 420 */
411 virtual bool isAssociated() const; 421 virtual bool isAssociated() const;
412 /** 422 /**
413 * @returns the MAC address of the Access Point if the device is in infrastructure mode. 423 * @returns the MAC address of the Access Point if the device is in infrastructure mode.
414 * @returns a (more or less random) cell ID address if the device is in adhoc mode. 424 * @returns a (more or less random) cell ID address if the device is in adhoc mode.
415 */ 425 */
416 virtual OMacAddress associatedAP() const; 426 virtual OMacAddress associatedAP() const;
417 /** 427 /**
418 * Set the @a ssid (Service Set ID) string. This is used to decide 428 * Set the @a ssid (Service Set ID) string. This is used to decide
419 * which network to associate with (use "any" to let the driver decide). 429 * which network to associate with (use "any" to let the driver decide).
420 */ 430 */
421 virtual void setSSID( const QString& ssid ); 431 virtual void setSSID( const QString& ssid );
422 /** 432 /**
423 * @returns the current SSID (Service Set ID). 433 * @returns the current SSID (Service Set ID).
424 */ 434 */
425 virtual QString SSID() const; 435 virtual QString SSID() const;
426 /** 436 /**
427 * Perform scanning the wireless network neighbourhood. 437 * Perform scanning the wireless network neighbourhood.
428 * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! 438 * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE!
429 */ 439 */
430 virtual OStationList* scanNetwork(); 440 virtual OStationList* scanNetwork();
431 /** 441 /**
432 * @return signal strength to associated neighbour (in percent). 442 * @return signal strength to associated neighbour (in percent).
433 * In infrastructure mode, this is the signal strength of the Access Point. 443 * In infrastructure mode, this is the signal strength of the Access Point.
434 * In other modes the result is driver dependent. 444 * In other modes the result is driver dependent.
435 */ 445 */
436 virtual int signalStrength() const; 446 virtual int signalStrength() const;
437 /** @internal commit pending changes to the driver 447 /** @internal commit pending changes to the driver
438 * 448 *
439 */ 449 */
440 void commit() const; 450 void commit() const;
441 451
442 protected: 452 protected:
443 void buildInformation(); 453 void buildInformation();
444 void buildPrivateList(); 454 void buildPrivateList();
445 void dumpInformation() const; 455 void dumpInformation() const;
446 virtual void init(); 456 virtual void init();
447 struct iwreq& iwr() const; 457 struct iwreq& iwr() const;
448 bool wioctl( int call ) const; 458 bool wioctl( int call ) const;
449 bool wioctl( int call, struct iwreq& ) const; 459 bool wioctl( int call, struct iwreq& ) const;
450 460
451 protected: 461 protected:
452 mutable struct iwreq _iwr; 462 mutable struct iwreq _iwr;
453 QMap<int,int> _channels; 463 QMap<int,int> _channels;
454 struct iw_range _range; 464 struct iw_range _range;
455 465
456 private: 466 private:
457 OChannelHopper* _hopper; 467 OChannelHopper* _hopper;
468 class Private;
469 Private *d;
458}; 470};
459 471
460 472
461/*====================================================================================== 473/*======================================================================================
462 * OMonitoringInterface 474 * OMonitoringInterface
463 *======================================================================================*/ 475 *======================================================================================*/
464 476
465 477
466class OMonitoringInterface 478class OMonitoringInterface
467{ 479{
468 public: 480 public:
469 OMonitoringInterface(); 481 OMonitoringInterface();
470 OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 482 OMonitoringInterface( ONetworkInterface*, bool _prismHeader );
471 virtual ~OMonitoringInterface(); 483 virtual ~OMonitoringInterface();
472 484
473 public: 485 public:
474 virtual void setEnabled( bool ); 486 virtual void setEnabled( bool );
475 virtual void setChannel( int ); 487 virtual void setChannel( int );
476 488
477 virtual QString name() const = 0; 489 virtual QString name() const = 0;
478 490
479 protected: 491 protected:
480 OWirelessNetworkInterface* _if; 492 OWirelessNetworkInterface* _if;
481 bool _prismHeader; 493 bool _prismHeader;
494 private:
495 class Private;
496 Private *d;
482 497
483}; 498};
484 499
485 500
486/*====================================================================================== 501/*======================================================================================
487 * OCiscoMonitoring 502 * OCiscoMonitoring
488 *======================================================================================*/ 503 *======================================================================================*/
489 504
490 505
491class OCiscoMonitoringInterface : public OMonitoringInterface 506class OCiscoMonitoringInterface : public OMonitoringInterface
492{ 507{
493 public: 508 public:
494 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 509 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
495 virtual ~OCiscoMonitoringInterface(); 510 virtual ~OCiscoMonitoringInterface();
496 511
497 virtual void setEnabled( bool ); 512 virtual void setEnabled( bool );
498 virtual QString name() const; 513 virtual QString name() const;
499 virtual void setChannel( int ); 514 virtual void setChannel( int );
515 private:
516 class Private;
517 Private *d;
500 518
501}; 519};
502 520
503 521
504/*====================================================================================== 522/*======================================================================================
505 * OWlanNGMonitoringInterface 523 * OWlanNGMonitoringInterface
506 *======================================================================================*/ 524 *======================================================================================*/
507 525
508 526
509class OWlanNGMonitoringInterface : public OMonitoringInterface 527class OWlanNGMonitoringInterface : public OMonitoringInterface
510{ 528{
511 public: 529 public:
512 OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 530 OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader );
513 virtual ~OWlanNGMonitoringInterface(); 531 virtual ~OWlanNGMonitoringInterface();
514 532
515 public: 533 public:
516 virtual void setEnabled( bool ); 534 virtual void setEnabled( bool );
517 virtual QString name() const; 535 virtual QString name() const;
518 virtual void setChannel( int ); 536 virtual void setChannel( int );
537 private:
538 class Private;
539 Private *d;
519 540
520}; 541};
521 542
522 543
523/*====================================================================================== 544/*======================================================================================
524 * OHostAPMonitoringInterface 545 * OHostAPMonitoringInterface
525 *======================================================================================*/ 546 *======================================================================================*/
526 547
527 548
528class OHostAPMonitoringInterface : public OMonitoringInterface 549class OHostAPMonitoringInterface : public OMonitoringInterface
529{ 550{
530 public: 551 public:
531 OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 552 OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader );
532 virtual ~OHostAPMonitoringInterface(); 553 virtual ~OHostAPMonitoringInterface();
533 554
534 public: 555 public:
535 virtual void setEnabled( bool ); 556 virtual void setEnabled( bool );
536 virtual QString name() const; 557 virtual QString name() const;
558
559 private:
560 class Private;
561 Private *d;
537 }; 562 };
538 563
539 564
540/*====================================================================================== 565/*======================================================================================
541 * OOrinocoMonitoringInterface 566 * OOrinocoMonitoringInterface
542 *======================================================================================*/ 567 *======================================================================================*/
543 568
544 569
545class OOrinocoMonitoringInterface : public OMonitoringInterface 570class OOrinocoMonitoringInterface : public OMonitoringInterface
546{ 571{
547 public: 572 public:
548 OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 573 OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
549 virtual ~OOrinocoMonitoringInterface(); 574 virtual ~OOrinocoMonitoringInterface();
550 575
551 public: 576 public:
552 virtual void setChannel( int ); 577 virtual void setChannel( int );
553 virtual void setEnabled( bool ); 578 virtual void setEnabled( bool );
554 virtual QString name() const; 579 virtual QString name() const;
555 580
581 private:
582 class Private;
583 Private *d;
556}; 584};
557 585
586}
587}
588
558#endif // ONETWORK_H 589#endif // ONETWORK_H
559 590
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index fdd519c..4081d4f 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -1,431 +1,436 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31/* OPIE */ 31/* OPIE */
32#include <opie2/opcap.h> 32#include <opie2/opcap.h>
33#include <opie2/odebug.h> 33#include <opie2/odebug.h>
34 34
35/* QT */ 35/* QT */
36#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) 36#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects)
37#include <qsocketnotifier.h> 37#include <qsocketnotifier.h>
38#include <qobjectlist.h> 38#include <qobjectlist.h>
39 39
40/* SYSTEM */ 40/* SYSTEM */
41#include <sys/time.h> 41#include <sys/time.h>
42#include <sys/types.h> 42#include <sys/types.h>
43#include <unistd.h> 43#include <unistd.h>
44 44
45/* LOCAL */ 45/* LOCAL */
46#include "udp_ports.h" 46#include "udp_ports.h"
47 47
48using namespace Opie::Core;
49
50namespace Opie {
51namespace Net {
52
48/*====================================================================================== 53/*======================================================================================
49 * OPacket 54 * OPacket
50 *======================================================================================*/ 55 *======================================================================================*/
51 56
52OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) 57OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent )
53 :QObject( parent, "Generic" ), _hdr( header ), _data( data ) 58 :QObject( parent, "Generic" ), _hdr( header ), _data( data )
54{ 59{
55 //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); 60 //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
56 61
57 _end = (unsigned char*) data + header.len; 62 _end = (unsigned char*) data + header.len;
58 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); 63 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end );
59 64
60 switch ( datalink ) 65 switch ( datalink )
61 { 66 {
62 case DLT_EN10MB: 67 case DLT_EN10MB:
63 odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl; 68 odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl;
64 new OEthernetPacket( _end, (const struct ether_header*) data, this ); 69 new OEthernetPacket( _end, (const struct ether_header*) data, this );
65 break; 70 break;
66 71
67 case DLT_IEEE802_11: 72 case DLT_IEEE802_11:
68 odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl; 73 odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl;
69 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); 74 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this );
70 break; 75 break;
71 76
72 case DLT_PRISM_HEADER: 77 case DLT_PRISM_HEADER:
73 odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl; 78 odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl;
74 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); 79 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this );
75 break; 80 break;
76 81
77 default: 82 default:
78 owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl; 83 owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl;
79 } 84 }
80} 85}
81 86
82 87
83OPacket::~OPacket() 88OPacket::~OPacket()
84{ 89{
85} 90}
86 91
87 92
88timevalstruct OPacket::timeval() const 93timevalstruct OPacket::timeval() const
89{ 94{
90 return _hdr.ts; 95 return _hdr.ts;
91} 96}
92 97
93 98
94int OPacket::caplen() const 99int OPacket::caplen() const
95{ 100{
96 return _hdr.caplen; 101 return _hdr.caplen;
97} 102}
98 103
99 104
100void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) 105void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l )
101{ 106{
102 if (!l) return; 107 if (!l) return;
103 QObject* o = l->first(); 108 QObject* o = l->first();
104 while ( o ) 109 while ( o )
105 { 110 {
106 stats[o->name()]++; 111 stats[o->name()]++;
107 updateStats( stats, const_cast<QObjectList*>( o->children() ) ); 112 updateStats( stats, const_cast<QObjectList*>( o->children() ) );
108 o = l->next(); 113 o = l->next();
109 } 114 }
110} 115}
111 116
112 117
113QString OPacket::dumpStructure() const 118QString OPacket::dumpStructure() const
114{ 119{
115 return "[ |" + _dumpStructure( const_cast<QObjectList*>( this->children() ) ) + " ]"; 120 return "[ |" + _dumpStructure( const_cast<QObjectList*>( this->children() ) ) + " ]";
116} 121}
117 122
118 123
119QString OPacket::_dumpStructure( QObjectList* l ) const 124QString OPacket::_dumpStructure( QObjectList* l ) const
120{ 125{
121 if (!l) return QString::null; 126 if (!l) return QString::null;
122 QObject* o = l->first(); 127 QObject* o = l->first();
123 QString str(" "); 128 QString str(" ");
124 129
125 while ( o ) 130 while ( o )
126 { 131 {
127 str.append( o->name() ); 132 str.append( o->name() );
128 str.append( " |" ); 133 str.append( " |" );
129 str += _dumpStructure( const_cast<QObjectList*>( o->children() ) ); 134 str += _dumpStructure( const_cast<QObjectList*>( o->children() ) );
130 o = l->next(); 135 o = l->next();
131 } 136 }
132 return str; 137 return str;
133} 138}
134 139
135QString OPacket::dump( int bpl ) const 140QString OPacket::dump( int bpl ) const
136{ 141{
137 static int index = 0; 142 static int index = 0;
138 index++; 143 index++;
139 int len = _hdr.caplen; 144 int len = _hdr.caplen;
140 QString str; 145 QString str;
141 str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); 146 str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len );
142 str.append( "0000: " ); 147 str.append( "0000: " );
143 QString tmp; 148 QString tmp;
144 QString bytes; 149 QString bytes;
145 QString chars; 150 QString chars;
146 151
147 for ( int i = 0; i < len; ++i ) 152 for ( int i = 0; i < len; ++i )
148 { 153 {
149 tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); 154 tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp );
150 if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); 155 if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] );
151 else chars.append( '.' ); 156 else chars.append( '.' );
152 157
153 if ( !((i+1) % bpl) ) 158 if ( !((i+1) % bpl) )
154 { 159 {
155 str.append( bytes ); 160 str.append( bytes );
156 str.append( ' ' ); 161 str.append( ' ' );
157 str.append( chars ); 162 str.append( chars );
158 str.append( '\n' ); 163 str.append( '\n' );
159 tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); 164 tmp.sprintf( "%04X: ", i+1 ); str.append( tmp );
160 bytes = ""; 165 bytes = "";
161 chars = ""; 166 chars = "";
162 } 167 }
163 168
164 } 169 }
165 if ( (len % bpl) ) 170 if ( (len % bpl) )
166 { 171 {
167 str.append( bytes.leftJustify( 1 + 3*bpl ) ); 172 str.append( bytes.leftJustify( 1 + 3*bpl ) );
168 str.append( chars ); 173 str.append( chars );
169 } 174 }
170 str.append( '\n' ); 175 str.append( '\n' );
171 return str; 176 return str;
172} 177}
173 178
174 179
175int OPacket::len() const 180int OPacket::len() const
176{ 181{
177 return _hdr.len; 182 return _hdr.len;
178} 183}
179 184
180 185
181QTextStream& operator<<( QTextStream& s, const OPacket& p ) 186QTextStream& operator<<( QTextStream& s, const OPacket& p )
182{ 187{
183 s << p.dumpStructure(); 188 s << p.dumpStructure();
184} 189}
185 190
186 191
187/*====================================================================================== 192/*======================================================================================
188 * OEthernetPacket 193 * OEthernetPacket
189 *======================================================================================*/ 194 *======================================================================================*/
190 195
191OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) 196OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent )
192 :QObject( parent, "Ethernet" ), _ether( data ) 197 :QObject( parent, "Ethernet" ), _ether( data )
193{ 198{
194 199
195 odebug << "Source = " << sourceAddress().toString(); 200 odebug << "Source = " << sourceAddress().toString();
196 odebug << "Destination = " << destinationAddress().toString(); 201 odebug << "Destination = " << destinationAddress().toString();
197 202
198 if ( sourceAddress() == OMacAddress::broadcast ) 203 if ( sourceAddress() == OMacAddress::broadcast )
199 odebug << "Source is broadcast address" << oendl; 204 odebug << "Source is broadcast address" << oendl;
200 if ( destinationAddress() == OMacAddress::broadcast ) 205 if ( destinationAddress() == OMacAddress::broadcast )
201 odebug << "Destination is broadcast address" << oendl; 206 odebug << "Destination is broadcast address" << oendl;
202 207
203 switch ( type() ) 208 switch ( type() )
204 { 209 {
205 case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; 210 case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
206 case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; 211 case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break;
207 case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; } 212 case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; }
208 default: odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" << oendl; 213 default: odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" << oendl;
209 } 214 }
210 215
211} 216}
212 217
213 218
214OEthernetPacket::~OEthernetPacket() 219OEthernetPacket::~OEthernetPacket()
215{ 220{
216} 221}
217 222
218 223
219OMacAddress OEthernetPacket::sourceAddress() const 224OMacAddress OEthernetPacket::sourceAddress() const
220{ 225{
221 return OMacAddress( _ether->ether_shost ); 226 return OMacAddress( _ether->ether_shost );
222} 227}
223 228
224 229
225OMacAddress OEthernetPacket::destinationAddress() const 230OMacAddress OEthernetPacket::destinationAddress() const
226{ 231{
227 return OMacAddress( _ether->ether_dhost ); 232 return OMacAddress( _ether->ether_dhost );
228} 233}
229 234
230int OEthernetPacket::type() const 235int OEthernetPacket::type() const
231{ 236{
232 return ntohs( _ether->ether_type ); 237 return ntohs( _ether->ether_type );
233} 238}
234 239
235 240
236/*====================================================================================== 241/*======================================================================================
237 * OIPPacket 242 * OIPPacket
238 *======================================================================================*/ 243 *======================================================================================*/
239 244
240 245
241OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) 246OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent )
242 :QObject( parent, "IP" ), _iphdr( data ) 247 :QObject( parent, "IP" ), _iphdr( data )
243{ 248{
244 odebug << "OIPPacket::OIPPacket(): decoding IP header..." << oendl; 249 odebug << "OIPPacket::OIPPacket(): decoding IP header..." << oendl;
245 250
246 odebug << "FromAddress = " << fromIPAddress().toString() << oendl; 251 odebug << "FromAddress = " << fromIPAddress().toString() << oendl;
247 odebug << " toAddress = " << toIPAddress().toString() << oendl; 252 odebug << " toAddress = " << toIPAddress().toString() << oendl;
248 253
249 switch ( protocol() ) 254 switch ( protocol() )
250 { 255 {
251 case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; 256 case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break;
252 case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; 257 case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break;
253 default: odebug << "OIPPacket::OIPPacket(): unknown IP protocol, type = " << protocol() << oendl; 258 default: odebug << "OIPPacket::OIPPacket(): unknown IP protocol, type = " << protocol() << oendl;
254 } 259 }
255 260
256} 261}
257 262
258OIPPacket::~OIPPacket() 263OIPPacket::~OIPPacket()
259{ 264{
260} 265}
261 266
262 267
263QHostAddress OIPPacket::fromIPAddress() const 268QHostAddress OIPPacket::fromIPAddress() const
264{ 269{
265 return EXTRACT_32BITS( &_iphdr->saddr ); 270 return EXTRACT_32BITS( &_iphdr->saddr );
266} 271}
267 272
268 273
269QHostAddress OIPPacket::toIPAddress() const 274QHostAddress OIPPacket::toIPAddress() const
270{ 275{
271 return EXTRACT_32BITS( &_iphdr->saddr ); 276 return EXTRACT_32BITS( &_iphdr->saddr );
272} 277}
273 278
274 279
275int OIPPacket::tos() const 280int OIPPacket::tos() const
276{ 281{
277 return _iphdr->tos; 282 return _iphdr->tos;
278} 283}
279 284
280 285
281int OIPPacket::len() const 286int OIPPacket::len() const
282{ 287{
283 return EXTRACT_16BITS( &_iphdr->tot_len ); 288 return EXTRACT_16BITS( &_iphdr->tot_len );
284} 289}
285 290
286 291
287int OIPPacket::id() const 292int OIPPacket::id() const
288{ 293{
289 return EXTRACT_16BITS( &_iphdr->id ); 294 return EXTRACT_16BITS( &_iphdr->id );
290} 295}
291 296
292 297
293int OIPPacket::offset() const 298int OIPPacket::offset() const
294{ 299{
295 return EXTRACT_16BITS( &_iphdr->frag_off ); 300 return EXTRACT_16BITS( &_iphdr->frag_off );
296} 301}
297 302
298 303
299int OIPPacket::ttl() const 304int OIPPacket::ttl() const
300{ 305{
301 return _iphdr->ttl; 306 return _iphdr->ttl;
302} 307}
303 308
304 309
305int OIPPacket::protocol() const 310int OIPPacket::protocol() const
306{ 311{
307 return _iphdr->protocol; 312 return _iphdr->protocol;
308} 313}
309 314
310 315
311int OIPPacket::checksum() const 316int OIPPacket::checksum() const
312{ 317{
313 return EXTRACT_16BITS( &_iphdr->check ); 318 return EXTRACT_16BITS( &_iphdr->check );
314} 319}
315 320
316/*====================================================================================== 321/*======================================================================================
317 * OARPPacket 322 * OARPPacket
318 *======================================================================================*/ 323 *======================================================================================*/
319 324
320 325
321OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent ) 326OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent )
322 :QObject( parent, "ARP" ), _arphdr( data ) 327 :QObject( parent, "ARP" ), _arphdr( data )
323{ 328{
324 odebug << "OARPPacket::OARPPacket(): decoding ARP header..." << oendl; 329 odebug << "OARPPacket::OARPPacket(): decoding ARP header..." << oendl;
325 odebug << "ARP type seems to be " << EXTRACT_16BITS( &_arphdr->ar_op ) << " = " << type() << oendl; 330 odebug << "ARP type seems to be " << EXTRACT_16BITS( &_arphdr->ar_op ) << " = " << type() << oendl;
326 odebug << "Sender: MAC " << senderMacAddress().toString() << " = IP " << senderIPV4Address().toString() << oendl; 331 odebug << "Sender: MAC " << senderMacAddress().toString() << " = IP " << senderIPV4Address().toString() << oendl;
327 odebug << "Target: MAC " << targetMacAddress().toString() << " = IP " << targetIPV4Address().toString() << oendl; 332 odebug << "Target: MAC " << targetMacAddress().toString() << " = IP " << targetIPV4Address().toString() << oendl;
328} 333}
329 334
330 335
331OARPPacket::~OARPPacket() 336OARPPacket::~OARPPacket()
332{ 337{
333} 338}
334 339
335 340
336QString OARPPacket::type() const 341QString OARPPacket::type() const
337{ 342{
338 switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) 343 switch ( EXTRACT_16BITS( &_arphdr->ar_op ) )
339 { 344 {
340 case 1: return "REQUEST"; 345 case 1: return "REQUEST";
341 case 2: return "REPLY"; 346 case 2: return "REPLY";
342 case 3: return "RREQUEST"; 347 case 3: return "RREQUEST";
343 case 4: return "RREPLY"; 348 case 4: return "RREPLY";
344 case 8: return "InREQUEST"; 349 case 8: return "InREQUEST";
345 case 9: return "InREPLY"; 350 case 9: return "InREPLY";
346 case 10: return "NAK"; 351 case 10: return "NAK";
347 default: owarn << "OARPPacket::type(): invalid ARP type!" << oendl; return "<unknown>"; 352 default: owarn << "OARPPacket::type(): invalid ARP type!" << oendl; return "<unknown>";
348 } 353 }
349} 354}
350 355
351 356
352QHostAddress OARPPacket::senderIPV4Address() const 357QHostAddress OARPPacket::senderIPV4Address() const
353{ 358{
354 return EXTRACT_32BITS( &_arphdr->ar_sip ); 359 return EXTRACT_32BITS( &_arphdr->ar_sip );
355} 360}
356 361
357 362
358QHostAddress OARPPacket::targetIPV4Address() const 363QHostAddress OARPPacket::targetIPV4Address() const
359{ 364{
360 return EXTRACT_32BITS( &_arphdr->ar_tip ); 365 return EXTRACT_32BITS( &_arphdr->ar_tip );
361} 366}
362 367
363 368
364OMacAddress OARPPacket::senderMacAddress() const 369OMacAddress OARPPacket::senderMacAddress() const
365{ 370{
366 return OMacAddress( _arphdr->ar_sha ); 371 return OMacAddress( _arphdr->ar_sha );
367} 372}
368 373
369 374
370OMacAddress OARPPacket::targetMacAddress() const 375OMacAddress OARPPacket::targetMacAddress() const
371{ 376{
372 return OMacAddress( _arphdr->ar_tha ); 377 return OMacAddress( _arphdr->ar_tha );
373} 378}
374 379
375 380
376/*====================================================================================== 381/*======================================================================================
377 * OUDPPacket 382 * OUDPPacket
378 *======================================================================================*/ 383 *======================================================================================*/
379 384
380 385
381OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) 386OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent )
382 :QObject( parent, "UDP" ), _udphdr( data ) 387 :QObject( parent, "UDP" ), _udphdr( data )
383 388
384{ 389{
385 odebug << "OUDPPacket::OUDPPacket(): decoding UDP header..." << oendl; 390 odebug << "OUDPPacket::OUDPPacket(): decoding UDP header..." << oendl;
386 odebug << "fromPort = " << fromPort() << oendl; 391 odebug << "fromPort = " << fromPort() << oendl;
387 odebug << " toPort = " << toPort() << oendl; 392 odebug << " toPort = " << toPort() << oendl;
388 393
389 // TODO: Make this a case or a hash if we know more udp protocols 394 // TODO: Make this a case or a hash if we know more udp protocols
390 395
391 if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC || 396 if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC ||
392 toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC ) 397 toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC )
393 { 398 {
394 odebug << "seems to be part of a DHCP conversation => creating DHCP packet." << oendl; 399 odebug << "seems to be part of a DHCP conversation => creating DHCP packet." << oendl;
395 new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this ); 400 new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this );
396 } 401 }
397} 402}
398 403
399 404
400OUDPPacket::~OUDPPacket() 405OUDPPacket::~OUDPPacket()
401{ 406{
402} 407}
403 408
404 409
405int OUDPPacket::fromPort() const 410int OUDPPacket::fromPort() const
406{ 411{
407 return EXTRACT_16BITS( &_udphdr->source ); 412 return EXTRACT_16BITS( &_udphdr->source );
408} 413}
409 414
410 415
411int OUDPPacket::toPort() const 416int OUDPPacket::toPort() const
412{ 417{
413 return EXTRACT_16BITS( &_udphdr->dest ); 418 return EXTRACT_16BITS( &_udphdr->dest );
414} 419}
415 420
416 421
417int OUDPPacket::length() const 422int OUDPPacket::length() const
418{ 423{
419 return EXTRACT_16BITS( &_udphdr->len ); 424 return EXTRACT_16BITS( &_udphdr->len );
420} 425}
421 426
422 427
423int OUDPPacket::checksum() const 428int OUDPPacket::checksum() const
424{ 429{
425 return EXTRACT_16BITS( &_udphdr->check ); 430 return EXTRACT_16BITS( &_udphdr->check );
426} 431}
427 432
428 433
429/*====================================================================================== 434/*======================================================================================
430 * ODHCPPacket 435 * ODHCPPacket
431 *======================================================================================*/ 436 *======================================================================================*/
@@ -963,385 +968,386 @@ OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* e
963 odebug << "OWaveLanManagementChallenge()" << oendl; 968 odebug << "OWaveLanManagementChallenge()" << oendl;
964} 969}
965 970
966 971
967OWaveLanManagementChallenge::~OWaveLanManagementChallenge() 972OWaveLanManagementChallenge::~OWaveLanManagementChallenge()
968{ 973{
969} 974}
970 975
971/*====================================================================================== 976/*======================================================================================
972 * OWaveLanDataPacket 977 * OWaveLanDataPacket
973 *======================================================================================*/ 978 *======================================================================================*/
974 979
975OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent ) 980OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent )
976 :QObject( parent, "802.11 Data" ), _header( data ) 981 :QObject( parent, "802.11 Data" ), _header( data )
977{ 982{
978 odebug << "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." << oendl; 983 odebug << "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." << oendl;
979 984
980 const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header ); 985 const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header );
981 986
982 #warning The next line works for most cases, but can not be correct generally! 987 #warning The next line works for most cases, but can not be correct generally!
983 if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address 988 if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address
984 989
985 new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this ); 990 new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this );
986} 991}
987 992
988 993
989OWaveLanDataPacket::~OWaveLanDataPacket() 994OWaveLanDataPacket::~OWaveLanDataPacket()
990{ 995{
991} 996}
992 997
993 998
994/*====================================================================================== 999/*======================================================================================
995 * OLLCPacket 1000 * OLLCPacket
996 *======================================================================================*/ 1001 *======================================================================================*/
997 1002
998OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent ) 1003OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent )
999 :QObject( parent, "802.11 LLC" ), _header( data ) 1004 :QObject( parent, "802.11 LLC" ), _header( data )
1000{ 1005{
1001 odebug << "OLLCPacket::OLLCPacket(): decoding frame..." << oendl; 1006 odebug << "OLLCPacket::OLLCPacket(): decoding frame..." << oendl;
1002 1007
1003 if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) ) 1008 if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) )
1004 { 1009 {
1005 owarn << "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type = " << EXTRACT_16BITS( &_header->type ) << ")" << oendl; 1010 owarn << "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type = " << EXTRACT_16BITS( &_header->type ) << ")" << oendl;
1006 1011
1007 switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h 1012 switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h
1008 { 1013 {
1009 case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; 1014 case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
1010 case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; 1015 case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break;
1011 default: owarn << "OLLCPacket::OLLCPacket(): Unknown Encapsulation type = " << EXTRACT_16BITS( &_header->type ) << oendl; 1016 default: owarn << "OLLCPacket::OLLCPacket(): Unknown Encapsulation type = " << EXTRACT_16BITS( &_header->type ) << oendl;
1012 } 1017 }
1013 } 1018 }
1014} 1019}
1015 1020
1016 1021
1017OLLCPacket::~OLLCPacket() 1022OLLCPacket::~OLLCPacket()
1018{ 1023{
1019} 1024}
1020 1025
1021 1026
1022/*====================================================================================== 1027/*======================================================================================
1023 * OWaveLanControlPacket 1028 * OWaveLanControlPacket
1024 *======================================================================================*/ 1029 *======================================================================================*/
1025 1030
1026OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent ) 1031OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent )
1027 :QObject( parent, "802.11 Control" ), _header( data ) 1032 :QObject( parent, "802.11 Control" ), _header( data )
1028{ 1033{
1029 odebug << "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." << oendl; 1034 odebug << "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." << oendl;
1030 odebug << "Detected subtype is " << controlType() << oendl; 1035 odebug << "Detected subtype is " << controlType() << oendl;
1031} 1036}
1032 1037
1033 1038
1034OWaveLanControlPacket::~OWaveLanControlPacket() 1039OWaveLanControlPacket::~OWaveLanControlPacket()
1035{ 1040{
1036} 1041}
1037 1042
1038 1043
1039QString OWaveLanControlPacket::controlType() const 1044QString OWaveLanControlPacket::controlType() const
1040{ 1045{
1041 switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ) 1046 switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) )
1042 { 1047 {
1043 case CTRL_PS_POLL: return "PowerSavePoll"; break; 1048 case CTRL_PS_POLL: return "PowerSavePoll"; break;
1044 case CTRL_RTS: return "RequestToSend"; break; 1049 case CTRL_RTS: return "RequestToSend"; break;
1045 case CTRL_CTS: return "ClearToSend"; break; 1050 case CTRL_CTS: return "ClearToSend"; break;
1046 case CTRL_ACK: return "Acknowledge"; break; 1051 case CTRL_ACK: return "Acknowledge"; break;
1047 case CTRL_CF_END: return "ContentionFreeEnd"; break; 1052 case CTRL_CF_END: return "ContentionFreeEnd"; break;
1048 case CTRL_END_ACK: return "AcknowledgeEnd"; break; 1053 case CTRL_END_ACK: return "AcknowledgeEnd"; break;
1049 default: 1054 default:
1050 owarn << "OWaveLanControlPacket::managementType(): unhandled subtype " << FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) << oendl; 1055 owarn << "OWaveLanControlPacket::managementType(): unhandled subtype " << FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) << oendl;
1051 return "Unknown"; 1056 return "Unknown";
1052 } 1057 }
1053} 1058}
1054 1059
1055 1060
1056/*====================================================================================== 1061/*======================================================================================
1057 * OPacketCapturer 1062 * OPacketCapturer
1058 *======================================================================================*/ 1063 *======================================================================================*/
1059 1064
1060OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) 1065OPacketCapturer::OPacketCapturer( QObject* parent, const char* name )
1061 :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 ) 1066 :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 )
1062{ 1067{
1063} 1068}
1064 1069
1065 1070
1066OPacketCapturer::~OPacketCapturer() 1071OPacketCapturer::~OPacketCapturer()
1067{ 1072{
1068 if ( _open ) 1073 if ( _open )
1069 { 1074 {
1070 odebug << "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." << oendl; 1075 odebug << "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." << oendl;
1071 close(); 1076 close();
1072 } 1077 }
1073} 1078}
1074 1079
1075 1080
1076void OPacketCapturer::setBlocking( bool b ) 1081void OPacketCapturer::setBlocking( bool b )
1077{ 1082{
1078 if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 ) 1083 if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 )
1079 { 1084 {
1080 odebug << "OPacketCapturer::setBlocking(): blocking mode changed successfully." << oendl; 1085 odebug << "OPacketCapturer::setBlocking(): blocking mode changed successfully." << oendl;
1081 } 1086 }
1082 else 1087 else
1083 { 1088 {
1084 odebug << "OPacketCapturer::setBlocking(): can't change blocking mode: " << _errbuf << oendl; 1089 odebug << "OPacketCapturer::setBlocking(): can't change blocking mode: " << _errbuf << oendl;
1085 } 1090 }
1086} 1091}
1087 1092
1088 1093
1089bool OPacketCapturer::blocking() const 1094bool OPacketCapturer::blocking() const
1090{ 1095{
1091 int b = pcap_getnonblock( _pch, _errbuf ); 1096 int b = pcap_getnonblock( _pch, _errbuf );
1092 if ( b == -1 ) 1097 if ( b == -1 )
1093 { 1098 {
1094 odebug << "OPacketCapturer::blocking(): can't get blocking mode: " << _errbuf << oendl; 1099 odebug << "OPacketCapturer::blocking(): can't get blocking mode: " << _errbuf << oendl;
1095 return -1; 1100 return -1;
1096 } 1101 }
1097 return !b; 1102 return !b;
1098} 1103}
1099 1104
1100 1105
1101void OPacketCapturer::closeDumpFile() 1106void OPacketCapturer::closeDumpFile()
1102{ 1107{
1103 if ( _pcd ) 1108 if ( _pcd )
1104 { 1109 {
1105 pcap_dump_close( _pcd ); 1110 pcap_dump_close( _pcd );
1106 _pcd = 0; 1111 _pcd = 0;
1107 } 1112 }
1108 pcap_close( _pch ); 1113 pcap_close( _pch );
1109} 1114}
1110 1115
1111 1116
1112void OPacketCapturer::close() 1117void OPacketCapturer::close()
1113{ 1118{
1114 if ( _open ) 1119 if ( _open )
1115 { 1120 {
1116 if ( _sn ) 1121 if ( _sn )
1117 { 1122 {
1118 _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); 1123 _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
1119 delete _sn; 1124 delete _sn;
1120 } 1125 }
1121 closeDumpFile(); 1126 closeDumpFile();
1122 _open = false; 1127 _open = false;
1123 } 1128 }
1124 1129
1125 odebug << "OPacketCapturer::close() --- dumping capturing statistics..." << oendl; 1130 odebug << "OPacketCapturer::close() --- dumping capturing statistics..." << oendl;
1126 odebug << "--------------------------------------------------" << oendl; 1131 odebug << "--------------------------------------------------" << oendl;
1127 for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it ) 1132 for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it )
1128 odebug << it.key() << " = " << it.data() << oendl; 1133 odebug << it.key() << " = " << it.data() << oendl;
1129 odebug << "--------------------------------------------------" << oendl; 1134 odebug << "--------------------------------------------------" << oendl;
1130 1135
1131} 1136}
1132 1137
1133 1138
1134int OPacketCapturer::dataLink() const 1139int OPacketCapturer::dataLink() const
1135{ 1140{
1136 return pcap_datalink( _pch ); 1141 return pcap_datalink( _pch );
1137} 1142}
1138 1143
1139 1144
1140void OPacketCapturer::dump( OPacket* p ) 1145void OPacketCapturer::dump( OPacket* p )
1141{ 1146{
1142 if ( !_pcd ) 1147 if ( !_pcd )
1143 { 1148 {
1144 owarn << "OPacketCapturer::dump() - cannot dump without open capture file!" << oendl; 1149 owarn << "OPacketCapturer::dump() - cannot dump without open capture file!" << oendl;
1145 return; 1150 return;
1146 } 1151 }
1147 pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data ); 1152 pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data );
1148} 1153}
1149 1154
1150 1155
1151int OPacketCapturer::fileno() const 1156int OPacketCapturer::fileno() const
1152{ 1157{
1153 if ( _open ) 1158 if ( _open )
1154 { 1159 {
1155 return pcap_fileno( _pch ); 1160 return pcap_fileno( _pch );
1156 } 1161 }
1157 else 1162 else
1158 { 1163 {
1159 return -1; 1164 return -1;
1160 } 1165 }
1161} 1166}
1162 1167
1163 1168
1164OPacket* OPacketCapturer::next( int time ) 1169OPacket* OPacketCapturer::next( int time )
1165{ 1170{
1166 fd_set fds; 1171 fd_set fds;
1167 struct timeval tv; 1172 struct timeval tv;
1168 FD_ZERO( &fds ); 1173 FD_ZERO( &fds );
1169 FD_SET( pcap_fileno( _pch ), &fds ); 1174 FD_SET( pcap_fileno( _pch ), &fds );
1170 tv.tv_sec = time / 1000; 1175 tv.tv_sec = time / 1000;
1171 tv.tv_usec = time % 1000; 1176 tv.tv_usec = time % 1000;
1172 int retval = select( pcap_fileno( _pch )+1, &fds, NULL, NULL, &tv); 1177 int retval = select( pcap_fileno( _pch )+1, &fds, NULL, NULL, &tv);
1173 if ( retval > 0 ) // clear to read! 1178 if ( retval > 0 ) // clear to read!
1174 return next(); 1179 return next();
1175 else 1180 else
1176 return 0; 1181 return 0;
1177} 1182}
1178 1183
1179 1184
1180OPacket* OPacketCapturer::next() 1185OPacket* OPacketCapturer::next()
1181{ 1186{
1182 packetheaderstruct header; 1187 packetheaderstruct header;
1183 odebug << "==> OPacketCapturer::next()" << oendl; 1188 odebug << "==> OPacketCapturer::next()" << oendl;
1184 const unsigned char* pdata = pcap_next( _pch, &header ); 1189 const unsigned char* pdata = pcap_next( _pch, &header );
1185 odebug << "<== OPacketCapturer::next()" << oendl; 1190 odebug << "<== OPacketCapturer::next()" << oendl;
1186 1191
1187 if ( pdata && header.len ) 1192 if ( pdata && header.len )
1188 { 1193 {
1189 OPacket* p = new OPacket( dataLink(), header, pdata, 0 ); 1194 OPacket* p = new OPacket( dataLink(), header, pdata, 0 );
1190 // packets shouldn't be inserted in the QObject child-parent hierarchy, 1195 // packets shouldn't be inserted in the QObject child-parent hierarchy,
1191 // because due to memory constraints they will be deleted as soon 1196 // because due to memory constraints they will be deleted as soon
1192 // as possible - that is right after they have been processed 1197 // as possible - that is right after they have been processed
1193 // by emit() [ see below ] 1198 // by emit() [ see below ]
1194 //TODO: make gathering statistics optional, because it takes time 1199 //TODO: make gathering statistics optional, because it takes time
1195 p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) ); 1200 p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) );
1196 odebug << "OPacket::dumpStructure: " << p->dumpStructure() << oendl; 1201 odebug << "OPacket::dumpStructure: " << p->dumpStructure() << oendl;
1197 return p; 1202 return p;
1198 } 1203 }
1199 else 1204 else
1200 { 1205 {
1201 owarn << "OPacketCapturer::next() - no packet received!" << oendl; 1206 owarn << "OPacketCapturer::next() - no packet received!" << oendl;
1202 return 0; 1207 return 0;
1203 } 1208 }
1204} 1209}
1205 1210
1206 1211
1207bool OPacketCapturer::open( const QString& name ) 1212bool OPacketCapturer::open( const QString& name )
1208{ 1213{
1209 if ( _open ) 1214 if ( _open )
1210 { 1215 {
1211 if ( name == _name ) // ignore opening an already openend device 1216 if ( name == _name ) // ignore opening an already openend device
1212 { 1217 {
1213 return true; 1218 return true;
1214 } 1219 }
1215 else // close the last opened device 1220 else // close the last opened device
1216 { 1221 {
1217 close(); 1222 close();
1218 } 1223 }
1219 } 1224 }
1220 1225
1221 _name = name; 1226 _name = name;
1222 1227
1223 // open libpcap 1228 // open libpcap
1224 pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] ); 1229 pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] );
1225 1230
1226 if ( !handle ) 1231 if ( !handle )
1227 { 1232 {
1228 owarn << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl; 1233 owarn << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl;
1229 return false; 1234 return false;
1230 } 1235 }
1231 1236
1232 odebug << "OPacketCapturer::open(): libpcap [" << name << "] opened successfully." << oendl; 1237 odebug << "OPacketCapturer::open(): libpcap [" << name << "] opened successfully." << oendl;
1233 _pch = handle; 1238 _pch = handle;
1234 _open = true; 1239 _open = true;
1235 _stats.clear(); 1240 _stats.clear();
1236 1241
1237 // in case we have an application object, create a socket notifier 1242 // in case we have an application object, create a socket notifier
1238 if ( qApp ) //TODO: I don't like this here... 1243 if ( qApp ) //TODO: I don't like this here...
1239 { 1244 {
1240 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); 1245 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read );
1241 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); 1246 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
1242 } 1247 }
1243 1248
1244 return true; 1249 return true;
1245} 1250}
1246 1251
1247 1252
1248bool OPacketCapturer::openDumpFile( const QString& filename ) 1253bool OPacketCapturer::openDumpFile( const QString& filename )
1249{ 1254{
1250 pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) ); 1255 pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) );
1251 if ( !dump ) 1256 if ( !dump )
1252 { 1257 {
1253 owarn << "OPacketCapturer::open(): can't open dump with '" << filename << "': " << _errbuf << oendl; 1258 owarn << "OPacketCapturer::open(): can't open dump with '" << filename << "': " << _errbuf << oendl;
1254 return false; 1259 return false;
1255 } 1260 }
1256 odebug << "OPacketCapturer::open(): dump [" << filename << "] opened successfully." << oendl; 1261 odebug << "OPacketCapturer::open(): dump [" << filename << "] opened successfully." << oendl;
1257 _pcd = dump; 1262 _pcd = dump;
1258 1263
1259 return true; 1264 return true;
1260} 1265}
1261 1266
1262 1267
1263bool OPacketCapturer::open( const QFile& file ) 1268bool OPacketCapturer::open( const QFile& file )
1264{ 1269{
1265 QString name = file.name(); 1270 QString name = file.name();
1266 1271
1267 if ( _open ) 1272 if ( _open )
1268 { 1273 {
1269 close(); 1274 close();
1270 if ( name == _name ) // ignore opening an already openend device 1275 if ( name == _name ) // ignore opening an already openend device
1271 { 1276 {
1272 return true; 1277 return true;
1273 } 1278 }
1274 else // close the last opened device 1279 else // close the last opened device
1275 { 1280 {
1276 close(); 1281 close();
1277 } 1282 }
1278 } 1283 }
1279 1284
1280 _name = name; 1285 _name = name;
1281 1286
1282 pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] ); 1287 pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] );
1283 1288
1284 if ( handle ) 1289 if ( handle )
1285 { 1290 {
1286 odebug << "OPacketCapturer::open(): libpcap opened successfully." << oendl; 1291 odebug << "OPacketCapturer::open(): libpcap opened successfully." << oendl;
1287 _pch = handle; 1292 _pch = handle;
1288 _open = true; 1293 _open = true;
1289 1294
1290 // in case we have an application object, create a socket notifier 1295 // in case we have an application object, create a socket notifier
1291 if ( qApp ) 1296 if ( qApp )
1292 { 1297 {
1293 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); 1298 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read );
1294 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); 1299 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
1295 } 1300 }
1296 1301
1297 return true; 1302 return true;
1298 } 1303 }
1299 else 1304 else
1300 { 1305 {
1301 odebug << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl; 1306 odebug << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl;
1302 return false; 1307 return false;
1303 } 1308 }
1304 1309
1305} 1310}
1306 1311
1307 1312
1308bool OPacketCapturer::isOpen() const 1313bool OPacketCapturer::isOpen() const
1309{ 1314{
1310 return _open; 1315 return _open;
1311} 1316}
1312 1317
1313 1318
1314void OPacketCapturer::readyToReceive() 1319void OPacketCapturer::readyToReceive()
1315{ 1320{
1316 odebug << "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" << oendl; 1321 odebug << "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" << oendl;
1317 OPacket* p = next(); 1322 OPacket* p = next();
1318 emit receivedPacket( p ); 1323 emit receivedPacket( p );
1319 // emit is synchronous - packet has been dealt with, now it's safe to delete 1324 // emit is synchronous - packet has been dealt with, now it's safe to delete
1320 delete p; 1325 delete p;
1321} 1326}
1322 1327
1323 1328
1324const QMap<QString,int>& OPacketCapturer::statistics() const 1329const QMap<QString,int>& OPacketCapturer::statistics() const
1325{ 1330{
1326 return _stats; 1331 return _stats;
1327} 1332}
1328 1333
1329 1334
1330int OPacketCapturer::snapShot() const 1335int OPacketCapturer::snapShot() const
1331{ 1336{
1332 return pcap_snapshot( _pch ); 1337 return pcap_snapshot( _pch );
1333} 1338}
1334 1339
1335 1340
1336bool OPacketCapturer::swapped() const 1341bool OPacketCapturer::swapped() const
1337{ 1342{
1338 return pcap_is_swapped( _pch ); 1343 return pcap_is_swapped( _pch );
1339} 1344}
1340 1345
1341 1346
1342QString OPacketCapturer::version() const 1347QString OPacketCapturer::version() const
1343{ 1348{
1344 return QString().sprintf( "%d.%d", pcap_major_version( _pch ), pcap_minor_version( _pch ) ); 1349 return QString().sprintf( "%d.%d", pcap_major_version( _pch ), pcap_minor_version( _pch ) );
1345} 1350}
1346 1351
1347 1352}
1353}
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index b873b49..dc609a3 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -1,671 +1,721 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef OPCAP_H 31#ifndef OPCAP_H
32#define OPCAP_H 32#define OPCAP_H
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/onetutils.h> 35#include <opie2/onetutils.h>
36 36
37/* QT */ 37/* QT */
38#include <qevent.h> 38#include <qevent.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qhostaddress.h> 40#include <qhostaddress.h>
41#include <qobject.h> 41#include <qobject.h>
42#include <qstring.h> 42#include <qstring.h>
43#include <qtextstream.h> 43#include <qtextstream.h>
44#include <qmap.h> 44#include <qmap.h>
45 45
46/* STD */ 46/* STD */
47extern "C" // work around a bpf/pcap conflict in recent headers 47extern "C" // work around a bpf/pcap conflict in recent headers
48{ 48{
49 #include <pcap.h> 49 #include <pcap.h>
50} 50}
51#include <netinet/ether.h> 51#include <netinet/ether.h>
52#include <netinet/ip.h> 52#include <netinet/ip.h>
53#include <netinet/udp.h> 53#include <netinet/udp.h>
54#include <netinet/tcp.h> 54#include <netinet/tcp.h>
55#include <time.h> 55#include <time.h>
56 56
57/* Custom Network Includes (must go here, don't reorder!) */ 57/* Custom Network Includes (must go here, don't reorder!) */
58#include "802_11_user.h" 58#include "802_11_user.h"
59#include "dhcp.h" 59#include "dhcp.h"
60 60
61 61
62/* TYPEDEFS */ 62/* TYPEDEFS */
63typedef struct timeval timevalstruct; 63typedef struct timeval timevalstruct;
64typedef struct pcap_pkthdr packetheaderstruct; 64typedef struct pcap_pkthdr packetheaderstruct;
65 65
66/* FORWARDS */ 66/* FORWARDS */
67class OPacketCapturer;
68class QSocketNotifier; 67class QSocketNotifier;
68namespace Opie {
69namespace Net {
70class OPacketCapturer;
69 71
70/*====================================================================================== 72/*======================================================================================
71 * OPacket - A frame on the wire 73 * OPacket - A frame on the wire
72 *======================================================================================*/ 74 *======================================================================================*/
73 75
74/** @brief A class representing a data frame on the wire. 76/** @brief A class representing a data frame on the wire.
75 * 77 *
76 * The whole family of the packet classes are used when capturing frames from a network. 78 * The whole family of the packet classes are used when capturing frames from a network.
77 * Most standard network protocols in use share a common architecture, which mostly is 79 * Most standard network protocols in use share a common architecture, which mostly is
78 * a packet header and then the packet payload. In layered architectures, each lower layer 80 * a packet header and then the packet payload. In layered architectures, each lower layer
79 * encapsulates data from its upper layer - that is it 81 * encapsulates data from its upper layer - that is it
80 * treats the data from its upper layer as payload and prepends an own header to the packet, 82 * treats the data from its upper layer as payload and prepends an own header to the packet,
81 * which - again - is treated as the payload for the layer below. The figure below is an 83 * which - again - is treated as the payload for the layer below. The figure below is an
82 * example for how such a data frame is composed out of packets, e.g. when sending a mail. 84 * example for how such a data frame is composed out of packets, e.g. when sending a mail.
83 * 85 *
84 * <pre> 86 * <pre>
85 * | User Data | == Mail Data 87 * | User Data | == Mail Data
86 * | SMTP Header | User Data | == SMTP 88 * | SMTP Header | User Data | == SMTP
87 * | TCP Header | SMTP Header | User Data | == TCP 89 * | TCP Header | SMTP Header | User Data | == TCP
88 * | IP Header | TCP Header | SMTP Header | User Data | == IP 90 * | IP Header | TCP Header | SMTP Header | User Data | == IP
89 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC 91 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC
90 * 92 *
91 * </pre> 93 * </pre>
92 * 94 *
93 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer 95 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer
94 * also contains a few more levels of encapsulation. 96 * also contains a few more levels of encapsulation.
95 * Since the type of the payload is more or less independent from the encapsulating protocol, 97 * Since the type of the payload is more or less independent from the encapsulating protocol,
96 * the header must be inspected before attempting to decode the payload. Hence, the 98 * the header must be inspected before attempting to decode the payload. Hence, the
97 * encapsulation level varies and can't be deduced without actually looking into the packets. 99 * encapsulation level varies and can't be deduced without actually looking into the packets.
98 * 100 *
99 * For actually working with captured frames, it's useful to identify the packets via names and 101 * For actually working with captured frames, it's useful to identify the packets via names and
100 * insert them into a parent/child - relationship based on the encapsulation. This is why 102 * insert them into a parent/child - relationship based on the encapsulation. This is why
101 * all packet classes derive from QObject. The amount of overhead caused by the QObject is 103 * all packet classes derive from QObject. The amount of overhead caused by the QObject is
102 * not a problem in this case, because we're talking about a theoratical maximum of about 104 * not a problem in this case, because we're talking about a theoratical maximum of about
103 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the 105 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the
104 * QObject also cares about destroying the sub-, (child-) packets. 106 * QObject also cares about destroying the sub-, (child-) packets.
105 * 107 *
106 * This enables us to perform a simple look for packets of a certain type: 108 * This enables us to perform a simple look for packets of a certain type:
107 * @code 109 * @code
108 * OPacketCapturer* pcap = new OPacketCapturer(); 110 * OPacketCapturer* pcap = new OPacketCapturer();
109 * pcap->open( "eth0" ); 111 * pcap->open( "eth0" );
110 * OPacket* p = pcap->next(); 112 * OPacket* p = pcap->next();
111 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists 113 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists
112 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; 114 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl;
113 * 115 *
114 */ 116 */
115 117
116class OPacket : public QObject 118class OPacket : public QObject
117{ 119{
118 Q_OBJECT 120 Q_OBJECT
119 121
120 friend class OPacketCapturer; 122 friend class OPacketCapturer;
121 friend QTextStream& operator<<( QTextStream& s, const OPacket& p ); 123 friend QTextStream& operator<<( QTextStream& s, const OPacket& p );
122 124
123 public: 125 public:
124 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); 126 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent );
125 virtual ~OPacket(); 127 virtual ~OPacket();
126 128
127 timevalstruct timeval() const; 129 timevalstruct timeval() const;
128 130
129 int caplen() const; 131 int caplen() const;
130 int len() const; 132 int len() const;
131 QString dump( int = 32 ) const; 133 QString dump( int = 32 ) const;
132 134
133 void updateStats( QMap<QString,int>&, QObjectList* ); 135 void updateStats( QMap<QString,int>&, QObjectList* );
134 136
135 private: 137 private:
136 138
137 QString dumpStructure() const; 139 QString dumpStructure() const;
138 QString _dumpStructure( QObjectList* ) const; 140 QString _dumpStructure( QObjectList* ) const;
139 141
140 private: 142 private:
141 const packetheaderstruct _hdr; // pcap packet header 143 const packetheaderstruct _hdr; // pcap packet header
142 const unsigned char* _data; // pcap packet data 144 const unsigned char* _data; // pcap packet data
143 const unsigned char* _end; // end of pcap packet data 145 const unsigned char* _end; // end of pcap packet data
146 private:
147 class Private;
148 Private *d;
144}; 149};
145 150
146QTextStream& operator<<( QTextStream& s, const OPacket& p ); 151QTextStream& operator<<( QTextStream& s, const OPacket& p );
147 152
148/*====================================================================================== 153/*======================================================================================
149 * OEthernetPacket - DLT_EN10MB frame 154 * OEthernetPacket - DLT_EN10MB frame
150 *======================================================================================*/ 155 *======================================================================================*/
151 156
152class OEthernetPacket : public QObject 157class OEthernetPacket : public QObject
153{ 158{
154 Q_OBJECT 159 Q_OBJECT
155 160
156 public: 161 public:
157 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); 162 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 );
158 virtual ~OEthernetPacket(); 163 virtual ~OEthernetPacket();
159 164
160 OMacAddress sourceAddress() const; 165 OMacAddress sourceAddress() const;
161 OMacAddress destinationAddress() const; 166 OMacAddress destinationAddress() const;
162 int type() const; 167 int type() const;
163 168
164 private: 169 private:
165 const struct ether_header* _ether; 170 const struct ether_header* _ether;
171 private:
172 class Private;
173 Private *d;
166}; 174};
167 175
168/*====================================================================================== 176/*======================================================================================
169 * OPrismHeaderPacket - DLT_PRISM_HEADER frame 177 * OPrismHeaderPacket - DLT_PRISM_HEADER frame
170 *======================================================================================*/ 178 *======================================================================================*/
171 179
172class OPrismHeaderPacket : public QObject 180class OPrismHeaderPacket : public QObject
173{ 181{
174 Q_OBJECT 182 Q_OBJECT
175 183
176 public: 184 public:
177 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); 185 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 );
178 virtual ~OPrismHeaderPacket(); 186 virtual ~OPrismHeaderPacket();
179 187
180 unsigned int signalStrength() const; 188 unsigned int signalStrength() const;
181 189
182 private: 190 private:
183 const struct prism_hdr* _header; 191 const struct prism_hdr* _header;
192 class Private;
193 Private *d;
184}; 194};
185 195
186/*====================================================================================== 196/*======================================================================================
187 * OWaveLanPacket - DLT_IEEE802_11 frame 197 * OWaveLanPacket - DLT_IEEE802_11 frame
188 *======================================================================================*/ 198 *======================================================================================*/
189 199
190class OWaveLanPacket : public QObject 200class OWaveLanPacket : public QObject
191{ 201{
192 Q_OBJECT 202 Q_OBJECT
193 203
194 public: 204 public:
195 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); 205 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 );
196 virtual ~OWaveLanPacket(); 206 virtual ~OWaveLanPacket();
197 207
198 int duration() const; 208 int duration() const;
199 bool fromDS() const; 209 bool fromDS() const;
200 bool toDS() const; 210 bool toDS() const;
201 virtual OMacAddress macAddress1() const; 211 virtual OMacAddress macAddress1() const;
202 virtual OMacAddress macAddress2() const; 212 virtual OMacAddress macAddress2() const;
203 virtual OMacAddress macAddress3() const; 213 virtual OMacAddress macAddress3() const;
204 virtual OMacAddress macAddress4() const; 214 virtual OMacAddress macAddress4() const;
205 bool usesPowerManagement() const; 215 bool usesPowerManagement() const;
206 int type() const; 216 int type() const;
207 int subType() const; 217 int subType() const;
208 int version() const; 218 int version() const;
209 bool usesWep() const; 219 bool usesWep() const;
210 220
211 private: 221 private:
212 const struct ieee_802_11_header* _wlanhdr; 222 const struct ieee_802_11_header* _wlanhdr;
223 class Private;
224 Private *d;
213}; 225};
214 226
215 227
216/*====================================================================================== 228/*======================================================================================
217 * OWaveLanManagementPacket - type: management (T_MGMT) 229 * OWaveLanManagementPacket - type: management (T_MGMT)
218 *======================================================================================*/ 230 *======================================================================================*/
219 231
220class OWaveLanManagementPacket : public QObject 232class OWaveLanManagementPacket : public QObject
221{ 233{
222 Q_OBJECT 234 Q_OBJECT
223 235
224 public: 236 public:
225 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); 237 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 );
226 virtual ~OWaveLanManagementPacket(); 238 virtual ~OWaveLanManagementPacket();
227 239
228 QString managementType() const; 240 QString managementType() const;
229 241
230 int beaconInterval() const; 242 int beaconInterval() const;
231 int capabilities() const; // generic 243 int capabilities() const; // generic
232 244
233 bool canESS() const; 245 bool canESS() const;
234 bool canIBSS() const; 246 bool canIBSS() const;
235 bool canCFP() const; 247 bool canCFP() const;
236 bool canCFP_REQ() const; 248 bool canCFP_REQ() const;
237 bool canPrivacy() const; 249 bool canPrivacy() const;
238 250
239 private: 251 private:
240 const struct ieee_802_11_mgmt_header* _header; 252 const struct ieee_802_11_mgmt_header* _header;
241 const struct ieee_802_11_mgmt_body* _body; 253 const struct ieee_802_11_mgmt_body* _body;
254 class Private;
255 Private *d;
242}; 256};
243 257
244 258
245/*====================================================================================== 259/*======================================================================================
246 * OWaveLanManagementSSID 260 * OWaveLanManagementSSID
247 *======================================================================================*/ 261 *======================================================================================*/
248 262
249class OWaveLanManagementSSID : public QObject 263class OWaveLanManagementSSID : public QObject
250{ 264{
251 Q_OBJECT 265 Q_OBJECT
252 266
253 public: 267 public:
254 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); 268 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 );
255 virtual ~OWaveLanManagementSSID(); 269 virtual ~OWaveLanManagementSSID();
256 270
257 QString ID( bool decloak = false ) const; 271 QString ID( bool decloak = false ) const;
258 272
259 private: 273 private:
260 const struct ssid_t* _data; 274 const struct ssid_t* _data;
275 class Private;
276 Private *d;
261}; 277};
262 278
263/*====================================================================================== 279/*======================================================================================
264 * OWaveLanManagementRates 280 * OWaveLanManagementRates
265 *======================================================================================*/ 281 *======================================================================================*/
266 282
267class OWaveLanManagementRates : public QObject 283class OWaveLanManagementRates : public QObject
268{ 284{
269 Q_OBJECT 285 Q_OBJECT
270 286
271 public: 287 public:
272 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); 288 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 );
273 virtual ~OWaveLanManagementRates(); 289 virtual ~OWaveLanManagementRates();
274 290
275 private: 291 private:
276 const struct rates_t* _data; 292 const struct rates_t* _data;
293 class Private;
294 Private *d;
277}; 295};
278 296
279/*====================================================================================== 297/*======================================================================================
280 * OWaveLanManagementCF 298 * OWaveLanManagementCF
281 *======================================================================================*/ 299 *======================================================================================*/
282 300
283class OWaveLanManagementCF : public QObject 301class OWaveLanManagementCF : public QObject
284{ 302{
285 Q_OBJECT 303 Q_OBJECT
286 304
287 public: 305 public:
288 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); 306 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 );
289 virtual ~OWaveLanManagementCF(); 307 virtual ~OWaveLanManagementCF();
290 308
291 private: 309 private:
292 const struct cf_t* _data; 310 const struct cf_t* _data;
311 class Private;
312 Private *d;
293}; 313};
294 314
295/*====================================================================================== 315/*======================================================================================
296 * OWaveLanManagementFH 316 * OWaveLanManagementFH
297 *======================================================================================*/ 317 *======================================================================================*/
298 318
299class OWaveLanManagementFH : public QObject 319class OWaveLanManagementFH : public QObject
300{ 320{
301 Q_OBJECT 321 Q_OBJECT
302 322
303 public: 323 public:
304 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); 324 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 );
305 virtual ~OWaveLanManagementFH(); 325 virtual ~OWaveLanManagementFH();
306 326
307 private: 327 private:
308 const struct fh_t* _data; 328 const struct fh_t* _data;
329 class Private;
330 Private *d;
309}; 331};
310 332
311/*====================================================================================== 333/*======================================================================================
312 * OWaveLanManagementDS 334 * OWaveLanManagementDS
313 *======================================================================================*/ 335 *======================================================================================*/
314 336
315class OWaveLanManagementDS : public QObject 337class OWaveLanManagementDS : public QObject
316{ 338{
317 Q_OBJECT 339 Q_OBJECT
318 340
319 public: 341 public:
320 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); 342 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 );
321 virtual ~OWaveLanManagementDS(); 343 virtual ~OWaveLanManagementDS();
322 344
323 int channel() const; 345 int channel() const;
324 346
325 private: 347 private:
326 const struct ds_t* _data; 348 const struct ds_t* _data;
349 class Private;
350 Private *d;
327}; 351};
328 352
329/*====================================================================================== 353/*======================================================================================
330 * OWaveLanManagementTim 354 * OWaveLanManagementTim
331 *======================================================================================*/ 355 *======================================================================================*/
332 356
333class OWaveLanManagementTim : public QObject 357class OWaveLanManagementTim : public QObject
334{ 358{
335 Q_OBJECT 359 Q_OBJECT
336 360
337 public: 361 public:
338 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); 362 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 );
339 virtual ~OWaveLanManagementTim(); 363 virtual ~OWaveLanManagementTim();
340 364
341 private: 365 private:
342 const struct tim_t* _data; 366 const struct tim_t* _data;
367 class Private;
368 Private *d;
343}; 369};
344 370
345/*====================================================================================== 371/*======================================================================================
346 * OWaveLanManagementIBSS 372 * OWaveLanManagementIBSS
347 *======================================================================================*/ 373 *======================================================================================*/
348 374
349class OWaveLanManagementIBSS : public QObject 375class OWaveLanManagementIBSS : public QObject
350{ 376{
351 Q_OBJECT 377 Q_OBJECT
352 378
353 public: 379 public:
354 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); 380 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 );
355 virtual ~OWaveLanManagementIBSS(); 381 virtual ~OWaveLanManagementIBSS();
356 382
357 private: 383 private:
358 const struct ibss_t* _data; 384 const struct ibss_t* _data;
385 class Private;
386 Private *d;
359}; 387};
360 388
361/*====================================================================================== 389/*======================================================================================
362 * OWaveLanManagementChallenge 390 * OWaveLanManagementChallenge
363 *======================================================================================*/ 391 *======================================================================================*/
364 392
365class OWaveLanManagementChallenge : public QObject 393class OWaveLanManagementChallenge : public QObject
366{ 394{
367 Q_OBJECT 395 Q_OBJECT
368 396
369 public: 397 public:
370 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); 398 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 );
371 virtual ~OWaveLanManagementChallenge(); 399 virtual ~OWaveLanManagementChallenge();
372 400
373 private: 401 private:
374 const struct challenge_t* _data; 402 const struct challenge_t* _data;
403 class Private;
404 Private *d;
375}; 405};
376 406
377/*====================================================================================== 407/*======================================================================================
378 * OWaveLanDataPacket - type: data (T_DATA) 408 * OWaveLanDataPacket - type: data (T_DATA)
379 *======================================================================================*/ 409 *======================================================================================*/
380 410
381class OWaveLanDataPacket : public QObject 411class OWaveLanDataPacket : public QObject
382{ 412{
383 Q_OBJECT 413 Q_OBJECT
384 414
385 public: 415 public:
386 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); 416 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 );
387 virtual ~OWaveLanDataPacket(); 417 virtual ~OWaveLanDataPacket();
388 418
389 private: 419 private:
390 const struct ieee_802_11_data_header* _header; 420 const struct ieee_802_11_data_header* _header;
421 class Private;
422 Private *d;
391}; 423};
392 424
393/*====================================================================================== 425/*======================================================================================
394 * OWaveLanControlPacket - type: control (T_CTRL) 426 * OWaveLanControlPacket - type: control (T_CTRL)
395 *======================================================================================*/ 427 *======================================================================================*/
396 428
397class OWaveLanControlPacket : public QObject 429class OWaveLanControlPacket : public QObject
398{ 430{
399 Q_OBJECT 431 Q_OBJECT
400 432
401 public: 433 public:
402 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); 434 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 );
403 virtual ~OWaveLanControlPacket(); 435 virtual ~OWaveLanControlPacket();
404 436
405 QString controlType() const; 437 QString controlType() const;
406 438
407 private: 439 private:
408 const struct ieee_802_11_control_header* _header; 440 const struct ieee_802_11_control_header* _header;
441 class Private;
442 Private *d;
409}; 443};
410 444
411/*====================================================================================== 445/*======================================================================================
412 * OLLCPacket - IEEE 802.2 Link Level Control 446 * OLLCPacket - IEEE 802.2 Link Level Control
413 *======================================================================================*/ 447 *======================================================================================*/
414 448
415class OLLCPacket : public QObject 449class OLLCPacket : public QObject
416{ 450{
417 Q_OBJECT 451 Q_OBJECT
418 452
419 public: 453 public:
420 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); 454 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 );
421 virtual ~OLLCPacket(); 455 virtual ~OLLCPacket();
422 456
423 private: 457 private:
424 const struct ieee_802_11_802_2_header* _header; 458 const struct ieee_802_11_802_2_header* _header;
459 class Private;
460 Private *d;
425}; 461};
426 462
427/*====================================================================================== 463/*======================================================================================
428 * OIPPacket 464 * OIPPacket
429 *======================================================================================*/ 465 *======================================================================================*/
430 466
431class OIPPacket : public QObject 467class OIPPacket : public QObject
432{ 468{
433 Q_OBJECT 469 Q_OBJECT
434 470
435 public: 471 public:
436 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); 472 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 );
437 virtual ~OIPPacket(); 473 virtual ~OIPPacket();
438 474
439 QHostAddress fromIPAddress() const; 475 QHostAddress fromIPAddress() const;
440 QHostAddress toIPAddress() const; 476 QHostAddress toIPAddress() const;
441 477
442 int tos() const; 478 int tos() const;
443 int len() const; 479 int len() const;
444 int id() const; 480 int id() const;
445 int offset() const; 481 int offset() const;
446 int ttl() const; 482 int ttl() const;
447 int protocol() const; 483 int protocol() const;
448 int checksum() const; 484 int checksum() const;
449 485
450 private: 486 private:
451 const struct iphdr* _iphdr; 487 const struct iphdr* _iphdr;
488 class Private;
489 Private *d;
452}; 490};
453 491
454/*====================================================================================== 492/*======================================================================================
455 * OARPPacket 493 * OARPPacket
456 *======================================================================================*/ 494 *======================================================================================*/
457 495
458class OARPPacket : public QObject 496class OARPPacket : public QObject
459{ 497{
460 Q_OBJECT 498 Q_OBJECT
461 499
462 public: 500 public:
463 OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 ); 501 OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 );
464 virtual ~OARPPacket(); 502 virtual ~OARPPacket();
465 503
466 QHostAddress senderIPV4Address() const; 504 QHostAddress senderIPV4Address() const;
467 OMacAddress senderMacAddress() const; 505 OMacAddress senderMacAddress() const;
468 QHostAddress targetIPV4Address() const; 506 QHostAddress targetIPV4Address() const;
469 OMacAddress targetMacAddress() const; 507 OMacAddress targetMacAddress() const;
470 508
471 //int type() const; 509 //int type() const;
472 QString type() const; 510 QString type() const;
473 511
474 private: 512 private:
475 const struct myarphdr* _arphdr; 513 const struct myarphdr* _arphdr;
514 class Private;
515 Private *d;
476}; 516};
477 517
478/*====================================================================================== 518/*======================================================================================
479 * OUDPPacket 519 * OUDPPacket
480 *======================================================================================*/ 520 *======================================================================================*/
481 521
482class OUDPPacket : public QObject 522class OUDPPacket : public QObject
483{ 523{
484 Q_OBJECT 524 Q_OBJECT
485 525
486 public: 526 public:
487 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); 527 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 );
488 virtual ~OUDPPacket(); 528 virtual ~OUDPPacket();
489 529
490 int fromPort() const; 530 int fromPort() const;
491 int toPort() const; 531 int toPort() const;
492 int length() const; 532 int length() const;
493 int checksum() const; 533 int checksum() const;
494 534
495 private: 535 private:
496 const struct udphdr* _udphdr; 536 const struct udphdr* _udphdr;
537 class Private;
538 Private *d;
497}; 539};
498 540
499/*====================================================================================== 541/*======================================================================================
500 * ODHCPPacket 542 * ODHCPPacket
501 *======================================================================================*/ 543 *======================================================================================*/
502 544
503class ODHCPPacket : public QObject 545class ODHCPPacket : public QObject
504{ 546{
505 Q_OBJECT 547 Q_OBJECT
506 548
507 public: 549 public:
508 ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 ); 550 ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 );
509 virtual ~ODHCPPacket(); 551 virtual ~ODHCPPacket();
510 552
511 QHostAddress clientAddress() const; 553 QHostAddress clientAddress() const;
512 QHostAddress yourAddress() const; 554 QHostAddress yourAddress() const;
513 QHostAddress serverAddress() const; 555 QHostAddress serverAddress() const;
514 QHostAddress relayAddress() const; 556 QHostAddress relayAddress() const;
515 557
516 OMacAddress clientMacAddress() const; 558 OMacAddress clientMacAddress() const;
517 559
518 bool isRequest() const; 560 bool isRequest() const;
519 bool isReply() const; 561 bool isReply() const;
520 QString type() const; 562 QString type() const;
521 563
522 private: 564 private:
523 const struct dhcp_packet* _dhcphdr; 565 const struct dhcp_packet* _dhcphdr;
524 unsigned char _type; 566 unsigned char _type;
567 class Private;
568 Private *d;
525}; 569};
526 570
527/*====================================================================================== 571/*======================================================================================
528 * OTCPPacket 572 * OTCPPacket
529 *======================================================================================*/ 573 *======================================================================================*/
530 574
531class OTCPPacket : public QObject 575class OTCPPacket : public QObject
532{ 576{
533 Q_OBJECT 577 Q_OBJECT
534 578
535 public: 579 public:
536 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); 580 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 );
537 virtual ~OTCPPacket(); 581 virtual ~OTCPPacket();
538 582
539 int fromPort() const; 583 int fromPort() const;
540 int toPort() const; 584 int toPort() const;
541 int seq() const; 585 int seq() const;
542 int ack() const; 586 int ack() const;
543 int window() const; 587 int window() const;
544 int checksum() const; 588 int checksum() const;
545 589
546 private: 590 private:
547 const struct tcphdr* _tcphdr; 591 const struct tcphdr* _tcphdr;
592 class Private;
593 Private *d;
548}; 594};
549 595
550 596
551/*====================================================================================== 597/*======================================================================================
552 * OPacketCapturer 598 * OPacketCapturer
553 *======================================================================================*/ 599 *======================================================================================*/
554 600
555/** 601/**
556 * @brief A class based wrapper for network packet capturing. 602 * @brief A class based wrapper for network packet capturing.
557 * 603 *
558 * This class is the base of a high-level interface to the well known packet capturing 604 * This class is the base of a high-level interface to the well known packet capturing
559 * library libpcap. 605 * library libpcap.
560 * @see http://tcpdump.org 606 * @see http://tcpdump.org
561 */ 607 */
562class OPacketCapturer : public QObject 608class OPacketCapturer : public QObject
563{ 609{
564 Q_OBJECT 610 Q_OBJECT
565 611
566 public: 612 public:
567 /** 613 /**
568 * Constructor. 614 * Constructor.
569 */ 615 */
570 OPacketCapturer( QObject* parent = 0, const char* name = 0 ); 616 OPacketCapturer( QObject* parent = 0, const char* name = 0 );
571 /** 617 /**
572 * Destructor. 618 * Destructor.
573 */ 619 */
574 ~OPacketCapturer(); 620 ~OPacketCapturer();
575 /** 621 /**
576 * Set the packet capturer to use blocking or non-blocking IO. This can be useful when 622 * Set the packet capturer to use blocking or non-blocking IO. This can be useful when
577 * not using the socket notifier, e.g. without an application object. 623 * not using the socket notifier, e.g. without an application object.
578 */ 624 */
579 void setBlocking( bool ); 625 void setBlocking( bool );
580 /** 626 /**
581 * @returns true if the packet capturer uses blocking IO calls. 627 * @returns true if the packet capturer uses blocking IO calls.
582 */ 628 */
583 bool blocking() const; 629 bool blocking() const;
584 /** 630 /**
585 * Close the packet capturer. This is automatically done in the destructor. 631 * Close the packet capturer. This is automatically done in the destructor.
586 */ 632 */
587 void close(); 633 void close();
588 /** 634 /**
589 * Close the output capture file. 635 * Close the output capture file.
590 */ 636 */
591 void closeDumpFile(); 637 void closeDumpFile();
592 /** 638 /**
593 * @returns the data link type. 639 * @returns the data link type.
594 * @see <pcap.h> for possible values. 640 * @see <pcap.h> for possible values.
595 */ 641 */
596 int dataLink() const; 642 int dataLink() const;
597 /** 643 /**
598 * Dump a packet to the output capture file. 644 * Dump a packet to the output capture file.
599 */ 645 */
600 void dump( OPacket* ); 646 void dump( OPacket* );
601 /** 647 /**
602 * @returns the file descriptor of the packet capturer. This is only useful, if 648 * @returns the file descriptor of the packet capturer. This is only useful, if
603 * not using the socket notifier, e.g. without an application object. 649 * not using the socket notifier, e.g. without an application object.
604 */ 650 */
605 int fileno() const; 651 int fileno() const;
606 /** 652 /**
607 * @returns the next @ref OPacket from the packet capturer. 653 * @returns the next @ref OPacket from the packet capturer.
608 * @note If blocking mode is true then this call might block. 654 * @note If blocking mode is true then this call might block.
609 */ 655 */
610 OPacket* next(); 656 OPacket* next();
611 /** 657 /**
612 * @returns the next @ref OPacket from the packet capturer, if 658 * @returns the next @ref OPacket from the packet capturer, if
613 * one arrives within @a time milliseconds. 659 * one arrives within @a time milliseconds.
614 */ 660 */
615 OPacket* next( int time ); 661 OPacket* next( int time );
616 /** 662 /**
617 * Open the packet capturer to capture packets in live-mode from @a interface. 663 * Open the packet capturer to capture packets in live-mode from @a interface.
618 */ 664 */
619 bool open( const QString& interface ); 665 bool open( const QString& interface );
620 /** 666 /**
621 * Open the packet capturer to capture packets in offline-mode from @a file. 667 * Open the packet capturer to capture packets in offline-mode from @a file.
622 */ 668 */
623 bool open( const QFile& file ); 669 bool open( const QFile& file );
624 /** 670 /**
625 * Open a prerecorded tcpdump compatible capture file for use with @ref dump() 671 * Open a prerecorded tcpdump compatible capture file for use with @ref dump()
626 */ 672 */
627 bool openDumpFile( const QString& filename ); 673 bool openDumpFile( const QString& filename );
628 /** 674 /**
629 * @returns true if the packet capturer is open 675 * @returns true if the packet capturer is open
630 */ 676 */
631 bool isOpen() const; 677 bool isOpen() const;
632 /** 678 /**
633 * @returns the snapshot length of this packet capturer 679 * @returns the snapshot length of this packet capturer
634 */ 680 */
635 int snapShot() const; 681 int snapShot() const;
636 /** 682 /**
637 * @returns true if the input capture file has a different byte-order 683 * @returns true if the input capture file has a different byte-order
638 * than the byte-order of the running system. 684 * than the byte-order of the running system.
639 */ 685 */
640 bool swapped() const; 686 bool swapped() const;
641 /** 687 /**
642 * @returns the libpcap version string used to write the input capture file. 688 * @returns the libpcap version string used to write the input capture file.
643 */ 689 */
644 QString version() const; 690 QString version() const;
645 /** 691 /**
646 * @returns the packet statistic database. 692 * @returns the packet statistic database.
647 * @see QMap 693 * @see QMap
648 */ 694 */
649 const QMap<QString,int>& statistics() const; 695 const QMap<QString,int>& statistics() const;
650 696
651 signals: 697 signals:
652 /** 698 /**
653 * This signal is emitted, when a packet has been received. 699 * This signal is emitted, when a packet has been received.
654 */ 700 */
655 void receivedPacket( OPacket* ); 701 void receivedPacket( OPacket* );
656 702
657 protected slots: 703 protected slots:
658 void readyToReceive(); 704 void readyToReceive();
659 705
660 protected: 706 protected:
661 QString _name; // devicename 707 QString _name; // devicename
662 bool _open; // check this before doing pcap calls 708 bool _open; // check this before doing pcap calls
663 pcap_t* _pch; // pcap library handle 709 pcap_t* _pch; // pcap library handle
664 pcap_dumper_t* _pcd; // pcap dumper handle 710 pcap_dumper_t* _pcd; // pcap dumper handle
665 QSocketNotifier* _sn; // socket notifier for main loop 711 QSocketNotifier* _sn; // socket notifier for main loop
666 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap 712 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap
667 QMap<QString, int> _stats; // statistics; 713 QMap<QString, int> _stats; // statistics;
714 class Private; // Private Forward declaration
715 Private *d; // if we need to add data
668}; 716};
717}
718}
669 719
670#endif // OPCAP_H 720#endif // OPCAP_H
671 721
diff --git a/libopie2/opienet/ostation.cpp b/libopie2/opienet/ostation.cpp
index 8c989d8..140b924 100644
--- a/libopie2/opienet/ostation.cpp
+++ b/libopie2/opienet/ostation.cpp
@@ -1,64 +1,72 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#include <opie2/ostation.h> 31#include <opie2/ostation.h>
32#include <opie2/odebug.h> 32#include <opie2/odebug.h>
33 33
34
35using namespace Opie::Core;
36
37namespace Opie {
38namespace Net {
34/*====================================================================================== 39/*======================================================================================
35 * OStation 40 * OStation
36 *======================================================================================*/ 41 *======================================================================================*/
37 42
38OStation::OStation() 43OStation::OStation()
39{ 44{
40 odebug << "OStation::OStation()" << oendl; 45 odebug << "OStation::OStation()" << oendl;
41 46
42 type = "<unknown>"; 47 type = "<unknown>";
43 macAddress = OMacAddress::unknown; 48 macAddress = OMacAddress::unknown;
44 ssid = "<unknown>"; 49 ssid = "<unknown>";
45 channel = 0; 50 channel = 0;
46 apAddress = OMacAddress::unknown; 51 apAddress = OMacAddress::unknown;
47 52
48} 53}
49 54
50 55
51OStation::~OStation() 56OStation::~OStation()
52{ 57{
53 odebug << "OStation::~OStation()" << oendl; 58 odebug << "OStation::~OStation()" << oendl;
54} 59}
55 60
56 61
57void OStation::dump() 62void OStation::dump()
58{ 63{
59 odebug << "------- OStation::dump() ------------" << oendl; 64 odebug << "------- OStation::dump() ------------" << oendl;
60 qDebug( "type: %s", (const char*) type ); 65 qDebug( "type: %s", (const char*) type );
61 qDebug( "mac: %s", (const char*) macAddress.toString() ); 66 qDebug( "mac: %s", (const char*) macAddress.toString() );
62 qDebug( "ap: %s", (const char*) apAddress.toString() ); 67 qDebug( "ap: %s", (const char*) apAddress.toString() );
63 qDebug( "ip: %s", (const char*) ipAddress.toString() ); 68 qDebug( "ip: %s", (const char*) ipAddress.toString() );
64} 69}
70
71}
72} \ No newline at end of file
diff --git a/libopie2/opienet/ostation.h b/libopie2/opienet/ostation.h
index 1e7366d..68f1114 100644
--- a/libopie2/opienet/ostation.h
+++ b/libopie2/opienet/ostation.h
@@ -1,73 +1,82 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef OSTATION_H 31#ifndef OSTATION_H
32#define OSTATION_H 32#define OSTATION_H
33 33
34#include <opie2/onetutils.h> 34#include <opie2/onetutils.h>
35 35
36#include <qlist.h> 36#include <qlist.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qhostaddress.h> 38#include <qhostaddress.h>
39#include <qobject.h> 39#include <qobject.h>
40 40
41#include <sys/types.h> 41#include <sys/types.h>
42 42
43namespace Opie {
44namespace Net {
45
43class OStation; 46class OStation;
44 47
48
45typedef QList<OStation> OStationList; 49typedef QList<OStation> OStationList;
46 50
47/*====================================================================================== 51/*======================================================================================
48 * OStation 52 * OStation
49 *======================================================================================*/ 53 *======================================================================================*/
50 54
51class OStation 55class OStation
52{ 56{
53 public: 57 public:
54 OStation(); 58 OStation();
55 ~OStation(); 59 ~OStation();
56 60
57 void dump(); 61 void dump();
58 62
59 /* Ethernet */ 63 /* Ethernet */
60 QString type; 64 QString type;
61 OMacAddress macAddress; 65 OMacAddress macAddress;
62 QHostAddress ipAddress; 66 QHostAddress ipAddress;
63 67
64 /* WaveLan */ 68 /* WaveLan */
65 QString ssid; 69 QString ssid;
66 OMacAddress apAddress; 70 OMacAddress apAddress;
67 int channel; 71 int channel;
68 bool encrypted; 72 bool encrypted;
73 private:
74 class Private;
75 Private *d;
69}; 76};
70 77
78}
79}
71 80
72#endif // OSTATION_H 81#endif // OSTATION_H
73 82