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