merge
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Fri, 23 Sep 2011 11:34:43 +0100
changeset 7557 00d2a1ff85b2
parent 7556 0b875c99c8b4 (current diff)
parent 7555 07cef32642a2 (diff)
child 7558 a42c512034f3
merge
--- a/src/click/model/ipv4-click-routing.cc	Fri Sep 23 11:21:00 2011 +0100
+++ b/src/click/model/ipv4-click-routing.cc	Fri Sep 23 11:34:43 2011 +0100
@@ -224,6 +224,15 @@
 }
 
 std::string
+Ipv4ClickRouting::GetIpPrefixFromInterfaceId (int ifid)
+{
+  std::stringstream addr;
+  m_ipv4->GetAddress (ifid, 0).GetMask ().Print (addr);
+
+  return addr.str ();
+}
+
+std::string
 Ipv4ClickRouting::GetMacAddressFromInterfaceId (int ifid)
 {
   std::stringstream addr;
@@ -583,6 +592,27 @@
         break;
       }
 
+    case SIMCLICK_IPPREFIX_FROM_NAME:
+      {
+        const char *ifname = va_arg (val, const char *);
+        char *buf = va_arg (val, char *);
+        int len = va_arg (val, int);
+
+        int ifid = clickInstance->GetInterfaceId (ifname);
+
+        if (ifid >= 0)
+          {
+            retval = simstrlcpy (buf, len, clickInstance->GetIpPrefixFromInterfaceId (ifid));
+          }
+        else
+          {
+            retval = -1;
+          }
+
+        NS_LOG_DEBUG (clickInstance->GetNodeName () << " SIMCLICK_IPPREFIX_FROM_NAME: " << ifname << " " << buf << " " << len);
+        break;
+      }
+
     case SIMCLICK_MACADDR_FROM_NAME:
       {
         const char *ifname = va_arg (val, const char *);
--- a/src/click/model/ipv4-click-routing.h	Fri Sep 23 11:21:00 2011 +0100
+++ b/src/click/model/ipv4-click-routing.h	Fri Sep 23 11:34:43 2011 +0100
@@ -143,6 +143,13 @@
   std::string GetIpAddressFromInterfaceId (int ifid);
 
   /**
+   * \brief Provides for SIMCLICK_IPPREFIX_FROM_NAME
+   * \param ifid The interface ID for which the IP Prefix is required
+   * \return The IP Prefix of the interface in string format
+   */
+  std::string GetIpPrefixFromInterfaceId (int ifid);
+
+  /**
    * \brief Provides for SIMCLICK_MACADDR_FROM_NAME
    * \param ifid The interface ID for which the MAC Address is required
    * \return The MAC Address of the interface in string format