| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_NETWORK_H_ | 5 #ifndef CHROMEOS_NETWORK_H_ |
| 6 #define CHROMEOS_NETWORK_H_ | 6 #define CHROMEOS_NETWORK_H_ |
| 7 | 7 |
| 8 #include <base/basictypes.h> | 8 #include <base/basictypes.h> |
| 9 | 9 |
| 10 namespace chromeos { // NOLINT | 10 namespace chromeos { // NOLINT |
| 11 | 11 |
| 12 // connection types (see connman/include/service.h) | 12 // Connection enums (see flimflam/files/include/service.h) |
| 13 enum ConnectionType { | 13 enum ConnectionType { |
| 14 TYPE_UNKNOWN = 0x00000, | 14 TYPE_UNKNOWN = 0, |
| 15 TYPE_ETHERNET = 0x00001, | 15 TYPE_ETHERNET = 1, |
| 16 TYPE_WIFI = 0x00010, | 16 TYPE_WIFI = 2, |
| 17 TYPE_WIMAX = 0x00100, | 17 TYPE_WIMAX = 3, |
| 18 TYPE_BLUETOOTH = 0x01000, | 18 TYPE_BLUETOOTH = 4, |
| 19 TYPE_CELLULAR = 0x10000, | 19 TYPE_CELLULAR = 5, |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 // connection states (see connman/include/service.h) | 22 enum ConnectionMode { |
| 23 enum ConnectionState { | 23 MODE_UNKNOWN = 0, |
| 24 STATE_UNKNOWN, | 24 MODE_MANAGED = 1, |
| 25 STATE_IDLE, | 25 MODE_ADHOC = 2, |
| 26 STATE_CARRIER, | |
| 27 STATE_ASSOCIATION, | |
| 28 STATE_CONFIGURATION, | |
| 29 STATE_READY, | |
| 30 STATE_DISCONNECT, | |
| 31 STATE_FAILURE, | |
| 32 }; | 26 }; |
| 33 | 27 |
| 34 enum EncryptionType { | 28 enum ConnectionSecurity { |
| 35 NONE, | 29 SECURITY_UNKNOWN = 0, |
| 36 WEP, | 30 SECURITY_NONE = 1, |
| 37 WPA, | 31 SECURITY_WEP = 2, |
| 38 RSN | 32 SECURITY_WPA = 3, |
| 33 SECURITY_RSN = 4, |
| 34 }; |
| 35 |
| 36 enum ConnectionState { |
| 37 STATE_UNKNOWN = 0, |
| 38 STATE_IDLE = 1, |
| 39 STATE_CARRIER = 2, |
| 40 STATE_ASSOCIATION = 3, |
| 41 STATE_CONFIGURATION = 4, |
| 42 STATE_READY = 5, |
| 43 STATE_DISCONNECT = 6, |
| 44 STATE_FAILURE = 7, |
| 45 }; |
| 46 |
| 47 enum ConnectionError { |
| 48 ERROR_UNKNOWN = 0, |
| 49 ERROR_OUT_OF_RANGE = 1, |
| 50 ERROR_PIN_MISSING = 2, |
| 51 ERROR_DHCP_FAILED = 3, |
| 52 ERROR_CONNECT_FAILED = 4, |
| 39 }; | 53 }; |
| 40 | 54 |
| 41 // ipconfig types (see flimflam/files/doc/ipconfig-api.txt | 55 // ipconfig types (see flimflam/files/doc/ipconfig-api.txt |
| 42 enum IPConfigType { | 56 enum IPConfigType { |
| 43 IPCONFIG_TYPE_UNKNOWN, | 57 IPCONFIG_TYPE_UNKNOWN, |
| 44 IPCONFIG_TYPE_IPV4, | 58 IPCONFIG_TYPE_IPV4, |
| 45 IPCONFIG_TYPE_IPV6, | 59 IPCONFIG_TYPE_IPV6, |
| 46 IPCONFIG_TYPE_DHCP, | 60 IPCONFIG_TYPE_DHCP, |
| 47 IPCONFIG_TYPE_BOOTP, //Not Used | 61 IPCONFIG_TYPE_BOOTP, //Not Used |
| 48 IPCONFIG_TYPE_ZEROCONF, | 62 IPCONFIG_TYPE_ZEROCONF, |
| 49 IPCONFIG_TYPE_DHCP6, | 63 IPCONFIG_TYPE_DHCP6, |
| 50 IPCONFIG_TYPE_PPP, | 64 IPCONFIG_TYPE_PPP, |
| 51 }; | 65 }; |
| 52 | 66 |
| 53 struct ServiceInfo { | 67 struct ServiceInfo { |
| 54 const char* ssid; | 68 const char* service_path; |
| 69 const char* name; |
| 70 ConnectionType type; |
| 71 ConnectionMode mode; |
| 72 ConnectionSecurity security; |
| 73 ConnectionState state; |
| 74 ConnectionError error; |
| 75 bool passphrase_required; |
| 76 const char* passphrase; |
| 77 int64 strength; |
| 78 bool favorite; |
| 79 bool auto_connect; |
| 55 const char* device_path; | 80 const char* device_path; |
| 56 ConnectionType type; | |
| 57 ConnectionState state; | |
| 58 int64 signal_strength; | |
| 59 bool needs_passphrase; | |
| 60 EncryptionType encryption; | |
| 61 }; | 81 }; |
| 62 | 82 |
| 63 struct ServiceStatus { | 83 struct ServiceStatus { |
| 64 ServiceInfo *services; | 84 ServiceInfo *services; |
| 65 int size; | 85 int size; |
| 66 }; | 86 }; |
| 67 | 87 |
| 68 struct IPConfig { | 88 struct IPConfig { |
| 69 const char* path; | 89 const char* path; |
| 70 IPConfigType type; | 90 IPConfigType type; |
| 71 const char* address; | 91 const char* address; |
| 72 int32 mtu; | 92 int32 mtu; |
| 73 const char* netmask; | 93 const char* netmask; |
| 74 const char* broadcast; | 94 const char* broadcast; |
| 75 const char* peer_address; | 95 const char* peer_address; |
| 76 const char* gateway; | 96 const char* gateway; |
| 77 const char* domainname; | 97 const char* domainname; |
| 78 const char* name_servers; | 98 const char* name_servers; |
| 79 }; | 99 }; |
| 80 | 100 |
| 81 struct IPConfigStatus { | 101 struct IPConfigStatus { |
| 82 IPConfig* ips; | 102 IPConfig* ips; |
| 83 int size; | 103 int size; |
| 84 }; | 104 }; |
| 85 | 105 |
| 86 // Connects to a given ssid. | 106 // Connects to the network with the |service_path|. |
| 87 // | 107 // |
| 88 // Set passphrase to NULL if the network doesn't require authentication. | 108 // Set |passphrase| to NULL if the network doesn't require authentication. |
| 89 // | |
| 90 // Set encryption to NULL if the network doesn't require authentication | |
| 91 // otherwise we will use 'rsn' as the default. | |
| 92 // | 109 // |
| 93 // returns false on failure and true on success. | 110 // returns false on failure and true on success. |
| 94 // | 111 // |
| 95 // Note, a successful call to this function only indicates that the | 112 // Note, a successful call to this function only indicates that the |
| 96 // connection process has started. You will have to query the connection state | 113 // connection process has started. You will have to query the connection state |
| 97 // to determine if the connection was established successfully. | 114 // to determine if the connection was established successfully. |
| 98 extern bool (*ConnectToWifiNetwork)(const char* ssid, | 115 extern bool (*ConnectToNetwork)(const char* service_path, |
| 99 const char* passphrase, | 116 const char* passphrase); |
| 100 const char* encryption); | |
| 101 | 117 |
| 102 // Returns a list of all of the available services that a user can connect to. | 118 // Returns a list of all of the available services that a user can connect to. |
| 103 // The ServiceStatus instance that is returned by this function MUST be | 119 // The ServiceStatus instance that is returned by this function MUST be |
| 104 // deleted with by calling FreeServiceStatus. | 120 // deleted with by calling FreeServiceStatus. |
| 105 // | 121 // |
| 106 // Returns NULL on error. | 122 // Returns NULL on error. |
| 107 extern ServiceStatus* (*GetAvailableNetworks)(); | 123 extern ServiceStatus* (*GetAvailableNetworks)(); |
| 108 | 124 |
| 109 // Deletes a ServiceStatus type that was allocated in the ChromeOS dll. We need | 125 // Deletes a ServiceStatus type that was allocated in the ChromeOS dll. We need |
| 110 // to do this to safely pass data over the dll boundary between our .so and | 126 // to do this to safely pass data over the dll boundary between our .so and |
| (...skipping 13 matching lines...) Expand all Loading... |
| 124 typedef void(*NetworkMonitor)(void* object, const ServiceStatus& status); | 140 typedef void(*NetworkMonitor)(void* object, const ServiceStatus& status); |
| 125 | 141 |
| 126 // Processes a callback from a d-bus signal by finding the path of the | 142 // Processes a callback from a d-bus signal by finding the path of the |
| 127 // Connman service that changed and sending the details along to the next | 143 // Connman service that changed and sending the details along to the next |
| 128 // handler in the chain as an instance of ServiceInfo. | 144 // handler in the chain as an instance of ServiceInfo. |
| 129 extern NetworkStatusConnection (*MonitorNetworkStatus)(NetworkMonitor, void*); | 145 extern NetworkStatusConnection (*MonitorNetworkStatus)(NetworkMonitor, void*); |
| 130 | 146 |
| 131 // Disconnects a NetworkStatusConnection. | 147 // Disconnects a NetworkStatusConnection. |
| 132 extern void (*DisconnectNetworkStatus)(NetworkStatusConnection connection); | 148 extern void (*DisconnectNetworkStatus)(NetworkStatusConnection connection); |
| 133 | 149 |
| 134 // Returns the enabled network devices as a bitwise or value of ConnectionTypes. | 150 // Returns the enabled network devices as a bitwise OR value of ConnectionTypes. |
| 151 // Each bit represents whether or not that ConnectionType is enabled. |
| 152 // For example, the bit representing TYPE_WIFI is (1 << TYPE_WIFI) |
| 135 // | 153 // |
| 136 // Returns 0 if no devices are enabled. | 154 // Returns 0 if no devices are enabled. |
| 137 // Returns -1 if offline mode, by definition, means all devices are disabled. | 155 // Returns -1 if offline mode, by definition, means all devices are disabled. |
| 138 extern int (*GetEnabledNetworkDevices)(); | 156 extern int (*GetEnabledNetworkDevices)(); |
| 139 | 157 |
| 140 // Enable or disable the specific network device for connection. | 158 // Enable or disable the specific network device for connection. |
| 141 // | 159 // |
| 142 // Returns false on failure and true on success. | 160 // Returns false on failure and true on success. |
| 143 extern bool (*EnableNetworkDevice)(ConnectionType type, bool enable); | 161 extern bool (*EnableNetworkDevice)(ConnectionType type, bool enable); |
| 144 | 162 |
| 145 // Set offline mode. This will turn off all radios. | 163 // Set offline mode. This will turn off all radios. |
| 146 // | 164 // |
| 147 // Returns false on failure and true on success. | 165 // Returns false on failure and true on success. |
| 148 extern bool (*SetOfflineMode)(bool offline); | 166 extern bool (*SetOfflineMode)(bool offline); |
| 149 | 167 |
| 150 // Gets a list of all the IPConfigs using a given device path | 168 // Gets a list of all the IPConfigs using a given device path |
| 151 extern IPConfigStatus* (*ListIPConfigs)(const char* device_path); | 169 extern IPConfigStatus* (*ListIPConfigs)(const char* device_path); |
| 152 | 170 |
| 153 // Add a IPConfig of the given type to the device | 171 // Add a IPConfig of the given type to the device |
| 154 extern bool (*AddIPConfig)(const char* device_path, IPConfigType type); | 172 extern bool (*AddIPConfig)(const char* device_path, IPConfigType type); |
| 155 | 173 |
| 156 // Sets a property of the IPConfig | |
| 157 // Address Mtu PrefixLen Broadcast PeerAddress Gateway DomainName | |
| 158 extern bool (*SetIPConfigProperty)(IPConfig* config, | |
| 159 const char* key, | |
| 160 const char* value); | |
| 161 | |
| 162 // Gets a property of this Ip address. Valid keys are: | |
| 163 // Address Mtu PrefixLen Broadcast PeerAddress Gateway DomainName | |
| 164 extern bool (*GetIPConfigProperty)(IPConfig* config, | |
| 165 const char* key, | |
| 166 char* val, | |
| 167 size_t valsz); | |
| 168 | |
| 169 // Save the IP config data | 174 // Save the IP config data |
| 170 extern bool (*SaveIPConfig)(IPConfig* config); | 175 extern bool (*SaveIPConfig)(IPConfig* config); |
| 171 | 176 |
| 172 // Remove an existing IP Config | 177 // Remove an existing IP Config |
| 173 extern bool (*RemoveIPConfig)(IPConfig* config); | 178 extern bool (*RemoveIPConfig)(IPConfig* config); |
| 174 | 179 |
| 175 // Free a found IPConfig | 180 // Free a found IPConfig |
| 176 extern void (*FreeIPConfig)(IPConfig* config); | 181 extern void (*FreeIPConfig)(IPConfig* config); |
| 177 | 182 |
| 178 // Free out a full status | 183 // Free out a full status |
| 179 extern void (*FreeIPConfigStatus)(IPConfigStatus* status); | 184 extern void (*FreeIPConfigStatus)(IPConfigStatus* status); |
| 180 | 185 |
| 181 } // namespace chromeos | 186 } // namespace chromeos |
| 182 | 187 |
| 183 #endif // CHROMEOS_NETWORK_H_ | 188 #endif // CHROMEOS_NETWORK_H_ |
| OLD | NEW |