blob: 050aaf78af7c92b92f3c442ad1cf93ff3e108383 [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">
Jeff Burke92dd8e42012-12-08 11:40:31 -08004<!--
5 See COPYING for copyright and distribution information.
6-->
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -07007<html xmlns = "http://www.w3.org/1999/xhtml">
8
9<head>
Jeff Thompsond9784e02012-10-18 23:39:39 -070010 <title>NDN Encode/Decode Interest</title>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070011
Jeff Thompson38422f42012-11-15 00:20:39 -080012 <script type="text/javascript" src="../Helper.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070013
14 <script type="text/javascript">
15
Jeff Thompson5fc9b672012-11-24 10:00:56 -080016 function encode() {
Jeff Thompsonf3bd3592012-09-29 23:25:30 -070017 var interest = new Interest( new Name(document.getElementById('interest').value ) );
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070018
Jeff Thompson5fc9b672012-11-24 10:00:56 -080019 interest.minSuffixComponents = 2;
20 interest.maxSuffixComponents = 4;
21 interest.childSelector = 1;
22 interest.answerOriginKind = 4;
23 interest.scope = 2;
Jeff Thompson42806a12012-12-29 18:19:39 -080024 interest.interestLifetime = 30000;
Jeff Thompson5fc9b672012-11-24 10:00:56 -080025 interest.nonce = new Uint8Array([0x61, 0x62, 0x61, 0x62, 0x61, 0x62]);
26 var pkd = [];
27 for (i = 0; i < 32; ++i)
28 pkd.push(i);
29 interest.publisherPublicKeyDigest = new PublisherPublicKeyDigest(new Uint8Array(pkd));
30
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070031 var output = encodeToHexInterest(interest);
32
33 document.getElementById('result').innerHTML = output;
34
35 }
36
Jeff Thompson5fc9b672012-11-24 10:00:56 -080037 function decode() {
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070038 var input = document.getElementById('result').innerHTML;
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070039
40 var interest = decodeHexInterest(input);
41
Jeff Thompson5fc9b672012-11-24 10:00:56 -080042 if (LOG>3)console.log('INTEREST DECODED');
43 if (LOG>3)console.log(interest);
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070044
45 ///////////////////////////////////////
46
47 var output ="";
48
Jeff Thompson5fc9b672012-11-24 10:00:56 -080049 if (interest.name != null && interest.name.components != null) {
50 output += "Name: ";
51 output += interest.name.getName();
52 output += "<br/>";
53 }
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070054
Jeff Thompson5fc9b672012-11-24 10:00:56 -080055 if (interest.minSuffixComponents != null ) {
56 output += "MinSuffixComponents : ";
57 output += interest.minSuffixComponents;
58 output += "<br/>";
59 }
60
61 if (interest.maxSuffixComponents != null ) {
62 output += "MaxSuffixComponents : ";
63 output += interest.maxSuffixComponents;
64 output += "<br/>";
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070065 }
66
Jeff Thompson5fc9b672012-11-24 10:00:56 -080067 if (interest.publisherPublicKeyDigest != null ) {
68 output += "PublisherPublicKeyDigest: ";
69 output += DataUtils.toHex(interest.publisherPublicKeyDigest.publisherPublicKeyDigest);
70 output += "<br/>";
71 }
Meki Cherkaoui8f173612012-06-06 01:05:40 -070072
Jeff Thompson5fc9b672012-11-24 10:00:56 -080073 if (interest.childSelector != null ) {
74 output += "ChildSelector: ";
75 output += interest.childSelector;
76 output += "<br/>";
77 }
78
79 if (interest.answerOriginKind != null ) {
80 output += "AnswerOriginKind: ";
81 output += interest.answerOriginKind;
82 output += "<br/>";
83 }
84
85 if (interest.scope != null ) {
86 output += "Scope: ";
87 output += interest.scope;
88 output += "<br/>";
89 }
90
91 if (interest.interestLifetime != null ) {
Jeff Thompson42806a12012-12-29 18:19:39 -080092 output += "InterestLifetime (milliseconds): ";
Jeff Thompson5fc9b672012-11-24 10:00:56 -080093 output += interest.interestLifetime;
94 output += "<br/>";
Meki Cherkaoui8f173612012-06-06 01:05:40 -070095 }
96
Jeff Thompson5fc9b672012-11-24 10:00:56 -080097 if (interest.nonce != null ) {
98 output += "Nonce: ";
99 output += DataUtils.toHex(interest.nonce);
100 output += "<br/>";
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700101 }
102
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700103 document.getElementById('result').innerHTML = output;
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700104 }
105
106 </script>
107
108</head>
109<body >
110 <form>
111
Jeff Thompson7ed5ef52012-08-26 11:28:48 -0700112 Please Enter an Interest:<br />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700113
Jeff Thompsonbd829262012-11-30 22:28:37 -0800114 <input id="interest" type="text" name="INTEREST" value="/ndn/abc" />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700115
116 </form>
117 <button onclick="encode()">Encode</button>
118 <button onclick="decode()">Decode</button>
119
Jeff Thompson7ed5ef52012-08-26 11:28:48 -0700120 <p id="result"></p>
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700121
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700122
123
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700124 <!-- p id="result">01d2f2fafdc12e4d2e532e6c6f63616c686f737400fabdc12e4d2e53525600faa563636e6400fa9d4b4559000002d28e310000</p-->
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700125
126</body>
jeff9797d3d2012-09-03 15:07:13 -0700127</html>