Implement encodeBinaryXMLInterest.
diff --git a/ndn-cpp/c/encoding/BinaryXMLInterest.c b/ndn-cpp/c/encoding/BinaryXMLInterest.c
index 1131428..7939556 100644
--- a/ndn-cpp/c/encoding/BinaryXMLInterest.c
+++ b/ndn-cpp/c/encoding/BinaryXMLInterest.c
@@ -1,5 +1,6 @@
 /**
  * @author: Jeff Thompson
+ * Derived from Interest.js by Meki Cheraoui.
  * See COPYING for copyright and distribution information.
  */
 
@@ -8,6 +9,74 @@
 #include "BinaryXMLName.h"
 #include "BinaryXMLInterest.h"
 
+ndn_Error ndn_encodeBinaryXMLInterest(struct ndn_Interest *interest, struct ndn_BinaryXMLEncoder *encoder)
+{
+  ndn_Error error;
+  if (error = ndn_BinaryXMLEncoder_writeElementStartDTag(encoder, ndn_BinaryXML_DTag_Interest))
+    return error;
+    
+  if (error = ndn_encodeBinaryXMLName(&interest->name, encoder))
+    return error;
+  
+  if (interest->minSuffixComponents >= 0) {
+    if (error = ndn_BinaryXMLEncoder_writeUnsignedDecimalIntDTagElement
+        (encoder, ndn_BinaryXML_DTag_MinSuffixComponents, (unsigned int)interest->minSuffixComponents))
+      return error;
+  }
+  if (interest->maxSuffixComponents >= 0) {
+    if (error = ndn_BinaryXMLEncoder_writeUnsignedDecimalIntDTagElement
+        (encoder, ndn_BinaryXML_DTag_MaxSuffixComponents, (unsigned int)interest->maxSuffixComponents))
+      return error;
+  }
+    
+  if (interest->publisherPublicKeyDigest && interest->publisherPublicKeyDigestLength > 0) {
+    if (error = ndn_BinaryXMLEncoder_writeBlobDTagElement
+        (encoder, ndn_BinaryXML_DTag_PublisherPublicKeyDigest, interest->publisherPublicKeyDigest, interest->publisherPublicKeyDigestLength))
+      return error;
+  }
+  
+  // TODO: Implement exclude
+
+  if (interest->childSelector >= 0) {
+    if (error = ndn_BinaryXMLEncoder_writeUnsignedDecimalIntDTagElement
+        (encoder, ndn_BinaryXML_DTag_ChildSelector, (unsigned int)interest->childSelector))
+      return error;
+  }
+  if (interest->answerOriginKind >= 0 && interest->answerOriginKind != ndn_Interest_DEFAULT_ANSWER_ORIGIN_KIND) {
+    if (error = ndn_BinaryXMLEncoder_writeUnsignedDecimalIntDTagElement
+        (encoder, ndn_BinaryXML_DTag_AnswerOriginKind, (unsigned int)interest->answerOriginKind))
+      return error;
+  }
+  if (interest->scope >= 0) {
+    if (error = ndn_BinaryXMLEncoder_writeUnsignedDecimalIntDTagElement
+        (encoder, ndn_BinaryXML_DTag_Scope, (unsigned int)interest->scope))
+      return error;
+  }
+  
+  if (interest->interestLifetime >= 0) {
+    if (error = ndn_BinaryXMLEncoder_writeElementStartDTag(encoder, ndn_BinaryXML_DTag_InterestLifetime))
+      return error;
+   
+    unsigned int ticks = (unsigned int)(((double)interest->interestLifetime / 1000.0) * 4096.0);
+    if (error = ndn_BinaryXMLEncoder_writeUnsignedIntBigEndianBlob(encoder, ticks))
+      return error;
+    
+    if (error = ndn_BinaryXMLEncoder_writeElementClose(encoder))
+      return error;
+  }
+  
+  if (interest->nonce && interest->nonceLength > 0) {
+    if (error = ndn_BinaryXMLEncoder_writeBlobDTagElement
+        (encoder, ndn_BinaryXML_DTag_Nonce, interest->nonce, interest->nonceLength))
+      return error;
+  }
+  
+	if (error = ndn_BinaryXMLEncoder_writeElementClose(encoder))
+    return error;
+  
+  return 0;  
+}
+
 ndn_Error ndn_decodeBinaryXMLInterest(struct ndn_Interest *interest, struct ndn_BinaryXMLDecoder *decoder)
 {
   ndn_Error error;
@@ -59,8 +128,8 @@
         (decoder, ndn_BinaryXML_DTag_InterestLifetime, 0, &interestLifetime, &interestLifetimeLength))
       return error;
     
-    interest->interestLifetime = 1000 * 
-      ndn_BinaryXMLDecoder_bigEndianToUnsignedInt(interestLifetime, interestLifetimeLength) / 4096;
+    interest->interestLifetime = (int)(1000.0 * 
+      (double)ndn_BinaryXMLDecoder_bigEndianToUnsignedInt(interestLifetime, interestLifetimeLength) / 4096.0);
   }
   else
     interest->interestLifetime = -1;
@@ -81,4 +150,4 @@
     return error;
   
   return 0;
-}
\ No newline at end of file
+}
diff --git a/test/test-encode-decode-interest.cpp b/test/test-encode-decode-interest.cpp
index ead57cc..e8c82c5 100644
--- a/test/test-encode-decode-interest.cpp
+++ b/test/test-encode-decode-interest.cpp
@@ -14,7 +14,7 @@
 unsigned char Interest1[] = {
 0x01, 0xd2,
   0xf2, 0xfa, 0x9d, 0x6e, 0x64, 0x6e, 0x00, 0xfa, 0x9d, 0x61, 0x62, 0x63, 0x00, 0x00, 
-  0x05, 0x9a, 0x8e, 0x32, 0x00, 
+  0x05, 0x9a, 0x9e, 0x31, 0x32, 0x33, 0x00, 
   0x05, 0xa2, 0x8e, 0x34, 0x00,
   0x03, 0xe2, 
     0x02, 0x85, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 
@@ -41,15 +41,18 @@
     Interest interest;
     interest.decode(Interest1, sizeof(Interest1));
     cout << "Interest name " << interest.getName().to_uri() << endl;
+    cout << "Interest minSuffixComponents " << interest.getMinSuffixComponents() << endl;
     cout << "InterestLifetime " << interest.getInterestLifetime() << endl;
     
-#if 0
     vector<unsigned char> encoding;
     interest.encode(encoding);
-    unsigned char *encodingBuffer = &encoding[0];
-    unsigned int encodingLength = encoding.size();
-    cout << "Interest encoding length " << encodingLength << " vs. sizeof(Interest1) " << sizeof(Interest1) << endl;
-#endif
+    cout << "Interest encoding length " << encoding.size() << " vs. sizeof(Interest1) " << sizeof(Interest1) << endl;
+    
+    Interest reDecodedInterest;
+    reDecodedInterest.decode(encoding);
+    cout << "Re-decoded Interest name " << reDecodedInterest.getName().to_uri() << endl;
+    cout << "Re-decoded Interest minSuffixComponents " << reDecodedInterest.getMinSuffixComponents() << endl;
+    cout << "Re-decoded InterestLifetime " << reDecodedInterest.getInterestLifetime() << endl;
   } catch (exception &e) {
     cout << "exception: " << e.what() << endl;
   }