interest/tlv: Do not encode InterestLifetime if it has default value (4sec)

Change-Id: I33dc7b7512e406655fe18c5e570bc69ad8d93298
diff --git a/src/interest.cpp b/src/interest.cpp
index c9be23d..c4046a4 100644
--- a/src/interest.cpp
+++ b/src/interest.cpp
@@ -27,6 +27,8 @@
 
 namespace ndn {
 
+const Milliseconds DEFAULT_INTEREST_LIFETIME = 4000;
+
 const uint32_t&
 Interest::getNonce() const
 {
@@ -89,7 +91,7 @@
     os << delim << "ndn.Scope=" << interest.getScope();
     delim = '&';
   }
-  if (interest.getInterestLifetime() >= 0) {
+  if (interest.getInterestLifetime() >= 0 && interest.getInterestLifetime() != DEFAULT_INTEREST_LIFETIME) {
     os << delim << "ndn.InterestLifetime=" << interest.getInterestLifetime();
     delim = '&';
   }
@@ -159,12 +161,15 @@
     wire_.push_back
       (nonNegativeIntegerBlock(Tlv::Nonce, getNonce()));
   }
-  
+
+  // Scope
   if (getScope() >= 0) {
     wire_.push_back
       (nonNegativeIntegerBlock(Tlv::Scope, getScope()));
   }
-  if (getInterestLifetime() >= 0) {
+
+  // InterestLifetime
+  if (getInterestLifetime() >= 0 && getInterestLifetime() != DEFAULT_INTEREST_LIFETIME) {
     wire_.push_back
       (nonNegativeIntegerBlock(Tlv::InterestLifetime, getInterestLifetime()));
   }
@@ -250,7 +255,11 @@
   if (val != wire_.getAll().end())
     {
       interestLifetime_ = readNonNegativeInteger(*val);
-    } 
+    }
+  else
+    {
+      interestLifetime_ = DEFAULT_INTEREST_LIFETIME;
+    }
 }