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