network-manager.h
00001 /* This file is part of the TDE libraries 00002 Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 #ifndef _TDENETWORKBACKEND_NETWORKMANAGER_H 00019 #define _TDENETWORKBACKEND_NETWORKMANAGER_H 00020 00021 #include "tdenetworkconnections.h" 00022 00023 //==================================================================================================== 00024 // General NetworkManager DBUS service paths 00025 //==================================================================================================== 00026 #define NM_DBUS_PATH "/org/freedesktop/NetworkManager" 00027 #define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManager/Settings" 00028 #define NM_DBUS_PATH_SETTINGS_CONNECTION "/org/freedesktop/NetworkManager/Settings/Connection" 00029 #define NM_VPN_DBUS_PLUGIN_PATH "/org/freedesktop/NetworkManager/VPN/Plugin" 00030 00031 #define NM_DBUS_SERVICE "org.freedesktop.NetworkManager" 00032 #define NM_DBUS_ACTIVE_CONNECTION_SERVICE "org.freedesktop.NetworkManager.Connection.Active" 00033 #define NM_DBUS_DEVICE_SERVICE "org.freedesktop.NetworkManager.Device" 00034 #define NM_DBUS_WIRED_DEVICE_SERVICE "org.freedesktop.NetworkManager.Device.Wired" 00035 #define NM_DBUS_WIRELESS_DEVICE_SERVICE "org.freedesktop.NetworkManager.Device.Wireless" 00036 #define NM_DBUS_SETTINGS_SERVICE "org.freedesktop.NetworkManager.Settings" 00037 #define NM_DBUS_SETTINGS_CONNECTION_SERVICE "org.freedesktop.NetworkManager.Settings.Connection" 00038 #define NM_VPN_DBUS_PLUGIN_SERVICE "org.freedesktop.NetworkManager.VPN.Plugin" 00039 #define NM_VPN_DBUS_CONNECTION_SERVICE "org.freedesktop.NetworkManager.VPN.Connection" 00040 //==================================================================================================== 00041 00042 //==================================================================================================== 00043 // These defines MUST be kept in sync with their respective introspection XML files 00044 //==================================================================================================== 00045 #define NM_DEVICE_TYPE_UNKNOWN 0 00046 #define NM_DEVICE_TYPE_ETHERNET 1 00047 #define NM_DEVICE_TYPE_WIFI 2 00048 #define NM_DEVICE_TYPE_UNUSED1 3 00049 #define NM_DEVICE_TYPE_UNUSED2 4 00050 #define NM_DEVICE_TYPE_BT 5 00051 #define NM_DEVICE_TYPE_OLPC_MESH 6 00052 #define NM_DEVICE_TYPE_WIMAX 7 00053 #define NM_DEVICE_TYPE_MODEM 8 00054 #define NM_DEVICE_TYPE_INFINIBAND 9 00055 #define NM_DEVICE_TYPE_BOND 10 00056 #define NM_DEVICE_TYPE_VLAN 11 00057 #define NM_DEVICE_TYPE_ADSL 12 00058 //==================================================================================================== 00059 #define NM_STATE_UNKNOWN 0 00060 #define NM_STATE_ASLEEP 10 00061 #define NM_STATE_DISCONNECTED 20 00062 #define NM_STATE_DISCONNECTING 30 00063 #define NM_STATE_CONNECTING 40 00064 #define NM_STATE_CONNECTED_LOCAL 50 00065 #define NM_STATE_CONNECTED_SITE 60 00066 #define NM_STATE_CONNECTED_GLOBAL 70 00067 //==================================================================================================== 00068 #define NM_DEVICE_STATE_UNKNOWN 0 00069 #define NM_DEVICE_STATE_UNMANAGED 10 00070 #define NM_DEVICE_STATE_UNAVAILABLE 20 00071 #define NM_DEVICE_STATE_DISCONNECTED 30 00072 #define NM_DEVICE_STATE_PREPARE 40 00073 #define NM_DEVICE_STATE_CONFIG 50 00074 #define NM_DEVICE_STATE_NEED_AUTH 60 00075 #define NM_DEVICE_STATE_IP_CONFIG 70 00076 #define NM_DEVICE_STATE_IP_CHECK 80 00077 #define NM_DEVICE_STATE_SECONDARIES 90 00078 #define NM_DEVICE_STATE_ACTIVATED 100 00079 #define NM_DEVICE_STATE_DEACTIVATING 110 00080 #define NM_DEVICE_STATE_FAILED 120 00081 //==================================================================================================== 00082 #define NM_VPN_STATE_UNKNOWN 0 00083 #define NM_VPN_STATE_PREPARE 1 00084 #define NM_VPN_STATE_NEED_AUTH 2 00085 #define NM_VPN_STATE_CONNECT 3 00086 #define NM_VPN_STATE_IP_CONFIG_GET 4 00087 #define NM_VPN_STATE_ACTIVATED 5 00088 #define NM_VPN_STATE_FAILED 6 00089 #define NM_VPN_STATE_DISCONNECTED 7 00090 //==================================================================================================== 00091 #define NM_DEVICE_CAP_NONE 0 00092 #define NM_DEVICE_CAP_NM_SUPPORTED 1 00093 #define NM_DEVICE_CAP_CARRIER_DETECT 2 00094 //==================================================================================================== 00095 #define NM_EAP_FAST_PROVISIONING_DISABLED 0 00096 #define NM_EAP_FAST_PROVISIONING_UNAUTHONLY 1 00097 #define NM_EAP_FAST_PROVISIONING_AUTHONLY 2 00098 #define NM_EAP_FAST_PROVISIONING_BOTH 3 00099 //==================================================================================================== 00100 #define NM_PASSWORD_SECRET_NONE 0 00101 #define NM_PASSWORD_SECRET_AGENTOWNED 1 00102 #define NM_PASSWORD_SECRET_NOTSAVED 2 00103 #define NM_PASSWORD_SECRET_NOTREQUIRED 4 00104 //==================================================================================================== 00105 #define NM_ACCESS_POINT_CAP_NONE 0x0 00106 #define NM_ACCESS_POINT_CAP_PRIVACY 0x1 00107 //==================================================================================================== 00108 #define NM_ACCESS_POINT_SEC_NONE 0x0 00109 #define NM_ACCESS_POINT_SEC_PAIR_WEP40 0x1 00110 #define NM_ACCESS_POINT_SEC_PAIR_WEP104 0x2 00111 #define NM_ACCESS_POINT_SEC_PAIR_TKIP 0x4 00112 #define NM_ACCESS_POINT_SEC_PAIR_CCMP 0x8 00113 #define NM_ACCESS_POINT_SEC_GROUP_WEP40 0x10 00114 #define NM_ACCESS_POINT_SEC_GROUP_WEP104 0x20 00115 #define NM_ACCESS_POINT_SEC_GROUP_TKIP 0x40 00116 #define NM_ACCESS_POINT_SEC_GROUP_CCMP 0x80 00117 #define NM_ACCESS_POINT_SEC_KEY_MGMT_PSK 0x100 00118 #define NM_ACCESS_POINT_SEC_KEY_MGMT_802_1X 0x200 00119 //==================================================================================================== 00120 #define NM_WEP_TYPE_HEXADECIMAL 1 00121 #define NM_WEP_TYPE_PASSPHRASE 2 00122 //==================================================================================================== 00123 #define NM_VLAN_REORDER_PACKET_HEADERS 0x01 00124 #define NM_VLAN_USE_GVRP 0x02 00125 #define NM_VLAN_LOOSE_BINDING 0x04 00126 //==================================================================================================== 00127 #define NM_GSM_3G_ALL -1 00128 #define NM_GSM_3G_ONLY 0 00129 #define NM_GSM_GPRS_EDGE_ONLY 1 00130 #define NM_GSM_PREFER_3G 2 00131 #define NM_GSM_PREFER_2G 3 00132 //==================================================================================================== 00133 #define NM_802_11_MODE_UNKNOWN 0 00134 #define NM_802_11_MODE_ADHOC 1 00135 #define NM_802_11_MODE_INFRASTRUCTURE 2 00136 //==================================================================================================== 00137 #define NM_802_11_DEVICE_CAP_NONE 0x0 00138 #define NM_802_11_DEVICE_CAP_CIPHER_WEP40 0x1 00139 #define NM_802_11_DEVICE_CAP_CIPHER_WEP104 0x2 00140 #define NM_802_11_DEVICE_CAP_CIPHER_TKIP 0x4 00141 #define NM_802_11_DEVICE_CAP_CIPHER_CCMP 0x8 00142 #define NM_802_11_DEVICE_CAP_WPA 0x10 00143 #define NM_802_11_DEVICE_CAP_RSN 0x20 00144 //==================================================================================================== 00145 #define NM_PLUGIN_SERVICE_DIR "/etc/NetworkManager/VPN" 00146 //==================================================================================================== 00147 00148 //==================================================================================================== 00149 // Device state change reason codes 00150 // Taken from NetworkManager.h 00151 //==================================================================================================== 00152 #define NM_DEVICE_STATE_REASON_NONE 0 00153 #define NM_DEVICE_STATE_REASON_UNKNOWN 1 00154 #define NM_DEVICE_STATE_REASON_NOW_MANAGED 2 00155 #define NM_DEVICE_STATE_REASON_NOW_UNMANAGED 3 00156 #define NM_DEVICE_STATE_REASON_CONFIG_FAILED 4 00157 #define NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE 5 00158 #define NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED 6 00159 #define NM_DEVICE_STATE_REASON_NO_SECRETS 7 00160 #define NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT 8 00161 #define NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED 9 00162 #define NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED 10 00163 #define NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT 11 00164 #define NM_DEVICE_STATE_REASON_PPP_START_FAILED 12 00165 #define NM_DEVICE_STATE_REASON_PPP_DISCONNECT 13 00166 #define NM_DEVICE_STATE_REASON_PPP_FAILED 14 00167 #define NM_DEVICE_STATE_REASON_DHCP_START_FAILED 15 00168 #define NM_DEVICE_STATE_REASON_DHCP_ERROR 16 00169 #define NM_DEVICE_STATE_REASON_DHCP_FAILED 17 00170 #define NM_DEVICE_STATE_REASON_SHARED_START_FAILED 18 00171 #define NM_DEVICE_STATE_REASON_SHARED_FAILED 19 00172 #define NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED 20 00173 #define NM_DEVICE_STATE_REASON_AUTOIP_ERROR 21 00174 #define NM_DEVICE_STATE_REASON_AUTOIP_FAILED 22 00175 #define NM_DEVICE_STATE_REASON_MODEM_BUSY 23 00176 #define NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE 24 00177 #define NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER 25 00178 #define NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT 26 00179 #define NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED 27 00180 #define NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED 28 00181 #define NM_DEVICE_STATE_REASON_GSM_APN_FAILED 29 00182 #define NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING 30 00183 #define NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED 31 00184 #define NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT 32 00185 #define NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED 33 00186 #define NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED 34 00187 #define NM_DEVICE_STATE_REASON_FIRMWARE_MISSING 35 00188 #define NM_DEVICE_STATE_REASON_REMOVED 36 00189 #define NM_DEVICE_STATE_REASON_SLEEPING 37 00190 #define NM_DEVICE_STATE_REASON_CONNECTION_REMOVED 38 00191 #define NM_DEVICE_STATE_REASON_USER_REQUESTED 39 00192 #define NM_DEVICE_STATE_REASON_CARRIER 40 00193 #define NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED 41 00194 #define NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE 42 00195 #define NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND 43 00196 #define NM_DEVICE_STATE_REASON_BT_FAILED 44 00197 #define NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED 45 00198 #define NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED 46 00199 #define NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED 47 00200 #define NM_DEVICE_STATE_REASON_GSM_SIM_WRONG 48 00201 #define NM_DEVICE_STATE_REASON_INFINIBAND_MODE 49 00202 #define NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED 50 00203 #define NM_DEVICE_STATE_REASON_BR2684_FAILED 51 00204 #define NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE 52 00205 #define NM_DEVICE_STATE_REASON_SSID_NOT_FOUND 53 00206 #define NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED 54 00207 //==================================================================================================== 00208 00209 class TDENetworkConnectionManager_BackendNMPrivate; 00210 00211 class TDECORE_EXPORT TDENetworkConnectionManager_BackendNM : public TDENetworkConnectionManager 00212 { 00213 Q_OBJECT 00214 00215 public: 00216 TDENetworkConnectionManager_BackendNM(TDENetworkDevice* networkDevice); 00217 ~TDENetworkConnectionManager_BackendNM(); 00218 00219 virtual TQString backendName(); 00220 virtual TDENetworkDeviceType::TDENetworkDeviceType deviceType(); 00221 virtual TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags backendStatus(); 00222 virtual TDENetworkDeviceInformation deviceInformation(); 00223 virtual TDENetworkDeviceInformation deviceStatus(); 00224 00225 virtual void loadConnectionInformation(); 00226 virtual void loadConnectionAllowedValues(TDENetworkConnection* connection); 00227 virtual bool loadConnectionSecrets(TQString uuid); 00228 virtual bool saveConnection(TDENetworkConnection* connection); 00229 virtual bool deleteConnection(TQString uuid); 00230 virtual bool verifyConnectionSettings(TDENetworkConnection* connection, TDENetworkConnectionErrorFlags::TDENetworkConnectionErrorFlags* type=NULL, TDENetworkErrorStringMap* reason=NULL); 00231 00232 virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus initiateConnection(TQString uuid); 00233 virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus checkConnectionStatus(TQString uuid); 00234 virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus deactivateConnection(TQString uuid); 00235 virtual TQStringList validSettings(); 00236 00237 virtual TDENetworkHWNeighborList* siteSurvey(); 00238 virtual TQStringList connectionPhysicalDeviceUUIDs(TQString uuid); 00239 virtual TDENetworkVPNTypeList availableVPNTypes(); 00240 00241 virtual bool networkingEnabled(); 00242 virtual bool wiFiHardwareEnabled(); 00243 00244 virtual bool enableNetworking(bool enable); 00245 virtual bool enableWiFi(bool enable); 00246 virtual bool wiFiEnabled(); 00247 00248 virtual TQStringList defaultNetworkDevices(); 00249 00250 private: 00251 TDENetworkDeviceType::TDENetworkDeviceType nmDeviceTypeToTDEDeviceType(TQ_UINT32 nmType); 00252 TQString deviceInterfaceString(TQString deviceNode); 00253 bool loadConnectionSecretsForGroup(TQString uuid, TQString group); 00254 TDENetworkWiFiAPInfo* getAccessPointDetails(TQString dbusPath); 00255 TDENetworkConnectionType::TDENetworkConnectionType connectionType(TQString dbusPath); 00256 TQCString getActiveConnectionPath(TQString uuid); 00257 00258 private: 00259 TDENetworkConnectionManager_BackendNMPrivate* d; 00260 friend class TDENetworkConnectionManager_BackendNMPrivate; 00261 }; 00262 00263 #endif // _TDENETWORKBACKEND_NETWORKMANAGER_H