shill: Add attribute-specific grandchildren of Nl80211Attribute type.
This checkin adds all the specific attribute types (base on the type-specific
children of the Nl80211Attribute type) without (still) actually changing any
of the code that's called (that's the next checkin).
BUG=chromium-os:36637
TEST=unittests.
Change-Id: I39df5fce5a20bbe9e533b587fc35711f2216b4f8
Reviewed-on: https://gerrit.chromium.org/gerrit/39407
Commit-Ready: Wade Guthrie <wdg@chromium.org>
Reviewed-by: Wade Guthrie <wdg@chromium.org>
Tested-by: Wade Guthrie <wdg@chromium.org>
diff --git a/nl80211_attribute.cc b/nl80211_attribute.cc
index 44753bc..bb65fcc 100644
--- a/nl80211_attribute.cc
+++ b/nl80211_attribute.cc
@@ -38,12 +38,81 @@
const nlattr *data) {
scoped_ptr<Nl80211Attribute> attr;
switch (name) {
+ case NL80211_ATTR_COOKIE:
+ attr.reset(new Nl80211AttributeCookie());
+ break;
+ case NL80211_ATTR_CQM:
+ attr.reset(new Nl80211AttributeCqm());
+ break;
+ case NL80211_ATTR_DISCONNECTED_BY_AP:
+ attr.reset(new Nl80211AttributeDisconnectedByAp());
+ break;
case NL80211_ATTR_DURATION:
attr.reset(new Nl80211AttributeDuration());
break;
-
- // TODO(wdg): Add more attributes.
-
+ case NL80211_ATTR_FRAME:
+ attr.reset(new Nl80211AttributeFrame());
+ break;
+ case NL80211_ATTR_GENERATION:
+ attr.reset(new Nl80211AttributeGeneration());
+ break;
+ case NL80211_ATTR_IFINDEX:
+ attr.reset(new Nl80211AttributeIfindex());
+ break;
+ case NL80211_ATTR_KEY_IDX:
+ attr.reset(new Nl80211AttributeKeyIdx());
+ break;
+ case NL80211_ATTR_KEY_SEQ:
+ attr.reset(new Nl80211AttributeKeySeq());
+ break;
+ case NL80211_ATTR_KEY_TYPE:
+ attr.reset(new Nl80211AttributeKeyType());
+ break;
+ case NL80211_ATTR_MAC:
+ attr.reset(new Nl80211AttributeMac());
+ break;
+ case NL80211_ATTR_REASON_CODE:
+ attr.reset(new Nl80211AttributeReasonCode());
+ break;
+ case NL80211_ATTR_REG_ALPHA2:
+ attr.reset(new Nl80211AttributeRegAlpha2());
+ break;
+ case NL80211_ATTR_REG_INITIATOR:
+ attr.reset(new Nl80211AttributeRegInitiator());
+ break;
+ case NL80211_ATTR_REG_TYPE:
+ attr.reset(new Nl80211AttributeRegType());
+ break;
+ case NL80211_ATTR_RESP_IE:
+ attr.reset(new Nl80211AttributeRespIe());
+ break;
+ case NL80211_ATTR_SCAN_FREQUENCIES:
+ attr.reset(new Nl80211AttributeScanFrequencies());
+ break;
+ case NL80211_ATTR_SCAN_SSIDS:
+ attr.reset(new Nl80211AttributeScanSsids());
+ break;
+ case NL80211_ATTR_STA_INFO:
+ attr.reset(new Nl80211AttributeStaInfo());
+ break;
+ case NL80211_ATTR_STATUS_CODE:
+ attr.reset(new Nl80211AttributeStatusCode());
+ break;
+ case NL80211_ATTR_SUPPORT_MESH_AUTH:
+ attr.reset(new Nl80211AttributeSupportMeshAuth());
+ break;
+ case NL80211_ATTR_TIMED_OUT:
+ attr.reset(new Nl80211AttributeTimedOut());
+ break;
+ case NL80211_ATTR_WIPHY_FREQ:
+ attr.reset(new Nl80211AttributeWiphyFreq());
+ break;
+ case NL80211_ATTR_WIPHY:
+ attr.reset(new Nl80211AttributeWiphy());
+ break;
+ case NL80211_ATTR_WIPHY_NAME:
+ attr.reset(new Nl80211AttributeWiphyName());
+ break;
default:
attr.reset(new Nl80211AttributeGeneric(name));
break;
@@ -363,12 +432,12 @@
return Nl80211Attribute::InitFromNlAttr(input);
}
-bool Nl80211RawAttribute::GetRawValue(const ByteString **output) const {
+bool Nl80211RawAttribute::GetRawValue(ByteString *output) const {
if (!output) {
LOG(ERROR) << "NULL |output|";
return false;
}
- *output = &data_;
+ *output = data_;
return true;
}
@@ -389,9 +458,95 @@
// Specific Attributes.
+
+const nl80211_attrs Nl80211AttributeCookie::kName = NL80211_ATTR_COOKIE;
+const char Nl80211AttributeCookie::kNameString[] = "NL80211_ATTR_COOKIE";
+
+const nl80211_attrs Nl80211AttributeCqm::kName = NL80211_ATTR_CQM;
+const char Nl80211AttributeCqm::kNameString[] = "NL80211_ATTR_CQM";
+
+const nl80211_attrs Nl80211AttributeDisconnectedByAp::kName
+ = NL80211_ATTR_DISCONNECTED_BY_AP;
+const char Nl80211AttributeDisconnectedByAp::kNameString[]
+ = "NL80211_ATTR_DISCONNECTED_BY_AP";
+
const nl80211_attrs Nl80211AttributeDuration::kName = NL80211_ATTR_DURATION;
const char Nl80211AttributeDuration::kNameString[] = "NL80211_ATTR_DURATION";
+const nl80211_attrs Nl80211AttributeFrame::kName = NL80211_ATTR_FRAME;
+const char Nl80211AttributeFrame::kNameString[] = "NL80211_ATTR_FRAME";
+
+const nl80211_attrs Nl80211AttributeGeneration::kName = NL80211_ATTR_GENERATION;
+const char Nl80211AttributeGeneration::kNameString[]
+ = "NL80211_ATTR_GENERATION";
+
+const nl80211_attrs Nl80211AttributeIfindex::kName = NL80211_ATTR_IFINDEX;
+const char Nl80211AttributeIfindex::kNameString[] = "NL80211_ATTR_IFINDEX";
+
+const nl80211_attrs Nl80211AttributeKeyIdx::kName = NL80211_ATTR_KEY_IDX;
+const char Nl80211AttributeKeyIdx::kNameString[] = "NL80211_ATTR_KEY_IDX";
+
+const nl80211_attrs Nl80211AttributeKeySeq::kName = NL80211_ATTR_KEY_SEQ;
+const char Nl80211AttributeKeySeq::kNameString[] = "NL80211_ATTR_KEY_SEQ";
+
+const nl80211_attrs Nl80211AttributeKeyType::kName = NL80211_ATTR_KEY_TYPE;
+const char Nl80211AttributeKeyType::kNameString[] = "NL80211_ATTR_KEY_TYPE";
+
+const nl80211_attrs Nl80211AttributeMac::kName = NL80211_ATTR_MAC;
+const char Nl80211AttributeMac::kNameString[] = "NL80211_ATTR_MAC";
+
+const nl80211_attrs Nl80211AttributeReasonCode::kName
+ = NL80211_ATTR_REASON_CODE;
+const char Nl80211AttributeReasonCode::kNameString[]
+ = "NL80211_ATTR_REASON_CODE";
+
+const nl80211_attrs Nl80211AttributeRegAlpha2::kName = NL80211_ATTR_REG_ALPHA2;
+const char Nl80211AttributeRegAlpha2::kNameString[] = "NL80211_ATTR_REG_ALPHA2";
+
+const nl80211_attrs Nl80211AttributeRegInitiator::kName
+ = NL80211_ATTR_REG_INITIATOR;
+const char Nl80211AttributeRegInitiator::kNameString[]
+ = "NL80211_ATTR_REG_INITIATOR";
+
+const nl80211_attrs Nl80211AttributeRegType::kName = NL80211_ATTR_REG_TYPE;
+const char Nl80211AttributeRegType::kNameString[] = "NL80211_ATTR_REG_TYPE";
+
+const nl80211_attrs Nl80211AttributeRespIe::kName = NL80211_ATTR_RESP_IE;
+const char Nl80211AttributeRespIe::kNameString[] = "NL80211_ATTR_RESP_IE";
+
+const nl80211_attrs Nl80211AttributeScanFrequencies::kName
+ = NL80211_ATTR_SCAN_FREQUENCIES;
+const char Nl80211AttributeScanFrequencies::kNameString[]
+ = "NL80211_ATTR_SCAN_FREQUENCIES";
+
+const nl80211_attrs Nl80211AttributeScanSsids::kName = NL80211_ATTR_SCAN_SSIDS;
+const char Nl80211AttributeScanSsids::kNameString[] = "NL80211_ATTR_SCAN_SSIDS";
+
+const nl80211_attrs Nl80211AttributeStaInfo::kName = NL80211_ATTR_STA_INFO;
+const char Nl80211AttributeStaInfo::kNameString[] = "NL80211_ATTR_STA_INFO";
+
+const nl80211_attrs Nl80211AttributeStatusCode::kName
+ = NL80211_ATTR_STATUS_CODE;
+const char Nl80211AttributeStatusCode::kNameString[]
+ = "NL80211_ATTR_STATUS_CODE";
+
+const nl80211_attrs Nl80211AttributeSupportMeshAuth::kName
+ = NL80211_ATTR_SUPPORT_MESH_AUTH;
+const char Nl80211AttributeSupportMeshAuth::kNameString[]
+ = "NL80211_ATTR_SUPPORT_MESH_AUTH";
+
+const nl80211_attrs Nl80211AttributeTimedOut::kName = NL80211_ATTR_TIMED_OUT;
+const char Nl80211AttributeTimedOut::kNameString[] = "NL80211_ATTR_TIMED_OUT";
+
+const nl80211_attrs Nl80211AttributeWiphyFreq::kName = NL80211_ATTR_WIPHY_FREQ;
+const char Nl80211AttributeWiphyFreq::kNameString[] = "NL80211_ATTR_WIPHY_FREQ";
+
+const nl80211_attrs Nl80211AttributeWiphy::kName = NL80211_ATTR_WIPHY;
+const char Nl80211AttributeWiphy::kNameString[] = "NL80211_ATTR_WIPHY";
+
+const nl80211_attrs Nl80211AttributeWiphyName::kName = NL80211_ATTR_WIPHY_NAME;
+const char Nl80211AttributeWiphyName::kNameString[] = "NL80211_ATTR_WIPHY_NAME";
+
Nl80211AttributeGeneric::Nl80211AttributeGeneric(nl80211_attrs name)
: Nl80211RawAttribute(name, "unused-string") {
StringAppendF(&name_string_, "<UNKNOWN ATTRIBUTE %d>", name);
diff --git a/nl80211_attribute.h b/nl80211_attribute.h
index d5916ab..89079b3 100644
--- a/nl80211_attribute.h
+++ b/nl80211_attribute.h
@@ -120,8 +120,7 @@
const char *type_string_;
};
-// Type-specific sub-classes. These provide their own type-specific data get
-// and set functions.
+// U8.
class Nl80211U8Attribute : public Nl80211Attribute {
public:
@@ -138,6 +137,22 @@
uint8_t value_;
};
+class Nl80211AttributeKeyIdx : public Nl80211U8Attribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeKeyIdx() : Nl80211U8Attribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeRegType : public Nl80211U8Attribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeRegType() : Nl80211U8Attribute(kName, kNameString) {}
+};
+
+// U16.
+
class Nl80211U16Attribute : public Nl80211Attribute {
public:
static const char kMyTypeString[];
@@ -153,6 +168,22 @@
uint16_t value_;
};
+class Nl80211AttributeReasonCode : public Nl80211U16Attribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeReasonCode() : Nl80211U16Attribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeStatusCode : public Nl80211U16Attribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeStatusCode() : Nl80211U16Attribute(kName, kNameString) {}
+};
+
+// U32.
+
class Nl80211U32Attribute : public Nl80211Attribute {
public:
static const char kMyTypeString[];
@@ -168,6 +199,57 @@
uint32_t value_;
};
+class Nl80211AttributeDuration : public Nl80211U32Attribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeDuration() : Nl80211U32Attribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeGeneration : public Nl80211U32Attribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeGeneration() : Nl80211U32Attribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeIfindex : public Nl80211U32Attribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeIfindex() : Nl80211U32Attribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeKeyType : public Nl80211U32Attribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeKeyType() : Nl80211U32Attribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeRegInitiator : public Nl80211U32Attribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeRegInitiator() : Nl80211U32Attribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeWiphy : public Nl80211U32Attribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeWiphy() : Nl80211U32Attribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeWiphyFreq : public Nl80211U32Attribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeWiphyFreq() : Nl80211U32Attribute(kName, kNameString) {}
+};
+
+// U64.
+
class Nl80211U64Attribute : public Nl80211Attribute {
public:
static const char kMyTypeString[];
@@ -183,6 +265,15 @@
uint64_t value_;
};
+class Nl80211AttributeCookie : public Nl80211U64Attribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeCookie() : Nl80211U64Attribute(kName, kNameString) {}
+};
+
+// Flag.
+
class Nl80211FlagAttribute : public Nl80211Attribute {
public:
static const char kMyTypeString[];
@@ -198,6 +289,31 @@
bool value_;
};
+class Nl80211AttributeDisconnectedByAp : public Nl80211FlagAttribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeDisconnectedByAp() :
+ Nl80211FlagAttribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeSupportMeshAuth : public Nl80211FlagAttribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeSupportMeshAuth() :
+ Nl80211FlagAttribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeTimedOut : public Nl80211FlagAttribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeTimedOut() : Nl80211FlagAttribute(kName, kNameString) {}
+};
+
+// String.
+
class Nl80211StringAttribute : public Nl80211Attribute {
public:
static const char kMyTypeString[];
@@ -213,6 +329,22 @@
std::string value_;
};
+class Nl80211AttributeRegAlpha2 : public Nl80211StringAttribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeRegAlpha2() : Nl80211StringAttribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeWiphyName : public Nl80211StringAttribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeWiphyName() : Nl80211StringAttribute(kName, kNameString) {}
+};
+
+// Raw.
+
class Nl80211RawAttribute : public Nl80211Attribute {
public:
static const char kMyTypeString[];
@@ -220,7 +352,7 @@
Nl80211RawAttribute(nl80211_attrs name, const char *name_string)
: Nl80211Attribute(name, name_string, kType, kMyTypeString) {}
bool InitFromNlAttr(const nlattr *data);
- bool GetRawValue(const ByteString **value) const;
+ bool GetRawValue(ByteString *value) const;
// Not supporting 'set' for raw data. This type is a "don't know" type to
// be used for user-bound massages (via InitFromNlAttr). The 'set' method
// is intended for building kernel-bound messages and shouldn't be used with
@@ -228,14 +360,20 @@
bool AsString(std::string *value) const;
};
-// Attribute-specific sub-classes.
-
-class Nl80211AttributeDuration : public Nl80211U32Attribute {
+// TODO(wdg): This should inherit from Nl80211NestedAttribute when that class
+// exists.
+class Nl80211AttributeCqm : public Nl80211RawAttribute {
public:
static const nl80211_attrs kName;
static const char kNameString[];
- explicit Nl80211AttributeDuration()
- : Nl80211U32Attribute(kName, kNameString) {}
+ Nl80211AttributeCqm() : Nl80211RawAttribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeFrame : public Nl80211RawAttribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeFrame() : Nl80211RawAttribute(kName, kNameString) {}
};
class Nl80211AttributeGeneric : public Nl80211RawAttribute {
@@ -247,6 +385,48 @@
std::string name_string_;
};
+class Nl80211AttributeKeySeq : public Nl80211RawAttribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeKeySeq() : Nl80211RawAttribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeMac : public Nl80211RawAttribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeMac() : Nl80211RawAttribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeRespIe : public Nl80211RawAttribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeRespIe() : Nl80211RawAttribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeScanFrequencies : public Nl80211RawAttribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeScanFrequencies() : Nl80211RawAttribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeScanSsids : public Nl80211RawAttribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeScanSsids() : Nl80211RawAttribute(kName, kNameString) {}
+};
+
+class Nl80211AttributeStaInfo : public Nl80211RawAttribute {
+ public:
+ static const nl80211_attrs kName;
+ static const char kNameString[];
+ Nl80211AttributeStaInfo() : Nl80211RawAttribute(kName, kNameString) {}
+};
+
} // namespace shill
#endif // SHILL_NLATTRIBUTE_H_
diff --git a/user_bound_nlmessage.cc b/user_bound_nlmessage.cc
index e822316..e91507d 100644
--- a/user_bound_nlmessage.cc
+++ b/user_bound_nlmessage.cc
@@ -27,7 +27,6 @@
#include <ctype.h>
#include <endian.h>
#include <errno.h>
-
#include <linux/nl80211.h>
#include <net/if.h>
#include <netinet/in.h>