shill: Add type-specific children of Nl80211Attribute type.
This checkin adds all the type-specific children of the Nl80211Attribute
type without actually changing any of the code that's called (that's
planned for a later checkin).
The next checkin includes all the attributes necessary to use
Nl80211Attribute. After that, we'll go for the functionality changes
(which, BTW, passes unittests).
BUG=chromium-os:36637
TEST=unittests.
Change-Id: Ib3944e3b18faeec322ea93cd989daa9bbeb0c0c7
Reviewed-on: https://gerrit.chromium.org/gerrit/39319
Commit-Ready: Wade Guthrie <wdg@chromium.org>
Reviewed-by: Wade Guthrie <wdg@chromium.org>
Tested-by: Wade Guthrie <wdg@chromium.org>
diff --git a/config80211_unittest.cc b/config80211_unittest.cc
index d6faf00..d9e93c8 100644
--- a/config80211_unittest.cc
+++ b/config80211_unittest.cc
@@ -11,6 +11,12 @@
#include "shill/config80211.h"
+#include <net/if.h>
+#include <netlink/attr.h>
+#include <netlink/genl/genl.h>
+#include <netlink/msg.h>
+#include <netlink/netlink.h>
+
#include <list>
#include <string>
#include <vector>
@@ -18,15 +24,11 @@
#include <base/bind.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
-#include <net/if.h>
-#include <netlink/attr.h>
-#include <netlink/genl/genl.h>
-#include <netlink/msg.h>
-#include <netlink/netlink.h>
#include "shill/kernel_bound_nlmessage.h"
#include "shill/mock_callback80211_object.h"
#include "shill/mock_nl80211_socket.h"
+#include "shill/nl80211_attribute.h"
#include "shill/nl80211_socket.h"
#include "shill/user_bound_nlmessage.h"
@@ -706,16 +708,12 @@
}
{
- void *rawdata = NULL;
- int frame_byte_count = 0;
- EXPECT_TRUE(message->GetRawAttributeData(NL80211_ATTR_FRAME, &rawdata,
- &frame_byte_count));
- EXPECT_NE(rawdata, reinterpret_cast<void *>(NULL));
- const uint8_t *frame_data = reinterpret_cast<const uint8_t *>(rawdata);
-
- Nl80211Frame frame(frame_data, frame_byte_count);
- Nl80211Frame expected_frame(kAuthenticateFrame, sizeof(kAuthenticateFrame));
-
+ ByteString rawdata;
+ EXPECT_TRUE(message->GetRawAttributeData(NL80211_ATTR_FRAME, &rawdata));
+ EXPECT_FALSE(rawdata.IsEmpty());
+ Nl80211Frame frame(rawdata);
+ Nl80211Frame expected_frame(ByteString(kAuthenticateFrame,
+ sizeof(kAuthenticateFrame)));
EXPECT_TRUE(frame.IsEqual(expected_frame));
}
}
@@ -741,16 +739,12 @@
}
{
- void *rawdata = NULL;
- int frame_byte_count = 0;
- EXPECT_TRUE(message->GetRawAttributeData(NL80211_ATTR_FRAME, &rawdata,
- &frame_byte_count));
- EXPECT_NE(rawdata, reinterpret_cast<void *>(NULL));
- const uint8_t *frame_data = reinterpret_cast<const uint8_t *>(rawdata);
-
- Nl80211Frame frame(frame_data, frame_byte_count);
- Nl80211Frame expected_frame(kAssociateFrame, sizeof(kAssociateFrame));
-
+ ByteString rawdata;
+ EXPECT_TRUE(message->GetRawAttributeData(NL80211_ATTR_FRAME, &rawdata));
+ EXPECT_FALSE(rawdata.IsEmpty());
+ Nl80211Frame frame(rawdata);
+ Nl80211Frame expected_frame(ByteString(kAssociateFrame,
+ sizeof(kAssociateFrame)));
EXPECT_TRUE(frame.IsEqual(expected_frame));
}
}
@@ -812,17 +806,12 @@
}
{
- void *rawdata = NULL;
- int frame_byte_count = 0;
- EXPECT_TRUE(message->GetRawAttributeData(NL80211_ATTR_FRAME, &rawdata,
- &frame_byte_count));
- EXPECT_NE(rawdata, reinterpret_cast<void *>(NULL));
- const uint8_t *frame_data = reinterpret_cast<const uint8_t *>(rawdata);
-
- Nl80211Frame frame(frame_data, frame_byte_count);
- Nl80211Frame expected_frame(kDeauthenticateFrame,
- sizeof(kDeauthenticateFrame));
-
+ ByteString rawdata;
+ EXPECT_TRUE(message->GetRawAttributeData(NL80211_ATTR_FRAME, &rawdata));
+ EXPECT_FALSE(rawdata.IsEmpty());
+ Nl80211Frame frame(rawdata);
+ Nl80211Frame expected_frame(ByteString(kDeauthenticateFrame,
+ sizeof(kDeauthenticateFrame)));
EXPECT_TRUE(frame.IsEqual(expected_frame));
}
}
@@ -905,7 +894,7 @@
EXPECT_FALSE(cqm[NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT]);
EXPECT_TRUE(cqm[NL80211_ATTR_CQM_PKT_LOSS_EVENT]);
- EXPECT_EQ(nla_get_u32(cqm[NL80211_ATTR_CQM_PKT_LOSS_EVENT]),
+ EXPECT_EQ(Nl80211Attribute::NlaGetU32(cqm[NL80211_ATTR_CQM_PKT_LOSS_EVENT]),
kExpectedCqmNotAcked);
}
}
@@ -932,16 +921,12 @@
}
{
- void *rawdata = NULL;
- int frame_byte_count = 0;
- EXPECT_TRUE(message->GetRawAttributeData(NL80211_ATTR_FRAME, &rawdata,
- &frame_byte_count));
- EXPECT_NE(rawdata, reinterpret_cast<void *>(NULL));
- const uint8_t *frame_data = reinterpret_cast<const uint8_t *>(rawdata);
-
- Nl80211Frame frame(frame_data, frame_byte_count);
- Nl80211Frame expected_frame(kDisassociateFrame, sizeof(kDisassociateFrame));
-
+ ByteString rawdata;
+ EXPECT_TRUE(message->GetRawAttributeData(NL80211_ATTR_FRAME, &rawdata));
+ EXPECT_FALSE(rawdata.IsEmpty());
+ Nl80211Frame frame(rawdata);
+ Nl80211Frame expected_frame(ByteString(kDisassociateFrame,
+ sizeof(kDisassociateFrame)));
EXPECT_TRUE(frame.IsEqual(expected_frame));
}
}