author | mickeyl <mickeyl> | 2004-02-24 22:56:24 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-24 22:56:24 (UTC) |
commit | 96ba6fcf27c785282c3fe05557df8b384df06852 (patch) (side-by-side diff) | |
tree | 9b25648f8518c8d152d4774ac05f81548828f3d5 | |
parent | a1a6a1013eae9a4ca4607f2d656c98821a30f431 (diff) | |
download | opie-96ba6fcf27c785282c3fe05557df8b384df06852.zip opie-96ba6fcf27c785282c3fe05557df8b384df06852.tar.gz opie-96ba6fcf27c785282c3fe05557df8b384df06852.tar.bz2 |
API extension: ONetwork::isPresent( const char* name )
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 11 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 4 |
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 @@ -146,2 +146,13 @@ ONetwork::InterfaceIterator ONetwork::iterator() const +bool ONetwork::isPresent( const char* name ) const
+{
+ int sfd = socket( AF_INET, SOCK_STREAM, 0 );
+ struct ifreq ifr;
+ memset( &ifr, 0, sizeof( struct ifreq ) );
+ strcpy( (char*) &ifr.ifr_name, name );
+ int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr );
+ return result != -1;
+}
+
+
bool ONetwork::isWirelessInterface( const char* name ) const
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 @@ -96,2 +96,6 @@ class ONetwork : public QObject /** + * @returns true, if the @a interface is present. + */ + bool isPresent( const char* interface ) const; + /** * @returns true, if the @a interface supports the wireless extension protocol. |