~morphis/aethercast/enable-arm64-builds

« back to all changes in this revision

Viewing changes to src/w11tng/dhcpclient.h

  • Committer: Tarmac
  • Author(s): Simon Fels
  • Date: 2016-02-04 06:38:31 UTC
  • mfrom: (119.1.65 trunk)
  • Revision ID: tarmac-20160204063831-b6q9o8ktznevvd8x
Add a network manager implementation to use the DBus interface of wpa-supplicant.

Approved by PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2015 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 3, as published
 
6
 * by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.  See the GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License along
 
14
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 */
 
17
 
 
18
#ifndef W11TNG_DHCPCLIENT_H_
 
19
#define W11TNG_DHCPCLIENT_H_
 
20
 
 
21
#include <glib.h>
 
22
 
 
23
#include <boost/noncopyable.hpp>
 
24
 
 
25
#include <string>
 
26
 
 
27
#include <mcs/ip_v4_address.h>
 
28
#include <mcs/non_copyable.h>
 
29
 
 
30
#include "processexecutor.h"
 
31
#include "filemonitor.h"
 
32
 
 
33
namespace w11tng {
 
34
class DhcpClient : public std::enable_shared_from_this<DhcpClient>,
 
35
                   public w11tng::ProcessExecutor::Delegate,
 
36
                   public w11tng::FileMonitor::Delegate {
 
37
public:
 
38
    typedef std::shared_ptr<DhcpClient> Ptr;
 
39
 
 
40
    class Delegate : private mcs::NonCopyable {
 
41
    public:
 
42
        virtual void OnDhcpAddressAssigned(const mcs::IpV4Address &local_address, const mcs::IpV4Address &remote_address) = 0;
 
43
        virtual void OnDhcpTerminated() = 0;
 
44
    };
 
45
 
 
46
    static Ptr Create(const std::weak_ptr<Delegate> &delegate, const std::string &interface_name);
 
47
 
 
48
    ~DhcpClient();
 
49
 
 
50
    mcs::IpV4Address RemoteAddress() const;
 
51
    mcs::IpV4Address LocalAddress() const;
 
52
 
 
53
    void OnProcessTerminated() override;
 
54
    void OnFileChanged(const std::string &path) override;
 
55
 
 
56
private:
 
57
    DhcpClient(const std::weak_ptr<Delegate> &delegate, const std::string &interface_name);
 
58
    void Start();
 
59
 
 
60
private:
 
61
    std::weak_ptr<Delegate> delegate_;
 
62
    std::string interface_name_;
 
63
    mcs::IpV4Address local_address_;
 
64
    mcs::IpV4Address remote_address_;
 
65
    std::string lease_file_path_;
 
66
    ProcessExecutor::Ptr executor_;
 
67
    FileMonitor::Ptr monitor_;
 
68
};
 
69
}
 
70
 
 
71
#endif