2 * Copyright (c) 2015 Cisco Systems, Inc. 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
9 package org.opendaylight.lispflowmapping.lisp.util;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * @author Lorand Jakab
22 public class SourceDestKeyHelper {
23 private final static Logger LOG = LoggerFactory.getLogger(SourceDestKeyHelper.class);
24 public static Eid getSrc(Eid eid) {
25 Address addr = eid.getAddress();
26 if (addr instanceof SourceDestKey) {
27 return LispAddressUtil.toEid(eid, ((SourceDestKey)addr).getSourceDestKey().getSource());
33 public static Eid getDst(Eid eid) {
34 Address addr = eid.getAddress();
35 if (addr instanceof SourceDestKey) {
36 return LispAddressUtil.toEid(eid, ((SourceDestKey)addr).getSourceDestKey().getDest());
42 public static short getSrcMask(Eid eid) {
43 Address addr = eid.getAddress();
44 if (!isSrcDst(addr)) {
47 return MaskUtil.getMaskForIpPrefix(((SourceDestKey)addr).getSourceDestKey().getSource());
50 public static short getDstMask(Eid eid) {
51 Address addr = eid.getAddress();
52 if (!isSrcDst(addr)) {
55 return MaskUtil.getMaskForIpPrefix(((SourceDestKey)addr).getSourceDestKey().getDest());
58 private static boolean isSrcDst(Address addr) {
59 if (!(addr instanceof SourceDestKey)) {
60 LOG.warn("Address {} is not a valid SourceDest LCAF", addr);