blob: 7eff73cff2266fb4da5847cafe75b701bb4f75a1 [file] [log] [blame]
Paul Stewarta3c56f92011-05-26 07:08:52 -07001// Copyright (c) 2011 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#include <base/callback_old.h>
6
7#include "shill/rtnl_listener.h"
8#include "shill/rtnl_handler.h"
9
10namespace shill {
11
12RTNLListener::RTNLListener(int listen_flags,
Chris Masone2aa97072011-08-09 17:35:08 -070013 Callback1<const RTNLMessage &>::Type *callback)
Paul Stewarta3c56f92011-05-26 07:08:52 -070014 : listen_flags_(listen_flags), callback_(callback) {
15 RTNLHandler::GetInstance()->AddListener(this);
16}
17
18RTNLListener::~RTNLListener() {
19 RTNLHandler::GetInstance()->RemoveListener(this);
20}
21
Chris Masone2aa97072011-08-09 17:35:08 -070022void RTNLListener::NotifyEvent(int type, const RTNLMessage &msg) {
Paul Stewarta3c56f92011-05-26 07:08:52 -070023 if ((type & listen_flags_) != 0)
Chris Masone2aa97072011-08-09 17:35:08 -070024 callback_->Run(msg);
Paul Stewarta3c56f92011-05-26 07:08:52 -070025}
26
27} // namespace shill