1
2
3
4
5
6
7
8 package org.opendaylight.lispflowmapping.southbound.util;
9
10 import java.net.InetAddress;
11
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifynotification.MapNotify;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifynotification.MapNotifyBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegister;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegisterBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplynotification.MapReply;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplynotification.MapReplyBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequest;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
22
23 public final class LispNotificationHelper {
24
25 private LispNotificationHelper() {
26 }
27
28 public static MapRegister convertMapRegister(
29 org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister mapRegister) {
30 return new MapRegisterBuilder(mapRegister).build();
31 }
32
33 public static MapNotify convertMapNotify(
34 org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify mapNotify) {
35 return new MapNotifyBuilder(mapNotify).build();
36 }
37
38 public static MapRequest convertMapRequest(
39 org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest mapRequest) {
40 return new MapRequestBuilder().setAuthoritative(mapRequest.isAuthoritative())
41 .setEidItem(mapRequest.getEidItem()).setItrRloc(mapRequest.getItrRloc())
42 .setMapDataPresent(mapRequest.isMapDataPresent()).setMapReply(mapRequest.getMapReply())
43 .setNonce(mapRequest.getNonce()).setPitr(mapRequest.isPitr()).setProbe(mapRequest.isProbe())
44 .setSmr(mapRequest.isSmr()).setSmrInvoked(mapRequest.isSmrInvoked())
45 .setSourceEid(mapRequest.getSourceEid()).build();
46 }
47
48 public static MapReply convertMapReply(
49 org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply mapReply) {
50 return new MapReplyBuilder().setEchoNonceEnabled(mapReply.isEchoNonceEnabled())
51 .setMappingRecordItem(mapReply.getMappingRecordItem()).setNonce(mapReply.getNonce())
52 .setProbe(mapReply.isProbe()).setSecurityEnabled(mapReply.isSecurityEnabled()).build();
53 }
54
55 public static IpAddress getIpAddressFromInetAddress(InetAddress address) {
56 InetAddress inetAddress = address;
57 if (inetAddress == null) {
58 inetAddress = InetAddress.getLoopbackAddress();
59 }
60
61 return IetfInetUtil.INSTANCE.ipAddressFor(address);
62 }
63 }