Pass more information to the attribute parsing functions.

Change-Id: I790dc54dd3de8a84758789d58f2ee17f175a6582
diff --git a/net/test/iproute.py b/net/test/iproute.py
index fa8025f..fef4b5c 100644
--- a/net/test/iproute.py
+++ b/net/test/iproute.py
@@ -222,7 +222,7 @@
   def _GetConstantName(self, value, prefix):
     return super(IPRoute, self)._GetConstantName(__name__, value, prefix)
 
-  def _Decode(self, command, family, nla_type, nla_data):
+  def _Decode(self, command, msg, nla_type, nla_data):
     """Decodes netlink attributes to Python types.
 
     Values for which the code knows the type (e.g., the fwmark ID in a
@@ -271,6 +271,8 @@
       # Don't know what this is. Leave it as an integer.
       name = nla_type
 
+    family = msg.family
+
     if name in ["FRA_PRIORITY", "FRA_FWMARK", "FRA_TABLE", "FRA_FWMASK",
                 "FRA_UID_START", "FRA_UID_END",
                 "RTA_OIF", "RTA_PRIORITY", "RTA_TABLE", "RTA_MARK",
@@ -289,7 +291,7 @@
     elif name in ["FRA_IIFNAME", "FRA_OIFNAME", "IFLA_IFNAME", "IFLA_QDISC"]:
       data = nla_data.strip("\x00")
     elif name == "RTA_METRICS":
-      data = self._ParseAttributes(-RTA_METRICS, family, nla_data)
+      data = self._ParseAttributes(-RTA_METRICS, family, RTMsg, nla_data)
     elif name == "RTA_CACHEINFO":
       data = RTACacheinfo(nla_data)
     elif name == "IFA_CACHEINFO":
diff --git a/net/test/netlink.py b/net/test/netlink.py
index a338f13..65dc4b6 100644
--- a/net/test/netlink.py
+++ b/net/test/netlink.py
@@ -86,11 +86,11 @@
         return name
     return value
 
-  def _Decode(self, command, family, nla_type, nla_data):
+  def _Decode(self, command, msg, nla_type, nla_data):
     """No-op, nonspecific version of decode."""
     return nla_type, nla_data
 
-  def _ParseAttributes(self, command, family, data):
+  def _ParseAttributes(self, command, family, msg, data):
     """Parses and decodes netlink attributes.
 
     Takes a block of NLAttr data structures, decodes them using Decode, and
@@ -99,6 +99,7 @@
     Args:
       command: An integer, the rtnetlink command being carried out.
       family: The address family.
+      msg: A Struct, the type of the data after the netlink header.
       data: A byte string containing a sequence of NLAttr data structures.
 
     Returns:
@@ -118,7 +119,7 @@
       nla_data, data = data[:datalen], data[padded_len:]
 
       # If it's an attribute we know about, try to decode it.
-      nla_name, nla_data = self._Decode(command, family, nla.nla_type, nla_data)
+      nla_name, nla_data = self._Decode(command, msg, nla.nla_type, nla_data)
 
       # We only support unique attributes for now.
       if nla_name in attributes:
@@ -194,7 +195,7 @@
     # Parse the attributes in the nlmsg.
     attrlen = nlmsghdr.length - len(nlmsghdr) - len(nlmsg)
     attributes = self._ParseAttributes(nlmsghdr.type, nlmsg.family,
-                                       data[:attrlen])
+                                       nlmsg, data[:attrlen])
     data = data[attrlen:]
     return (nlmsg, attributes), data