blob: 7beef74367caee35fffce4ccc16fc9655f8ef5d4 [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
Alexander Afanasyev2a2c9d22013-03-13 16:21:32 -070012 <script type="text/javascript" src="../build/ndn-js.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));
Jeff Thompson08d41b72013-02-03 23:09:29 -080030 interest.exclude = new Exclude([Name.fromEscapedString("abc"), Exclude.ANY]);
Jeff Thompson5fc9b672012-11-24 10:00:56 -080031
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070032 var output = encodeToHexInterest(interest);
33
34 document.getElementById('result').innerHTML = output;
35
36 }
37
Jeff Thompson5fc9b672012-11-24 10:00:56 -080038 function decode() {
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070039 var input = document.getElementById('result').innerHTML;
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070040
41 var interest = decodeHexInterest(input);
42
Jeff Thompson5fc9b672012-11-24 10:00:56 -080043 if (LOG>3)console.log('INTEREST DECODED');
44 if (LOG>3)console.log(interest);
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070045
46 ///////////////////////////////////////
47
48 var output ="";
49
Jeff Thompson08d41b72013-02-03 23:09:29 -080050 if (interest.name != null && interest.name.components != null)
51 output += "Name: " + interest.name.getName() + "<br/>";
52 if (interest.minSuffixComponents != null )
53 output += "MinSuffixComponents : " + interest.minSuffixComponents + "<br/>";
54 if (interest.maxSuffixComponents != null )
55 output += "MaxSuffixComponents : " + interest.maxSuffixComponents + "<br/>";
56 if (interest.publisherPublicKeyDigest != null )
57 output += "PublisherPublicKeyDigest: " +
58 DataUtils.toHex(interest.publisherPublicKeyDigest.publisherPublicKeyDigest) + "<br/>";
59 if (interest.childSelector != null )
60 output += "ChildSelector: " + interest.childSelector + "<br/>";
61 if (interest.answerOriginKind != null )
62 output += "AnswerOriginKind: " + interest.answerOriginKind + "<br/>";
63 if (interest.scope != null )
64 output += "Scope: " + interest.scope + "<br/>";
65 if (interest.interestLifetime != null )
66 output += "InterestLifetime (milliseconds): " + interest.interestLifetime + "<br/>";
67 if (interest.nonce != null )
68 output += "Nonce: " + DataUtils.toHex(interest.nonce) + "<br/>";
69 if (interest.exclude != null )
70 output += "Exclude: " + interest.exclude.to_uri() + "<br/>";
Meki Cherkaoui8f173612012-06-06 01:05:40 -070071
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070072 document.getElementById('result').innerHTML = output;
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070073 }
74
75 </script>
76
77</head>
78<body >
79 <form>
80
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070081 Please Enter an Interest:<br />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070082
Jeff Thompsonbd829262012-11-30 22:28:37 -080083 <input id="interest" type="text" name="INTEREST" value="/ndn/abc" />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070084
85 </form>
86 <button onclick="encode()">Encode</button>
87 <button onclick="decode()">Decode</button>
88
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070089 <p id="result"></p>
Meki Cherkaoui8f173612012-06-06 01:05:40 -070090
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070091
92
Meki Cherkaoui8f173612012-06-06 01:05:40 -070093 <!-- p id="result">01d2f2fafdc12e4d2e532e6c6f63616c686f737400fabdc12e4d2e53525600faa563636e6400fa9d4b4559000002d28e310000</p-->
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070094
95</body>
jeff9797d3d2012-09-03 15:07:13 -070096</html>