dc05fd61eefcb7a4355ec31b24d39974779c7b68
[lispflowmapping.git] / mappingservice / southbound / src / test / java / org / opendaylight / lispflowmapping / southbound / lisp / LispSouthboundServiceTest.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
9 package org.opendaylight.lispflowmapping.southbound.lisp;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertTrue;
14
15 import java.net.DatagramPacket;
16 import java.nio.ByteBuffer;
17 import java.util.ArrayList;
18 import java.util.Arrays;
19 import java.util.List;
20
21 import junitx.framework.ArrayAssert;
22 import junitx.framework.Assert;
23
24 import org.apache.commons.lang3.ArrayUtils;
25 import org.jmock.api.Invocation;
26 import org.junit.Before;
27 import org.junit.Ignore;
28 import org.junit.Test;
29 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
30 import org.opendaylight.lispflowmapping.lisp.type.AddressFamilyNumberEnum;
31 import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
32 import org.opendaylight.lispflowmapping.lisp.type.LispMessageEnum;
33 import org.opendaylight.lispflowmapping.lisp.util.ByteUtil;
34 import org.opendaylight.lispflowmapping.lisp.util.LispAFIConvertor;
35 import org.opendaylight.lispflowmapping.lisp.util.MapNotifyBuilderHelper;
36 import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
37 import org.opendaylight.lispflowmapping.lisp.serializer.MapReplySerializer;
38 import org.opendaylight.lispflowmapping.southbound.lisp.exception.LispMalformedPacketException;
39 import org.opendaylight.lispflowmapping.tools.junit.BaseTestCase;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.EidToLocatorRecord.Action;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.RequestMapping;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eidrecords.EidRecord;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eidtolocatorrecords.EidToLocatorRecord;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eidtolocatorrecords.EidToLocatorRecordBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.lispaddress.LispAddressContainer;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder;
53 import org.opendaylight.yangtools.yang.binding.Notification;
54
55 public class LispSouthboundServiceTest extends BaseTestCase {
56
57     private LispSouthboundService testedLispService;
58     private NotificationPublishService nps;
59     private byte[] mapRequestPacket;
60     private byte[] mapRegisterPacket;
61     private ValueSaverAction<Notification> lispNotificationSaver;
62     // private ValueSaverAction<MapRegister> mapRegisterSaver;
63     // private ValueSaverAction<MapRequest> mapRequestSaver;
64     private MapNotifyBuilder mapNotifyBuilder;
65     private MapReplyBuilder mapReplyBuilder;
66     private EidToLocatorRecordBuilder eidToLocatorBuilder;
67
68     private interface MapReplyIpv4SingleLocatorPos {
69         int RECORD_COUNT = 3;
70         int NONCE = 4;
71         int LOCATOR_COUNT = 16;
72         int EID_MASK_LEN = 17;
73         int AFI_TYPE = 22;
74         int EID_PREFIX = 24;
75         int LOC_AFI = 34;
76         int LOCATOR_RBIT = 33;
77         int LOCATOR = 36;
78     }
79
80     private interface MapReplyIpv4SecondLocatorPos {
81         int FIRST_LOCATOR_IPV4_LENGTH = 12;
82         int LOC_AFI = MapReplyIpv4SingleLocatorPos.LOC_AFI + FIRST_LOCATOR_IPV4_LENGTH;
83         int LOCATOR_RBIT = MapReplyIpv4SingleLocatorPos.LOCATOR_RBIT + FIRST_LOCATOR_IPV4_LENGTH;
84         int LOCATOR = MapReplyIpv4SingleLocatorPos.LOCATOR + FIRST_LOCATOR_IPV4_LENGTH;
85     }
86
87     @Override
88     @Before
89     public void before() throws Exception {
90         super.before();
91         // mapResolver = context.mock(IMapResolver.class);
92         // mapServer = context.mock(IMapServer.class);
93         testedLispService = new LispSouthboundService(null);
94         nps = context.mock(NotificationPublishService.class);
95         testedLispService.setNotificationProvider(nps);
96         lispNotificationSaver = new ValueSaverAction<Notification>();
97         // mapRegisterSaver = new ValueSaverAction<MapRegister>();
98         // mapRequestSaver = new ValueSaverAction<MapRequest>();
99         // SRC: 127.0.0.1:58560 to 127.0.0.1:4342
100         // LISP(Type = 8 - Encapsulated)
101         // IP: 192.168.136.10 -> 1.2.3.4
102         // UDP: 56756
103         // LISP(Type = 1 Map-Request
104         // Record Count: 1
105         // ITR-RLOC count: 0
106         // Source EID AFI: 0
107         // Source EID not present
108         // Nonce: 0x3d8d2acd39c8d608
109         // ITR-RLOC AFI=1 Address=192.168.136.10
110         // Record 1: 1.2.3.4/32
111         mapRequestPacket = extractWSUdpByteArray(new String("0000   00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 " //
112                 + "0010   00 58 00 00 40 00 40 11 3c 93 7f 00 00 01 7f 00 "
113                 + "0020   00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 "
114                 + "0030   00 38 d4 31 00 00 ff 11 56 f3 c0 a8 88 0a 01 02 "
115                 + "0040   03 04 dd b4 10 f6 00 24 ef 3a 10 00 00 01 3d 8d "
116                 + "0050   2a cd 39 c8 d6 08 00 01 01 02 03 04 00 01 c0 a8 88 0a 00 20 " //
117                 + "0060   00 01 01 02 03 04"));
118         mapReplyBuilder = new MapReplyBuilder();
119         mapReplyBuilder.setEidToLocatorRecord(new ArrayList<EidToLocatorRecord>());
120         mapReplyBuilder.setNonce((long) 0);
121         mapReplyBuilder.setEchoNonceEnabled(false);
122         mapReplyBuilder.setProbe(true);
123         mapReplyBuilder.setSecurityEnabled(true);
124         eidToLocatorBuilder = new EidToLocatorRecordBuilder();
125         String ip = "0.0.0.0";
126         eidToLocatorBuilder.setLispAddressContainer(LispAFIConvertor.asIPv4Prefix(ip, 0));
127         eidToLocatorBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
128         eidToLocatorBuilder.setRecordTtl(10);
129         eidToLocatorBuilder.setMapVersion((short) 0);
130         eidToLocatorBuilder.setMaskLength((short) 0);
131         eidToLocatorBuilder.setAction(Action.NativelyForward);
132         eidToLocatorBuilder.setAuthoritative(false);
133         // eidToLocatorBuilder.setPrefix(new LispIpv4Address(0));
134         // mapReply.addEidToLocator(eidToLocatorBuilder);
135
136         // IP: 192.168.136.10 -> 128.223.156.35
137         // UDP: 49289 -> 4342
138         // LISP(Type = 3 Map-Register, P=1, M=1
139         // Record Counter: 1
140         // Nonce: 0
141         // Key ID: 0x0001
142         // AuthDataLength: 20 Data:
143         // e8:f5:0b:c5:c5:f2:b0:21:27:a8:21:41:04:f3:46:5a:a5:68:89:ec
144         // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
145         // No-Action
146         // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
147         // Priority/Weight: 1/100, Multicast Priority/Weight:
148         // 255/0
149         //
150
151         mapRegisterPacket = extractWSUdpByteArray(new String("0000   00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " //
152                 + "0010   00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df "
153                 + "0020   9c 23 d6 40 10 f6 00 48 59 a4 38 00 01 01 00 00 "
154                 + "0030   00 00 00 00 00 00 00 01 00 14 0e a4 c6 d8 a4 06 "
155                 + "0040   71 7c 33 a4 5c 4a 83 1c de 74 53 03 0c ad 00 00 "
156                 + "0050   00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
157                 + "0060   ff 00 00 05 00 01 c0 a8 88 0a"));
158         mapNotifyBuilder = new MapNotifyBuilder();
159         mapNotifyBuilder.setAuthenticationData(new byte[0]);
160     }
161
162     @Test
163     @Ignore
164     public void todos() throws Exception {
165
166         // TODO: MapRequest: usage of Map-Reply-Record in MapRequest packet.
167         // TODO: Non-Encapsulated packets
168     }
169
170     @Test(expected = LispMalformedPacketException.class)
171     public void mapRegister__IllegalPacket() throws Exception {
172         mapRegisterPacket = extractWSUdpByteArray(new String("0000   00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 "
173                 + "0010   00 68 00 00 40 00 40 11 26 15 0a 01 00 6e 0a 01 " //
174                 + "0020   00 01 10 f6 10 f6 00 54 03 3b 38 00 01 01 00 00 "));
175
176         handleMapRegisterPacket(mapRegisterPacket);
177     }
178
179     @Test(expected = LispMalformedPacketException.class)
180     public void mapRequest__IllegalPacket() throws Exception {
181         mapRequestPacket = extractWSUdpByteArray(new String("0000   00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 " //
182                 + "0010   00 58 00 00 40 00 40 11 3c 93 7f 00 00 01 7f 00 "
183                 + "0020   00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 "
184                 + "0030   00 38 d4 31 00 00 ff 11 56 f3 c0 a8 88 0a 01 02 " //
185                 + "0040   03 04 dd b4 10 f6 00 24 ef 3a 10 00 00 01 3d 8d "));
186         handleMapRequestPacket(mapRequestPacket);
187     }
188
189     @Test(expected = LispMalformedPacketException.class)
190     public void mapRequest__IllegalEncapsulatedPacket() throws Exception {
191         mapRequestPacket = extractWSUdpByteArray(new String("0000   00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 " //
192                 + "0010   00 58 00 00 40 00 40 11 3c 93 7f 00 00 01 7f 00 " //
193                 + "0020   00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 "));
194         handleMapRequestPacket(mapRequestPacket);
195     }
196
197     private MapRegister lastMapRegister() {
198         assertTrue(lispNotificationSaver.lastValue instanceof AddMapping);
199         AddMapping lastValue = (AddMapping) lispNotificationSaver.lastValue;
200         return lastValue.getMapRegister();
201     }
202
203     private MapRequest lastMapRequest() {
204         RequestMapping lastValue = (RequestMapping) lispNotificationSaver.lastValue;
205         return lastValue.getMapRequest();
206     }
207
208     @Test
209     public void mapRegister__TwoRlocs() throws Exception {
210         // P Bit & M Bit set
211         // EID prefix: 172.1.1.2/32, TTL: 10, Authoritative, No-Action
212         // Local RLOC: 10.1.0.110, Reachable, Priority/Weight: 1/100, Multicast
213         // Priority/Weight: 255/0
214         // Local RLOC: 192.168.136.51, Reachable, Priority/Weight: 6/100,
215         // Multicast Priority/Weight: 255/0
216         mapRegisterPacket = extractWSUdpByteArray(new String("0000   00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 "
217                 + "0010   00 68 00 00 40 00 40 11 26 15 0a 01 00 6e 0a 01 " //
218                 + "0020   00 01 10 f6 10 f6 00 54 03 3b 38 00 01 01 00 00 " //
219                 + "0030   00 00 00 00 00 00 00 01 00 14 ae d8 7b d4 9c 59 " //
220                 + "0040   e9 35 75 6e f1 29 27 a3 45 20 96 06 c2 e1 00 00 " //
221                 + "0050   00 0a 02 20 10 00 00 00 00 01 ac 01 01 02 01 64 " //
222                 + "0060   ff 00 00 05 00 01 0a 01 00 6e 06 64 ff 00 00 05 " //
223                 + "0070   00 01 c0 a8 88 33"));
224
225         oneOf(nps).putNotification(with(lispNotificationSaver));
226
227         handleMapRegisterPacket(mapRegisterPacket);
228
229         List<EidToLocatorRecord> eidRecords = lastMapRegister().getEidToLocatorRecord();
230         assertEquals(1, eidRecords.size());
231         EidToLocatorRecord eidRecord = eidRecords.get(0);
232         assertEquals(2, eidRecord.getLocatorRecord().size());
233         assertEquals(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("10.1.0.110")), eidRecord.getLocatorRecord().get(0).getLispAddressContainer());
234         assertEquals(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("192.168.136.51")), eidRecord.getLocatorRecord().get(1).getLispAddressContainer());
235     }
236
237     @Test
238     public void mapRegister__Ipv6Rloc() throws Exception {
239         // P bit (Proxy-Map-Reply): Set
240         // M bit (Want-Map-Notify): Set
241         // Record Counter: 1
242         // Nonce: 0
243         // Key ID: 1
244         // AuthLength: 20
245         // Authentication Data: 5bc4d44a57e2a55d577a6f89779c004f5da713fb
246         // EID prefix: 2610:d0:ffff:192::1/128, TTL: 10, Authoritative,
247         // No-Action
248         // Local RLOC: 10.0.58.156, Reachable, Priority/Weight: 1/100, Multicast
249         // Priority/Weight: 255/0
250
251         mapRegisterPacket = extractWSUdpByteArray(new String("0000   00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 " //
252                 + "0010   00 68 00 00 40 00 40 11 ea c3 0a 00 3a 9c 0a 00 " //
253                 + "0020   01 26 10 f6 10 f6 00 54 f5 9a 38 00 03 01 00 00 " //
254                 + "0030   00 00 00 00 00 00 00 01 00 14 22 97 ff 61 ec d8 " //
255                 + "0040   0f 91 c6 c4 01 ef 7f bb 77 58 39 5c 92 23 00 00 " //
256                 + "0050   00 0a 01 80 10 00 00 00 00 02 26 10 00 d0 ff ff " //
257                 + "0060   01 92 00 00 00 00 00 00 00 01 01 64 ff 00 00 05 " //
258                 + "0070   00 01 0a 00 3a 9c"));
259
260         oneOf(nps).putNotification(with(lispNotificationSaver));
261
262         handleMapRegisterPacket(mapRegisterPacket);
263
264         EidToLocatorRecord eidToLocatorRecord = lastMapRegister().getEidToLocatorRecord().get(0);
265         assertEquals(LispAFIConvertor.asIPv6Address("2610:d0:ffff:192:0:0:0:1"), eidToLocatorRecord.getLispAddressContainer());
266         assertEquals(AddressFamilyNumberEnum.IP6,
267                 AddressFamilyNumberEnum.valueOf(LispAFIConvertor.toAFI(eidToLocatorRecord.getLispAddressContainer()).getAfi()));
268
269         assertEquals(LispAFIConvertor.asIPAfiAddress("10.0.58.156"), LispAFIConvertor.toAFI(eidToLocatorRecord.getLocatorRecord().get(0).getLispAddressContainer()));
270     }
271
272     @Test
273     public void mapRegister__VerifyBasicFields() throws Exception {
274         oneOf(nps).putNotification(with(lispNotificationSaver));
275         handleMapRegisterPacket(mapRegisterPacket);
276
277         EidToLocatorRecord eidToLocator = lastMapRegister().getEidToLocatorRecord().get(0);
278         assertEquals(LispAFIConvertor.asIPv4Address("153.16.254.1"), eidToLocator.getLispAddressContainer());
279
280         assertEquals(1, eidToLocator.getLocatorRecord().size());
281         assertEquals(LispAFIConvertor.asIPAfiAddress("192.168.136.10"), LispAFIConvertor.toAFI(eidToLocator.getLocatorRecord().get(0).getLispAddressContainer()));
282     }
283
284     @Test
285     @Ignore
286     public void mapRegister__NoResponseFromMapServerShouldReturnNullPacket() throws Exception {
287         oneOf(nps).putNotification(with(lispNotificationSaver));
288         mapNotifyBuilder = null;
289
290         assertNull(handleMapRegisterPacket(mapRegisterPacket));
291     }
292
293     @Test
294     public void mapRegister__NonSetMBit() throws Exception {
295         byte[] registerWithNonSetMBit = extractWSUdpByteArray(new String("0000   00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " //
296                 + "0010   00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df " //
297                 + "0020   9c 23 d6 40 10 f6 00 48 59 a4 38 00 00 01 00 00 "
298                 + "0030   00 00 00 00 00 00 00 01 00 14 79 d1 44 66 19 99 "
299                 + "0040   83 63 a7 79 6e f0 40 97 54 26 3a 44 b4 eb 00 00 " //
300                 + "0050   00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
301                 + "0060   ff 00 00 05 00 01 c0 a8 88 0a"));
302         stubMapRegister(true);
303
304         handleMapRegisterPacket(registerWithNonSetMBit);
305
306         assertFalse(lastMapRegister().isWantMapNotify());
307     }
308
309     @Test
310     public void mapRegister__NonSetMBitWithNonZeroReservedBits() throws Exception {
311         byte[] registerWithNonSetMBit = extractWSUdpByteArray(new String("0000   00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " //
312                 + "0010   00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df "
313                 + "0020   9c 23 d6 40 10 f6 00 48 59 a4 38 00 02 01 00 00 "
314                 + "0030   00 00 00 00 00 00 00 01 00 14 c0 c7 c5 2f 57 f6 "
315                 + "0040   e7 20 25 3d e8 b2 07 e2 63 de 62 2b 7a 20 00 00 "
316                 + "0050   00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
317                 + "0060   ff 00 00 05 00 01 c0 a8 88 0a"));
318         stubMapRegister(true);
319
320         handleMapRegisterPacket(registerWithNonSetMBit);
321         assertFalse(lastMapRegister().isWantMapNotify());
322     }
323
324     @Test
325     public void mapRegister__SetMBitWithNonZeroReservedBits() throws Exception {
326         byte[] registerWithNonSetMBit = extractWSUdpByteArray(new String("0000   00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " //
327                 + "0010   00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df "
328                 + "0020   9c 23 d6 40 10 f6 00 48 59 a4 38 00 03 01 00 00 "
329                 + "0030   00 00 00 00 00 00 00 01 00 14 a2 72 40 7b 1a ae "
330                 + "0040   4e 6b e2 e5 e1 01 40 8a c9 e1 d1 80 cb 72 00 00 "
331                 + "0050   00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
332                 + "0060   ff 00 00 05 00 01 c0 a8 88 0a"));
333         stubMapRegister(true);
334
335         handleMapRegisterPacket(registerWithNonSetMBit);
336         assertTrue(lastMapRegister().isWantMapNotify());
337     }
338
339     @Test
340     @Ignore
341     public void mapRegisterAndNotify__ValidExtraDataParsedSuccessfully() throws Exception {
342         byte[] extraDataPacket = new byte[mapRegisterPacket.length + 3];
343         extraDataPacket[mapRegisterPacket.length] = 0x9;
344         System.arraycopy(mapRegisterPacket, 0, extraDataPacket, 0, mapRegisterPacket.length);
345         stubMapRegister(true);
346
347         DatagramPacket dp = new DatagramPacket(extraDataPacket, extraDataPacket.length);
348         dp.setLength(mapRegisterPacket.length);
349         testedLispService.handlePacket(dp);
350         // Check map register fields.
351         // XXX: test
352         // byte[] notifyResult = testedLispService.handlePacket(dp).getData();
353         byte[] notifyResult = lastMapNotifyPacket().getData();
354         assertEquals(mapRegisterPacket.length, notifyResult.length);
355
356     }
357
358     private DatagramPacket lastMapReplyPacket() {
359         ByteBuffer serialize = MapReplySerializer.getInstance().serialize(mapReplyBuilder.build());
360         return new DatagramPacket(serialize.array(), serialize.array().length);
361     }
362
363     private DatagramPacket lastMapNotifyPacket() {
364         if (mapNotifyBuilder.getEidToLocatorRecord() == null) {
365             mapNotifyBuilder.setEidToLocatorRecord(new ArrayList<EidToLocatorRecord>());
366         }
367         mapNotifyBuilder.getEidToLocatorRecord().add(eidToLocatorBuilder.build());
368         mapNotifyBuilder.setNonce((long) 0);
369         mapNotifyBuilder.setKeyId((short) 0);
370         mapNotifyBuilder.setAuthenticationData(new byte[0]);
371         ByteBuffer serialize = MapNotifySerializer.getInstance().serialize(mapNotifyBuilder.build());
372         return new DatagramPacket(serialize.array(), serialize.array().length);
373     }
374
375     @Test
376     @Ignore
377     public void mapNotify__VerifyBasicFields() throws Exception {
378         byte registerType = mapRegisterPacket[0];
379         assertEquals(LispMessageEnum.MapRegister.getValue(), registerType >> 4);
380
381         stubMapRegister(true);
382
383         byte[] result = handleMapRegisterAsByteArray(mapRegisterPacket);
384
385         assertEquals(mapRegisterPacket.length, result.length);
386
387         byte expectedType = (byte) (LispMessageEnum.MapNotify.getValue() << 4);
388         assertHexEquals(expectedType, result[0]);
389         assertHexEquals((byte) 0x00, result[1]);
390         assertHexEquals((byte) 0x00, result[2]);
391
392         byte[] registerWithoutTypeWithoutAuthenticationData = ArrayUtils.addAll(Arrays.copyOfRange(mapRegisterPacket, 3, 16),
393                 Arrays.copyOfRange(mapRegisterPacket, 36, mapRegisterPacket.length));
394         byte[] notifyWithoutTypeWithOutAuthenticationData = ArrayUtils.addAll(Arrays.copyOfRange(result, 3, 16),
395                 Arrays.copyOfRange(result, 36, result.length));
396         ArrayAssert.assertEquals(registerWithoutTypeWithoutAuthenticationData, notifyWithoutTypeWithOutAuthenticationData);
397     }
398
399     @Ignore
400     @Test
401     public void mapNotify__VerifyPort() throws Exception {
402         stubMapRegister(true);
403
404         DatagramPacket notifyPacket = handleMapRegisterPacket(mapRegisterPacket);
405         assertEquals(LispMessage.PORT_NUM, notifyPacket.getPort());
406     }
407
408     @Test
409     public void mapRequest__VerifyBasicFields() throws Exception {
410         oneOf(nps).putNotification(with(lispNotificationSaver));
411         handleMapRequestAsByteArray(mapRequestPacket);
412         List<EidRecord> eids = lastMapRequest().getEidRecord();
413         assertEquals(1, eids.size());
414         LispAddressContainer lispAddress = eids.get(0).getLispAddressContainer();
415         assertTrue(LispAFIConvertor.toAFI(lispAddress) instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.lispaddress.lispaddresscontainer.address.ipv4.Ipv4Address);
416         assertEquals(LispAFIConvertor.asIPv4Address("1.2.3.4"), lispAddress);
417         assertEquals((byte) 0x20, eids.get(0).getMask().byteValue());
418         assertEquals(0x3d8d2acd39c8d608L, lastMapRequest().getNonce().longValue());
419         // assertEquals(AddressFamilyNumberEnum.RESERVED,
420         // AddressFamilyNumberEnum.valueOf(LispAFIToContainerConvertorFactory.toAFI(
421         // lastMapRequest().getSourceEid().getLispAddressContainer()).getAfi()));
422     }
423
424     @Test
425     public void mapRequest__Ipv6Eid() throws Exception {
426         // Internet Protocol Version 6, Src: 2610:d0:ffff:192::1
427         // (2610:d0:ffff:192::1), Dst: 2610:d0:ffff:192::2
428         // (2610:d0:ffff:192::2)
429         // MBIT: SET
430         // EID AFI: 2
431         // Source EID: 2610:d0:ffff:192::1 (2610:d0:ffff:192::1)
432         // ITR-RLOC 1: 10.0.58.156
433         // Record 1: 2610:d0:ffff:192::2/128
434         // Map-Reply Record: EID prefix: 2610:d0:ffff:192::1/128, TTL: 10,
435         // Authoritative, No-Action
436
437         mapRequestPacket = extractWSUdpByteArray(new String("0000   00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 " //
438                 + "0010   00 b0 00 00 40 00 40 11 ea 7b 0a 00 3a 9c 0a 00 "
439                 + "0020   01 26 10 f6 10 f6 00 9c 9b 19 80 00 00 00 60 00 "
440                 + "0030   00 00 00 68 11 ff 26 10 00 d0 ff ff 01 92 00 00 "
441                 + "0040   00 00 00 00 00 01 26 10 00 d0 ff ff 01 92 00 00 "
442                 + "0050   00 00 00 00 00 02 10 f6 10 f6 00 68 94 8b 10 00 "
443                 + "0060   00 01 ff f5 bf 5d 7b 75 93 e6 00 02 26 10 00 d0 "
444                 + "0070   ff ff 01 92 00 00 00 00 00 00 00 01 00 01 0a 00 "
445                 + "0080   3a 9c 00 80 00 02 26 10 00 d0 ff ff 01 92 00 00 "
446                 + "0090   00 00 00 00 00 02 00 00 00 0a 01 80 10 00 00 00 " //
447                 + "00a0   00 02 26 10 00 d0 ff ff 01 92 00 00 00 00 00 00 " //
448                 + "00b0   00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c"));
449
450         oneOf(nps).putNotification(with(lispNotificationSaver));
451         // ret(mapReply);
452
453         handleMapRequestAsByteArray(mapRequestPacket);
454         assertEquals(LispAFIConvertor.asIPv6AfiAddress("2610:d0:ffff:192:0:0:0:1"), LispAFIConvertor.toAFI(lastMapRequest().getSourceEid().getLispAddressContainer()));
455         assertEquals(LispAFIConvertor.asIPv6Address("2610:d0:ffff:192:0:0:0:2"), lastMapRequest().getEidRecord().get(0).getLispAddressContainer());
456     }
457
458     @Ignore
459     @Test
460     public void mapRequest__UsesIpv6EncapsulatedUdpPort() throws Exception {
461         // Internet Protocol Version 6, Src: 2610:d0:ffff:192::1
462         // (2610:d0:ffff:192::1), Dst: 2610:d0:ffff:192::2
463         // (2610:d0:ffff:192::2)
464         // encapsulated UDP source port: 4342
465
466         mapRequestPacket = extractWSUdpByteArray(new String("0000   00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 " //
467                 + "0010   00 b0 00 00 40 00 40 11 ea 7b 0a 00 3a 9c 0a 00 "
468                 + "0020   01 26 10 f6 10 f6 00 9c 9b 19 80 00 00 00 60 00 "
469                 + "0030   00 00 00 68 11 ff 26 10 00 d0 ff ff 01 92 00 00 "
470                 + "0040   00 00 00 00 00 01 26 10 00 d0 ff ff 01 92 00 00 "
471                 + "0050   00 00 00 00 00 02 10 f6 10 f6 00 68 94 8b 14 00 "
472                 + "0060   00 01 ff f5 bf 5d 7b 75 93 e6 00 02 26 10 00 d0 "
473                 + "0070   ff ff 01 92 00 00 00 00 00 00 00 01 00 01 0a 00 "
474                 + "0080   3a 9c 00 80 00 02 26 10 00 d0 ff ff 01 92 00 00 "
475                 + "0090   00 00 00 00 00 02 00 00 00 0a 01 80 10 00 00 00 " //
476                 + "00a0   00 02 26 10 00 d0 ff ff 01 92 00 00 00 00 00 00 " //
477                 + "00b0   00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c"));
478         oneOf(nps).putNotification(with(lispNotificationSaver));
479         // ret(mapReply);
480
481         DatagramPacket replyPacket = handleMapRequestPacket(mapRequestPacket);
482         assertEquals(4342, replyPacket.getPort());
483     }
484
485     @Test
486     public void mapRequest__WithSourceEid() throws Exception {
487         // encapsulated LISP packet
488         // Source EID = 153.16.254.1
489
490         mapRequestPacket = extractWSUdpByteArray(new String("0000   00 0c 29 7a ce 83 00 15 17 c6 4a c9 08 00 45 00 " //
491                 + "0010   00 78 00 00 40 00 3e 11 ec b1 0a 00 01 26 0a 00 "
492                 + "0020   3a 9e 10 f6 10 f6 00 64 c3 a5 80 00 00 00 45 00 "
493                 + "0030   00 58 d4 31 00 00 ff 11 31 89 99 10 fe 01 0a 00 "
494                 + "0040   14 c8 10 f6 10 f6 00 44 84 ee 10 00 00 01 ba f9 "
495                 + "0050   ff 53 27 36 38 3a 00 01 99 10 fe 01 00 01 0a 00 "
496                 + "0060   01 26 00 20 00 01 0a 00 14 c8 00 00 00 0a 01 20 "
497                 + "0070   10 00 00 00 00 01 99 10 fe 01 01 64 ff 00 00 05 " //
498                 + "0080   00 01 0a 00 01 26"));
499
500         oneOf(nps).putNotification(with(lispNotificationSaver));
501         // ret(mapReply);
502
503         handleMapRequestAsByteArray(mapRequestPacket);
504         Assert.assertNotEquals(AddressFamilyNumberEnum.IP, LispAFIConvertor.toAFI(lastMapRequest().getSourceEid().getLispAddressContainer()));
505
506     }
507
508     @Test
509     @Ignore
510     public void mapReply__VerifyBasicIPv4Fields() throws Exception {
511         eidToLocatorBuilder.setMaskLength((short) 0x20).setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("10.0.20.200")));
512         mapReplyBuilder.setNonce(0x3d8d2acd39c8d608L);
513
514         stubHandleRequest();
515
516         byte[] result = handleMapRequestAsByteArray(mapRequestPacket);
517
518         assertEquals(28, result.length);
519
520         byte expectedLispMessageType = 2;
521         assertEquals(expectedLispMessageType, (byte) (result[LispMessage.Pos.TYPE] >> 4));
522         assertEquals(0x3d8d2acd39c8d608L, ByteUtil.getLong(result, MapReplyIpv4SingleLocatorPos.NONCE));
523
524         byte expectedRecordCount = (byte) 1;
525         assertEquals(expectedRecordCount, result[MapReplyIpv4SingleLocatorPos.RECORD_COUNT]);
526
527         assertEquals(eidToLocatorBuilder.getMaskLength().byteValue(), result[MapReplyIpv4SingleLocatorPos.EID_MASK_LEN]);
528         assertEquals(AddressFamilyNumberEnum.IP.getIanaCode(), ByteUtil.getShort(result, MapReplyIpv4SingleLocatorPos.AFI_TYPE));
529         assertEquals(0x0a0014c8, ByteUtil.getInt(result, MapReplyIpv4SingleLocatorPos.EID_PREFIX));
530     }
531
532     @Test
533     @Ignore
534     public void mapReply__VerifyBasicIPv6() throws Exception {
535         eidToLocatorBuilder.setMaskLength((short) 0x80).setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPv6AfiAddress("0:0:0:0:0:0:0:1")));
536
537         stubHandleRequest();
538
539         byte[] result = handleMapRequestAsByteArray(mapRequestPacket);
540
541         assertEquals(40, result.length);
542
543         byte expectedRecordCount = (byte) 1;
544         assertEquals(expectedRecordCount, result[MapReplyIpv4SingleLocatorPos.RECORD_COUNT]);
545
546         assertEquals(eidToLocatorBuilder.getMaskLength().byteValue(), result[MapReplyIpv4SingleLocatorPos.EID_MASK_LEN]);
547         assertEquals(AddressFamilyNumberEnum.IP6.getIanaCode(), ByteUtil.getShort(result, MapReplyIpv4SingleLocatorPos.AFI_TYPE));
548         byte[] expectedIpv6 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
549
550         ArrayAssert.assertEquals(expectedIpv6, Arrays.copyOfRange(result, 24, 40));
551     }
552
553     @Test
554     @Ignore
555     public void mapReply__VerifyIPv6EidAndLocator() throws Exception {
556         eidToLocatorBuilder.setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPv6AfiAddress("0:0:0:0:0:0:0:1")));
557         eidToLocatorBuilder.getLocatorRecord().add(
558                 new LocatorRecordBuilder().setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPv6AfiAddress("0:0:0:0:0:0:0:2"))).build());
559
560         stubHandleRequest();
561
562         byte[] result = handleMapRequestAsByteArray(mapRequestPacket);
563
564         assertEquals(64, result.length);
565
566         byte[] expectedIpv6Eid = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
567         ArrayAssert.assertEquals(expectedIpv6Eid, Arrays.copyOfRange(result, 24, 40));
568
569         byte[] expectedIpv6Rloc = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 };
570         ArrayAssert.assertEquals(expectedIpv6Rloc, Arrays.copyOfRange(result, 48, 64));
571     }
572
573     @Ignore
574     @Test
575     public void mapReply__UseEncapsulatedUdpPort() throws Exception {
576         stubHandleRequest();
577
578         assertEquals(LispMessage.PORT_NUM, handleMapRequestPacket(mapRequestPacket).getPort());
579     }
580
581     @Test
582     @Ignore
583     public void mapReply__WithNonRoutableSingleLocator() throws Exception {
584         eidToLocatorBuilder.setMaskLength((short) 0x20).setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("10.0.20.200")));
585         eidToLocatorBuilder.getLocatorRecord().add(
586                 new LocatorRecordBuilder().setRouted(false).setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("4.3.2.1"))).build());
587         stubHandleRequest();
588
589         byte[] result = handleMapRequestAsByteArray(mapRequestPacket);
590         assertEquals(0x00, result[MapReplyIpv4SingleLocatorPos.LOCATOR_RBIT] & 0x01);
591     }
592
593     @Test
594     @Ignore
595     public void mapReply__WithSingleLocator() throws Exception {
596         eidToLocatorBuilder.setMaskLength((short) 0x20)//
597                 .setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("10.0.20.200")));
598         eidToLocatorBuilder.getLocatorRecord().add(
599                 new LocatorRecordBuilder().setRouted(true).setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("4.3.2.1"))).build());
600         stubHandleRequest();
601
602         byte[] result = handleMapRequestAsByteArray(mapRequestPacket);
603         assertEquals(40, result.length);
604
605         byte expectedLocCount = 1;
606         assertEquals(expectedLocCount, result[MapReplyIpv4SingleLocatorPos.LOCATOR_COUNT]);
607
608         assertEquals(AddressFamilyNumberEnum.IP.getIanaCode(), ByteUtil.getShort(result, MapReplyIpv4SingleLocatorPos.LOC_AFI));
609
610         assertEquals(0x04030201, ByteUtil.getInt(result, MapReplyIpv4SingleLocatorPos.LOCATOR));
611         assertEquals(0x01, result[MapReplyIpv4SingleLocatorPos.LOCATOR_RBIT] & 0x01);
612     }
613
614     @Test
615     @Ignore
616     public void mapReply__WithMultipleLocator() throws Exception {
617         eidToLocatorBuilder.getLocatorRecord().add(
618                 new LocatorRecordBuilder().setRouted(true).setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress("4.3.2.1"))).build());
619         eidToLocatorBuilder.getLocatorRecord().add(
620                 new LocatorRecordBuilder().setRouted(true).setLispAddressContainer(LispAFIConvertor.toContainer(LispAFIConvertor.asIPv6AfiAddress("0:0:0:0:0:0:0:1"))).build());
621         stubHandleRequest();
622
623         byte[] result = handleMapRequestAsByteArray(mapRequestPacket);
624         assertEquals(64, result.length);
625
626         assertEquals(2, result[MapReplyIpv4SingleLocatorPos.LOCATOR_COUNT]);
627
628         assertEquals(AddressFamilyNumberEnum.IP.getIanaCode(), ByteUtil.getShort(result, MapReplyIpv4SingleLocatorPos.LOC_AFI));
629         assertEquals(0x04030201, ByteUtil.getInt(result, MapReplyIpv4SingleLocatorPos.LOCATOR));
630         assertEquals(0x01, result[MapReplyIpv4SingleLocatorPos.LOCATOR_RBIT] & 0x01);
631
632         assertEquals(AddressFamilyNumberEnum.IP6.getIanaCode(), ByteUtil.getShort(result, MapReplyIpv4SecondLocatorPos.LOC_AFI));
633
634         byte[] expectedIpv6Rloc = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
635         ArrayAssert.assertEquals(expectedIpv6Rloc,
636                 Arrays.copyOfRange(result, MapReplyIpv4SecondLocatorPos.LOCATOR, MapReplyIpv4SecondLocatorPos.LOCATOR + 16));
637
638         assertEquals(0x01, result[MapReplyIpv4SecondLocatorPos.LOCATOR_RBIT] & 0x01);
639     }
640
641     @Test
642     public void handleUnknownLispMessage() throws Exception {
643         // IP: 192.168.136.10 -> 128.223.156.35
644         // UDP: 49289 -> 4342
645         // LISP(Type = 14 UNKNOWN!!!, P=1, M=1
646
647         byte[] unknownTypePacket = extractWSUdpByteArray(new String("0000   00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " //
648                 + "0010   00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df "
649                 + "0020   9c 23 d6 40 10 f6 00 48 59 a4 F8 00 01 01 00 00 "
650                 + "0030   00 00 00 00 00 00 00 01 00 14 e8 f5 0b c5 c5 f2 "
651                 + "0040   b0 21 27 a8 21 41 04 f3 46 5a a5 68 89 ec 00 00 "
652                 + "0050   00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
653                 + "0060   ff 00 00 05 00 01 c0 a8 88 0a"));
654         assertNull(handlePacket(unknownTypePacket));
655     }
656
657     @Test
658     public void mapRequest__MultipleItrRlocs() throws Exception {
659         // this is what LISPmob sends when configured multiple RLOCs for single
660         // EID.
661         // ITR-RLOC 1: 10.1.0.111
662         // ITR-RLOC 2: 192.168.136.51
663         //
664         mapRequestPacket = extractWSUdpByteArray(new String("0000   00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 "
665                 + "0010   00 8a 00 00 40 00 40 11 25 f2 0a 01 00 6f 0a 01 " //
666                 + "0020   00 01 10 f6 10 f6 00 76 06 1f 80 00 00 00 45 00 " //
667                 + "0030   00 6a d4 31 00 00 ff 11 2a 3e ac 01 01 02 08 08 " //
668                 + "0040   08 08 10 f6 10 f6 00 56 63 14 10 00 01 01 79 67 " //
669                 + "0050   ff 75 a0 61 66 19 00 01 ac 01 01 02 00 01 0a 01 " //
670                 + "0060   00 6f 00 01 c0 a8 88 33 00 20 00 01 08 08 08 08 " //
671                 + "0070   00 00 00 0a 02 20 10 00 00 00 00 01 ac 01 01 02 " //
672                 + "0080   01 64 ff 00 00 05 00 01 0a 01 00 6f 06 64 ff 00 " //
673                 + "0090   00 05 00 01 c0 a8 88 33"));
674
675         oneOf(nps).putNotification(with(lispNotificationSaver));
676         handleMapRequestAsByteArray(mapRequestPacket);
677
678     }
679
680     private void stubMapRegister(final boolean setNotifyFromRegister) {
681         try {
682             allowing(nps).putNotification(with(lispNotificationSaver));
683         } catch (InterruptedException e) {
684         }
685         will(new SimpleAction() {
686
687             @Override
688             public Object invoke(Invocation invocation) throws Throwable {
689                 if (setNotifyFromRegister) {
690                     MapNotifyBuilderHelper.setFromMapRegister(mapNotifyBuilder, lastMapRegister());
691                 }
692                 return null;
693             }
694         });
695     }
696
697     private void stubHandleRequest() {
698         try {
699             allowing(nps).putNotification(wany(Notification.class));
700         } catch (InterruptedException e) {
701         }
702     }
703
704     private byte[] handleMapRequestAsByteArray(byte[] inPacket) {
705         handleMapRequestPacket(inPacket);
706         return lastMapReplyPacket().getData();
707     }
708
709     private byte[] handleMapRegisterAsByteArray(byte[] inPacket) {
710         handleMapRegisterPacket(inPacket);
711         return lastMapNotifyPacket().getData();
712     }
713
714     private DatagramPacket handleMapRequestPacket(byte[] inPacket) {
715         DatagramPacket dp = new DatagramPacket(inPacket, inPacket.length);
716         // Unless we explicitly set the source port, it will be -1, which breaks some tests
717         // This is till not the real port number, but it's better
718         dp.setPort(LispMessage.PORT_NUM);
719         testedLispService.handlePacket(dp);
720         return lastMapReplyPacket();
721     }
722
723     private DatagramPacket handleMapRegisterPacket(byte[] inPacket) {
724         DatagramPacket dp = new DatagramPacket(inPacket, inPacket.length);
725         // Unless we explicitly set the source port, it will be -1, which breaks some tests
726         // This is till not the real port number, but it's better
727         dp.setPort(LispMessage.PORT_NUM);
728         testedLispService.handlePacket(dp);
729         if (mapNotifyBuilder == null) {
730             return null;
731         } else {
732             return lastMapNotifyPacket();
733         }
734     }
735
736     private DatagramPacket handlePacket(byte[] inPacket) {
737         // TODO get from mock
738         testedLispService.handlePacket(new DatagramPacket(inPacket, inPacket.length));
739         return null;
740     }
741
742     private byte[] extractWSUdpByteArray(String wiresharkHex) {
743         final int HEADER_LEN = 42;
744         byte[] res = new byte[1000];
745         String[] split = wiresharkHex.split(" ");
746         int counter = 0;
747         for (String cur : split) {
748             cur = cur.trim();
749             if (cur.length() == 2) {
750                 ++counter;
751                 if (counter > HEADER_LEN) {
752                     res[counter - HEADER_LEN - 1] = (byte) Integer.parseInt(cur, 16);
753                 }
754
755             }
756         }
757         return Arrays.copyOf(res, counter - HEADER_LEN);
758     }
759
760     @Test(expected = LispMalformedPacketException.class)
761     public void mapRequest__NoIPITRRLOC() throws Exception {
762         mapRequestPacket = hexToByteBuffer("10 00 " //
763                 + "02 " // This means 3 ITR - RLOCs
764                 + "01 3d 8d 2a cd 39 c8 d6 08 00 00 " //
765                 + "40 05 c0 a8 88 0a 01 02 " // MAC (ITR-RLOC #1 of 3)
766                 + "40 05 00 00 00 00 00 00 " // MAC (ITR-RLOC #2 of 3)
767                 + "40 05 11 22 34 56 78 90 " // MAC (ITR-RLOC #3 of 3)
768                 + "00 20 00 01 01 02 03 04").array();
769         handleMapRequestPacket(mapRequestPacket);
770     }
771
772     // @Ignore
773     // @Test
774     // public void mapRequest__IPITRRLOCIsSecond() throws Exception {
775     // mapRequestPacket = hexToByteBuffer("10 00 " //
776     // + "01 " // This means 3 ITR - RLOCs
777     // + "01 3d 8d 2a cd 39 c8 d6 08 00 00 " //
778     // + "40 05 c0 a8 88 0a 01 02 " // MAC (ITR-RLOC #1 of 2)
779     // + "00 01 01 02 03 04 " // IP (ITR-RLOC #2 of 2)
780     // + "00 20 00 01 01 02 03 04").array();
781     // oneOf(nps).putNotification(with(lispNotificationSaver));
782     // // ret(mapReply);
783     // DatagramPacket packet = handleMapRequestPacket(mapRequestPacket);
784     // assertEquals(2, lastMapRequest().getItrRlocs().size());
785     // assertEquals((new LispIpv4Address("1.2.3.4")).getAddress(),
786     // packet.getAddress());
787     // }
788     //
789     // @Ignore
790     // @Test
791     // public void mapRequest__MULTIPLEIPITRRLOCs() throws Exception {
792     // mapRequestPacket = hexToByteBuffer("10 00 " //
793     // + "01 " // This means 3 ITR - RLOCs
794     // + "01 3d 8d 2a cd 39 c8 d6 08 00 00 " //
795     // + "00 01 01 02 03 04 " // IP (ITR-RLOC #1 of 2)
796     // + "00 01 c0 a8 88 0a " // MAC (ITR-RLOC #2 of 2)
797     // + "00 20 00 01 01 02 03 04").array();
798     // oneOf(nps).putNotification(with(lispNotificationSaver));
799     // // ret(mapReply);
800     // DatagramPacket packet = handleMapRequestPacket(mapRequestPacket);
801     // assertEquals(2, lastMapRequest().getItrRloc().size());
802     // assertEquals((new LispIpv4Address("1.2.3.4")).getAddress(),
803     // packet.getAddress());
804     // }
805
806 }