shill: Random cleanup.
For this checkin, I've done a number of small things. I've:
o Moved the parsing of incoming message attributes inside
Nl80211Message::InitFromNlmsg (because it should be there).
o Added Ack, Noop, and Error messages (along with their handling).
This will improve message handling once I further abandon libnl.
o Added NL80211_CMD_GET_REG message and handling. There are several
messages that aren't currently handled and I'm adding them as they
become necessary. This is one of those.
o Removed the copy of the message that Nl80211Message was storing --
it's no longer needed.
BUG=None.
TEST=unittests.
Change-Id: Ibf79e6a0ac32ed03cd37c81c68555801b9ab5d16
Reviewed-on: https://gerrit.chromium.org/gerrit/40278
Commit-Queue: Wade Guthrie <wdg@chromium.org>
Reviewed-by: Wade Guthrie <wdg@chromium.org>
Tested-by: Wade Guthrie <wdg@chromium.org>
diff --git a/nl80211_message.h b/nl80211_message.h
index 32d51ea..70916cb 100644
--- a/nl80211_message.h
+++ b/nl80211_message.h
@@ -32,15 +32,13 @@
static const char kBogusMacAddress[];
Nl80211Message(uint8 message_type, const char *message_type_string)
- : message_(NULL),
- message_type_(message_type),
+ : message_type_(message_type),
message_type_string_(message_type_string),
sequence_number_(kIllegalMessage) {}
virtual ~Nl80211Message() {}
- // TODO(wdg): Change to |InitFromNlmsg|.
// Initializes the message with bytes from the kernel.
- virtual bool Init(nlattr *tb[NL80211_ATTR_MAX + 1], nlmsghdr *msg);
+ virtual bool InitFromNlmsg(const nlmsghdr *msg);
uint32_t sequence_number() const { return sequence_number_; }
@@ -123,7 +121,6 @@
static const uint32_t kIllegalMessage;
- nlmsghdr *message_;
const uint8 message_type_;
const char *message_type_string_;
static std::map<uint16_t, std::string> *reason_code_string_;
@@ -172,6 +169,19 @@
// Specific Nl80211Message types.
//
+class AckMessage : public Nl80211Message {
+ public:
+ static const uint8_t kCommand;
+ static const char kCommandString[];
+
+ AckMessage() : Nl80211Message(kCommand, kCommandString) {}
+
+ virtual std::string ToString() const;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AckMessage);
+};
+
class AssociateMessage : public Nl80211Message {
public:
static const uint8_t kCommand;
@@ -285,6 +295,22 @@
};
+class ErrorMessage : public Nl80211Message {
+ public:
+ static const uint8_t kCommand;
+ static const char kCommandString[];
+
+ ErrorMessage(uint32_t error);
+
+ virtual std::string ToString() const;
+
+ private:
+ uint32_t error_;
+
+ DISALLOW_COPY_AND_ASSIGN(ErrorMessage);
+};
+
+
class FrameTxStatusMessage : public Nl80211Message {
public:
static const uint8_t kCommand;
@@ -298,6 +324,17 @@
DISALLOW_COPY_AND_ASSIGN(FrameTxStatusMessage);
};
+class GetRegMessage : public Nl80211Message {
+ public:
+ static const uint8_t kCommand;
+ static const char kCommandString[];
+
+ GetRegMessage() : Nl80211Message(kCommand, kCommandString) {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(GetRegMessage);
+};
+
class JoinIbssMessage : public Nl80211Message {
public:
@@ -369,6 +406,20 @@
};
+class NoopMessage : public Nl80211Message {
+ public:
+ static const uint8_t kCommand;
+ static const char kCommandString[];
+
+ NoopMessage() : Nl80211Message(kCommand, kCommandString) {}
+
+ virtual std::string ToString() const;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NoopMessage);
+};
+
+
class NotifyCqmMessage : public Nl80211Message {
public:
static const uint8_t kCommand;