Paul Stewart | a3c56f9 | 2011-05-26 07:08:52 -0700 | [diff] [blame] | 1 | // 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 | |
| 10 | namespace shill { |
| 11 | |
| 12 | RTNLListener::RTNLListener(int listen_flags, |
| 13 | Callback1<struct nlmsghdr *>::Type *callback) |
| 14 | : listen_flags_(listen_flags), callback_(callback) { |
| 15 | RTNLHandler::GetInstance()->AddListener(this); |
| 16 | } |
| 17 | |
| 18 | RTNLListener::~RTNLListener() { |
| 19 | RTNLHandler::GetInstance()->RemoveListener(this); |
| 20 | } |
| 21 | |
| 22 | void RTNLListener::NotifyEvent(int type, struct nlmsghdr *hdr) { |
| 23 | if ((type & listen_flags_) != 0) |
| 24 | callback_->Run(hdr); |
| 25 | } |
| 26 | |
| 27 | } // namespace shill |