2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.lispflowmapping.implementation.util;
10 import java.net.InetAddress;
11 import java.net.UnknownHostException;
13 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.LispIpv4Address;
14 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.LispIpv6Address;
15 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest;
16 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.lispaddresscontainer.Address;
17 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.maprequest.ItrRloc;
19 public class MapRequestUtil {
20 public static InetAddress selectItrRloc(MapRequest request) {
21 if (request.getItrRloc() == null) {
24 InetAddress selectedItrRloc = null;
25 for (ItrRloc itr : request.getItrRloc()) {
26 Address addr = itr.getLispAddressContainer().getAddress();
27 if (addr instanceof LispIpv4Address) {
29 selectedItrRloc = InetAddress.getByName(((LispIpv4Address) addr).getIpv4Address().getValue());
30 } catch (UnknownHostException e) {
34 if (addr instanceof LispIpv6Address) {
36 selectedItrRloc = InetAddress.getByName((((LispIpv6Address) addr).getIpv6Address().getValue()));
37 } catch (UnknownHostException e) {
42 return selectedItrRloc;