2 * Copyright (c) 2018 SUSE LINUX GmbH. 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.readUint8;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.openflowjava.nx.api.NiciraConstants;
14 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
15 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
16 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshTtl;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.exp.match.NxExpMatchEntryValue;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.exp.match.nx.exp.match.entry.value.NshTtlCaseValue;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.exp.match.nx.exp.match.entry.value.NshTtlCaseValueBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.ttl.grouping.NshTtlValuesBuilder;
24 import org.opendaylight.yangtools.yang.common.Uint32;
26 public class NshTtlCodec extends AbstractExperimenterMatchCodec {
28 private static final int VALUE_LENGTH = Byte.BYTES;
29 private static final int NXM_FIELD_CODE = 10;
30 public static final MatchEntrySerializerKey<ExperimenterClass, NxmNxNshTtl> SERIALIZER_KEY =
31 createSerializerKey(EncodeConstants.OF_VERSION_1_3, NiciraConstants.NX_NSH_VENDOR_ID, NxmNxNshTtl.VALUE);
32 public static final MatchEntryDeserializerKey DESERIALIZER_KEY =
33 createDeserializerKey(EncodeConstants.OF_VERSION_1_3, NiciraConstants.NX_NSH_VENDOR_ID, NXM_FIELD_CODE);
36 protected void serializeValue(final NxExpMatchEntryValue value, final boolean hasMask, final ByteBuf outBuffer) {
37 final var nshTtlValues = ((NshTtlCaseValue) value).getNshTtlValues();
38 outBuffer.writeByte(nshTtlValues.getNshTtl().toJava());
40 outBuffer.writeByte(nshTtlValues.getMask().toJava());
45 protected NxExpMatchEntryValue deserializeValue(final ByteBuf message, final boolean hasMask) {
46 return new NshTtlCaseValueBuilder()
47 .setNshTtlValues(new NshTtlValuesBuilder()
48 .setNshTtl(readUint8(message))
49 .setMask(hasMask ? readUint8(message) : null)
55 protected Uint32 getExperimenterId() {
56 return NiciraConstants.NX_NSH_VENDOR_ID;
60 public int getValueLength() {
65 public int getNxmFieldCode() {
66 return NXM_FIELD_CODE;
70 public MatchField getNxmField() {
71 return NxmNxNshTtl.VALUE;