Utils: Removed ErrnoException and implemented generic Exception base-class
[senf.git] / Socket / NetdeviceController.cc
index c51302b..a11c494 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 //
 // Copyright (C) 2007
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-//     Thorsten Horstmann <thorsten.horstmann@fokus.fraunhofer.de>
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+//     Thorsten Horstmann <tho@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -30,7 +30,6 @@
 // Custom includes
 #include <sys/socket.h>
 #include <sys/ioctl.h>
-#include <net/if.h>
 #include "../Utils/Exception.hh"
 
 #define prefix_
@@ -55,13 +54,14 @@ prefix_ senf::NetdeviceController::NetdeviceController(int interface_index)
 prefix_ std::string senf::NetdeviceController::interfaceName()
 {
     struct ifreq ifr;
-    set_ifr_name( ifr);
+    ifrName( ifr);
     return std::string( ifr.ifr_name);
 }
 
 prefix_ senf::MACAddress senf::NetdeviceController::hardwareAddress()
 {
     struct ifreq ifr;
+    ifrName( ifr);
     doIoctl( ifr, SIOCGIFHWADDR);
     return senf::MACAddress::from_data( ifr.ifr_hwaddr.sa_data);
 }
@@ -69,7 +69,7 @@ prefix_ senf::MACAddress senf::NetdeviceController::hardwareAddress()
 prefix_ int senf::NetdeviceController::mtu()
 {
     struct ifreq ifr;
-    set_ifr_name(ifr);
+    ifrName( ifr);
     doIoctl( ifr, SIOCGIFMTU);
     return ifr.ifr_mtu;
 }
@@ -77,7 +77,7 @@ prefix_ int senf::NetdeviceController::mtu()
 prefix_ void senf::NetdeviceController::mtu(int new_mtu)
 {
     struct ifreq ifr;
-    set_ifr_name( ifr);
+    ifrName( ifr);
     ifr.ifr_mtu = new_mtu;
     doIoctl( ifr, SIOCSIFMTU);
 }
@@ -96,22 +96,22 @@ prefix_ void senf::NetdeviceController::openSocket()
 {
     sockfd_ = ::socket( PF_INET, SOCK_DGRAM, 0);
     if ( sockfd_ < 0)
-        throwErrno();
+        throw SystemException();
 }
 
-prefix_ void senf::NetdeviceController::set_ifr_name(ifreq& ifr)
+prefix_ void senf::NetdeviceController::ifrName(ifreq& ifr)
 {
     ::memset( &ifr, 0, sizeof(ifr));
     ifr.ifr_ifindex = ifindex_;
     if ( ::ioctl( sockfd_, SIOCGIFNAME, &ifr ) < 0 )
-        throwErrno();
+        throw SystemException();
 }
 
 
 prefix_ void senf::NetdeviceController::doIoctl(ifreq& ifr, int request)
 {
     if ( ::ioctl( sockfd_, request, &ifr ) < 0 )
-        throwErrno();
+        throw SystemException();
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////