Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

onetutils.h

Go to the documentation of this file.
00001 /*
00002                              This file is part of the Opie Project
00003               =.             (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
00004             .=l.
00005            .>+-=
00006  _;:,     .>    :=|.         This program is free software; you can
00007 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00008 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00009 .="- .-=="i,     .._         License as published by the Free Software
00010  - .   .-<_>     .<>         Foundation; version 2 of the License.
00011      ._= =}       :
00012     .%`+i>       _;_.
00013     .i_,=:_.      -<s.       This program is distributed in the hope that
00014      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00015     : ..    .:,     . . .    without even the implied warranty of
00016     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00017   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00018 ..}^=.=       =       ;      Library General Public License for more
00019 ++=   -.     .`     .:       details.
00020  :     =  ...= . :.=-
00021  -.   .:....=;==+<;          You should have received a copy of the GNU
00022   -_. . .   )=.  =           Library General Public License along with
00023     --        :-=`           this library; see the file COPYING.LIB.
00024                              If not, write to the Free Software Foundation,
00025                              Inc., 59 Temple Place - Suite 330,
00026                              Boston, MA 02111-1307, USA.
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  * OMacAddress
00050  *======================================================================================*/
00051 
00052 class OMacAddress
00053 {
00054   public:
00055     // QString c'tor? -zecke
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     // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem?
00067     static OMacAddress fromString( const QString& );
00068 
00069   public:
00070     static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff
00071     static const OMacAddress& unknown;   // 44:44:44:44:44:44
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  * OHostAddress
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  * ONetworkInterfaceDriverInfo
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  * OPrivateIOCTL
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     // FIXME return int? as ::ioctl does? -zecke
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  * Miscellaneous
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       /* Not available */
00179 #define IW_HEADER_TYPE_CHAR     2       /* char [IFNAMSIZ] */
00180 #define IW_HEADER_TYPE_UINT     4       /* __u32 */
00181 #define IW_HEADER_TYPE_FREQ     5       /* struct iw_freq */
00182 #define IW_HEADER_TYPE_ADDR     6       /* struct sockaddr */
00183 #define IW_HEADER_TYPE_POINT    8       /* struct iw_point */
00184 #define IW_HEADER_TYPE_PARAM    9       /* struct iw_param */
00185 #define IW_HEADER_TYPE_QUAL     10      /* struct iw_quality */
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 /* Wireless Extension Scanning Stuff */
00198 struct iw_stream_descr
00199 {
00200     char *        end;            /* End of the stream */
00201     char *        current;        /* Current event in stream of events */
00202     char *        value;          /* Current value in event */
00203 };
00204 
00205 
00206 /* Network to host order macros */
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 /* Little endian protocol host order macros */
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 

Generated on Sat Nov 5 16:16:12 2005 for OPIE by  doxygen 1.4.2