2 * Copyright (c) 2016 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.match;
10 import io.netty.buffer.ByteBuf;
11 import java.util.Iterator;
12 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
13 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
14 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
18 public class ArpSourceTransportAddressEntrySerializer extends AbstractMatchEntrySerializer {
21 public void serialize(Match match, ByteBuf outBuffer) {
22 super.serialize(match, outBuffer);
23 writeIpv4Prefix(((ArpMatch) match.getLayer3Match()).getArpSourceTransportAddress(), outBuffer);
27 public boolean matchTypeCheck(Match match) {
28 return match.getLayer3Match() != null
29 && match.getLayer3Match() instanceof ArpMatch
30 && ((ArpMatch) match.getLayer3Match()).getArpSourceTransportAddress() != null;
34 protected boolean getHasMask(Match match) {
35 // Split address to IP and mask
36 final Iterator<String> addressParts = IpConversionUtil.splitToParts(
37 ((ArpMatch) match.getLayer3Match()).getArpSourceTransportAddress());
40 // Check if we have mask
41 return addressParts.hasNext() && Integer.parseInt(addressParts.next()) < 32;
45 protected int getOxmFieldCode() {
46 return OxmMatchConstants.ARP_SPA;
50 protected int getOxmClassCode() {
51 return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
55 protected int getValueLength() {
56 return EncodeConstants.SIZE_OF_INT_IN_BYTES;