Major update: refactored the API of Interest and ContentObject according to the API notes:
http://sea.remap.ucla.edu:8080/attachments/download/23/lwndn_api-notes_21020830.txt
diff --git a/js/ContentName.js b/js/ContentName.js
index 74ce00e..59a9b94 100644
--- a/js/ContentName.js
+++ b/js/ContentName.js
@@ -4,20 +4,20 @@
*/
-var ContentName = function ContentName(_Components){
+var ContentName = function ContentName(_components){
- if( typeof _Components == 'string') {
+ if( typeof _components == 'string') {
- if(LOG>3)console.log('Content Name String '+_Components);
- this.Components = ContentName.makeBlob(ContentName.createNameArray(_Components));
+ if(LOG>3)console.log('Content Name String '+_components);
+ this.Components = ContentName.makeBlob(ContentName.createNameArray(_components));
}
- else if(typeof _Components === 'object' && _Components instanceof Array ){
+ else if(typeof _components === 'object' && _components instanceof Array ){
- if(LOG>4)console.log('Content Name Array '+_Components);
- this.Components = ContentName.makeBlob(_Components);
+ if(LOG>4)console.log('Content Name Array '+_components);
+ this.Components = ContentName.makeBlob(_components);
}
- else if(_Components==null){
+ else if(_components==null){
this.Components =[];
}
else{
diff --git a/js/ContentObject.js b/js/ContentObject.js
index 0d58ba6..5ac4d28 100644
--- a/js/ContentObject.js
+++ b/js/ContentObject.js
@@ -2,33 +2,33 @@
* @author: ucla-cs
* This class represents ContentObject Objects
*/
-var ContentObject = function ContentObject(_Name,_SignedInfo,_Content,_Signature){
+var ContentObject = function ContentObject(_name,_signedInfo,_content,_signature){
- if (typeof _Name === 'string'){
- this.Name = new ContentName(_Name);
+ if (typeof _name === 'string'){
+ this.name = new ContentName(_name);
}
else{
- //TODO Check the class of _Name
- this.Name = _Name;
+ //TODO Check the class of _name
+ this.name = _name;
}
- this.SignedInfo = _SignedInfo;
- this.Content=_Content;
- this.Signature = _Signature;
+ this.SignedInfo = _signedInfo;
+ this.content=_content;
+ this.Signature = _signature;
- this.StartSIG = null;
- this.EndSIG = null;
+ this.startSIG = null;
+ this.endSIG = null;
- this.StartSignedInfo = null;
- this.EndContent = null;
+ this.startSignedInfo = null;
+ this.endContent = null;
this.rawSignatureData = null;
};
ContentObject.prototype.sign = function(){
- var n1 = this.encodeObject(this.Name);
+ var n1 = this.encodeObject(this.name);
var n2 = this.encodeObject(this.SignedInfo);
var n3 = this.encodeContent();
@@ -78,7 +78,7 @@
ContentObject.prototype.encodeContent = function encodeContent(obj){
var enc = new BinaryXMLEncoder();
- enc.writeElement(CCNProtocolDTags.Content, this.Content);
+ enc.writeElement(CCNProtocolDTags.Content, this.content);
var num = enc.getReducedOstream();
@@ -89,12 +89,12 @@
ContentObject.prototype.saveRawData = function(bytes){
- var sigBits = bytes.slice(this.StartSIG, this.EndSIG );
+ var sigBits = bytes.slice(this.startSIG, this.endSIG );
this.rawSignatureData = sigBits;
};
-ContentObject.prototype.decode = function(/*XMLDecoder*/ decoder) {
+ContentObject.prototype.from_ccnb = function(/*XMLDecoder*/ decoder) {
// TODO VALIDATE THAT ALL FIELDS EXCEPT SIGNATURE ARE PRESENT
@@ -106,14 +106,14 @@
this.Signature.decode(decoder);
}
- //this.EndSIG = decoder.offset;
+ //this.endSIG = decoder.offset;
- this.StartSIG = decoder.offset;
+ this.startSIG = decoder.offset;
- this.Name = new ContentName();
- this.Name.decode(decoder);
+ this.name = new ContentName();
+ this.name.decode(decoder);
- //this.StartSignedInfo = decoder.offset;
+ //this.startSignedInfo = decoder.offset;
if( decoder.peekStartElement(CCNProtocolDTags.SignedInfo) ){
@@ -121,11 +121,11 @@
this.SignedInfo.decode(decoder);
}
- this.Content = decoder.readBinaryElement(CCNProtocolDTags.Content);
+ this.content = decoder.readBinaryElement(CCNProtocolDTags.Content);
- //this.EndContent = decoder.offset;
- this.EndSIG = decoder.offset;
+ //this.endContent = decoder.offset;
+ this.endSIG = decoder.offset;
decoder.readEndElement();
@@ -133,9 +133,9 @@
this.saveRawData(decoder.istream);
};
-ContentObject.prototype.encode = function(/*XMLEncoder*/ encoder) {
+ContentObject.prototype.to_ccnb = function(/*XMLEncoder*/ encoder) {
- //TODO verify Name, SignedInfo and Signature is present
+ //TODO verify name, SignedInfo and Signature is present
encoder.writeStartElement(this.getElementLabel());
@@ -146,23 +146,23 @@
if(null!=this.Signature) this.Signature.encode(encoder);
- this.StartSIG = encoder.offset;
+ this.startSIG = encoder.offset;
- if(null!=this.Name) this.Name.encode(encoder);
+ if(null!=this.name) this.name.encode(encoder);
- //this.EndSIG = encoder.offset;
- //this.StartSignedInfo = encoder.offset;
+ //this.endSIG = encoder.offset;
+ //this.startSignedInfo = encoder.offset;
if(null!=this.SignedInfo) this.SignedInfo.encode(encoder);
- encoder.writeElement(CCNProtocolDTags.Content, this.Content);
+ encoder.writeElement(CCNProtocolDTags.Content, this.content);
- this.EndSIG = encoder.offset;
+ this.endSIG = encoder.offset;
- //this.EndContent = encoder.offset;
+ //this.endContent = encoder.offset;
encoder.writeEndElement();
diff --git a/js/Interest.js b/js/Interest.js
index ab20de1..46303b1 100644
--- a/js/Interest.js
+++ b/js/Interest.js
@@ -3,20 +3,20 @@
* This class represents Interest Objects
*/
-var Interest = function Interest(_Name,_FaceInstance,_MinSuffixComponents,_MaxSuffixComponents,_PublisherID, _Exclude, _ChildSelector,_AnswerOriginKind,_Scope,_InterestLifetime,_Nonce){
+var Interest = function Interest(_name,_faceInstance,_minSuffixComponents,_maxSuffixComponents,_publisherPublicKeyDigest, _exclude, _childSelector,_answerOriginKind,_scope,_interestLifetime,_nonce){
- this.Name = _Name;
- this.FaceInstance = _FaceInstance;
- this.MaxSuffixComponents = _MaxSuffixComponents;
- this.MinSuffixComponents = _MinSuffixComponents;
+ this.name = _name;
+ this.faceInstance = _faceInstance;
+ this.maxSuffixComponents = _maxSuffixComponents;
+ this.minSuffixComponents = _minSuffixComponents;
- this.PublisherID = _PublisherID;
- this.Exclude = _Exclude;
- this.ChildSelector = _ChildSelector;
- this.AnswerOriginKind = _AnswerOriginKind;
- this.Scope = _Scope;
- this.InterestLifetime = null; // For now we don't have the ability to set an interest lifetime
- this.Nonce = _Nonce;
+ this.publisherPublicKeyDigest = _publisherPublicKeyDigest;
+ this.exclude = _exclude;
+ this.childSelector = _childSelector;
+ this.answerOriginKind = _answerOriginKind;
+ this.scope = _scope;
+ this.interestLifetime = null; // For now we don't have the ability to set an interest lifetime
+ this.nonce = _nonce;
this.RECURSIVE_POSTFIX = "*";
@@ -26,99 +26,111 @@
this.ANSWER_CONTENT_STORE = 1;
this.ANSWER_GENERATED = 2;
this.ANSWER_STALE = 4; // Stale answer OK
- this.MARK_STALE = 16; // Must have Scope 0. Michael calls this a "hack"
+ this.MARK_STALE = 16; // Must have scope 0. Michael calls this a "hack"
this.DEFAULT_ANSWER_ORIGIN_KIND = this.ANSWER_CONTENT_STORE | this.ANSWER_GENERATED;
};
-Interest.prototype.decode = function(/*XMLDecoder*/ decoder) {
+Interest.prototype.from_ccnb = function(/*XMLDecoder*/ decoder) {
decoder.readStartElement(CCNProtocolDTags.Interest);
- this.Name = new ContentName();
- this.Name.decode(decoder);
+ this.name = new ContentName();
+ this.name.decode(decoder);
if (decoder.peekStartElement(CCNProtocolDTags.MinSuffixComponents)) {
- this.MinSuffixComponents = decoder.readIntegerElement(CCNProtocolDTags.MinSuffixComponents);
+ this.minSuffixComponents = decoder.readIntegerElement(CCNProtocolDTags.MinSuffixComponents);
}
if (decoder.peekStartElement(CCNProtocolDTags.MaxSuffixComponents)) {
- this.MaxSuffixComponents = decoder.readIntegerElement(CCNProtocolDTags.MaxSuffixComponents);
+ this.maxSuffixComponents = decoder.readIntegerElement(CCNProtocolDTags.MaxSuffixComponents);
}
- //TODO decode PublisherID
- if (PublisherID.peek(decoder)) {
- this.Publisher = new PublisherID();
- this.Publisher.decode(decoder);
+ if (decoder.peekStartElement(CCNProtocolDTags.PublisherPublicKeyDigest)) {
+ this.publisherPublicKeyDigest = new PublisherPublicKeyDigest();
+ this.publisherPublicKeyDigest.decode(decoder);
}
if (decoder.peekStartElement(CCNProtocolDTags.Exclude)) {
- this.Exclude = new Exclude();
- this.Exclude.decode(decoder);
+ this.exclude = new Exclude();
+ this.exclude.decode(decoder);
}
if (decoder.peekStartElement(CCNProtocolDTags.ChildSelector)) {
- this.ChildSelector = decoder.readIntegerElement(CCNProtocolDTags.ChildSelector);
+ this.childSelector = decoder.readIntegerElement(CCNProtocolDTags.ChildSelector);
}
if (decoder.peekStartElement(CCNProtocolDTags.AnswerOriginKind)) {
// call setter to handle defaulting
- this.AnswerOriginKind = decoder.readIntegerElement(CCNProtocolDTags.AnswerOriginKind);
+ this.answerOriginKind = decoder.readIntegerElement(CCNProtocolDTags.AnswerOriginKind);
}
if (decoder.peekStartElement(CCNProtocolDTags.Scope)) {
- this.Scope = decoder.readIntegerElement(CCNProtocolDTags.Scope);
+ this.scope = decoder.readIntegerElement(CCNProtocolDTags.Scope);
}
if (decoder.peekStartElement(CCNProtocolDTags.InterestLifetime)) {
- this.InterestLifetime = decoder.readBinaryElement(CCNProtocolDTags.InterestLifetime);
+ this.interestLifetime = decoder.readBinaryElement(CCNProtocolDTags.InterestLifetime);
}
if (decoder.peekStartElement(CCNProtocolDTags.Nonce)) {
- this.Nonce = decoder.readBinaryElement(CCNProtocolDTags.Nonce);
+ this.nonce = decoder.readBinaryElement(CCNProtocolDTags.Nonce);
}
decoder.readEndElement();
};
-Interest.prototype.encode = function(/*XMLEncoder*/ encoder){
+Interest.prototype.to_ccnb = function(/*XMLEncoder*/ encoder){
//Could check if name is present
encoder.writeStartElement(CCNProtocolDTags.Interest);
- this.Name.encode(encoder);
+ this.name.encode(encoder);
- if (null != this.MinSuffixComponents)
- encoder.writeElement(CCNProtocolDTags.MinSuffixComponents, this.MinSuffixComponents);
+ if (null != this.minSuffixComponents)
+ encoder.writeElement(CCNProtocolDTags.MinSuffixComponents, this.minSuffixComponents);
- if (null != this.MaxSuffixComponents)
- encoder.writeElement(CCNProtocolDTags.MaxSuffixComponents, this.MaxSuffixComponents);
+ if (null != this.maxSuffixComponents)
+ encoder.writeElement(CCNProtocolDTags.MaxSuffixComponents, this.maxSuffixComponents);
- //TODO Encode PublisherID
+ if (null != this.publisherPublicKeyDigest)
+ this.publisherPublicKeyDigest.encode(encoder);
- if (null != this.PublisherID)
- publisherID().encode(encoder);
+ if (null != this.exclude)
+ this.exclude.encode(encoder);
- //TODO Encode Exclude
-
- if (null != this.Exclude)
- exclude().encode(encoder);
-
- if (null != this.ChildSelector)
- encoder.writeElement(CCNProtocolDTags.ChildSelector, this.ChildSelector);
+ if (null != this.childSelector)
+ encoder.writeElement(CCNProtocolDTags.ChildSelector, this.childSelector);
//TODO Encode OriginKind
- if (this.DEFAULT_ANSWER_ORIGIN_KIND != this.AnswerOriginKind && this.AnswerOriginKind!=null)
- encoder.writeElement(CCNProtocolDTags.AnswerOriginKind, this.AnswerOriginKind);
+ if (this.DEFAULT_ANSWER_ORIGIN_KIND != this.answerOriginKind && this.answerOriginKind!=null)
+ encoder.writeElement(CCNProtocolDTags.AnswerOriginKind, this.answerOriginKind);
- if (null != this.Scope)
- encoder.writeElement(CCNProtocolDTags.Scope, this.Scope);
+ if (null != this.scope)
+ encoder.writeElement(CCNProtocolDTags.Scope, this.scope);
- if (null != this.Nonce)
- encoder.writeElement(CCNProtocolDTags.Nonce, this.Nonce);
+ if (null != this.nonce)
+ encoder.writeElement(CCNProtocolDTags.Nonce, this.nonce);
encoder.writeEndElement();
};
+Interest.prototype.matches_name = function(/*ContentName*/ name){
+ var i_name = this.name.Components;
+ var o_name = name.Components;
+
+ // The intrest name is longer than the name we are checking it against.
+ if (i_name.length > o_name.length)
+ return false;
+
+ // Check if at least one of given components doesn't match.
+ for (var i = 0; i < i_name.length; ++i) {
+ if (!DataUtils.arraysEqual(i_name[i], o_name[i]))
+ return false;
+ }
+
+ return true;
+}
+
diff --git a/js/PublisherID.js b/js/PublisherID.js
index 1c98435..64955f3 100644
--- a/js/PublisherID.js
+++ b/js/PublisherID.js
@@ -71,9 +71,7 @@
encoder.writeElement(this.getElementLabel(), this.PublisherID);
};
-PublisherID.peek = function(
- //XMLDecoder
- decoder) {
+PublisherID.peek = function(/* XMLDecoder */ decoder) {
//Long
nextTag = decoder.peekStartElementAsLong();
diff --git a/js/Signature.js b/js/Signature.js
index 9dcbbc5..7eef1d1 100644
--- a/js/Signature.js
+++ b/js/Signature.js
@@ -18,7 +18,7 @@
var hex1 = toHex(enc.getReducedOstream());
var enc = new BinaryXMLEncoder();
- content.encode(enc);
+ content.to_ccnb(enc);
var hex2 = toHex(enc.getReducedOstream());
var enc = new BinaryXMLEncoder();
diff --git a/js/encoding/EncodingUtils.js b/js/encoding/EncodingUtils.js
index ee6af87..653bafd 100644
--- a/js/encoding/EncodingUtils.js
+++ b/js/encoding/EncodingUtils.js
@@ -2,11 +2,11 @@
-function encodeToHexInterest(int){
+function encodeToHexInterest(interest){
var enc = new BinaryXMLEncoder();
- int.encode(enc);
+ interest.to_ccnb(enc);
var hex = DataUtils.toHex(enc.getReducedOstream());
@@ -19,7 +19,7 @@
function encodeToHexContentObject(co){
var enc = new BinaryXMLEncoder();
- co.encode(enc);
+ co.to_ccnb(enc);
var hex = DataUtils.toHex(enc.getReducedOstream());
@@ -31,7 +31,7 @@
function encodeToBinaryContentObject(co){
var enc = new BinaryXMLEncoder();
- co.encode(enc);
+ co.to_ccnb(enc);
var hex = enc.getReducedOstream();
@@ -43,7 +43,7 @@
function encodeForwardingEntry(co){
var enc = new BinaryXMLEncoder();
- co.encode(enc);
+ co.to_ccnb(enc);
var bytes = enc.getReducedOstream();
@@ -63,11 +63,11 @@
if(LOG>3)console.log('DECODING HEX FACE INSTANCE \n'+numbers);
- i = new FaceInstance();
+ var faceInstance = new FaceInstance();
- i.decode(decoder);
+ faceInstance.decode(decoder);
- return i;
+ return faceInstance;
}
@@ -78,11 +78,11 @@
decoder = new BinaryXMLDecoder(numbers);
if(LOG>3)console.log('DECODING HEX INTERST \n'+numbers);
- i = new Interest();
+ var interest = new Interest();
- i.decode(decoder);
+ interest.from_ccnb(decoder);
- return i;
+ return interest;
}
@@ -96,7 +96,7 @@
co = new ContentObject();
- co.decode(decoder);
+ co.from_ccnb(decoder);
return co;
@@ -111,11 +111,11 @@
if(LOG>3)console.log('DECODED HEX FORWARDING ENTRY \n'+numbers);
- co = new ForwardingEntry();
+ forwardingEntry = new ForwardingEntry();
- co.decode(decoder);
+ forwardingEntry.decode(decoder);
- return co;
+ return forwardingEntry;
}
@@ -130,24 +130,24 @@
else if (co==-2)
output+= "CONTENT NAME IS EMPTY"
else{
- if(co.Name!=null && co.Name.Components!=null){
+ if(co.name!=null && co.name.Components!=null){
output+= "NAME: ";
- for(var i=0;i<co.Name.Components.length;i++){
- output+= "/"+ DataUtils.toString(co.Name.Components[i]);
+ for(var i=0;i<co.name.Components.length;i++){
+ output+= "/"+ DataUtils.toString(co.name.Components[i]);
}
output+= "<br />";
output+= "<br />";
}
- if(co.Content !=null){
- output += "CONTENT(ASCII): "+ DataUtils.toString(co.Content);
+ if(co.content !=null){
+ output += "CONTENT(ASCII): "+ DataUtils.toString(co.content);
output+= "<br />";
output+= "<br />";
}
- if(co.Content !=null){
- output += "CONTENT(hex): "+ DataUtils.toHex(co.Content);
+ if(co.content !=null){
+ output += "CONTENT(hex): "+ DataUtils.toHex(co.content);
output+= "<br />";
output+= "<br />";
diff --git a/js/image-loader.html b/js/image-loader.html
index 4ea5b47..b6740bf 100644
--- a/js/image-loader.html
+++ b/js/image-loader.html
@@ -90,10 +90,10 @@
var co = connector.get( contentName );
if(co){
- loadedImageString += DataUtils.toString(co.Content);
- console.log("Received length: " + co.Content.length);
- if(co.Content.length == pieceSize){
- pieceNumber += co.Content.length;
+ loadedImageString += DataUtils.toString(co.content);
+ console.log("Received length: " + co.content.length);
+ if(co.content.length == pieceSize){
+ pieceNumber += co.content.length;
getPiece();
}
else document.getElementById('image').src += loadedImageString;
diff --git a/js/lwNDN.js b/js/lwNDN.js
index 41b7acf..717ac07 100644
--- a/js/lwNDN.js
+++ b/js/lwNDN.js
@@ -98,7 +98,7 @@
var interestName = new ContentName(['ccnx',ccnxnodename,'selfreg',coBinary]);
int = new Interest(interestName);
- int.Scope = 1;
+ int.scope = 1;
var hex = encodeToHexInterest(int);
diff --git a/js/publish-data.html b/js/publish-data.html
index 9cf6433..1534aa9 100644
--- a/js/publish-data.html
+++ b/js/publish-data.html
@@ -110,7 +110,7 @@
else if (co==-2)
output+= "CONTENT NAME IS EMPTY"
else{
- if(co.Name!=null && co.Name.Components!=null){
+ if(co.name!=null && co.Name.Components!=null){
output+= "NAME: ";
for(var i=0;i<co.Name.Components.length;i++){
@@ -120,7 +120,7 @@
output+= "<br />";
}
- if(co.Content !=null){
+ if(co.content !=null){
output += "CONTENT(ASCII): "+ toString(co.Content);
output+= "<br />";
diff --git a/js/request-data.html b/js/request-data.html
index 65dd8c1..b86170b 100644
--- a/js/request-data.html
+++ b/js/request-data.html
@@ -98,24 +98,24 @@
if(co==null)
output+= "NO CONTENT FOUND"
else{
- if(co.Name!=null && co.Name.Components!=null){
+ if(co.name!=null && co.name.Components!=null){
output+= "NAME: ";
- for(var i=0;i<co.Name.Components.length;i++){
- output+= "/"+ DataUtils.toString(co.Name.Components[i]);
+ for(var i=0;i<co.name.Components.length;i++){
+ output+= "/"+ DataUtils.toString(co.name.Components[i]);
}
output+= "<br />";
output+= "<br />";
}
- if(co.Content !=null){
- output += "CONTENT(ASCII): "+ DataUtils.toString(co.Content);
+ if(co.content !=null){
+ output += "CONTENT(ASCII): "+ DataUtils.toString(co.content);
output+= "<br />";
output+= "<br />";
}
- if(co.Content !=null){
- output += "CONTENT(hex): "+ DataUtils.toHex(co.Content);
+ if(co.content !=null){
+ output += "CONTENT(hex): "+ DataUtils.toHex(co.content);
output+= "<br />";
output+= "<br />";
diff --git a/js/testing/test-decode-FaceInstance.html b/js/testing/test-decode-FaceInstance.html
index 7d168cc..7818e55 100644
--- a/js/testing/test-decode-FaceInstance.html
+++ b/js/testing/test-decode-FaceInstance.html
@@ -134,7 +134,7 @@
output+= "<br />";
}
- /*if(interest.Name!=null && interest.Name.Components!=null){
+ /*if(interest.name!=null && interest.name.Components!=null){
output+= "NAME: ";
for(var i=0;i<interest.Name.Components.length;i++){
diff --git a/js/testing/test-decode-Interest+Forwarding+Entry.html b/js/testing/test-decode-Interest+Forwarding+Entry.html
index adb7058..0ece80f 100644
--- a/js/testing/test-decode-Interest+Forwarding+Entry.html
+++ b/js/testing/test-decode-Interest+Forwarding+Entry.html
@@ -77,7 +77,6 @@
function decode(){
-
var input = document.getElementById('result').innerHTML;
@@ -92,136 +91,125 @@
var output ="";
- if(interest.Name!=null && interest.Name.Components!=null){
+ if(interest.name!=null && interest.name.Components!=null){
output+= "NAME: ";
- for(var i=0;i<interest.Name.Components.length;i++){
- output+= "/"+ DataUtils.toString(interest.Name.Components[i]);
+ for(var i=0;i<interest.name.Components.length;i++){
+ output+= "/"+ DataUtils.toString(interest.name.Components[i]);
}
output+= "<br />";
output+= "<br />";
}
- if(interest.FaceInstance!=null ){
+ if(interest.faceInstance!=null ){
output+= "FaceInstance: ";
- output+= interest.FaceInstance;
+ output+= interest.faceInstance;
output+= "<br />";
output+= "<br />";
}
- if(interest.Exclude!=null ){
+ if(interest.exclude!=null ){
output+= "Exclude: ";
- output+= interest.Exclude;
+ output+= interest.exclude;
output+= "<br />";
output+= "<br />";
}
- if(interest.ChildSelector!=null ){
+ if(interest.childSelector!=null ){
output+= "ChildSelector: ";
- output+= interest.ChildSelector;
+ output+= interest.childSelector;
output+= "<br />";
output+= "<br />";
}
- if(interest.AnswerOriginKind!=null ){
+ if(interest.answerOriginKind!=null ){
output+= "AnswerOriginKind: ";
- output+= interest.AnswerOriginKind;
+ output+= interest.answerOriginKind;
output+= "<br />";
output+= "<br />";
}
- if(interest.InterestLifetime!=null ){
+ if(interest.interestLifetime!=null ){
output+= "InterestLifetime: ";
- output+= interest.InterestLifetime;
+ output+= interest.interestLifetime;
output+= "<br />";
output+= "<br />";
}
- if(interest.Nonce!=null ){
+ if(interest.nonce!=null ){
output+= "Nonce: ";
- output+= interest.Nonce;
+ output+= interest.nonce;
output+= "<br />";
output+= "<br />";
}
- if(interest.Scope!=null ){
+ if(interest.scope!=null ){
output+= "SCOPE: ";
- output+= interest.Scope;
+ output+= interest.scope;
output+= "<br />";
output+= "<br />";
}
- if(interest.PublisherID!=null ){
- output+= "PUBLISHER ID: ";
+ if(interest.publisherPublicKeyDigest!=null ){
+ output+= "PUBLISHER PUBLIC KEY DIGEST: ";
- output+= interest.PublisherID.PublisherID;
-
- output+= "PUBLISHER ID TYPE: ";
- output+= interest.PublisherID.PublisherType;
+ output+= interest.publisherPublicKeyDigest.PublisherPublicKeyDigest;
+
output+= "<br />";
output+= "<br />";
}
- if(interest.MaxSuffixComponents!=null ){
+ if(interest.maxSuffixComponents!=null ){
output+= "MaxSuffixComponents : ";
- output+= interest.MaxSuffixComponents;
+ output+= interest.maxSuffixComponents;
output+= "<br />";
output+= "<br />";
}
- if(interest.MinSuffixComponents!=null ){
+ if(interest.minSuffixComponents!=null ){
output+= "MinSuffixComponents : ";
- output+= interest.MinSuffixComponents;
+ output+= interest.minSuffixComponents;
output+= "<br />";
output+= "<br />";
}
- if(interest.MinSuffixComponents!=null ){
- output+= "MinSuffixComponents : ";
-
- output+= interest.MinSuffixComponents;
-
- output+= "<br />";
- output+= "<br />";
- }
-
- if(interest.Name.Components[3] !=null){
+ if(interest.name.Components[3] !=null){
- var input = DataUtils.toHex(interest.Name.Components[3]) ;
+ var input = DataUtils.toHex(interest.name.Components[3]) ;
var contentObject = decodeHexContentObject(input);
- if(contentObject.Content!=null ){
+ if(contentObject.content!=null ){
output+= "Content of content Object: ";
- output+= DataUtils.toHex(contentObject.Content);
+ output+= DataUtils.toHex(contentObject.content);
output+= "<br />";
output+= "<br />";
}
- var content = DataUtils.toHex(contentObject.Content);
+ var content = DataUtils.toHex(contentObject.content);
var co = contentObject;
@@ -229,24 +217,24 @@
////////////////////////////////////////
- if(co.Name!=null && co.Name.Components!=null){
+ if(co.name!=null && co.name.Components!=null){
output+= "NAME: ";
- for(var i=0;i<co.Name.Components.length;i++){
- output+= "/"+ DataUtils.toString(co.Name.Components[i]);
+ for(var i=0;i<co.name.Components.length;i++){
+ output+= "/"+ DataUtils.toString(co.name.Components[i]);
}
output+= "<br />";
output+= "<br />";
}
- if(co.Content !=null){
- output += "CONTENT(ASCII): "+ DataUtils.toString(co.Content);
+ if(co.content !=null){
+ output += "CONTENT(ASCII): "+ DataUtils.toString(co.content);
output+= "<br />";
output+= "<br />";
}
- if(co.Content !=null){
- output += "CONTENT(hex): "+ DataUtils.toHex(co.Content);
+ if(co.content !=null){
+ output += "CONTENT(hex): "+ DataUtils.toHex(co.content);
output+= "<br />";
output+= "<br />";
@@ -472,7 +460,7 @@
<body >
<form>
- Please Press decode:<br />
+ Please Press Decode:<br />
</form>
diff --git a/js/testing/test-encode-decode-ContentObject-bis.html b/js/testing/test-encode-decode-ContentObject-bis.html
index 7956af3..f66cae5 100644
--- a/js/testing/test-encode-decode-ContentObject-bis.html
+++ b/js/testing/test-encode-decode-ContentObject-bis.html
@@ -116,24 +116,24 @@
else if (co==-2)
output+= "CONTENT NAME IS EMPTY"
else{
- if(co.Name!=null && co.Name.Components!=null){
+ if(co.name!=null && co.name.Components!=null){
output+= "NAME: ";
- for(var i=0;i<co.Name.Components.length;i++){
- output+= "/"+ toString(co.Name.Components[i]);
+ for(var i=0;i<co.name.Components.length;i++){
+ output+= "/"+ toString(co.name.Components[i]);
}
output+= "<br />";
output+= "<br />";
}
- if(co.Content !=null){
- output += "CONTENT(ASCII): "+ toString(co.Content);
+ if(co.content !=null){
+ output += "CONTENT(ASCII): "+ toString(co.content);
output+= "<br />";
output+= "<br />";
}
- if(co.Content !=null){
- output += "CONTENT(hex): "+ toHex(co.Content);
+ if(co.content !=null){
+ output += "CONTENT(hex): "+ toHex(co.content);
output+= "<br />";
output+= "<br />";
diff --git a/js/testing/test-encode-decode-Interest.html b/js/testing/test-encode-decode-Interest.html
index 04cbae2..dd3e3b4 100644
--- a/js/testing/test-encode-decode-Interest.html
+++ b/js/testing/test-encode-decode-Interest.html
@@ -76,7 +76,7 @@
function encode(){
var interest = new Interest( new ContentName(document.getElementById('interest').value ) );
- interest.Scope = 1;
+ interest.scope = 1;
var output = encodeToHexInterest(interest);
@@ -100,14 +100,14 @@
var output ="";
- if(interest.Name!=null && interest.Name.Components!=null){
+ if(interest.name!=null && interest.name.Components!=null){
output+= "NAME: ";
- output+= interest.Name.getName();
+ output+= interest.name.getName();
- /*for(var i=0;i<interest.Name.Components.length;i++){
- output+= "/"+ DataUtils.toString(interest.Name.Components[i]);
+ /*for(var i=0;i<interest.name.Components.length;i++){
+ output+= "/"+ DataUtils.toString(interest.name.Components[i]);
}*/
output+= "<br />";
@@ -115,48 +115,39 @@
}
- if(interest.Scope!=null ){
+ if(interest.scope!=null ){
output+= "SCOPE: ";
- output+= interest.Scope;
+ output+= interest.scope;
output+= "<br />";
output+= "<br />";
}
- if(interest.PublisherID!=null ){
+ if(interest.publisherID!=null ){
output+= "PUBLISHER ID: ";
- output+= interest.PublisherID.PublisherID;
+ output+= interest.publisherID.PublisherID;
output+= "PUBLISHER ID TYPE: ";
- output+= interest.PublisherID.PublisherType;
+ output+= interest.publisherID.PublisherType;
output+= "<br />";
output+= "<br />";
}
- if(interest.MaxSuffixComponents!=null ){
+ if(interest.maxSuffixComponents!=null ){
output+= "MaxSuffixComponents : ";
- output+= interest.MaxSuffixComponents;
+ output+= interest.maxSuffixComponents;
output+= "<br />";
output+= "<br />";
}
- if(interest.MinSuffixComponents!=null ){
+ if(interest.minSuffixComponents!=null ){
output+= "MinSuffixComponents : ";
- output+= interest.MinSuffixComponents;
-
- output+= "<br />";
- output+= "<br />";
- }
-
- if(interest.MinSuffixComponents!=null ){
- output+= "MinSuffixComponents : ";
-
- output+= interest.MinSuffixComponents;
+ output+= interest.minSuffixComponents;
output+= "<br />";
output+= "<br />";
diff --git a/js/testing/test-get.html b/js/testing/test-get.html
index ad4886c..8053655 100644
--- a/js/testing/test-get.html
+++ b/js/testing/test-get.html
@@ -75,7 +75,7 @@
function getAction(){
var interest = new Interest( new ContentName(document.getElementById('interest').value));
- interest.Scope = 1;
+ interest.scope = 1;
var received = get('127.0.0.1', 9695, encodeToHexInterest(interest));
diff --git a/js/testing/test-interest-matches-name.html b/js/testing/test-interest-matches-name.html
new file mode 100644
index 0000000..111789f
--- /dev/null
+++ b/js/testing/test-interest-matches-name.html
@@ -0,0 +1,104 @@
+<?xml version = "1.0" encoding="utf-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"DTD/xhtml1-strict.dtd">
+<html xmlns = "http://www.w3.org/1999/xhtml">
+
+<head>
+ <title>NDN Interest Matches Name</title>
+
+ <script type="text/javascript" src="../java_socket_bridge.js"></script>
+
+ <script type="text/javascript" src="../CCNProtocolDTags.js"></script>
+
+ <script type="text/javascript" src="../CCNTime.js"></script>
+
+ <script type="text/javascript" src="../ContentName.js"></script>
+
+ <script type="text/javascript" src="../ContentObject.js"></script>
+
+ <script type="text/javascript" src="../DateFormat.js"></script>
+
+ <script type="text/javascript" src="../Exclude.js"></script>
+
+ <script type="text/javascript" src="../ExcludeAny.js"></script>
+
+ <script type="text/javascript" src="../ExcludeComponent.js"></script>
+
+ <script type="text/javascript" src="../Interest.js"></script>
+
+ <script type="text/javascript" src="../KeyLocator.js"></script>
+
+ <script type="text/javascript" src="../KeyName.js"></script>
+
+ <script type="text/javascript" src="../PublisherID.js"></script>
+
+ <script type="text/javascript" src="../Signature.js"></script>
+
+ <script type="text/javascript" src="../SignedInfo.js"></script>
+
+ <script type="text/javascript" src="../PublisherPublicKeyDigest.js"></script>
+
+ <script type="text/javascript" src="../FaceInstance.js"></script>
+
+ <script type="text/javascript" src="../ForwardingEntry.js"></script>
+
+ <script type="text/javascript" src="../encoding/BinaryXMLEncoder.js"></script>
+
+ <script type="text/javascript" src="../encoding/BinaryXMLCodec.js"></script>
+
+ <script type="text/javascript" src="../encoding/BinaryXMLDecoder.js"></script>
+
+ <script type="text/javascript" src="../encoding/DataUtils.js"></script>
+
+ <script type="text/javascript" src="../encoding/EncodingUtils.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../security/KeyManager.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn2.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsa.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsa2.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha256.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha512.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/md5.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/ripemd160.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/base64.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsapem-1.1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsasign-1.2.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/asn1hex-1.1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/x509-1.1.js"></script>
+
+ <script type="text/javascript">
+
+ function check(){
+ var interest = new Interest( new ContentName(document.getElementById('interest').value));
+ interest.scope = 1;
+
+ var nameToCheck = new ContentName(document.getElementById('nameToCheck').value);
+
+ var output = (interest.matches_name(nameToCheck) ? "matches" : "doesn't match");
+ document.getElementById('result').innerHTML = output;
+ }
+
+ </script>
+
+</head>
+<body >
+ <form>
+
+ Please enter the name of an interest:<br />
+ <input id="interest" type="text" name="INTEREST" value="/ndn/ucla.edu" /> <br/>
+
+ Please enter a name to check if the interest matches the name:<br />
+ <input id="nameToCheck" type="text" name="NAME_TO_CHECK" value="/ndn/ucla.edu" /> <br/>
+
+ </form>
+ <button onclick="check()">Check</button>
+
+ <p id="result"></p>
+
+</body>
+</html>
diff --git a/js/testing/test-request-send-hex.html b/js/testing/test-request-send-hex.html
index f1acb20..3ed1a90 100644
--- a/js/testing/test-request-send-hex.html
+++ b/js/testing/test-request-send-hex.html
@@ -130,7 +130,7 @@
co = new ContentObject();
- co.decode(decoder);
+ co.from_ccnb(decoder);
if(LOG>2) console.log(co);