author | mickeyl <mickeyl> | 2003-03-28 15:11:52 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-28 15:11:52 (UTC) |
commit | 11304d02942e9fa493e4e80943a828f9c65f6772 (patch) (unidiff) | |
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 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This program is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This program is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | |||
30 | */ | ||
31 | |||
32 | #ifndef ONETUTILS_H | ||
33 | #define ONETUTILS_H | ||
34 | |||
35 | #include <qdict.h> | ||
36 | #include <qmap.h> | ||
37 | #include <qstring.h> | ||
38 | #include <qhostaddress.h> | ||
39 | |||
40 | struct ifreq; | ||
41 | |||
42 | /*====================================================================================== | ||
43 | * OMacAddress | ||
44 | *======================================================================================*/ | ||
45 | |||
46 | class OMacAddress | ||
47 | { | ||
48 | public: | ||
49 | OMacAddress( unsigned char* ); | ||
50 | OMacAddress( const unsigned char* ); | ||
51 | OMacAddress( struct ifreq& ); | ||
52 | ~OMacAddress(); | ||
53 | |||
54 | QString toString() const; | ||
55 | |||
56 | public: | ||
57 | static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff | ||
58 | static const OMacAddress& unknown; // 44:44:44:44:44:44 | ||
59 | |||
60 | private: | ||
61 | unsigned char _bytes[6]; | ||
62 | |||
63 | friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | ||
64 | |||
65 | }; | ||
66 | |||
67 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | ||
68 | |||
69 | |||
70 | /*====================================================================================== | ||
71 | * OHostAddress | ||
72 | *======================================================================================*/ | ||
73 | |||
74 | class OHostAddress : public QHostAddress | ||
75 | { | ||
76 | public: | ||
77 | OHostAddress(); | ||
78 | ~OHostAddress(); | ||
79 | }; | ||
80 | |||
81 | |||
82 | /*====================================================================================== | ||
83 | * Miscellaneous | ||
84 | *======================================================================================*/ | ||
85 | |||
86 | /* dump bytes */ | ||
87 | |||
88 | void dumpBytes( const unsigned char* data, int num ); | ||
89 | |||
90 | /* Network to host order macros */ | ||
91 | |||
92 | #ifdef LBL_ALIGN | ||
93 | #define EXTRACT_16BITS(p) \ | ||
94 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ | ||
95 | (u_int16_t)*((const u_int8_t *)(p) + 1))) | ||
96 | #define EXTRACT_32BITS(p) \ | ||
97 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ | ||
98 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ | ||
99 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ | ||
100 | (u_int32_t)*((const u_int8_t *)(p) + 3))) | ||
101 | #else | ||
102 | #define EXTRACT_16BITS(p) \ | ||
103 | ((u_int16_t)ntohs(*(const u_int16_t *)(p))) | ||
104 | #define EXTRACT_32BITS(p) \ | ||
105 | ((u_int32_t)ntohl(*(const u_int32_t *)(p))) | ||
106 | #endif | ||
107 | |||
108 | #define EXTRACT_24BITS(p) \ | ||
109 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ | ||
110 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ | ||
111 | (u_int32_t)*((const u_int8_t *)(p) + 2))) | ||
112 | |||
113 | /* Little endian protocol host order macros */ | ||
114 | #define EXTRACT_LE_8BITS(p) (*(p)) | ||
115 | #define EXTRACT_LE_16BITS(p) \ | ||
116 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ | ||
117 | (u_int16_t)*((const u_int8_t *)(p) + 0))) | ||
118 | #define EXTRACT_LE_32BITS(p) \ | ||
119 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ | ||
120 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ | ||
121 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ | ||
122 | (u_int32_t)*((const u_int8_t *)(p) + 0))) | ||
123 | |||
124 | #endif // ONETUTILS_H | ||
125 | |||