2 * Copyright (c) 2014, 2015 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.openflowjava.nx.codec.match;
10 import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.reg.grouping.RegValuesBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.RegCaseValue;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.RegCaseValueBuilder;
22 public abstract class AbstractRegCodec extends AbstractMatchCodec {
23 private static final int VALUE_LENGTH = 4;
26 public MatchEntry deserialize(ByteBuf message) {
27 final MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message);
28 final RegValuesBuilder regValuesBuilder = new RegValuesBuilder();
29 regValuesBuilder.setValue(readUint32(message));
31 if (matchEntriesBuilder.isHasMask()) {
32 regValuesBuilder.setMask(readUint32(message));
35 return matchEntriesBuilder
36 .setMatchEntryValue(new RegCaseValueBuilder()
37 .setRegValues(regValuesBuilder.build())
43 public void serialize(MatchEntry input, ByteBuf outBuffer) {
44 serializeHeader(input, outBuffer);
45 final RegCaseValue regCase = (RegCaseValue) input.getMatchEntryValue();
46 outBuffer.writeInt(regCase.getRegValues().getValue().intValue());
48 if (input.isHasMask()) {
49 outBuffer.writeInt(regCase.getRegValues().getMask().intValue());
54 public int getOxmClassCode() {
55 return OxmMatchConstants.NXM_1_CLASS;
59 public int getValueLength() {
64 public Class<? extends OxmClassBase> getOxmClass() {
65 return Nxm1Class.class;