Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 1 | <?xml version = "1.0" encoding="utf-8" ?>
|
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
| 3 | "DTD/xhtml1-strict.dtd">
|
Jeff Burke | 92dd8e4 | 2012-12-08 11:40:31 -0800 | [diff] [blame] | 4 | <!--
|
| 5 | See COPYING for copyright and distribution information.
|
| 6 | -->
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 7 | <html xmlns = "http://www.w3.org/1999/xhtml">
|
| 8 |
|
| 9 | <head>
|
Jeff Thompson | d9784e0 | 2012-10-18 23:39:39 -0700 | [diff] [blame] | 10 | <title>NDN Encode/Decode Interest</title>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 11 |
|
Jeff Thompson | 38422f4 | 2012-11-15 00:20:39 -0800 | [diff] [blame] | 12 | <script type="text/javascript" src="../Helper.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 13 |
|
| 14 | <script type="text/javascript">
|
| 15 |
|
Jeff Thompson | 5fc9b67 | 2012-11-24 10:00:56 -0800 | [diff] [blame] | 16 | function encode() {
|
Jeff Thompson | f3bd359 | 2012-09-29 23:25:30 -0700 | [diff] [blame] | 17 | var interest = new Interest( new Name(document.getElementById('interest').value ) );
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 18 |
|
Jeff Thompson | 5fc9b67 | 2012-11-24 10:00:56 -0800 | [diff] [blame] | 19 | interest.minSuffixComponents = 2;
|
| 20 | interest.maxSuffixComponents = 4;
|
| 21 | interest.childSelector = 1;
|
| 22 | interest.answerOriginKind = 4;
|
| 23 | interest.scope = 2;
|
Jeff Thompson | 42806a1 | 2012-12-29 18:19:39 -0800 | [diff] [blame] | 24 | interest.interestLifetime = 30000;
|
Jeff Thompson | 5fc9b67 | 2012-11-24 10:00:56 -0800 | [diff] [blame] | 25 | 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 Thompson | 08d41b7 | 2013-02-03 23:09:29 -0800 | [diff] [blame] | 30 | interest.exclude = new Exclude([Name.fromEscapedString("abc"), Exclude.ANY]);
|
Jeff Thompson | 5fc9b67 | 2012-11-24 10:00:56 -0800 | [diff] [blame] | 31 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 32 | var output = encodeToHexInterest(interest);
|
| 33 |
|
| 34 | document.getElementById('result').innerHTML = output;
|
| 35 |
|
| 36 | }
|
| 37 |
|
Jeff Thompson | 5fc9b67 | 2012-11-24 10:00:56 -0800 | [diff] [blame] | 38 | function decode() {
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 39 | var input = document.getElementById('result').innerHTML;
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 40 |
|
| 41 | var interest = decodeHexInterest(input);
|
| 42 |
|
Jeff Thompson | 5fc9b67 | 2012-11-24 10:00:56 -0800 | [diff] [blame] | 43 | if (LOG>3)console.log('INTEREST DECODED');
|
| 44 | if (LOG>3)console.log(interest);
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 45 |
|
| 46 | ///////////////////////////////////////
|
| 47 |
|
| 48 | var output ="";
|
| 49 |
|
Jeff Thompson | 08d41b7 | 2013-02-03 23:09:29 -0800 | [diff] [blame] | 50 | 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 Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 71 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 72 | document.getElementById('result').innerHTML = output;
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 73 | }
|
| 74 |
|
| 75 | </script>
|
| 76 |
|
| 77 | </head>
|
| 78 | <body >
|
| 79 | <form>
|
| 80 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 81 | Please Enter an Interest:<br />
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 82 |
|
Jeff Thompson | bd82926 | 2012-11-30 22:28:37 -0800 | [diff] [blame] | 83 | <input id="interest" type="text" name="INTEREST" value="/ndn/abc" />
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 84 |
|
| 85 | </form>
|
| 86 | <button onclick="encode()">Encode</button>
|
| 87 | <button onclick="decode()">Decode</button>
|
| 88 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 89 | <p id="result"></p>
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 90 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 91 |
|
| 92 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 93 | <!-- p id="result">01d2f2fafdc12e4d2e532e6c6f63616c686f737400fabdc12e4d2e53525600faa563636e6400fa9d4b4559000002d28e310000</p-->
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 94 |
|
| 95 | </body>
|
jeff | 9797d3d | 2012-09-03 15:07:13 -0700 | [diff] [blame] | 96 | </html>
|