Split off rtnl facility from device_info

Create an "rtnl_handler" singleton for conversing with rtnl socket.
Create "listener" objects that hold callbacks to interested parties.

BUG=chromium-os:15804
TEST=Rerun unit tests

Change-Id: Ica845b39ce6a0885a4e6d2560146ff8f5f45b900
Reviewed-on: http://gerrit.chromium.org/gerrit/1632
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/rtnl_listener.cc b/rtnl_listener.cc
new file mode 100644
index 0000000..643a19e
--- /dev/null
+++ b/rtnl_listener.cc
@@ -0,0 +1,27 @@
+// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <base/callback_old.h>
+
+#include "shill/rtnl_listener.h"
+#include "shill/rtnl_handler.h"
+
+namespace shill {
+
+RTNLListener::RTNLListener(int listen_flags,
+                           Callback1<struct nlmsghdr *>::Type *callback)
+    : listen_flags_(listen_flags), callback_(callback) {
+  RTNLHandler::GetInstance()->AddListener(this);
+}
+
+RTNLListener::~RTNLListener() {
+  RTNLHandler::GetInstance()->RemoveListener(this);
+}
+
+void RTNLListener::NotifyEvent(int type, struct nlmsghdr *hdr) {
+  if ((type & listen_flags_) != 0)
+    callback_->Run(hdr);
+}
+
+}  // namespace shill