2
* Copyright (C) 2015 Canonical, Ltd.
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.
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.
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/>.
18
#ifndef W11TNG_NETLINK_LISTENER_H_
19
#define W11TNG_NETLINK_LISTENER_H_
25
#include <mcs/non_copyable.h>
26
#include <mcs/scoped_gobject.h>
32
class NetlinkListener : public std::enable_shared_from_this<NetlinkListener> {
34
typedef std::shared_ptr<NetlinkListener> Ptr;
36
class Delegate : public mcs::NonCopyable {
38
virtual void OnInterfaceAddressChanged(const std::string &interface, const std::string &address) { }
41
static Ptr Create(const std::weak_ptr<Delegate> &delegate);
45
void SetInterfaceFilter(const std::string &interface_name);
48
NetlinkListener(const std::weak_ptr<Delegate> &delegate);
49
Ptr FinalizeConstruction();
51
void ProcessNewAddress(struct nlmsghdr *hdr);
54
static gboolean OnDataAvailable(GIOChannel *channel, GIOCondition condition, gpointer user_data);
57
const std::weak_ptr<Delegate> delegate_;
59
int interface_index_filter_;