2017-02-16 22:52:07 +00:00
|
|
|
'use strict';
|
|
|
|
|
2017-02-17 23:07:26 +00:00
|
|
|
var packer = require('../packer/type.aaaa.js').DNS_PACKER_TYPE_AAAA;
|
2017-02-17 22:14:14 +00:00
|
|
|
var ab = new ArrayBuffer(22);
|
2017-02-16 22:52:07 +00:00
|
|
|
var dv = new DataView(ab);
|
|
|
|
var total = 0;
|
|
|
|
|
|
|
|
// just to see that bytes are changed as a marker
|
|
|
|
dv.setUint16(0x0, 0xDDDD, false);
|
|
|
|
dv.setUint16(0x2, 0xDDDD, false);
|
|
|
|
dv.setUint16(0x4, 0xDDDD, false);
|
|
|
|
dv.setUint16(0x6, 0xDDDD, false);
|
|
|
|
dv.setUint16(0x8, 0xDDDD, false);
|
|
|
|
dv.setUint16(0xA, 0xDDDD, false);
|
|
|
|
dv.setUint16(0xC, 0xDDDD, false);
|
|
|
|
dv.setUint16(0xE, 0xDDDD, false);
|
|
|
|
dv.setUint16(0x10, 0xDDDD, false);
|
|
|
|
dv.setUint16(0x12, 0xDDDD, false);
|
2017-02-17 22:14:14 +00:00
|
|
|
dv.setUint16(0x14, 0xDDDD, false);
|
2017-02-16 22:52:07 +00:00
|
|
|
|
|
|
|
[ [ '::1'
|
2017-02-17 22:14:14 +00:00
|
|
|
, [ 0xDD, 0xDD, 0x00, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0xDD, 0xDD ].join(' ') ]
|
2017-02-16 22:52:07 +00:00
|
|
|
, [ 'fe80::1'
|
2017-02-17 22:14:14 +00:00
|
|
|
, [ 0xDD, 0xDD, 0x00, 0x10, 0xFE, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0xDD, 0xDD ].join(' ') ]
|
2017-02-16 22:52:07 +00:00
|
|
|
, [ 'fd41:50ca:2169:f4e:5020:f756:ca4e:c3b5'
|
2017-02-17 22:14:14 +00:00
|
|
|
, [ 0xDD, 0xDD, 0x00, 0x10, 0xFD, 0x41, 0x50, 0xCA, 0x21, 0x69, 0x0F, 0x4E
|
2017-02-16 22:52:07 +00:00
|
|
|
, 0x50, 0x20, 0xF7, 0x56, 0xCA, 0x4E, 0xC3, 0xB5, 0xDD, 0xDD ].join(' ') ]
|
|
|
|
].forEach(function (ipv6) {
|
2017-02-17 22:14:14 +00:00
|
|
|
total = 2; // leave leading 0xDD
|
2017-02-16 22:52:07 +00:00
|
|
|
total = packer(ab, dv, total, { address: ipv6[0] });
|
2017-02-17 22:14:14 +00:00
|
|
|
if (0x14 !== total) {
|
2017-02-16 22:52:07 +00:00
|
|
|
console.error('unexpected total ' + total);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
if (ipv6[1] !== new Uint8Array(ab).join(' ')) {
|
|
|
|
console.error("expected: ", ipv6[1]);
|
|
|
|
console.error("actual: ", new Uint8Array(ab).join(' '));
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log('PASS');
|