Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2015 The Android Open Source Project |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | // |
| 16 | |
| 17 | #ifndef DHCP_CLIENT_SERVICE_H_ |
| 18 | #define DHCP_CLIENT_SERVICE_H_ |
| 19 | |
| 20 | #include <string> |
| 21 | |
| 22 | #include <base/macros.h> |
| 23 | #include <base/memory/ref_counted.h> |
| 24 | #include <brillo/variant_dictionary.h> |
| 25 | |
Ningyuan Wang | b52786a | 2015-12-10 14:25:15 -0800 | [diff] [blame] | 26 | #include "dhcp_client/dhcp.h" |
| 27 | #include "dhcp_client/dhcpv4.h" |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 28 | #include "dhcp_client/event_dispatcher_interface.h" |
Ningyuan Wang | 63aa9b5 | 2016-01-19 10:24:59 -0800 | [diff] [blame] | 29 | #include "shill/net/byte_string.h" |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 30 | |
| 31 | namespace dhcp_client { |
| 32 | |
| 33 | class Manager; |
| 34 | |
| 35 | class Service : public base::RefCounted<Service> { |
| 36 | public: |
| 37 | Service(Manager* manager, |
| 38 | int service_identifier, |
| 39 | EventDispatcherInterface* event_dispatcher, |
| 40 | const brillo::VariantDictionary& configs); |
| 41 | |
| 42 | virtual ~Service(); |
Ningyuan Wang | b52786a | 2015-12-10 14:25:15 -0800 | [diff] [blame] | 43 | bool Start(); |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 44 | void Stop(); |
| 45 | |
| 46 | private: |
| 47 | Manager* manager_; |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame] | 48 | // Indentifier number of this service. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 49 | int identifier_; |
| 50 | EventDispatcherInterface* event_dispatcher_; |
Ningyuan Wang | b52786a | 2015-12-10 14:25:15 -0800 | [diff] [blame] | 51 | // Interface parameters. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 52 | std::string interface_name_; |
Ningyuan Wang | 63aa9b5 | 2016-01-19 10:24:59 -0800 | [diff] [blame] | 53 | shill::ByteString hardware_address_; |
Ningyuan Wang | b52786a | 2015-12-10 14:25:15 -0800 | [diff] [blame] | 54 | unsigned int interface_index_; |
| 55 | |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame] | 56 | // Unique network/connection identifier, |
| 57 | // lease will persist to storage if this identifier is specified. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 58 | std::string network_id_; |
| 59 | |
Ningyuan Wang | b52786a | 2015-12-10 14:25:15 -0800 | [diff] [blame] | 60 | // Type of the DHCP service. |
| 61 | // It can be IPv4 only or IPv6 only or both. |
| 62 | DHCP::ServiceType type_; |
| 63 | |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 64 | // DHCP IPv4 configurations: |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame] | 65 | // Request hostname from server. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 66 | bool request_hostname_; |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame] | 67 | // ARP for default gateway. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 68 | bool arp_gateway_; |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame] | 69 | // Enable unicast ARP on renew. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 70 | bool unicast_arp_; |
| 71 | |
| 72 | // DHCP IPv6 configurations: |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame] | 73 | // Request non-temporary address. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 74 | bool request_na_; |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame] | 75 | // Request prefix delegation. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 76 | bool request_pd_; |
Ningyuan Wang | b52786a | 2015-12-10 14:25:15 -0800 | [diff] [blame] | 77 | |
| 78 | std::unique_ptr<DHCPV4> state_machine_ipv4_; |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame] | 79 | // Parse DHCP configurations from the VariantDictionary. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 80 | void ParseConfigs(const brillo::VariantDictionary& configs); |
| 81 | |
| 82 | DISALLOW_COPY_AND_ASSIGN(Service); |
| 83 | }; |
| 84 | |
| 85 | } // namespace dhcp_client |
| 86 | |
| 87 | #endif // DHCP_CLIENT_SERVICE_H_ |