2 * Copyright (c) 2014 Contextream, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.lispflowmapping.implementation.serializer;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertTrue;
15 import java.nio.ByteBuffer;
16 import java.util.ArrayList;
18 import junitx.framework.ArrayAssert;
20 import org.junit.Test;
21 import org.opendaylight.lispflowmapping.implementation.lisp.exception.LispSerializationException;
22 import org.opendaylight.lispflowmapping.implementation.serializer.MapRegisterSerializer.Length;
23 import org.opendaylight.lispflowmapping.implementation.util.LispAFIConvertor;
24 import org.opendaylight.lispflowmapping.tools.junit.BaseTestCase;
25 import org.opendaylight.lispflowmapping.type.AddressFamilyNumberEnum;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.EidToLocatorRecord.Action;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.MapRegister;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.eidtolocatorrecords.EidToLocatorRecord;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.eidtolocatorrecords.EidToLocatorRecordBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.lispaddress.lispaddresscontainer.address.no.NoAddressBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.locatorrecords.LocatorRecord;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.mapregisternotification.MapRegisterBuilder;
34 public class MapRegisterSerializationTest extends BaseTestCase {
37 public void serialize__Fields() throws Exception {
38 MapRegisterBuilder mrBuilder = new MapRegisterBuilder();
39 mrBuilder.setEidToLocatorRecord(new ArrayList<EidToLocatorRecord>());
40 EidToLocatorRecordBuilder etlrBuilder = new EidToLocatorRecordBuilder();
41 etlrBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
42 etlrBuilder.setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("0.0.0.1")));
44 mrBuilder.getEidToLocatorRecord().add(etlrBuilder.build());
45 etlrBuilder.setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("0.0.0.73")));
46 mrBuilder.getEidToLocatorRecord().add(etlrBuilder.build());
48 mrBuilder.setNonce(6161616161L);
49 mrBuilder.setKeyId((short) 0x0001);
50 mrBuilder.setWantMapNotify(true);
51 mrBuilder.setProxyMapReply(true);
52 mrBuilder.setXtrSiteIdPresent(true);
53 byte[] authenticationData = new byte[] { (byte) 0x16, (byte) 0x98, (byte) 0x96, (byte) 0xeb, (byte) 0x88, (byte) 0x2d, (byte) 0x4d,
54 (byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64, (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba,
55 (byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
56 mrBuilder.setAuthenticationData(authenticationData);
57 byte[] xtrId = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
58 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 };
59 mrBuilder.setXtrId(xtrId);
60 byte[] siteId = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 };
61 mrBuilder.setSiteId(siteId);
63 ByteBuffer bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
64 assertHexEquals((byte) 0x3a, bb.get()); // Type + MSByte of reserved
65 assertEquals(1, bb.getShort()); // Rest of reserved + want map notify
66 assertEquals(2, bb.get()); // Record Count
67 assertEquals(6161616161L, bb.getLong()); // Nonce
68 assertHexEquals((short) 0x0001, bb.getShort()); // Key ID
69 assertEquals(authenticationData.length, bb.getShort());
71 byte[] actualAuthenticationData = new byte[20];
72 bb.get(actualAuthenticationData);
73 ArrayAssert.assertEquals(authenticationData, actualAuthenticationData);
75 bb.position(bb.position() + 12); /* EID in first record */
76 assertEquals(0x1, bb.getInt());
78 bb.position(bb.position() + 12); /* EID in second record */
79 assertEquals(73, bb.getInt());
81 byte[] actualXtrId = new byte[Length.XTRID_SIZE];
83 ArrayAssert.assertEquals(xtrId, actualXtrId);
85 byte[] actualSiteId = new byte[Length.SITEID_SIZE];
87 ArrayAssert.assertEquals(siteId, actualSiteId);
89 assertEquals(bb.position(), bb.capacity());
93 public void serialize__deserialize() throws Exception {
94 MapRegisterBuilder mrBuilder = new MapRegisterBuilder();
95 mrBuilder.setEidToLocatorRecord(new ArrayList<EidToLocatorRecord>());
96 EidToLocatorRecordBuilder etlrBuilder = new EidToLocatorRecordBuilder();
97 etlrBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
98 etlrBuilder.setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("0.0.0.1")));
100 etlrBuilder.setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("0.0.0.73")));
101 mrBuilder.getEidToLocatorRecord().add(etlrBuilder.build());
103 etlrBuilder.setAction(Action.NoAction);
104 etlrBuilder.setMapVersion((short) 0);
105 etlrBuilder.setMaskLength((short) 0);
106 etlrBuilder.setRecordTtl(0);
107 mrBuilder.setNonce(6161616161L);
108 mrBuilder.setKeyId((short) 0x0001);
109 mrBuilder.setWantMapNotify(true);
110 mrBuilder.setProxyMapReply(true);
111 byte[] authenticationData = new byte[] { (byte) 0x16, (byte) 0x98, (byte) 0x96, (byte) 0xeb, (byte) 0x88, (byte) 0x2d, (byte) 0x4d,
112 (byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64, (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba,
113 (byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
114 mrBuilder.setAuthenticationData(authenticationData);
116 MapRegister mapRegister = mrBuilder.build();
117 ArrayAssert.assertEquals(
118 MapRegisterSerializer.getInstance().serialize(mapRegister).array(),
119 MapRegisterSerializer.getInstance()
120 .serialize(MapRegisterSerializer.getInstance().deserialize(MapRegisterSerializer.getInstance().serialize(mapRegister)))
125 public void serialize__NoAuthenticationData() throws Exception {
126 MapRegisterBuilder mrBuilder = new MapRegisterBuilder();
127 mrBuilder.setEidToLocatorRecord(new ArrayList<EidToLocatorRecord>());
128 mrBuilder.getEidToLocatorRecord().add(
129 new EidToLocatorRecordBuilder().setRecordTtl(55)
130 .setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("0.0.0.1"))).build());
131 // mrBuilder.addEidToLocator(new EidToLocatorRecord().setPrefix(new
132 // LispIpv4Address(1)).setRecordTtl(55));
134 ByteBuffer bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
135 bb.position(bb.position() + 14); // jump to AuthenticationDataLength
136 assertEquals(0, bb.getShort());
137 assertEquals(55, bb.getInt());
139 mrBuilder.setAuthenticationData(null);
141 bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
142 bb.position(bb.position() + 14); // jump to AuthenticationDataLength
143 assertEquals(0, bb.getShort());
144 assertEquals(55, bb.getInt());
146 mrBuilder.setAuthenticationData(new byte[0]);
148 bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
149 bb.position(bb.position() + 14); // jump to AuthenticationDataLength
150 assertEquals(0, bb.getShort());
151 assertEquals(55, bb.getInt());
155 public void serialize__NoPrefixInEidToLocator() throws Exception {
156 MapRegisterBuilder mrBuilder = new MapRegisterBuilder();
157 mrBuilder.setEidToLocatorRecord(new ArrayList<EidToLocatorRecord>());
158 mrBuilder.getEidToLocatorRecord().add(new EidToLocatorRecordBuilder().build());
159 mrBuilder.getEidToLocatorRecord().add(new EidToLocatorRecordBuilder().setLispAddressContainer(null).build());
160 mrBuilder.getEidToLocatorRecord().add(
161 new EidToLocatorRecordBuilder().setLispAddressContainer(
162 LispAFIConvertor.toContainer(new NoAddressBuilder().setAfi(AddressFamilyNumberEnum.NO_ADDRESS.getIanaCode()).build())).build());
164 ByteBuffer bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
165 bb.position(bb.position() + 16); // jump to first record prefix AFI
166 assertEquals(0, bb.getShort());
168 bb.position(bb.position() + 10); // jump to second record prefix AFI
169 assertEquals(0, bb.getShort());
171 bb.position(bb.position() + 10); // jump to third record prefix AFI
172 assertEquals(0, bb.getShort());
176 public void deserialize__AllFields() throws Exception {
177 // LISP(Type = 3 Map-Register, P=1, M=1
179 // Nonce: (something)
181 // AuthDataLength: 00 Data:
182 // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
184 // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
185 // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
187 MapRegister mr = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 01 FF BB "
189 + "00 00 00 00 00 00 00 00 00 00 00 00 " //
190 + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
191 + "ff 00 00 05 00 01 c0 a8 88 0a"));
193 assertTrue(mr.isProxyMapReply());
194 assertTrue(mr.isWantMapNotify());
196 assertEquals(1, mr.getEidToLocatorRecord().size());
197 assertEquals(0xFFBB000000000000L, mr.getNonce().longValue());
198 assertEquals(0x0000, mr.getKeyId().shortValue());
199 byte[] expectedAuthenticationData = {};
200 ArrayAssert.assertEquals(expectedAuthenticationData, mr.getAuthenticationData());
204 public void deserialize__serialize() throws Exception {
205 ByteBuffer bb = hexToByteBuffer("32 00 01 01 63 99 "
206 + "83 64 23 06 a8 be 00 01 00 14 b8 c2 a2 e1 dc 4a "
207 + "08 0c f6 01 b0 9d 70 5a d4 88 95 f8 73 dd 00 00 "
208 + "05 a0 01 20 10 00 00 00 40 03 00 00 02 20 00 0a "
209 + "00 00 00 01 00 01 c3 a8 c8 01 0a 32 ff 00 00 04 "
210 + "00 01 ac 10 01 02 15 1a 39 80 e3 35 e6 c4 49 a6 "
211 + "90 87 20 65 9a b7 00 00 00 00 00 00 00 00 ");
212 MapRegister mr = MapRegisterSerializer.getInstance().deserialize(bb);
214 assertTrue(mr.isXtrSiteIdPresent());
216 ArrayAssert.assertEquals(bb.array(), MapRegisterSerializer.getInstance().serialize(mr).array());
220 public void deserialize__MultipleRecords() throws Exception {
221 // LISP(Type = 3 Map-Register, P=1, M=1
223 // EID prefixes: 153.16.254.1 -- 152.16.254.1 -- 151.16.254.1 --
225 // Local RLOCs: 192.168.136.10 -- 192.168.136.11 -- 192.168.136.12 --
228 MapRegister mr = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 "
230 + "04 " // Record count
231 + "FF BB 00 00 00 00 00 00 00 01 00 14 87 c1 33 cd " //
232 + "d1 1e bc 80 fd 3e 71 11 81 17 40 74 26 25 44 bd " //
233 + "00 00 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " // Record
235 + "ff 00 00 05 00 01 c0 a8 88 0a " // contd
236 + "00 00 00 0a 01 20 10 00 00 00 00 01 98 10 fe 01 01 64 " // Record
238 + "ff 00 00 05 00 01 c0 a8 88 0b " // contd
239 + "00 00 00 0a 01 20 10 00 00 00 00 01 97 10 fe 01 01 64 " // Record
241 + "ff 00 00 05 00 01 c0 a8 88 0c " // contd
242 + "00 00 00 0a 01 20 10 00 00 00 00 01 96 10 fe 01 01 64 " // Record
244 + "ff 00 00 05 00 01 c0 a8 88 0d " // contd
247 assertEquals(4, mr.getEidToLocatorRecord().size());
248 assertEquals(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("153.16.254.1")), mr.getEidToLocatorRecord().get(0)
249 .getLispAddressContainer());
250 assertEquals(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("151.16.254.1")), mr.getEidToLocatorRecord().get(2)
251 .getLispAddressContainer());
252 assertEquals(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("192.168.136.11")), mr.getEidToLocatorRecord().get(1)
253 .getLocatorRecord().get(0).getLispAddressContainer());
254 assertEquals(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("192.168.136.13")), mr.getEidToLocatorRecord().get(3)
255 .getLocatorRecord().get(0).getLispAddressContainer());
259 public void deserialize__Locators() throws Exception {
260 MapRegister mr = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 01 "
262 + "FF BB 00 00 00 00 00 00 00 01 00 14 f1 b8 ab f0 " //
263 + "66 bb 2e ef 12 70 74 46 6f 6b 8e ca bf 1e 68 40 " //
265 + "03 " // Locator Count
266 + "20 10 00 00 00 00 01 99 10 fe 01 "
268 + "01 64 1f 00 " // priorities + weights
270 + "00 01 c0 a8 88 0a " // Locator
272 + "67 00 30 34 " // priorities + weights
274 + "00 01 cc aa AA 11 " // Locator
276 + "60 11 34 A4 " // priorities + weights
278 + "00 01 c0 a8 88 0a " // Locator
281 assertEquals(1, mr.getEidToLocatorRecord().size());
282 EidToLocatorRecord eidToLocator = mr.getEidToLocatorRecord().get(0);
283 assertEquals(3, eidToLocator.getLocatorRecord().size());
284 LocatorRecord loc0 = eidToLocator.getLocatorRecord().get(0);
285 LocatorRecord loc1 = eidToLocator.getLocatorRecord().get(1);
286 LocatorRecord loc2 = eidToLocator.getLocatorRecord().get(2);
287 assertEquals((byte) 0x01, loc0.getPriority().byteValue());
288 assertEquals((byte) 0x67, loc1.getPriority().byteValue());
289 assertEquals((byte) 0x60, loc2.getPriority().byteValue());
291 assertEquals((byte) 0x64, loc0.getWeight().byteValue());
292 assertEquals((byte) 0x00, loc1.getWeight().byteValue());
293 assertEquals((byte) 0x11, loc2.getWeight().byteValue());
295 assertEquals((byte) 0x1F, loc0.getMulticastPriority().byteValue());
296 assertEquals((byte) 0x30, loc1.getMulticastPriority().byteValue());
297 assertEquals((byte) 0x34, loc2.getMulticastPriority().byteValue());
299 assertEquals((byte) 0x00, loc0.getMulticastWeight().byteValue());
300 assertEquals((byte) 0x34, loc1.getMulticastWeight().byteValue());
301 assertEquals((byte) 0xA4, loc2.getMulticastWeight().byteValue());
303 assertTrue(loc0.isLocalLocator());
304 assertFalse(loc1.isLocalLocator());
305 assertFalse(loc2.isLocalLocator());
307 assertFalse(loc0.isRlocProbed());
308 assertTrue(loc1.isRlocProbed());
309 assertTrue(loc2.isRlocProbed());
311 assertTrue(loc0.isRouted());
312 assertFalse(loc1.isRouted());
313 assertTrue(loc2.isRouted());
315 assertEquals(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("192.168.136.10")), loc0.getLispAddressContainer());
316 assertEquals(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("204.170.170.17")), loc1.getLispAddressContainer());
320 public void deserialize__SomeEidToLocatorFiels() throws Exception {
321 // LISP(Type = 3 Map-Register, P=1, M=1
323 // EID prefixes: 153.16.254.1 -- 152.16.254.1 -- 151.16.254.1 --
325 // Local RLOCs: 192.168.136.10 -- 192.168.136.11 -- 192.168.136.12 --
328 MapRegister mr = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 "
330 + "04 " // Record count
331 + "FF BB 00 00 00 00 00 00 00 01 00 14 b9 cd 7b 89 " //
332 + "65 c2 56 03 be dd 81 20 47 e5 c3 4f 56 02 e1 59 " //
333 + "00 00 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " // Record
335 + "ff 00 00 05 00 01 c0 a8 88 0a " // contd
336 + "00 00 00 0b 01 17 50 00 01 11 00 01 98 10 fe 01 01 64 " // Record
338 + "ff 00 00 05 00 01 c0 a8 88 0b " // contd
339 + "00 00 00 0c 01 20 00 00 02 22 00 01 97 10 fe 01 01 64 " // Record
341 + "ff 00 00 05 00 01 c0 a8 88 0c " // contd
342 + "00 00 00 0d 01 20 20 00 03 33 00 01 96 10 fe 01 01 64 " // Record
344 + "ff 00 00 05 00 01 c0 a8 88 0d " // contd
347 assertEquals(4, mr.getEidToLocatorRecord().size());
349 EidToLocatorRecord record0 = mr.getEidToLocatorRecord().get(0);
350 EidToLocatorRecord record1 = mr.getEidToLocatorRecord().get(1);
351 EidToLocatorRecord record2 = mr.getEidToLocatorRecord().get(2);
352 EidToLocatorRecord record3 = mr.getEidToLocatorRecord().get(3);
354 assertEquals(10, record0.getRecordTtl().intValue());
355 assertEquals(13, record3.getRecordTtl().intValue());
357 assertEquals(32, record0.getMaskLength().intValue());
358 assertEquals(23, record1.getMaskLength().intValue());
360 assertEquals(Action.NoAction, record0.getAction());
361 assertEquals(Action.SendMapRequest, record1.getAction());
362 assertEquals(Action.NoAction, record2.getAction());
363 assertEquals(Action.NativelyForward, record3.getAction());
365 assertTrue(record0.isAuthoritative());
366 assertTrue(record1.isAuthoritative());
367 assertFalse(record2.isAuthoritative());
368 assertFalse(record3.isAuthoritative());
370 assertEquals(0x000, record0.getMapVersion().shortValue());
371 assertEquals(0x111, record1.getMapVersion().shortValue());
372 assertEquals(0x222, record2.getMapVersion().shortValue());
373 assertEquals(0x333, record3.getMapVersion().shortValue());
377 public void deserialize__IllegalAction() throws Exception {
378 MapRegister mr = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 01 FF BB "
380 + "00 00 00 00 00 00 00 01 00 14 ec 47 1e 53 25 91 " //
381 + "2f 68 10 75 13 dd 2c e8 6e 3c ac 94 ed e4 00 00 " //
382 + "00 0a 01 20 F0 00 00 00 00 01 99 10 fe 01 01 64 " //
383 + "ff 00 00 05 00 01 c0 a8 88 0a"));
385 assertEquals(1, mr.getEidToLocatorRecord().size());
386 assertEquals(Action.NoAction, mr.getEidToLocatorRecord().get(0).getAction());
389 @Test(expected = LispSerializationException.class)
390 public void deserialize_WrongAuthenticationLength() throws Exception {
391 // LISP(Type = 3 Map-Register, P=1, M=1
393 // Nonce: (something)
395 // AuthDataLength: 20 Data:
396 // e8:f5:0b:c5:c5:f2:b0:21:27:a8:a5:68:89:ec
397 // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
399 // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
400 // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
402 MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 01 FF BB "
404 + "00 00 00 00 00 00 00 00 00 14 e8 f5 0b c5 c5 f2 " //
405 + "b0 21 27 a8 21 a5 68 89 ec 00 00 " //
406 + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
407 + "ff 00 00 05 00 01 c0 a8 88 0a"));
411 public void deserialize__SHA1() throws Exception {
412 // LISP(Type = 3 Map-Register, P=1, M=1
414 // Nonce: (something)
416 // AuthDataLength: 20 Data:
417 // b2:dd:1a:25:c0:60:b1:46:e8:dc:6d:a6:ae:2e:92:92:a6:ca:b7:9d
418 // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
420 // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
421 // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
423 MapRegister mr = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 01 FF BB "
425 + "00 00 00 00 00 00 00 01 00 14 2c 61 b9 c9 9a 20 " //
426 + "ba d8 f5 40 d3 55 6f 5f 6e 5a b2 0a bf b5 00 00 " //
427 + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
428 + "ff 00 00 05 00 01 c0 a8 88 0a"));
430 assertTrue(mr.isProxyMapReply());
431 assertTrue(mr.isWantMapNotify());
433 assertEquals(1, mr.getEidToLocatorRecord().size());
434 assertEquals(0xFFBB000000000000L, mr.getNonce().longValue());
435 assertEquals(0x0001, mr.getKeyId().shortValue());
436 byte[] expectedAuthenticationData = { (byte) 0x2c, (byte) 0x61, (byte) 0xb9, (byte) 0xc9, (byte) 0x9a, (byte) 0x20, (byte) 0xba, (byte) 0xd8, //
437 (byte) 0xf5, (byte) 0x40, (byte) 0xd3, (byte) 0x55, (byte) 0x6f, (byte) 0x5f, (byte) 0x6e, (byte) 0x5a, //
438 (byte) 0xb2, (byte) 0x0a, (byte) 0xbf, (byte) 0xb5 };
439 ArrayAssert.assertEquals(expectedAuthenticationData, mr.getAuthenticationData());
443 public void deserialize__SHA256() throws Exception {
444 // LISP(Type = 3 Map-Register, P=1, M=1
446 // Nonce: (something)
448 // AuthDataLength: 32 Data:
449 // 70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d 68 a5 bf 32 11 c9 7b
450 // 58 c4 b9 9f 06 11 23 b9 38
451 // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
453 // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
454 // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
456 MapRegister mr = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 01 FF BB "
458 + "00 00 00 00 00 00 00 02 00 20 70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d 68 a5 bf 32 "
460 + "11 c9 7b 58 c4 b9 9f 06 11 23 b9 38 00 00 " //
461 + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
462 + "ff 00 00 05 00 01 c0 a8 88 0a"));
464 assertTrue(mr.isProxyMapReply());
465 assertTrue(mr.isWantMapNotify());
467 assertEquals(1, mr.getEidToLocatorRecord().size());
468 assertEquals(0xFFBB000000000000L, mr.getNonce().longValue());
469 assertEquals(0x0002, mr.getKeyId().shortValue());
470 byte[] expectedAuthenticationData = { (byte) 0x70, (byte) 0x30, (byte) 0xd4, (byte) 0xc6, (byte) 0x10, (byte) 0x44, (byte) 0x0d, (byte) 0x83,
471 (byte) 0xbe, (byte) 0x4d, (byte) 0xbf, (byte) 0xfd, (byte) 0xa9, (byte) 0x8c, (byte) 0x57, (byte) 0x6d, (byte) 0x68, (byte) 0xa5,
472 (byte) 0xbf, (byte) 0x32, (byte) 0x11, (byte) 0xc9, (byte) 0x7b, (byte) 0x58, (byte) 0xc4, (byte) 0xb9, (byte) 0x9f, (byte) 0x06,
473 (byte) 0x11, (byte) 0x23, (byte) 0xb9, (byte) 0x38 };
474 ArrayAssert.assertEquals(expectedAuthenticationData, mr.getAuthenticationData());