Bump versions by x.(y+1).z
[lispflowmapping.git] / mappingservice / lisp-proto / src / test / java / org / opendaylight / lispflowmapping / serializer / MapNotifySerializationTest.java
1 /*
2  * Copyright (c) 2014 Contextream, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.lispflowmapping.serializer;
9
10 import static org.junit.Assert.assertArrayEquals;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertTrue;
14 import static org.opendaylight.lispflowmapping.TestUtils.assertHexEquals;
15 import static org.opendaylight.lispflowmapping.TestUtils.hexToByteBuffer;
16
17 import java.nio.ByteBuffer;
18 import java.util.ArrayList;
19 import org.junit.Test;
20 import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
21 import org.opendaylight.lispflowmapping.lisp.serializer.exception.LispSerializationException;
22 import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
23 import org.opendaylight.lispflowmapping.lisp.util.MaskUtil;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.container.MappingRecord;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.container.MappingRecord.Action;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.container.MappingRecordBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.list.MappingRecordItem;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.list.MappingRecordItemBuilder;
32
33 public class MapNotifySerializationTest {
34
35     @Test
36     public void serialize__Fields() throws Exception {
37         MapNotifyBuilder mnBuilder = new MapNotifyBuilder();
38         mnBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
39         mnBuilder.getMappingRecordItem().add(
40                 new MappingRecordItemBuilder().setMappingRecord(
41                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32")).build())
42                                 .setMappingRecordItemId("xyzzy").build());
43         mnBuilder.getMappingRecordItem().add(
44                 new MappingRecordItemBuilder().setMappingRecord(
45                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.73/32")).build())
46                                 .setMappingRecordItemId("xyzzy").build());
47
48         mnBuilder.setNonce(6161616161L);
49         mnBuilder.setKeyId((short) 0x0001);
50         byte[] authenticationData = new byte[] { (byte) 0x16, (byte) 0x98, (byte) 0x96, (byte) 0xeb, (byte) 0x88,
51             (byte) 0x2d, (byte) 0x4d, (byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64,
52             (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba, (byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
53         mnBuilder.setAuthenticationData(authenticationData);
54
55         ByteBuffer bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
56         assertHexEquals((byte) 0x40, bb.get()); // Type + MSByte of reserved
57         assertEquals(0, bb.getShort()); // Rest of reserved
58         assertEquals(2, bb.get()); // Record Count
59         assertEquals(6161616161L, bb.getLong()); // Nonce
60         assertHexEquals((short) 0x0001, bb.getShort()); // Key ID
61         assertEquals(authenticationData.length, bb.getShort());
62
63         byte[] actualAuthenticationData = new byte[20];
64         bb.get(actualAuthenticationData);
65         assertArrayEquals(authenticationData, actualAuthenticationData);
66
67         bb.position(bb.position() + 12); /* EID in first record */
68         assertEquals(0x1, bb.getInt());
69
70         bb.position(bb.position() + 12); /* EID in second record */
71         assertEquals(73, bb.getInt());
72
73         assertEquals(bb.position(), bb.capacity());
74     }
75
76     @Test
77     public void serialize__deserialize() throws Exception {
78         MapNotifyBuilder mnBuilder = new MapNotifyBuilder();
79         mnBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
80         mnBuilder.getMappingRecordItem().add(
81                 new MappingRecordItemBuilder().setMappingRecord(
82                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32")).build())
83                                 .setMappingRecordItemId("xyzzy").build());
84         mnBuilder.getMappingRecordItem().add(
85                 new MappingRecordItemBuilder().setMappingRecord(
86                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.73/32")).build())
87                                 .setMappingRecordItemId("xyzzy").build());
88
89         mnBuilder.setNonce(6161616161L);
90         mnBuilder.setKeyId((short) 0x0001);
91         byte[] authenticationData = new byte[] { (byte) 0x16, (byte) 0x98, (byte) 0x96, (byte) 0xeb, (byte) 0x88,
92             (byte) 0x2d, (byte) 0x4d, (byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64,
93             (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba, (byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
94         mnBuilder.setAuthenticationData(authenticationData);
95
96         MapNotify mn = mnBuilder.build();
97         assertArrayEquals(MapNotifySerializer.getInstance().serialize(mn).array(),
98                 MapNotifySerializer.getInstance().serialize(MapNotifySerializer.getInstance()
99                         .deserialize(MapNotifySerializer.getInstance().serialize(mn))).array());
100
101     }
102
103     @Test
104     public void deserialize__AllFields() throws Exception {
105         // LISP(Type = 4 Map-Notify, I=1
106         // Record Counter: 1
107         // Nonce: (something)
108         // Key ID: 0x0000
109         // AuthDataLength: 00 Data:
110         // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
111         // No-Action
112         // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
113         // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
114         // xTR-ID 1
115         // Site-ID 1
116         MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("48 00 00 01 FF BB "
117                 + "00 00 00 00 00 00 00 00 00 00 00 00 "
118                 + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
119                 + "ff 00 00 05 00 01 c0 a8 88 0a "
120                 + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 " // xTR-ID
121                 + "00 00 00 00 00 00 00 01 " // Site-ID
122                 ));
123
124
125         assertTrue(mn.getXtrSiteIdPresent());
126
127         assertEquals(1, mn.getMappingRecordItem().size());
128         assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
129         assertEquals(0x0000, mn.getKeyId().shortValue());
130         byte[] expectedAuthenticationData = {};
131         assertArrayEquals(expectedAuthenticationData, mn.getAuthenticationData());
132     }
133
134     @Test
135     public void serialize__NoAuthenticationData() throws Exception {
136         MapNotifyBuilder mnBuilder = new MapNotifyBuilder();
137         mnBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
138         mnBuilder.getMappingRecordItem().add(
139                 new MappingRecordItemBuilder().setMappingRecord(
140                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32"))
141                         .setRecordTtl(55).build()).setMappingRecordItemId("xyzzy").build());
142
143         ByteBuffer bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
144         bb.position(bb.position() + 14); // jump to AuthenticationDataLength
145         assertEquals(0, bb.getShort());
146         assertEquals(55, bb.getInt());
147
148         mnBuilder.setAuthenticationData(null);
149
150         bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
151         bb.position(bb.position() + 14); // jump to AuthenticationDataLength
152         assertEquals(0, bb.getShort());
153         assertEquals(55, bb.getInt());
154
155         mnBuilder.setAuthenticationData(new byte[0]);
156
157         bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
158         bb.position(bb.position() + 14); // jump to AuthenticationDataLength
159         assertEquals(0, bb.getShort());
160         assertEquals(55, bb.getInt());
161     }
162
163     @Test
164     public void serialize__NoPrefixInEidToLocator() throws Exception {
165         MapNotifyBuilder mnBuilder = new MapNotifyBuilder();
166         mnBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
167         mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(
168                 new MappingRecordBuilder().build()).setMappingRecordItemId("xyzzy").build());
169         mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(
170                 new MappingRecordBuilder().setEid(null).build()).setMappingRecordItemId("xyzzy").build());
171         mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(
172                 new MappingRecordBuilder().setEid(LispAddressUtil.getNoAddressEid()).build())
173                     .setMappingRecordItemId("xyzzy").build());
174
175         ByteBuffer bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
176         bb.position(bb.position() + 16); // jump to first record prefix AFI
177         assertEquals(0, bb.getShort());
178
179         bb.position(bb.position() + 10); // jump to second record prefix AFI
180         assertEquals(0, bb.getShort());
181
182         bb.position(bb.position() + 10); // jump to third record prefix AFI
183         assertEquals(0, bb.getShort());
184     }
185
186     @Test
187     public void deserialize__MultipleRecords() throws Exception {
188         // LISP(Type = 4 Map-Notify, I=1
189         // Record Counter: 4
190         // EID prefixes: 153.16.254.1 -- 152.16.254.1 -- 151.16.254.1 --
191         // 150.16.254.1
192         // Local RLOCs: 192.168.136.10 -- 192.168.136.11 -- 192.168.136.12 --
193         // 192.168.136.13
194         //
195         MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 "
196                 + "04 " // Record count
197                 + "FF BB 00 00 00 00 00 00 00 01 00 14 87 c1 33 cd "
198                 + "d1 1e bc 80 fd 3e 71 11 81 17 40 74 26 25 44 bd "
199                 + "00 00 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " // Record
200                 // 1
201                 + "ff 00 00 05 00 01 c0 a8 88 0a " // contd
202                 + "00 00 00 0a 01 20 10 00 00 00 00 01 98 10 fe 01 01 64 " // Record
203                 // 2
204                 + "ff 00 00 05 00 01 c0 a8 88 0b " // contd
205                 + "00 00 00 0a 01 20 10 00 00 00 00 01 97 10 fe 01 01 64 " // Record
206                 // 3
207                 + "ff 00 00 05 00 01 c0 a8 88 0c " // contd
208                 + "00 00 00 0a 01 20 10 00 00 00 00 01 96 10 fe 01 01 64 " // Record
209                 // 4
210                 + "ff 00 00 05 00 01 c0 a8 88 0d " // contd
211         ));
212
213         assertEquals(4, mn.getMappingRecordItem().size());
214         assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("153.16.254.1/32"), mn.getMappingRecordItem().get(0)
215                 .getMappingRecord().getEid());
216         assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("151.16.254.1/32"), mn.getMappingRecordItem().get(2)
217                 .getMappingRecord().getEid());
218         assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.11"), mn.getMappingRecordItem().get(1)
219                 .getMappingRecord().getLocatorRecord().get(0).getRloc());
220         assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.13"), mn.getMappingRecordItem().get(3)
221                 .getMappingRecord().getLocatorRecord().get(0).getRloc());
222     }
223
224     @Test
225     public void deserialize__Locators() throws Exception {
226         MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 01 01 "
227                 + "FF BB 00 00 00 00 00 00 00 01 00 14 f1 b8 ab f0 "
228                 + "66 bb 2e ef 12 70 74 46 6f 6b 8e ca bf 1e 68 40 "
229                 + "00 00 00 0a "
230                 + "03 " // Locator Count
231                 + "20 10 00 00 00 00 01 99 10 fe 01 "
232                 // Locator 1
233                 + "01 64 1f 00 " // priorities + weights
234                 + "00 05 " // Flags
235                 + "00 01 c0 a8 88 0a " // Locator
236                 // Locator 2
237                 + "67 00 30 34 " // priorities + weights
238                 + "00 02 " // Flags
239                 + "00 01 cc aa AA 11 " // Locator
240                 // Locator 3
241                 + "60 11 34 A4 " // priorities + weights
242                 + "00 03 " // Flags
243                 + "00 01 c0 a8 88 0a " // Locator
244         ));
245
246         assertEquals(1, mn.getMappingRecordItem().size());
247         MappingRecordItem eidToLocator = mn.getMappingRecordItem().get(0);
248         assertEquals(3, eidToLocator.getMappingRecord().getLocatorRecord().size());
249         LocatorRecord loc0 = eidToLocator.getMappingRecord().getLocatorRecord().get(0);
250         LocatorRecord loc1 = eidToLocator.getMappingRecord().getLocatorRecord().get(1);
251         LocatorRecord loc2 = eidToLocator.getMappingRecord().getLocatorRecord().get(2);
252         assertEquals((byte) 0x01, loc0.getPriority().byteValue());
253         assertEquals((byte) 0x67, loc1.getPriority().byteValue());
254         assertEquals((byte) 0x60, loc2.getPriority().byteValue());
255
256         assertEquals((byte) 0x64, loc0.getWeight().byteValue());
257         assertEquals((byte) 0x00, loc1.getWeight().byteValue());
258         assertEquals((byte) 0x11, loc2.getWeight().byteValue());
259
260         assertEquals((byte) 0x1F, loc0.getMulticastPriority().byteValue());
261         assertEquals((byte) 0x30, loc1.getMulticastPriority().byteValue());
262         assertEquals((byte) 0x34, loc2.getMulticastPriority().byteValue());
263
264         assertEquals((byte) 0x00, loc0.getMulticastWeight().byteValue());
265         assertEquals((byte) 0x34, loc1.getMulticastWeight().byteValue());
266         assertEquals((byte) 0xA4, loc2.getMulticastWeight().byteValue());
267
268         assertTrue(loc0.getLocalLocator());
269         assertFalse(loc1.getLocalLocator());
270         assertFalse(loc2.getLocalLocator());
271
272         assertFalse(loc0.getRlocProbed());
273         assertTrue(loc1.getRlocProbed());
274         assertTrue(loc2.getRlocProbed());
275
276         assertTrue(loc0.getRouted());
277         assertFalse(loc1.getRouted());
278         assertTrue(loc2.getRouted());
279
280         assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.10"), loc0.getRloc());
281         assertEquals(LispAddressUtil.asIpv4Rloc("204.170.170.17"), loc1.getRloc());
282     }
283
284     @Test
285     public void deserialize__SomeEidToLocatorFiels() throws Exception {
286         // LISP(Type = 4 Map-Notify, I=0
287         // Record Counter: 4
288         // EID prefixes: 153.16.254.1 -- 152.16.254.1 -- 151.16.254.1 --
289         // 150.16.254.1
290         // Local RLOCs: 192.168.136.10 -- 192.168.136.11 -- 192.168.136.12 --
291         // 192.168.136.13
292         //
293         MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 "
294         //
295                 + "04 " // Record count
296                 + "FF BB 00 00 00 00 00 00 00 01 00 14 b9 cd 7b 89 " //
297                 + "65 c2 56 03 be dd 81 20 47 e5 c3 4f 56 02 e1 59 " //
298                 + "00 00 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " // Record
299                 // 0
300                 + "ff 00 00 05 00 01 c0 a8 88 0a " // contd
301                 + "00 00 00 0b 01 17 50 00 01 11 00 01 98 10 fe 01 01 64 " // Record
302                 // 1
303                 + "ff 00 00 05 00 01 c0 a8 88 0b " // contd
304                 + "00 00 00 0c 01 20 00 00 02 22 00 01 97 10 fe 01 01 64 " // Record
305                 // 2
306                 + "ff 00 00 05 00 01 c0 a8 88 0c " // contd
307                 + "00 00 00 0d 01 20 20 00 03 33 00 01 96 10 fe 01 01 64 " // Record
308                 // 3
309                 + "ff 00 00 05 00 01 c0 a8 88 0d " // contd
310         ));
311
312         assertEquals(4, mn.getMappingRecordItem().size());
313
314         final MappingRecord record0 = mn.getMappingRecordItem().get(0).getMappingRecord();
315         final MappingRecord record1 = mn.getMappingRecordItem().get(1).getMappingRecord();
316         final MappingRecord record2 = mn.getMappingRecordItem().get(2).getMappingRecord();
317         final MappingRecord record3 = mn.getMappingRecordItem().get(3).getMappingRecord();
318
319         assertEquals(10, record0.getRecordTtl().intValue());
320         assertEquals(13, record3.getRecordTtl().intValue());
321
322         assertEquals(32, MaskUtil.getMaskForAddress(record0.getEid().getAddress()));
323         assertEquals(23, MaskUtil.getMaskForAddress(record1.getEid().getAddress()));
324
325         assertEquals(Action.NoAction, record0.getAction());
326         assertEquals(Action.SendMapRequest, record1.getAction());
327         assertEquals(Action.NoAction, record2.getAction());
328         assertEquals(Action.NativelyForward, record3.getAction());
329
330         assertTrue(record0.getAuthoritative());
331         assertTrue(record1.getAuthoritative());
332         assertFalse(record2.getAuthoritative());
333         assertFalse(record3.getAuthoritative());
334
335         assertEquals(0x000, record0.getMapVersion().shortValue());
336         assertEquals(0x111, record1.getMapVersion().shortValue());
337         assertEquals(0x222, record2.getMapVersion().shortValue());
338         assertEquals(0x333, record3.getMapVersion().shortValue());
339     }
340
341     @Test
342     public void deserialize__IllegalAction() throws Exception {
343         MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 01 01 FF BB "
344                 + "00 00 00 00 00 00 00 01 00 14 ec 47 1e 53 25 91 "
345                 + "2f 68 10 75 13 dd 2c e8 6e 3c ac 94 ed e4 00 00 "
346                 + "00 0a 01 20 F0 00 00 00 00 01 99 10 fe 01 01 64 "
347                 + "ff 00 00 05 00 01 c0 a8 88 0a"));
348
349         assertEquals(1, mn.getMappingRecordItem().size());
350         assertEquals(Action.NoAction, mn.getMappingRecordItem().get(0).getMappingRecord().getAction());
351     }
352
353     @Test(expected = LispSerializationException.class)
354     public void deserialize_WrongAuthenticationLength() throws Exception {
355         // LISP(Type = 4 Map-Notify, I=0
356         // Record Counter: 1
357         // Nonce: (something)
358         // Key ID: 0x0000
359         // AuthDataLength: 20 Data:
360         // e8:f5:0b:c5:c5:f2:b0:21:27:a8:a5:68:89:ec
361         // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
362         // No-Action
363         // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
364         // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
365         //
366         MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("48 00 00 01 FF BB "
367                 + "00 00 00 00 00 00 00 00 00 14 e8 f5 0b c5 c5 f2 "
368                 + "b0 21 27 a8 21 a5 68 89 ec 00 00 "
369                 + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
370                 + "ff 00 00 05 00 01 c0 a8 88 0a"));
371     }
372
373     @Test
374     public void deserialize__SHA1() throws Exception {
375         // LISP(Type = 4 Map-Notify, I=0
376         // Record Counter: 1
377         // Nonce: (something)
378         // Key ID: 0x0001
379         // AuthDataLength: 20 Data:
380         // b2:dd:1a:25:c0:60:b1:46:e8:dc:6d:a6:ae:2e:92:92:a6:ca:b7:9d
381         // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
382         // No-Action
383         // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
384         // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
385         //
386         MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 01 FF BB "
387                 + "00 00 00 00 00 00 00 01 00 14 2c 61 b9 c9 9a 20 "
388                 + "ba d8 f5 40 d3 55 6f 5f 6e 5a b2 0a bf b5 00 00 "
389                 + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
390                 + "ff 00 00 05 00 01 c0 a8 88 0a"));
391
392         assertFalse(mn.getXtrSiteIdPresent());
393
394         assertEquals(1, mn.getMappingRecordItem().size());
395         assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
396         assertEquals(0x0001, mn.getKeyId().shortValue());
397         byte[] expectedAuthenticationData = { (byte) 0x2c, (byte) 0x61, (byte) 0xb9, (byte) 0xc9, (byte) 0x9a,
398             (byte) 0x20, (byte) 0xba, (byte) 0xd8, (byte) 0xf5, (byte) 0x40, (byte) 0xd3, (byte) 0x55, (byte) 0x6f,
399             (byte) 0x5f, (byte) 0x6e, (byte) 0x5a, (byte) 0xb2, (byte) 0x0a, (byte) 0xbf, (byte) 0xb5 };
400         assertArrayEquals(expectedAuthenticationData, mn.getAuthenticationData());
401     }
402
403     @Test
404     public void deserialize__SHA256() throws Exception {
405         // LISP(Type = 4 Map-Notify, I=0
406         // Record Counter: 1
407         // Nonce: (something)
408         // Key ID: 0x0002
409         // AuthDataLength: 32 Data:
410         // 70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d 68 a5 bf 32 11 c9 7b
411         // 58 c4 b9 9f 06 11 23 b9 38
412         // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
413         // No-Action
414         // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
415         // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
416         //
417         MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 01 FF BB "
418                 + "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 "
419                 + "11 c9 7b 58 c4 b9 9f 06 11 23 b9 38 00 00 "
420                 + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
421                 + "ff 00 00 05 00 01 c0 a8 88 0a"));
422
423         assertFalse(mn.getXtrSiteIdPresent());
424
425         assertEquals(1, mn.getMappingRecordItem().size());
426         assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
427         assertEquals(0x0002, mn.getKeyId().shortValue());
428         byte[] expectedAuthenticationData = { (byte) 0x70, (byte) 0x30, (byte) 0xd4, (byte) 0xc6, (byte) 0x10,
429             (byte) 0x44, (byte) 0x0d, (byte) 0x83, (byte) 0xbe, (byte) 0x4d, (byte) 0xbf, (byte) 0xfd, (byte) 0xa9,
430             (byte) 0x8c, (byte) 0x57, (byte) 0x6d, (byte) 0x68, (byte) 0xa5, (byte) 0xbf, (byte) 0x32, (byte) 0x11,
431             (byte) 0xc9, (byte) 0x7b, (byte) 0x58, (byte) 0xc4, (byte) 0xb9, (byte) 0x9f, (byte) 0x06, (byte) 0x11,
432             (byte) 0x23, (byte) 0xb9, (byte) 0x38 };
433         assertArrayEquals(expectedAuthenticationData, mn.getAuthenticationData());
434     }
435 }