X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fopenflow%2Fmd%2Fcore%2Fsal%2Fconvertor%2Faction%2FActionSetNwDstConvertorV10Impl.java;fp=openflowplugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fopenflow%2Fmd%2Fcore%2Fsal%2Fconvertor%2Faction%2FActionSetNwDstConvertorV10Impl.java;h=f3a0f95c17a6b37bf73d9288653730d2b688f7a5;hb=15924783882b4c31238141af8495ee62b08fb6f8;hp=0000000000000000000000000000000000000000;hpb=2a242bab506d49a48c7302af5ef768971d7b1cd0;p=openflowplugin.git diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstConvertorV10Impl.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstConvertorV10Impl.java new file mode 100644 index 0000000000..f3a0f95c17 --- /dev/null +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstConvertorV10Impl.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2013 Ericsson. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action; + +import java.math.BigInteger; + +import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4; + +/** + * Utility class for converting a MD-SAL action subelement into the OF subelement + */ +public class ActionSetNwDstConvertorV10Impl implements Convertor { + + @Override + public Object convert(SetNwDstActionCase source, BigInteger datapathid) { + Address address = source.getSetNwDstAction().getAddress(); + if (address instanceof Ipv4) { + return new Ipv4Address(((Ipv4) address).getIpv4Address().getValue()); + } else { + throw new IllegalArgumentException("Address is not supported by OF-1.0: "+address.getClass().getName()); + } + } +}