apmanager: add support for HT capability

Parse wiphy's HT capability and add it to the AP service's configuration
file to correctly support AP in 80211n mode.

BUG=chromium:431763
TEST=unittests and manual test by using python to invoke dbus calls
     to start AP service in 802.11n mode.

Change-Id: I6c902136832eea6b38b806f733231d6cbe14e3f6
Reviewed-on: https://chromium-review.googlesource.com/231681
Reviewed-by: Peter Qiu <zqiu@chromium.org>
Commit-Queue: Peter Qiu <zqiu@chromium.org>
Tested-by: Peter Qiu <zqiu@chromium.org>
diff --git a/device.h b/device.h
index 7e51dae..dadf8b1 100644
--- a/device.h
+++ b/device.h
@@ -45,6 +45,12 @@
     }
   };
 
+  struct BandCapability {
+    std::vector<uint32_t> frequencies;
+    uint16_t ht_capability_mask;
+    uint16_t vht_capability_mask;
+  };
+
   explicit Device(const std::string& device_name);
   virtual ~Device();
 
@@ -71,19 +77,38 @@
   // false otherwise.
   virtual bool InterfaceExists(const std::string& interface_name);
 
+  // Get HT and VHT capability string based on the operating channel.
+  // Return true and set the output capability string if such capability
+  // exist for the band the given |channel| is in, false otherwise.
+  virtual bool GetHTCapability(uint16_t channel, std::string* ht_cap);
+  virtual bool GetVHTCapability(uint16_t channel, std::string* vht_cap);
+
  private:
   friend class DeviceTest;
 
+  // Get the HT secondary channel location base on the primary channel.
+  // Return true and set the output |above| flag if channel is valid,
+  // otherwise return false.
+  static bool GetHTSecondaryChannelLocation(uint16_t channel, bool* above);
+
   // Determine preferred interface to used for AP operation based on the list
   // of interfaces reside on this device
   void UpdatePreferredAPInterface();
 
+  // Get the capability for the band the given |channel| is in. Return true
+  // and set the output |capability| pointer if such capability exist for the
+  // band the given |channel| is in, false otherwise.
+  bool GetBandCapability(uint16_t channel, BandCapability* capability);
+
   // List of WiFi interfaces live on this device (PHY).
   std::vector<WiFiInterface> interface_list_;
 
   dbus::ObjectPath dbus_path_;
   std::unique_ptr<chromeos::dbus_utils::DBusObject> dbus_object_;
 
+  // Wiphy band capabilities.
+  std::vector<BandCapability> band_capability_;
+
   DISALLOW_COPY_AND_ASSIGN(Device);
 };