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 | |
| 26 | #include "dhcp_client/event_dispatcher_interface.h" |
| 27 | |
| 28 | namespace dhcp_client { |
| 29 | |
| 30 | class Manager; |
| 31 | |
| 32 | class Service : public base::RefCounted<Service> { |
| 33 | public: |
| 34 | Service(Manager* manager, |
| 35 | int service_identifier, |
| 36 | EventDispatcherInterface* event_dispatcher, |
| 37 | const brillo::VariantDictionary& configs); |
| 38 | |
| 39 | virtual ~Service(); |
| 40 | void Start(); |
| 41 | void Stop(); |
| 42 | |
| 43 | private: |
| 44 | Manager* manager_; |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame^] | 45 | // Indentifier number of this service. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 46 | int identifier_; |
| 47 | EventDispatcherInterface* event_dispatcher_; |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame^] | 48 | // Name of the network interface. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 49 | std::string interface_name_; |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame^] | 50 | // Type of the DHCP service. |
| 51 | // It can be IPv4 only or IPv6 only or both. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 52 | int type_; |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame^] | 53 | // Unique network/connection identifier, |
| 54 | // lease will persist to storage if this identifier is specified. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 55 | std::string network_id_; |
| 56 | |
| 57 | // DHCP IPv4 configurations: |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame^] | 58 | // Request hostname from server. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 59 | bool request_hostname_; |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame^] | 60 | // ARP for default gateway. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 61 | bool arp_gateway_; |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame^] | 62 | // Enable unicast ARP on renew. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 63 | bool unicast_arp_; |
| 64 | |
| 65 | // DHCP IPv6 configurations: |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame^] | 66 | // Request non-temporary address. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 67 | bool request_na_; |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame^] | 68 | // Request prefix delegation. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 69 | bool request_pd_; |
Ningyuan Wang | ab2af97 | 2015-12-03 13:57:40 -0800 | [diff] [blame^] | 70 | // Parse DHCP configurations from the VariantDictionary. |
Ningyuan Wang | b683602 | 2015-12-02 14:39:01 -0800 | [diff] [blame] | 71 | void ParseConfigs(const brillo::VariantDictionary& configs); |
| 72 | |
| 73 | DISALLOW_COPY_AND_ASSIGN(Service); |
| 74 | }; |
| 75 | |
| 76 | } // namespace dhcp_client |
| 77 | |
| 78 | #endif // DHCP_CLIENT_SERVICE_H_ |