author | mickeyl <mickeyl> | 2003-03-28 15:11:52 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-28 15:11:52 (UTC) |
commit | 11304d02942e9fa493e4e80943a828f9c65f6772 (patch) (side-by-side diff) | |
tree | a0223c10c067e1afc70d15c2b82be3f3c15e41ae /libopie2/opienet/onetutils.h | |
parent | b271d575fa05cf570a1a829136517761bd47e69b (diff) | |
download | opie-11304d02942e9fa493e4e80943a828f9c65f6772.zip opie-11304d02942e9fa493e4e80943a828f9c65f6772.tar.gz opie-11304d02942e9fa493e4e80943a828f9c65f6772.tar.bz2 |
skeleton and the start of libopie2, please read README, ROADMAP and STATUS and comment...
Diffstat (limited to 'libopie2/opienet/onetutils.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opienet/onetutils.h | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h new file mode 100644 index 0000000..0dabe8d --- a/dev/null +++ b/libopie2/opienet/onetutils.h @@ -0,0 +1,125 @@ +/* + This file is part of the Opie Project + + (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> + =. + .=l. + .>+-= + _;:, .> :=|. This program is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef ONETUTILS_H +#define ONETUTILS_H + +#include <qdict.h> +#include <qmap.h> +#include <qstring.h> +#include <qhostaddress.h> + +struct ifreq; + +/*====================================================================================== + * OMacAddress + *======================================================================================*/ + +class OMacAddress +{ + public: + OMacAddress( unsigned char* ); + OMacAddress( const unsigned char* ); + OMacAddress( struct ifreq& ); + ~OMacAddress(); + + QString toString() const; + + public: + static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff + static const OMacAddress& unknown; // 44:44:44:44:44:44 + + private: + unsigned char _bytes[6]; + + friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); + +}; + +bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); + + +/*====================================================================================== + * OHostAddress + *======================================================================================*/ + +class OHostAddress : public QHostAddress +{ + public: + OHostAddress(); + ~OHostAddress(); +}; + + +/*====================================================================================== + * Miscellaneous + *======================================================================================*/ + +/* dump bytes */ + +void dumpBytes( const unsigned char* data, int num ); + +/* Network to host order macros */ + +#ifdef LBL_ALIGN +#define EXTRACT_16BITS(p) \ + ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ + (u_int16_t)*((const u_int8_t *)(p) + 1))) +#define EXTRACT_32BITS(p) \ + ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ + (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ + (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ + (u_int32_t)*((const u_int8_t *)(p) + 3))) +#else +#define EXTRACT_16BITS(p) \ + ((u_int16_t)ntohs(*(const u_int16_t *)(p))) +#define EXTRACT_32BITS(p) \ + ((u_int32_t)ntohl(*(const u_int32_t *)(p))) +#endif + +#define EXTRACT_24BITS(p) \ + ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ + (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ + (u_int32_t)*((const u_int8_t *)(p) + 2))) + +/* Little endian protocol host order macros */ +#define EXTRACT_LE_8BITS(p) (*(p)) +#define EXTRACT_LE_16BITS(p) \ + ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ + (u_int16_t)*((const u_int8_t *)(p) + 0))) +#define EXTRACT_LE_32BITS(p) \ + ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ + (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ + (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ + (u_int32_t)*((const u_int8_t *)(p) + 0))) + +#endif // ONETUTILS_H + |