summaryrefslogtreecommitdiff
path: root/libopie2/opienet/onetwork.h
Unidiff
Diffstat (limited to 'libopie2/opienet/onetwork.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.h49
1 files changed, 35 insertions, 14 deletions
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index db8e702..2348bbc 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -47,78 +47,87 @@
47#include <opie2/onetutils.h> 47#include <opie2/onetutils.h>
48 48
49#ifndef IFNAMSIZ 49#ifndef IFNAMSIZ
50#define IFNAMSIZ 16 50#define IFNAMSIZ 16
51#endif 51#endif
52#ifndef IW_MAX_PRIV_DEF 52#ifndef IW_MAX_PRIV_DEF
53#define IW_MAX_PRIV_DEF 128 53#define IW_MAX_PRIV_DEF 128
54#endif 54#endif
55 55
56// ML: Yeah, I hate to include kernel headers, but it's necessary here 56// ML: Yeah, I hate to include kernel headers, but it's necessary here
57// ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h> 57// ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h>
58// ML: which conflicts with the user header <net/if.h> 58// ML: which conflicts with the user header <net/if.h>
59// ML: We really a user header for the Wireless Extensions, something like <net/wireless.h> 59// ML: We really need a user header for the Wireless Extensions, something like <net/wireless.h>
60// ML: I will drop Jean an mail on that subject 60// ML: I will drop Jean a mail on that subject
61 61
62#include <net/if.h> 62#include <net/if.h>
63#define _LINUX_IF_H 63#define _LINUX_IF_H
64#include <linux/wireless.h> 64#include <linux/wireless.h>
65 65
66class ONetworkInterface; 66class ONetworkInterface;
67class OWirelessNetworkInterface; 67class OWirelessNetworkInterface;
68class OChannelHopper; 68class OChannelHopper;
69class OMonitoringInterface; 69class OMonitoringInterface;
70 70
71/*====================================================================================== 71/*======================================================================================
72 * ONetwork 72 * ONetwork
73 *======================================================================================*/ 73 *======================================================================================*/
74 74
75/** 75/**
76 * @brief A container class for all network devices. 76 * @brief A container class for all network interfaces
77 * 77 *
78 * This class provides access to all available network devices of your computer. 78 * This class provides access to all available network interfaces of your computer.
79 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 79 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
80 */ 80 */
81class ONetwork : public QObject 81class ONetwork : public QObject
82{ 82{
83 Q_OBJECT 83 Q_OBJECT
84 84
85 public: 85 public:
86 typedef QDict<ONetworkInterface> InterfaceMap; 86 typedef QDict<ONetworkInterface> InterfaceMap;
87 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 87 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
88 88
89 public: 89 public:
90 /** 90 /**
91 * @returns the number of available interfaces
92 */
93 int count() const;
94 /**
91 * @returns a pointer to the (one and only) @ref ONetwork instance. 95 * @returns a pointer to the (one and only) @ref ONetwork instance.
92 */ 96 */
93 static ONetwork* instance(); 97 static ONetwork* instance();
94 /** 98 /**
95 * @returns an iterator usable for iterating through all network interfaces. 99 * @returns an iterator usable for iterating through all network interfaces.
96 */ 100 */
97 InterfaceIterator iterator() const; 101 InterfaceIterator iterator() const;
98 /** 102 /**
99 * @returns true, if the @p interface supports the wireless extension protocol. 103 * @returns true, if the @p interface supports the wireless extension protocol.
100 */ 104 */
101 // FIXME QString? -zecke 105 // FIXME QString? -zecke
102 bool isWirelessInterface( const char* interface ) const; 106 bool isWirelessInterface( const char* interface ) const;
103 /** 107 /**
104 * @returns a pointer to the @ref ONetworkInterface object for the specified @p interface or 0, if not found 108 * @returns a pointer to the @ref ONetworkInterface object for the specified @p interface or 0, if not found
105 * @see ONetworkInterface 109 * @see ONetworkInterface
106 */ 110 */
107 // FIXME: const QString& is prefered over QString!!! -zecke 111 // FIXME: const QString& is prefered over QString!!! -zecke
108 ONetworkInterface* interface( const QString& interface ) const; 112 ONetworkInterface* interface( const QString& interface ) const;
113 /**
114 * @internal Rebuild the internal interface database
115 * @note Sometimes it might be useful to call this from client code,
116 * e.g. after cardctl insert
117 */
118 void synchronize();
109 119
110 protected: 120 protected:
111 ONetwork(); 121 ONetwork();
112 void synchronize();
113 122
114 private: 123 private:
115 static ONetwork* _instance; 124 static ONetwork* _instance;
116 InterfaceMap _interfaces; 125 InterfaceMap _interfaces;
117}; 126};
118 127
119 128
120/*====================================================================================== 129/*======================================================================================
121 * ONetworkInterface 130 * ONetworkInterface
122 *======================================================================================*/ 131 *======================================================================================*/
123 132
124/** 133/**
@@ -165,48 +174,60 @@ class ONetworkInterface : public QObject
165 /** 174 /**
166 * @returns true if the interface is set to promiscuous mode. 175 * @returns true if the interface is set to promiscuous mode.
167 */ 176 */
168 bool promiscuousMode() const; 177 bool promiscuousMode() const;
169 /** 178 /**
170 * Setting an interface to up enables it to receive packets. 179 * Setting an interface to up enables it to receive packets.
171 */ 180 */
172 bool setUp( bool ); 181 bool setUp( bool );
173 /** 182 /**
174 * @returns true if the interface is up. 183 * @returns true if the interface is up.
175 */ 184 */
176 bool isUp() const; 185 bool isUp() const;
177 /* 186 /**
178 * @returns true if the interface is a loopback interface. 187 * @returns true if the interface is a loopback interface.
179 */ 188 */
180 bool isLoopback() const; 189 bool isLoopback() const;
181 /* 190 /**
182 * @returns true if the interface is featuring supports the wireless extension protocol. 191 * @returns true if the interface is featuring supports the wireless extension protocol.
183 */ 192 */
184 bool isWireless() const; 193 bool isWireless() const;
185 /* 194 /**
186 * @returns the IPv4 address associated with this interface. 195 * Associate the IP address @ addr with the interface.
196 */
197 void setIPV4Address( const QHostAddress& addr );
198 /**
199 * @returns the IPv4 address associated with the interface.
187 */ 200 */
188 QString ipV4Address() const; 201 QString ipV4Address() const;
189 /* 202 /**
190 * Associate the MAC address @a addr with the interface. 203 * Associate the MAC address @a addr with the interface.
191 * @note It can be necessary to shut down the interface prior to calling this method. 204 * @note It can be necessary to shut down the interface prior to calling this method.
192 * @warning This is not supported by all drivers. 205 * @warning This is not supported by all drivers.
193 */ 206 */
194 void setMacAddress( const OMacAddress& addr ); 207 void setMacAddress( const OMacAddress& addr );
195 /* 208 /**
196 * @returns the MAC address associated with this interface. 209 * @returns the MAC address associated with the interface.
197 */ 210 */
198 OMacAddress macAddress() const; 211 OMacAddress macAddress() const;
199 /* 212 /**
200 * @returns the data link type currently associated with this interface. 213 * Associate the IPv4 @a netmask with the interface.
214 */
215 void setIPV4Netmask( const QHostAddress& netmask );
216 /**
217 * @returns the IPv4 netmask associated with the interface.
218 */
219 QString ipV4Netmask() const;
220 /**
221 * @returns the data link type currently associated with the interface.
201 * @see #include <net/if_arp.h> for possible values. 222 * @see #include <net/if_arp.h> for possible values.
202 */ 223 */
203 int dataLinkType() const; 224 int dataLinkType() const;
204 225
205 protected: 226 protected:
206 const int _sfd; 227 const int _sfd;
207 mutable ifreq _ifr; 228 mutable ifreq _ifr;
208 OMonitoringInterface* _mon; 229 OMonitoringInterface* _mon;
209 230
210 protected: 231 protected:
211 struct ifreq& ifr() const; 232 struct ifreq& ifr() const;
212 virtual void init(); 233 virtual void init();