summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp11
-rw-r--r--libopie2/opienet/onetwork.h4
2 files changed, 15 insertions, 0 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 915814d..e5b091f 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -141,12 +141,23 @@ ONetwork* ONetwork::instance()
141ONetwork::InterfaceIterator ONetwork::iterator() const 141ONetwork::InterfaceIterator ONetwork::iterator() const
142{ 142{
143 return ONetwork::InterfaceIterator( _interfaces ); 143 return ONetwork::InterfaceIterator( _interfaces );
144} 144}
145 145
146 146
147bool ONetwork::isPresent( const char* name ) const
148{
149 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
150 struct ifreq ifr;
151 memset( &ifr, 0, sizeof( struct ifreq ) );
152 strcpy( (char*) &ifr.ifr_name, name );
153 int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr );
154 return result != -1;
155}
156
157
147bool ONetwork::isWirelessInterface( const char* name ) const 158bool ONetwork::isWirelessInterface( const char* name ) const
148{ 159{
149 int sfd = socket( AF_INET, SOCK_STREAM, 0 ); 160 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
150 struct iwreq iwr; 161 struct iwreq iwr;
151 memset( &iwr, 0, sizeof( struct iwreq ) ); 162 memset( &iwr, 0, sizeof( struct iwreq ) );
152 strcpy( (char*) &iwr.ifr_name, name ); 163 strcpy( (char*) &iwr.ifr_name, name );
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index 0a51108..93b129f 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -91,12 +91,16 @@ class ONetwork : public QObject
91 static ONetwork* instance(); 91 static ONetwork* instance();
92 /** 92 /**
93 * @returns an iterator usable for iterating through all network interfaces. 93 * @returns an iterator usable for iterating through all network interfaces.
94 */ 94 */
95 InterfaceIterator iterator() const; 95 InterfaceIterator iterator() const;
96 /** 96 /**
97 * @returns true, if the @a interface is present.
98 */
99 bool isPresent( const char* interface ) const;
100 /**
97 * @returns true, if the @a interface supports the wireless extension protocol. 101 * @returns true, if the @a interface supports the wireless extension protocol.
98 */ 102 */
99 bool isWirelessInterface( const char* interface ) const; 103 bool isWirelessInterface( const char* interface ) const;
100 /** 104 /**
101 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. 105 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found.
102 * @see ONetworkInterface 106 * @see ONetworkInterface