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