model: Adding ability to select desired default wire format

ndnSIM will accept and process (if no modifications required) packets in
any supported wire format (right now it is only ndnSIM and ccnb).
Wire format for creating of new packets can be selected (per-face)
thorough ns3::ndn::Face::WireFormat variable.

Refs #1008 (http://redmine.named-data.net/)
diff --git a/model/ndn-face.cc b/model/ndn-face.cc
index 3681ffb..9434ed8 100644
--- a/model/ndn-face.cc
+++ b/model/ndn-face.cc
@@ -35,6 +35,7 @@
 #include "ns3/ndn-header-helper.h"
 #include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.h"
 #include "ns3/ndnSIM/model/wire/ndnsim.h"
+#include "ns3/ndnSIM/model/wire/ccnb.h"
 
 #include <boost/ref.hpp>
 
@@ -56,6 +57,14 @@
                    UintegerValue (0),
                    MakeUintegerAccessor (&Face::m_id),
                    MakeUintegerChecker<uint32_t> ())
+
+    .AddAttribute ("WireFormat",
+                   "Default wire format for the face.  The face will be accepting packets "
+                   "in any supported packet formats, but if encoding requested, it will "
+                   "use default wire format to encode (0 for ndnSIM (default), 1 for CCNb)",
+                   UintegerValue (WIRE_FORMAT_NDNSIM),
+                   MakeUintegerAccessor (&Face::m_wireFormat),
+                   MakeUintegerChecker<uint32_t> ())
     ;
   return tid;
 }
@@ -128,7 +137,15 @@
       return false;
     }
 
-  Ptr<Packet> packet = wire::ndnSIM::Interest::ToWire (interest);
+  Ptr<Packet> packet;
+  if (m_wireFormat == WIRE_FORMAT_NDNSIM)
+    packet = wire::ndnSIM::Interest::ToWire (interest);
+  else if (m_wireFormat == WIRE_FORMAT_CCNB)
+    packet = wire::ccnb::Interest::ToWire (interest);
+  else
+    {
+      NS_FATAL_ERROR ("Unsupported format requested");
+    }
   return Send (packet);
 }
 
@@ -142,7 +159,15 @@
       return false;
     }
 
-  Ptr<Packet> packet = wire::ndnSIM::Data::ToWire (data);
+  Ptr<Packet> packet;
+  if (m_wireFormat == WIRE_FORMAT_NDNSIM)
+    packet = wire::ndnSIM::Data::ToWire (data);
+  else if (m_wireFormat == WIRE_FORMAT_CCNB)
+    packet = wire::ccnb::Data::ToWire (data);
+  else
+    {
+      NS_FATAL_ERROR ("Unsupported format requested");
+    }
   return Send (packet);
 }
 
@@ -188,9 +213,15 @@
             return ReceiveData (data);
           }
         case HeaderHelper::INTEREST_CCNB:
+          {
+            Ptr<Interest> interest = wire::ccnb::Interest::FromWire (packet);
+            return ReceiveInterest (interest);
+          }
         case HeaderHelper::CONTENT_OBJECT_CCNB:
-          NS_FATAL_ERROR ("ccnb support is broken in this implementation");
-          return false;
+          {
+            Ptr<ContentObject> data = wire::ccnb::Data::FromWire (packet);
+            return ReceiveData (data);
+          }
         }
 
       // exception will be thrown if packet is not recognized
@@ -242,19 +273,12 @@
   return m_metric;
 }
 
-/**
- * These are face states and may be distinct from
- * NetDevice states, such as found in real implementations
- * (where the device may be down but face state is still up).
- */
-
 void
 Face::SetFlags (uint32_t flags)
 {
   m_flags = flags;
 }
 
-
 bool
 Face::operator== (const Face &face) const
 {
diff --git a/model/ndn-face.h b/model/ndn-face.h
index 5f6c884..1fba08f 100644
--- a/model/ndn-face.h
+++ b/model/ndn-face.h
@@ -59,6 +59,12 @@
     public Object
 {
 public:
+  enum
+    {
+      WIRE_FORMAT_NDNSIM = 0,
+      WIRE_FORMAT_CCNB = 1
+    };
+
   static TypeId
   GetTypeId ();
 
@@ -190,7 +196,7 @@
     {
       APPLICATION = 1 ///< @brief An application face
     };
-  
+
   /**
    * @brief Print information about the face into the stream
    * @param os stream to write information to
@@ -248,7 +254,7 @@
    */
   virtual bool
   Send (Ptr<Packet> packet);
-  
+
   /**
    * @brief Send packet up to the stack (towards forwarding strategy)
    */
@@ -269,6 +275,8 @@
   Ptr<Node> m_node; ///< \brief Smart pointer to Node
 
 private:
+  uint32_t m_wireFormat;
+
   InterestHandler m_upstreamInterestHandler;
   DataHandler m_upstreamDataHandler;
   bool m_ifup;