blob: f95ac16c84e298c516e84a572d7c6927c65a5ff7 [file] [log] [blame]
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -07001<?xml version = "1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3"DTD/xhtml1-strict.dtd">
4<html xmlns = "http://www.w3.org/1999/xhtml">
5
6<head>
Jeff Thompsond9784e02012-10-18 23:39:39 -07007 <title>NDN Encode/Decode Interest</title>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -07008
Jeff Thompson38422f42012-11-15 00:20:39 -08009 <script type="text/javascript" src="../Helper.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070010
11 <script type="text/javascript">
12
Jeff Thompson5fc9b672012-11-24 10:00:56 -080013 function encode() {
Jeff Thompsonf3bd3592012-09-29 23:25:30 -070014 var interest = new Interest( new Name(document.getElementById('interest').value ) );
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070015
Jeff Thompson5fc9b672012-11-24 10:00:56 -080016 interest.minSuffixComponents = 2;
17 interest.maxSuffixComponents = 4;
18 interest.childSelector = 1;
19 interest.answerOriginKind = 4;
20 interest.scope = 2;
21 interest.interestLifetime = 30;
22 interest.nonce = new Uint8Array([0x61, 0x62, 0x61, 0x62, 0x61, 0x62]);
23 var pkd = [];
24 for (i = 0; i < 32; ++i)
25 pkd.push(i);
26 interest.publisherPublicKeyDigest = new PublisherPublicKeyDigest(new Uint8Array(pkd));
27
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070028 var output = encodeToHexInterest(interest);
29
30 document.getElementById('result').innerHTML = output;
31
32 }
33
Jeff Thompson5fc9b672012-11-24 10:00:56 -080034 function decode() {
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070035 var input = document.getElementById('result').innerHTML;
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070036
37 var interest = decodeHexInterest(input);
38
Jeff Thompson5fc9b672012-11-24 10:00:56 -080039 if (LOG>3)console.log('INTEREST DECODED');
40 if (LOG>3)console.log(interest);
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070041
42 ///////////////////////////////////////
43
44 var output ="";
45
Jeff Thompson5fc9b672012-11-24 10:00:56 -080046 if (interest.name != null && interest.name.components != null) {
47 output += "Name: ";
48 output += interest.name.getName();
49 output += "<br/>";
50 }
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070051
Jeff Thompson5fc9b672012-11-24 10:00:56 -080052 if (interest.minSuffixComponents != null ) {
53 output += "MinSuffixComponents : ";
54 output += interest.minSuffixComponents;
55 output += "<br/>";
56 }
57
58 if (interest.maxSuffixComponents != null ) {
59 output += "MaxSuffixComponents : ";
60 output += interest.maxSuffixComponents;
61 output += "<br/>";
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070062 }
63
Jeff Thompson5fc9b672012-11-24 10:00:56 -080064 if (interest.publisherPublicKeyDigest != null ) {
65 output += "PublisherPublicKeyDigest: ";
66 output += DataUtils.toHex(interest.publisherPublicKeyDigest.publisherPublicKeyDigest);
67 output += "<br/>";
68 }
Meki Cherkaoui8f173612012-06-06 01:05:40 -070069
Jeff Thompson5fc9b672012-11-24 10:00:56 -080070 if (interest.childSelector != null ) {
71 output += "ChildSelector: ";
72 output += interest.childSelector;
73 output += "<br/>";
74 }
75
76 if (interest.answerOriginKind != null ) {
77 output += "AnswerOriginKind: ";
78 output += interest.answerOriginKind;
79 output += "<br/>";
80 }
81
82 if (interest.scope != null ) {
83 output += "Scope: ";
84 output += interest.scope;
85 output += "<br/>";
86 }
87
88 if (interest.interestLifetime != null ) {
89 output += "InterestLifetime: ";
90 output += interest.interestLifetime;
91 output += "<br/>";
Meki Cherkaoui8f173612012-06-06 01:05:40 -070092 }
93
Jeff Thompson5fc9b672012-11-24 10:00:56 -080094 if (interest.nonce != null ) {
95 output += "Nonce: ";
96 output += DataUtils.toHex(interest.nonce);
97 output += "<br/>";
Meki Cherkaoui8f173612012-06-06 01:05:40 -070098 }
99
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700100 document.getElementById('result').innerHTML = output;
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700101 }
102
103 </script>
104
105</head>
106<body >
107 <form>
108
Jeff Thompson7ed5ef52012-08-26 11:28:48 -0700109 Please Enter an Interest:<br />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700110
jeff9797d3d2012-09-03 15:07:13 -0700111 <input id="interest" type="text" name="INTEREST" value="/PARC/abc" />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700112
113 </form>
114 <button onclick="encode()">Encode</button>
115 <button onclick="decode()">Decode</button>
116
Jeff Thompson7ed5ef52012-08-26 11:28:48 -0700117 <p id="result"></p>
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700118
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700119
120
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700121 <!-- p id="result">01d2f2fafdc12e4d2e532e6c6f63616c686f737400fabdc12e4d2e53525600faa563636e6400fa9d4b4559000002d28e310000</p-->
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700122
123</body>
jeff9797d3d2012-09-03 15:07:13 -0700124</html>