blob: 4b267143cba261bb0a8b2c1d0a00fb13f6ac4ebe [file] [log] [blame]
Peter Qiubf8e36c2014-12-03 22:59:45 -08001// Copyright 2014 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef APMANAGER_DHCP_SERVER_H_
6#define APMANAGER_DHCP_SERVER_H_
7
8#include <string>
9
10#include <base/macros.h>
11#include <chromeos/process.h>
12#include <shill/net/ip_address.h>
13#include <shill/net/rtnl_handler.h>
14
Peter Qiu77517302015-01-08 16:22:16 -080015#include "apmanager/file_writer.h"
16
Peter Qiubf8e36c2014-12-03 22:59:45 -080017namespace apmanager {
18
19class DHCPServer {
20 public:
21 DHCPServer(uint16_t server_address_index,
22 const std::string& interface_name);
23 virtual ~DHCPServer();
24
25 // Start the DHCP server
26 virtual bool Start();
27
28 private:
29 friend class DHCPServerTest;
30
31 std::string GenerateConfigFile();
32
33 static const char kDnsmasqPath[];
34 static const char kDnsmasqConfigFilePathFormat[];
35 static const char kDHCPLeasesFilePathFormat[];
36 static const char kServerAddressFormat[];
37 static const char kAddressRangeLowFormat[];
38 static const char kAddressRangeHighFormat[];
39 static const int kServerAddressPrefix;
40 static const int kTerminationTimeoutSeconds;
41
42 uint16_t server_address_index_;
43 std::string interface_name_;
44 shill::IPAddress server_address_;
45 std::unique_ptr<chromeos::Process> dnsmasq_process_;
46 shill::RTNLHandler* rtnl_handler_;
Peter Qiu77517302015-01-08 16:22:16 -080047 FileWriter* file_writer_;
Peter Qiubf8e36c2014-12-03 22:59:45 -080048
49 DISALLOW_COPY_AND_ASSIGN(DHCPServer);
50};
51
52} // namespace apmanager
53
54#endif // APMANAGER_DHCP_SERVER_H_