shill: Set interface MAC address for RTNL handler

This is equivalent to ip link dev $INTERFACE address $MAC_ADDRESS

BUG=b:112327498
TEST=tested on biggie and gale.
Create a station interface, set MAC address and observe by ifconfig and
iw dev output.

Change-Id: I7cd83814a5d721cb71c4030a4a6669a046d3d958
Reviewed-on: https://chromium-review.googlesource.com/1166222
Commit-Ready: Julan Hsu <julanhsu@google.com>
Tested-by: Julan Hsu <julanhsu@google.com>
Tested-by: Julan Hsu <julanhsu@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
diff --git a/net/rtnl_handler.cc b/net/rtnl_handler.cc
index 94ea471..a9a4288 100644
--- a/net/rtnl_handler.cc
+++ b/net/rtnl_handler.cc
@@ -180,6 +180,21 @@
   CHECK(SendMessage(&msg));
 }
 
+void RTNLHandler::SetInterfaceMac(int interface_index,
+                                  const ByteString& mac_address) {
+  RTNLMessage msg(RTNLMessage::kTypeLink,
+                  RTNLMessage::kModeAdd,
+                  NLM_F_REQUEST,
+                  0,  // sequence to be filled in by RTNLHandler::SendMessage().
+                  0,  // pid.
+                  interface_index,
+                  IPAddress::kFamilyUnknown);
+
+  msg.SetAttribute(IFLA_ADDRESS, mac_address);
+
+  CHECK(SendMessage(&msg));
+}
+
 void RTNLHandler::RequestDump(int request_flags) {
   if (rtnl_socket_ == Sockets::kInvalidFileDescriptor) {
     LOG(ERROR) << __func__ << " called while not started.  "
diff --git a/net/rtnl_handler.h b/net/rtnl_handler.h
index 233fb52..f0429e1 100644
--- a/net/rtnl_handler.h
+++ b/net/rtnl_handler.h
@@ -86,6 +86,11 @@
   // has a kernel index of |interface_index|.
   virtual void SetInterfaceMTU(int interface_index, unsigned int mtu);
 
+  // Set the MAC address for the network interface that has a kernel index of
+  // |interface_index|.
+  virtual void SetInterfaceMac(int interface_index,
+                               const ByteString& mac_address);
+
   // Set address of a network interface that has a kernel index of
   // 'interface_index'.
   virtual bool AddInterfaceAddress(int interface_index,