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/dhcp.h"
27#include "dhcp_client/dhcpv4.h"
28#include "dhcp_client/event_dispatcher_interface.h"
29#include "shill/net/byte_string.h"
30
31namespace dhcp_client {
32
33class Manager;
34
35class 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();
43  bool Start();
44  void Stop();
45
46 private:
47  Manager* manager_;
48  // Indentifier number of this service.
49  int identifier_;
50  EventDispatcherInterface* event_dispatcher_;
51  // Interface parameters.
52  std::string interface_name_;
53  shill::ByteString hardware_address_;
54  unsigned int interface_index_;
55
56  // Unique network/connection identifier,
57  // lease will persist to storage if this identifier is specified.
58  std::string network_id_;
59
60  // Type of the DHCP service.
61  // It can be IPv4 only or IPv6 only or both.
62  DHCP::ServiceType type_;
63
64  // DHCP IPv4 configurations:
65  // Request hostname from server.
66  bool request_hostname_;
67  // ARP for default gateway.
68  bool arp_gateway_;
69  // Enable unicast ARP on renew.
70  bool unicast_arp_;
71
72  // DHCP IPv6 configurations:
73  // Request non-temporary address.
74  bool request_na_;
75  // Request prefix delegation.
76  bool request_pd_;
77
78  std::unique_ptr<DHCPV4> state_machine_ipv4_;
79  // Parse DHCP configurations from the VariantDictionary.
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_
88