shill: Separates Attributes into Netlink and Nl80211 classes.

This CL separates Nl80211Attribute into a base class (NetlinkAttribute)
and an nl80211-specific portion, replaces the enum 'nl80211_attrs' with
'int' in various places (to genericize those operations), and makes
|CreateAndInitFromNlAttr| take an attribute-type-specific factory as a
parameter.  This work prepares the Config80211 code to handle control
messages along with control message-specific attributes in preparation
for Config80211 to make the transition from using libnl for kernel
communication to using netlink sockets directly.

BUG=chromium-os:39022
TEST=unittest.

Change-Id: Icbd9d171b16eb0088c90be9de1092006b75e1e42
Reviewed-on: https://gerrit.chromium.org/gerrit/44108
Reviewed-by: Paul Stewart <pstew@chromium.org>
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Queue: Wade Guthrie <wdg@chromium.org>
Tested-by: Wade Guthrie <wdg@chromium.org>
diff --git a/nl80211_message.cc b/nl80211_message.cc
index 952ada6..4b5ef2c 100644
--- a/nl80211_message.cc
+++ b/nl80211_message.cc
@@ -41,6 +41,7 @@
 #include <iomanip>
 #include <string>
 
+#include <base/bind.h>
 #include <base/format_macros.h>
 #include <base/stl_util.h>
 #include <base/stringprintf.h>
@@ -53,6 +54,7 @@
 #include "shill/scope_logger.h"
 #include "shill/wifi.h"
 
+using base::Bind;
 using base::LazyInstance;
 using base::StringAppendF;
 using base::StringPrintf;
@@ -140,8 +142,8 @@
     if (tb[i]) {
       // TODO(wdg): When Nl80211Messages instantiate their own attributes,
       // this call should, instead, call |SetAttributeFromNlAttr|.
-      attributes_.CreateAndInitFromNlAttr(static_cast<enum nl80211_attrs>(i),
-                                          tb[i]);
+      attributes_.CreateAndInitAttribute(
+          i, tb[i], Bind(&NetlinkAttribute::NewNl80211AttributeFromId));
     }
   }
 
@@ -393,8 +395,7 @@
 }
 
 // Helper function to provide a string for a MAC address.
-bool Nl80211Message::GetMacAttributeString(nl80211_attrs id,
-                                           string *value) const {
+bool Nl80211Message::GetMacAttributeString(int id, string *value) const {
   if (!value) {
     LOG(ERROR) << "Null |value| parameter";
     return false;
@@ -412,7 +413,7 @@
 
 // Helper function to provide a string for NL80211_ATTR_SCAN_FREQUENCIES.
 bool Nl80211Message::GetScanFrequenciesAttribute(
-    nl80211_attrs id, vector<uint32_t> *value) const {
+    int id, vector<uint32_t> *value) const {
   if (!value) {
     LOG(ERROR) << "Null |value| parameter";
     return false;
@@ -431,14 +432,14 @@
   int len = rawdata.GetLength();
 
   nla_for_each_attr(nst, attr_data, len, rem_nst) {
-    value->push_back(Nl80211Attribute::NlaGetU32(nst));
+    value->push_back(NetlinkAttribute::NlaGetU32(nst));
   }
   return true;
 }
 
 // Helper function to provide a string for NL80211_ATTR_SCAN_SSIDS.
 bool Nl80211Message::GetScanSsidsAttribute(
-    nl80211_attrs id, vector<string> *value) const {
+    int id, vector<string> *value) const {
   if (!value) {
     LOG(ERROR) << "Null |value| parameter";
     return false;
@@ -490,7 +491,7 @@
   return output;
 }
 
-string Nl80211Message::StringFromFrame(nl80211_attrs attr_name) const {
+string Nl80211Message::StringFromFrame(int attr_name) const {
   string output;
   ByteString frame_data;
   if (attributes().GetRawAttributeValue(attr_name,