blob: 1f3f2232301b673a9782b0b333880b605d944992 [file] [log] [blame]
Ningyuan Wangb6836022015-12-02 14:39:01 -08001//
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
28namespace dhcp_client {
29
30class Manager;
31
32class 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 Wangab2af972015-12-03 13:57:40 -080045 // Indentifier number of this service.
Ningyuan Wangb6836022015-12-02 14:39:01 -080046 int identifier_;
47 EventDispatcherInterface* event_dispatcher_;
Ningyuan Wangab2af972015-12-03 13:57:40 -080048 // Name of the network interface.
Ningyuan Wangb6836022015-12-02 14:39:01 -080049 std::string interface_name_;
Ningyuan Wangab2af972015-12-03 13:57:40 -080050 // Type of the DHCP service.
51 // It can be IPv4 only or IPv6 only or both.
Ningyuan Wangb6836022015-12-02 14:39:01 -080052 int type_;
Ningyuan Wangab2af972015-12-03 13:57:40 -080053 // Unique network/connection identifier,
54 // lease will persist to storage if this identifier is specified.
Ningyuan Wangb6836022015-12-02 14:39:01 -080055 std::string network_id_;
56
57 // DHCP IPv4 configurations:
Ningyuan Wangab2af972015-12-03 13:57:40 -080058 // Request hostname from server.
Ningyuan Wangb6836022015-12-02 14:39:01 -080059 bool request_hostname_;
Ningyuan Wangab2af972015-12-03 13:57:40 -080060 // ARP for default gateway.
Ningyuan Wangb6836022015-12-02 14:39:01 -080061 bool arp_gateway_;
Ningyuan Wangab2af972015-12-03 13:57:40 -080062 // Enable unicast ARP on renew.
Ningyuan Wangb6836022015-12-02 14:39:01 -080063 bool unicast_arp_;
64
65 // DHCP IPv6 configurations:
Ningyuan Wangab2af972015-12-03 13:57:40 -080066 // Request non-temporary address.
Ningyuan Wangb6836022015-12-02 14:39:01 -080067 bool request_na_;
Ningyuan Wangab2af972015-12-03 13:57:40 -080068 // Request prefix delegation.
Ningyuan Wangb6836022015-12-02 14:39:01 -080069 bool request_pd_;
Ningyuan Wangab2af972015-12-03 13:57:40 -080070 // Parse DHCP configurations from the VariantDictionary.
Ningyuan Wangb6836022015-12-02 14:39:01 -080071 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_