00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef ONETUTILS_H
00031 #define ONETUTILS_H
00032
00033 #include <qdict.h>
00034 #include <qmap.h>
00035 #include <qstring.h>
00036 #include <qhostaddress.h>
00037 #include <qobject.h>
00038
00039 #include <sys/types.h>
00040
00041 struct ifreq;
00042
00043 namespace Opie {
00044 namespace Net {
00045
00046 class OWirelessNetworkInterface;
00047
00048
00049
00050
00051
00052 class OMacAddress
00053 {
00054 public:
00055
00056 OMacAddress();
00057 OMacAddress( unsigned char* );
00058 OMacAddress( const unsigned char* );
00059 OMacAddress( struct ifreq& );
00060 ~OMacAddress();
00061
00062 QString manufacturer() const;
00063 QString toString( bool substitute = false ) const;
00064 const unsigned char* native() const;
00065
00066
00067 static OMacAddress fromString( const QString& );
00068
00069 public:
00070 static const OMacAddress& broadcast;
00071 static const OMacAddress& unknown;
00072
00073 private:
00074 unsigned char _bytes[6];
00075
00076 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
00077 class Private;
00078 Private *d;
00079
00080 };
00081
00082 bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
00083
00084
00085
00086
00087
00088
00089 class OHostAddress : public QHostAddress
00090 {
00091 public:
00092 OHostAddress();
00093 OHostAddress( Q_UINT32 ip4Addr );
00094 ~OHostAddress();
00095
00096 private:
00097 class Private;
00098 Private *d;
00099 };
00100
00101
00102
00103
00104
00105
00106 class ONetworkInterfaceDriverInfo
00107 {
00108 public:
00109 ONetworkInterfaceDriverInfo( const QString& name = "<unknown>",
00110 const QString& version = "<unknown>",
00111 const QString& firmware = "<unknown>",
00112 const QString& bus = "<unknown>" ) :
00113 _name( name ), _version( version ), _firmware( firmware ), _bus( bus ) { };
00114 ~ONetworkInterfaceDriverInfo() { };
00115
00116 QString name() const { return _name; };
00117 QString version() const { return _version; };
00118 QString firmware() const { return _firmware; };
00119 QString bus() const { return _bus; };
00120
00121 private:
00122 const QString _name;
00123 const QString _version;
00124 const QString _firmware;
00125 const QString _bus;
00126 };
00127
00128
00129
00130
00131
00132 class OPrivateIOCTL : public QObject
00133 {
00134 public:
00135 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs );
00136 ~OPrivateIOCTL();
00137
00138 int numberGetArgs() const;
00139 int typeGetArgs() const;
00140 int numberSetArgs() const;
00141 int typeSetArgs() const;
00142
00143
00144 void invoke() const;
00145 void setParameter( int, u_int32_t );
00146
00147 private:
00148 u_int32_t _ioctl;
00149 u_int16_t _getargs;
00150 u_int16_t _setargs;
00151
00152 class Private;
00153 Private *d;
00154 };
00155
00156
00157
00158
00159
00160 namespace Internal {
00161 void dumpBytes( const unsigned char* data, int num );
00162 QString modeToString( int );
00163 int stringToMode( const QString& );
00164 }
00165 }
00166 }
00167
00168 #define IW_PRIV_TYPE_MASK 0x7000
00169 #define IW_PRIV_TYPE_NONE 0x0000
00170 #define IW_PRIV_TYPE_BYTE 0x1000
00171 #define IW_PRIV_TYPE_CHAR 0x2000
00172 #define IW_PRIV_TYPE_INT 0x4000
00173 #define IW_PRIV_TYPE_FLOAT 0x5000
00174 #define IW_PRIV_TYPE_ADDR 0x6000
00175 #define IW_PRIV_SIZE_FIXED 0x0800
00176 #define IW_PRIV_SIZE_MASK 0x07FF
00177
00178 #define IW_HEADER_TYPE_NULL 0
00179 #define IW_HEADER_TYPE_CHAR 2
00180 #define IW_HEADER_TYPE_UINT 4
00181 #define IW_HEADER_TYPE_FREQ 5
00182 #define IW_HEADER_TYPE_ADDR 6
00183 #define IW_HEADER_TYPE_POINT 8
00184 #define IW_HEADER_TYPE_PARAM 9
00185 #define IW_HEADER_TYPE_QUAL 10
00186
00187 #define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
00188 (char *) NULL)
00189
00190 #ifndef ARPHRD_IEEE80211
00191 #define ARPHRD_IEEE80211 801
00192 #endif
00193 #ifndef ARPHRD_IEEE80211_PRISM
00194 #define ARPHRD_IEEE80211_PRISM 802
00195 #endif
00196
00197
00198 struct iw_stream_descr
00199 {
00200 char * end;
00201 char * current;
00202 char * value;
00203 };
00204
00205
00206
00207
00208 #ifdef LBL_ALIGN
00209 #define EXTRACT_16BITS(p) \
00210 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
00211 (u_int16_t)*((const u_int8_t *)(p) + 1)))
00212 #define EXTRACT_32BITS(p) \
00213 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
00214 (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
00215 (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
00216 (u_int32_t)*((const u_int8_t *)(p) + 3)))
00217 #else
00218 #define EXTRACT_16BITS(p) \
00219 ((u_int16_t)ntohs(*(const u_int16_t *)(p)))
00220 #define EXTRACT_32BITS(p) \
00221 ((u_int32_t)ntohl(*(const u_int32_t *)(p)))
00222 #endif
00223
00224 #define EXTRACT_24BITS(p) \
00225 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
00226 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
00227 (u_int32_t)*((const u_int8_t *)(p) + 2)))
00228
00229
00230 #define EXTRACT_LE_8BITS(p) (*(p))
00231 #define EXTRACT_LE_16BITS(p) \
00232 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
00233 (u_int16_t)*((const u_int8_t *)(p) + 0)))
00234 #define EXTRACT_LE_32BITS(p) \
00235 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \
00236 (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
00237 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
00238 (u_int32_t)*((const u_int8_t *)(p) + 0)))
00239
00240 #endif // ONETUTILS_H
00241