BUG-2825: use provided Ipv4/MacAddress factories
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / serialization / action / OF10SetNwSrcActionSerializer.java
index d63bf9c499c4528276821b9ed4b304e3d85cb938..bf98a2780d09fbf47ea547c4a374750065826080 100644 (file)
@@ -9,9 +9,8 @@
 package org.opendaylight.openflowjava.protocol.impl.serialization.action;
 
 import io.netty.buffer.ByteBuf;
-
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
-import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
 
@@ -24,12 +23,8 @@ public class OF10SetNwSrcActionSerializer extends AbstractActionSerializer {
     @Override
     public void serialize(final Action action, final ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
-        Iterable<String> addressGroups = ByteBufUtils.DOT_SPLITTER
-                .split(((SetNwSrcCase) action.getActionChoice()).getSetNwSrcAction()
-                        .getIpAddress().getValue());
-        for (String group : addressGroups) {
-            outBuffer.writeByte(Short.parseShort(group));
-        }
+        outBuffer.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(
+            ((SetNwSrcCase) action.getActionChoice()).getSetNwSrcAction().getIpAddress()));
     }
 
     @Override